Clean, update comments
authorBruno Sinou <bsinou@argeo.org>
Wed, 26 Feb 2014 11:19:30 +0000 (11:19 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 26 Feb 2014 11:19:30 +0000 (11:19 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6855 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DeleteArtifacts.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DeleteWorkspace.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/DisplayRepoInformation.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/Fetch.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/ManageWorkspaceAuth.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/MergeWorkspaces.java

index beb0dd8c4e4b7ce91f9c36bbc217ed61dc7e0269..ef2a94a1e3a636401b69830466a229229aa72015 100644 (file)
@@ -25,6 +25,7 @@ import javax.jcr.security.Privilege;
 
 import org.argeo.ArgeoException;
 import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
 import org.argeo.slc.repo.RepoUtils;
@@ -49,15 +50,11 @@ public class CopyWorkspace extends AbstractHandler {
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/addItem.gif");
 
-//     public final static String DEFAULT_ICON_PATH = "icons/addItem.gif";
-
        // DEPENDENCY INJECTION
        private RepositoryFactory repositoryFactory;
        private Keyring keyring;
        private Repository nodeRepository;
 
-       private String slcRole = "ROLE_SLC";
-
        public Object execute(ExecutionEvent event) throws ExecutionException {
 
                String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
@@ -90,7 +87,8 @@ public class CopyWorkspace extends AbstractHandler {
                        Node newRootNode = newSession.getRootNode();
                        RepoUtils.copy(srcRootNode, newRootNode);
                        newSession.save();
-                       JcrUtils.addPrivilege(newSession, "/", slcRole, Privilege.JCR_ALL);
+                       JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
+                                       Privilege.JCR_ALL);
                        CommandHelpers.callCommand(RefreshDistributionsView.ID);
                } catch (RepositoryException re) {
                        throw new ArgeoException(
index 38cd456dbf7757586e1b6802268758869dd84afc..5a697bc225fae22570b51f82b092ef64095c86ba 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.eclipse.ui.ErrorFeedback;
 import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
 import org.argeo.slc.repo.RepoUtils;
@@ -45,17 +46,16 @@ import org.eclipse.ui.handlers.HandlerUtil;
 
 public class CreateWorkspace extends AbstractHandler {
        private static final Log log = LogFactory.getLog(CreateWorkspace.class);
+
+       // Exposes commands meta-info
        public final static String ID = DistPlugin.ID + ".createWorkspace";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-       public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
        public final static String DEFAULT_LABEL = "Create workspace...";
-       
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/addItem.gif");
 
-       // public final static String DEFAULT_ICON_PATH = "icons/addItem.gif";
-
-       private String slcRole = "ROLE_SLC";
+       // Parameters
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+       public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
 
        // DEPENDENCY INJECTION
        private RepositoryFactory repositoryFactory;
@@ -119,7 +119,8 @@ public class CreateWorkspace extends AbstractHandler {
                        JcrUtils.logoutQuietly(session);
                        // init new workspace
                        session = repository.login(credentials, workspaceName);
-                       JcrUtils.addPrivilege(session, "/", slcRole, Privilege.JCR_ALL);
+                       JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+                                       Privilege.JCR_ALL);
                        CommandHelpers.callCommand(RefreshDistributionsView.ID);
                        if (log.isTraceEnabled())
                                log.trace("WORKSPACE " + workspaceName + " CREATED");
index 51143dc4e44f688da7acc2399676c136ac541a9f..893ca36bfd5bc5795fa62b663aef20fdc33bba96 100644 (file)
@@ -36,17 +36,14 @@ import org.eclipse.ui.IWorkbenchPart;
 /**
  * Delete chosen artifacts from the current workspace.
  */
-
 public class DeleteArtifacts extends AbstractHandler {
        // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
+
        public final static String ID = DistPlugin.ID + ".deleteArtifacts";
        public final static String DEFAULT_LABEL = "Delete selected items";
-       // public final static String DEFAULT_ICON_PATH = "icons/removeItem.gif";
-
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/removeItem.gif");
 
-       
        public Object execute(ExecutionEvent event) throws ExecutionException {
                try {
                        IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
@@ -63,11 +60,11 @@ public class DeleteArtifacts extends AbstractHandler {
                                        String msg = "Your are about to definitively remove the "
                                                        + ((IStructuredSelection) selector).size()
                                                        + " selected artifacts.\n"
-                                                       + "Are you sure you want to proceed ?";
+                                                       + "Are you sure you want to proceed?";
 
                                        boolean result = MessageDialog.openConfirm(DistPlugin
                                                        .getDefault().getWorkbench().getDisplay()
-                                                       .getActiveShell(), "Confirm Delete", msg);
+                                                       .getActiveShell(), "Confirm Deletion", msg);
 
                                        if (result) {
                                                while (it.hasNext()) {
index 4b3be7de9f50bb3327eae07271d516117a40a7f7..d4a7783a48857c937cc74ab52c1b75a1dea029a3 100644 (file)
@@ -43,13 +43,11 @@ import org.eclipse.jface.resource.ImageDescriptor;
  * removing all nodes of type {@code NodeType.NT_FOLDER} and
  * {@code NodeType.NT_UNSTRUCTURED}
  */
-
 public class DeleteWorkspace extends AbstractHandler {
        // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
 
        public final static String ID = DistPlugin.ID + ".deleteWorkspace";
        public final static String DEFAULT_LABEL = "Clear";
-       // public final static String DEFAULT_ICON_PATH = "icons/removeItem.gif";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/removeItem.gif");
 
@@ -68,7 +66,6 @@ public class DeleteWorkspace extends AbstractHandler {
 
                Session nodeSession = null;
                Session session = null;
-
                try {
                        nodeSession = nodeRepository.login();
                        Node repoNode = nodeSession.getNode(targetRepoPath);
@@ -78,7 +75,7 @@ public class DeleteWorkspace extends AbstractHandler {
                                        keyring, repoNode);
 
                        String msg = "Your are about to completely delete workspace ["
-                                       + workspaceName + "].\n Do you really want to proceed ?";
+                                       + workspaceName + "].\n Do you really want to proceed?";
                        boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
                                        .getWorkbench().getDisplay().getActiveShell(),
                                        "Confirm workspace deletion", msg);
@@ -87,10 +84,10 @@ public class DeleteWorkspace extends AbstractHandler {
                                // msg =
                                // "There is no possible turning back, are your REALLY sure you want to proceed ?";
                                msg = "WARNING: \nCurrent Jackrabbit version used does "
-                                               + "not support workspace management.\n"
+                                               + "not support workspace deletion.\n"
                                                + "Thus, the workspace will only be cleaned so "
                                                + "that you can launch fetch process again.\n\n"
-                                               + "Do you still want to proceed ?";
+                                               + "Do you still want to proceed?";
                                result = MessageDialog.openConfirm(DistPlugin.getDefault()
                                                .getWorkbench().getDisplay().getActiveShell(),
                                                "Confirm workspace deletion", msg);
@@ -98,11 +95,9 @@ public class DeleteWorkspace extends AbstractHandler {
 
                        if (result) {
                                session = repository.login(credentials, workspaceName);
-
                                // TODO use this with a newer version of Jackrabbit
                                // Workspace wsp = session.getWorkspace();
                                // wsp.deleteWorkspace(workspaceName);
-
                                NodeIterator nit = session.getRootNode().getNodes();
                                while (nit.hasNext()) {
                                        Node node = nit.nextNode();
index a5b7f14885782900b6a4760ba2c062a5d98ba42c..e5c733dfa9d863c0610c326fa7cbc0e97bdbd772 100644 (file)
@@ -42,22 +42,17 @@ import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
- * Create a new empty workspace in the current repository.
+ * Opens a popup that displays various information on the current reppository.
  */
-
 public class DisplayRepoInformation extends AbstractHandler {
        public final static String ID = DistPlugin.ID + ".displayRepoInformation";
-       public final static String DEFAULT_LABEL = "Repository infos...";
+       public final static String DEFAULT_LABEL = "Repository infos";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/help.gif");
 
-       // public final static String DEFAULT_ICON_PATH = "icons/help.gif";
-
        public Object execute(ExecutionEvent event) throws ExecutionException {
-
                IStructuredSelection iss = (IStructuredSelection) HandlerUtil
                                .getActiveSite(event).getSelectionProvider().getSelection();
-
                if (iss.getFirstElement() instanceof RepoElem) {
                        RepoElem re = (RepoElem) iss.getFirstElement();
                        InformationDialog inputDialog = new InformationDialog(HandlerUtil
@@ -72,7 +67,7 @@ public class DisplayRepoInformation extends AbstractHandler {
                                inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
                        } catch (RepositoryException e) {
                                throw new SlcException("Unexpected error while "
-                                               + "getting repository infos.", e);
+                                               + "getting repository information.", e);
                        } finally {
                                JcrUtils.logoutQuietly(session);
                        }
@@ -81,7 +76,7 @@ public class DisplayRepoInformation extends AbstractHandler {
                return null;
        }
 
-       public class InformationDialog extends Dialog {
+       private class InformationDialog extends Dialog {
                Text nameTxt;
                Text uriTxt;
                Text loginTxt;
@@ -102,7 +97,6 @@ public class DisplayRepoInformation extends AbstractHandler {
                }
 
                protected Control createDialogArea(Composite parent) {
-
                        Composite dialogarea = (Composite) super.createDialogArea(parent);
                        dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
                                        true));
index d2cac60290adf8251bc4df31185214bfd0b0ee45..b6537d832fc83679ae99a4894b7d8ebb8cbb911e 100644 (file)
@@ -21,17 +21,20 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
-/** Wraps a {@link RepoSync} as an Eclipse command. */
+/**
+ * Wrap a {@link RepoSync} as an Eclipse command. Open a wizard that enable
+ * definition of the fetch process parameters
+ */
 public class Fetch extends AbstractHandler {
        // private final static Log log = LogFactory.getLog(Fetch.class);
 
        public final static String ID = DistPlugin.ID + ".fetch";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
        public final static String DEFAULT_LABEL = "Fetch...";
-       // public final static String DEFAULT_ICON_PATH = "icons/fetchRepo.png";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/fetchRepo.png");
 
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+
        // DEPENDENCY INJECTION
        private Keyring keyring;
        private RepositoryFactory repositoryFactory;
@@ -57,7 +60,7 @@ public class Fetch extends AbstractHandler {
                                CommandHelpers.callCommand(RefreshDistributionsView.ID);
                        return null;
                } catch (RepositoryException e) {
-                       throw new SlcException("Unexpected error while fetching data", e);
+                       throw new SlcException("Unable te retrieve repo node from path", e);
                } finally {
                        JcrUtils.logoutQuietly(currSession);
                }
index 3f47b78da745dd1538d80d618836f529f47e127c..bd64aeb3af9eab6c77818a3843542d77b8466b16 100644 (file)
@@ -20,6 +20,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.argeo.ArgeoException;
+import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.client.ui.dist.wizards.ChangeRightsWizard;
 import org.eclipse.core.commands.AbstractHandler;
@@ -30,24 +31,21 @@ import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
- * Open a dialog to change rights on the root node of the current workspace.
+ * Open a dialog to manage rights on the current workspace's root node.
  */
-
 public class ManageWorkspaceAuth extends AbstractHandler {
        // private static final Log log =
        // LogFactory.getLog(ManageWorkspaceAuth.class);
        public final static String ID = DistPlugin.ID + ".manageWorkspaceAuth";
-       public final static String PARAM_WORKSPACE_NAME = DistPlugin.ID
-                       + ".workspaceName";
        public final static String DEFAULT_LABEL = "Manage Rights";
-       // public final static String DEFAULT_ICON_PATH = "icons/changeRights.gif";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/changeRights.gif");
 
+       public final static String PARAM_WORKSPACE_NAME = DistPlugin.ID
+                       + ".workspaceName";
 
        /* DEPENDENCY INJECTION */
        private Repository repository;
-
        private Session session;
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
@@ -60,11 +58,10 @@ public class ManageWorkspaceAuth extends AbstractHandler {
                        dialog.open();
                        return null;
                } catch (RepositoryException re) {
-                       throw new ArgeoException(
-                                       "Unexpected error while creating the new workspace.", re);
+                       throw new ArgeoException("Cannot log in the repository "
+                                       + repository + " in workspace " + workspaceName, re);
                } finally {
-                       if (session != null)
-                               session.logout();
+                       JcrUtils.logoutQuietly(session);
                }
        }
 
index cd535dd6912d40fda3475b9413c82f9200ba5c06..5fd8fcaf1774a55445b47fdcb19a95cd2f436e2b 100644 (file)
@@ -45,12 +45,12 @@ import org.eclipse.core.runtime.jobs.Job;
 /**
  * Merge two workspaces
  */
-
 public class MergeWorkspaces extends AbstractHandler {
        private final static Log log = LogFactory.getLog(MergeWorkspaces.class);
 
        public final static String ID = DistPlugin.ID + ".mergeWorkspaces";
        public final static String DEFAULT_LABEL = "Merge";
+
        public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
        public final static String PARAM_SOURCE_REPO_PATH = "srcRepoPath";
        public final static String PARAM_TARGET_WORKSPACE_NAME = "targetWkspName";
@@ -62,7 +62,6 @@ public class MergeWorkspaces extends AbstractHandler {
        private Repository nodeRepository;
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
-
                String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
                String targetWkspName = event.getParameter(PARAM_TARGET_WORKSPACE_NAME);
                String sourceRepoPath = event.getParameter(PARAM_SOURCE_REPO_PATH);