+ clean repo model
authorBruno Sinou <bsinou@argeo.org>
Fri, 21 Mar 2014 15:42:13 +0000 (15:42 +0000)
committerBruno Sinou <bsinou@argeo.org>
Fri, 21 Mar 2014 15:42:13 +0000 (15:42 +0000)
+ enhance remote session management
+ fix a few bugs

git-svn-id: https://svn.argeo.org/slc/trunk@6907 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

30 files changed:
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/editors.xml
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml
plugins/org.argeo.slc.client.ui.dist/plugin.xml
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistConstants.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/RepoService.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/RepoServiceImpl.java [new file with mode: 0644]
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/MarkAsRelevantCategory.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/OpenGenerateBinariesWizard.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/OpenModuleEditor.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeDoubleClickListener.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/controllers/DistTreeLabelProvider.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ArtifactVersionEditor.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/DistWorkspaceEditor.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModularDistVersionEditor.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModularDistVersionOverviewPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/ModuleEditorInput.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/WkspCategoryBaseListPage.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/ModularDistBaseElem.java [deleted file]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/ModularDistVersionElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/RepoElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/wizards/GenerateBinariesWizard.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoUtils.java
runtime/org.argeo.slc.repo/src/main/resources/org/argeo/slc/repo/repo.cnd
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcNames.java
runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcTypes.java

index c8ec38b376af7718428478d69ecc3ce79b00e39e..bdf126d82225b27656a072778362085603202665 100644 (file)
@@ -14,9 +14,7 @@
 
        <bean id="openModuleEditor" class="org.argeo.slc.client.ui.dist.commands.OpenModuleEditor"
                scope="prototype">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="localRepository" ref="nodeRepository" />
+               <property name="repoService" ref="repoService" />
        </bean>
 
        <!-- REPOSITORY MANAGEMENT -->
@@ -36,8 +34,8 @@
        <bean id="displayRepoInformation"
                class="org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation"
                scope="prototype">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
+               <property name="repoService" ref="repoService" />
+               <property name="nodeRepository" ref="nodeRepository" />
        </bean>
 
 
                <property name="nodeRepository" ref="nodeRepository" />
                <property name="keyring" ref="keyring" />
        </bean>
+       <bean id="openGenerateBinariesWizard"
+               class="org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard">
+               <property name="repoService" ref="repoService" />
+       </bean>
 
        <!-- WORKSPACE CRUD -->
        <bean id="createWorkspace" class="org.argeo.slc.client.ui.dist.commands.CreateWorkspace">
index 3dd0cbae06ea51b5488a1f119c9757bd40793afd..e36f591cbbab9d5adb447426e213dc147947b12a 100644 (file)
        <bean id="artifactVersionEditor"
                class="org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor"
                scope="prototype">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="localRepository" ref="nodeRepository" />
+               <property name="repoService" ref="repoService" />
        </bean>
+
        <bean id="modularDistVersionEditor"
                class="org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor"
                scope="prototype">
-               <property name="repositoryFactory" ref="repositoryFactory" />
-               <property name="keyring" ref="keyring" />
-               <property name="localRepository" ref="nodeRepository" />
+               <property name="repoService" ref="repoService" />
        </bean>
 </beans>
index 1d2cd11c4f354095c2fabd600b63bc959efbfc2c..e6b5e60ddfc6921c064944344ae1ecdf64e44e25 100644 (file)
                <property name="workspace" value="org.argeo.tp-1.3.1" />
        </bean>
 
+       <bean id="repoService" class="org.argeo.slc.client.ui.dist.RepoServiceImpl">
+               <property name="repositoryFactory" ref="repositoryFactory" />
+               <property name="keyring" ref="keyring" />
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
        <!-- For the record <property name="session"> <bean factory-bean="repository" 
                factory-method="login" /> </property> -->
 </beans>
index 530833b99be8b549a23ce20c481339c84e118ecd..97637957699dde5dd421260980c348ab8fac6f8b 100644 (file)
                        </commandParameter>
        </command>
        
-       <command
+       <!-- <command
             defaultHandler="org.argeo.slc.client.ui.dist.commands.MarkAsRelevantCategory"
             id="org.argeo.slc.client.ui.dist.markAsRelevantCategory"
             name="Mark as relevant category">
-       </command>
+       </command> --> 
        
        <command
-            defaultHandler="org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard"
             id="org.argeo.slc.client.ui.dist.openGenerateBinariesWizard"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="Generate Binaries...">
+            <commandParameter
+                               id="param.repoNodePath"
+                               name="Repo node path">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="param.modulePath"
+                               name="Module path name">
+                       </commandParameter>
        </command>
        
        <command
index e7fbef20a0ccc227e6f0b9dbf7f133c81f765d02..589f660cd7aba8e946440294052319d26c7111f6 100644 (file)
@@ -40,6 +40,9 @@ public interface DistConstants {
        public final static String SLC_BUNDLE_VENDOR = SlcNames.SLC_
                        + Constants.BUNDLE_VENDOR;
 
+       public final static String SLC_BUNDLE_DESCRIPTION = SlcNames.SLC_
+                       + Constants.BUNDLE_DESCRIPTION;
+
        public final String DEFAULT_PUBLIC_REPOSITORY_URI = "vm:///java";
 
 }
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/RepoService.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/RepoService.java
new file mode 100644 (file)
index 0000000..8e4a09e
--- /dev/null
@@ -0,0 +1,14 @@
+package org.argeo.slc.client.ui.dist;
+
+import javax.jcr.Session;
+
+/** Start factorisation of the session management using a manager service */
+public interface RepoService {
+
+       /**
+        * Returns a corresponding session given the current context. Caller must
+        * close the session once it as been used
+        */
+       public Session getRemoteSession(String repoNodePath, String uri,
+                       String workspaceName);
+}
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/RepoServiceImpl.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/RepoServiceImpl.java
new file mode 100644 (file)
index 0000000..be012f2
--- /dev/null
@@ -0,0 +1,36 @@
+package org.argeo.slc.client.ui.dist;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.util.security.Keyring;
+
+public class RepoServiceImpl implements RepoService {
+
+       /* DEPENDENCY INJECTION */
+       private Repository nodeRepository;
+       private RepositoryFactory repositoryFactory;
+       private Keyring keyring;
+
+       public Session getRemoteSession(String repoNodePath, String uri,
+                       String workspaceName) {
+               return RepoUtils.getRemoteSession(repositoryFactory, keyring,
+                               nodeRepository, repoNodePath, uri, workspaceName);
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+               this.repositoryFactory = repositoryFactory;
+       }
+
+       public void setKeyring(Keyring keyring) {
+               this.keyring = keyring;
+       }
+
+}
index 6ccd8d8eb3e196c6bb302a39108bc1b46cf853d5..3325092de8b7c584218b048b4bff1fa8b493a391 100644 (file)
  */
 package org.argeo.slc.client.ui.dist.commands;
 
-import javax.jcr.RepositoryFactory;
+import javax.jcr.Repository;
 import javax.jcr.Session;
 
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.RepoService;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -50,31 +49,32 @@ public class DisplayRepoInformation extends AbstractHandler {
        public final static String DEFAULT_LABEL = "Information";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/help.gif");
-       
+
        /* DEPENDENCY INJECTION */
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
-       
+       private RepoService repoService;
+       private Repository nodeRepository;
+
        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();
-               
-                       Session defaultSession =  null;
-                       try{
-                               defaultSession = RepoUtils.getCorrespondingSession(repositoryFactory, keyring, re.getRepoNode(), re.getUri(), null);
-                       
-                       
-                       InformationDialog inputDialog = new InformationDialog(HandlerUtil
-                                       .getActiveSite(event).getShell());
-                       inputDialog.create();
-                       inputDialog.loginTxt.setText(defaultSession.getUserID());
-                       inputDialog.nameTxt.setText(re.getLabel());
-                       inputDialog.uriTxt.setText(re.getUri());
-                       inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
-               
-                       inputDialog.open();
+
+                       Session defaultSession = null;
+                       try {
+                               defaultSession = repoService.getRemoteSession(re.getRepoNodePath(),
+                                               re.getUri(), null);
+
+                               InformationDialog inputDialog = new InformationDialog(
+                                               HandlerUtil.getActiveSite(event).getShell());
+                               inputDialog.create();
+                               // TODO add more information.
+                               inputDialog.loginTxt.setText(defaultSession.getUserID());
+                               inputDialog.nameTxt.setText(re.getLabel());
+                               inputDialog.uriTxt.setText(re.getUri());
+                               inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
+
+                               inputDialog.open();
                                // } catch (RepositoryException e) {
                                // throw new SlcException("Unexpected error while "
                                // + "getting repository information.", e);
@@ -147,14 +147,14 @@ public class DisplayRepoInformation extends AbstractHandler {
                        shell.setText("Repository information");
                }
        }
-       
+
        /* DEPENDENCY INJECTION */
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
        }
 
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
        }
-       
+
 }
\ No newline at end of file
index f4f8bcbc3db57b8e4761342519894f953b2c0075..e58aa1addc852fc452816d7fc522d3170726eaf0 100644 (file)
  */
 package org.argeo.slc.client.ui.dist.commands;
 
-import java.util.Iterator;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.ArgeoException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.jcr.SlcTypes;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
 
 /**
  * Add the {@code SlcNames.SLC_RELEVANT_CATEGORY} mixin to the selected node
@@ -41,52 +29,51 @@ public class MarkAsRelevantCategory extends AbstractHandler {
 
        public final static String ID = DistPlugin.ID + ".markAsRelevantCategory";
        public final static String DEFAULT_LABEL = "Mark as relevant category base";
-       public final static String DEFAULT_REMOVE_LABEL = "Remove this category from relevant list";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/addItem.gif");
-       public final static ImageDescriptor DEFAULT_REMOVE_ICON = DistPlugin
-                       .getImageDescriptor("icons/removeMark.gif");
-
+       
        public Object execute(ExecutionEvent event) throws ExecutionException {
-               try {
-                       IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
-                                       .getActiveWorkbenchWindow().getActivePage().getActivePart();
-
-                       if (activePart instanceof IEditorPart) {
-                               ISelection selector = ((IEditorPart) activePart)
-                                               .getEditorSite().getSelectionProvider().getSelection();
-                               if (selector != null
-                                               && selector instanceof IStructuredSelection) {
-                                       Iterator<?> it = ((IStructuredSelection) selector)
-                                                       .iterator();
-
-                                       Node node = (Node) it.next();
-                                       if (node.isNodeType(SlcTypes.SLC_CATEGORY)) {
-                                               String msg = "Your are about to unlist this category from the relevant category list for current workspace"
-                                                               + ".\n" + "Are you sure you want to proceed?";
-                                               if (MessageDialog.openConfirm(DistPlugin.getDefault()
-                                                               .getWorkbench().getDisplay().getActiveShell(),
-                                                               "Confirm", msg)) {
-                                                       node.removeMixin(SlcTypes.SLC_CATEGORY);
-                                                       node.getSession().save();
-                                               }
-                                       } else {
-                                               String msg = "Your are about to mark this group as category base in the current workspace"
-                                                               + ".\n" + "Are you sure you want to proceed?";
-
-                                               if (MessageDialog.openConfirm(DistPlugin.getDefault()
-                                                               .getWorkbench().getDisplay().getActiveShell(),
-                                                               "Confirm", msg)) {
-                                                       node.addMixin(SlcTypes.SLC_CATEGORY);
-                                                       node.getSession().save();
-                                               }
-                                       }
-                               }
-                       }
-               } catch (RepositoryException re) {
-                       throw new ArgeoException(
-                                       "Unexpected error while deleting artifacts.", re);
-               }
+               // try {
+               // IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
+               // .getActiveWorkbenchWindow().getActivePage().getActivePart();
+               //
+               // if (activePart instanceof IEditorPart) {
+               // ISelection selector = ((IEditorPart) activePart)
+               // .getEditorSite().getSelectionProvider().getSelection();
+               // if (selector != null
+               // && selector instanceof IStructuredSelection) {
+               // Iterator<?> it = ((IStructuredSelection) selector)
+               // .iterator();
+               //
+               // Node node = (Node) it.next();
+               // if (node.isNodeType(SlcTypes.SLC_CATEGORY)) {
+               // String msg =
+               // "Your are about to unlist this category from the relevant category list for current workspace"
+               // + ".\n" + "Are you sure you want to proceed?";
+               // if (MessageDialog.openConfirm(DistPlugin.getDefault()
+               // .getWorkbench().getDisplay().getActiveShell(),
+               // "Confirm", msg)) {
+               // node.removeMixin(SlcTypes.SLC_CATEGORY);
+               // node.getSession().save();
+               // }
+               // } else {
+               // String msg =
+               // "Your are about to mark this group as category base in the current workspace"
+               // + ".\n" + "Are you sure you want to proceed?";
+               //
+               // if (MessageDialog.openConfirm(DistPlugin.getDefault()
+               // .getWorkbench().getDisplay().getActiveShell(),
+               // "Confirm", msg)) {
+               // node.addMixin(SlcTypes.SLC_CATEGORY);
+               // node.getSession().save();
+               // }
+               // }
+               // }
+               // }
+               // } catch (RepositoryException re) {
+               // throw new ArgeoException(
+               // "Unexpected error while deleting artifacts.", re);
+               // }
                return null;
        }
 }
\ No newline at end of file
index 1c2ad68c33b33c29eda85f397d7d1cf8c6ef8185..84ee759d71ce591447961107244302819f882b37 100644 (file)
  */
 package org.argeo.slc.client.ui.dist.commands;
 
-import java.util.Iterator;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.model.ModularDistBaseElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
+import org.argeo.slc.client.ui.dist.RepoService;
 import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
 import org.argeo.slc.client.ui.dist.wizards.GenerateBinariesWizard;
 import org.eclipse.core.commands.AbstractHandler;
@@ -33,10 +24,7 @@ import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.handlers.HandlerUtil;
 
@@ -51,53 +39,38 @@ public class OpenGenerateBinariesWizard extends AbstractHandler {
        public final static String DEFAULT_LABEL = "Generate Aether Index";
        public final static ImageDescriptor DEFAULT_ICON = null;
 
+       /* DEPENDENCY INJECTION */
+       private RepoService repoService;
+
+       // Absolute Coordinates of the current group node
+       public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
+       public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
+       public final static String PARAM_MODULE_PATH = "param.modulePath";
+
        public Object execute(ExecutionEvent event) throws ExecutionException {
                IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
                                .getActiveWorkbenchWindow().getActivePage().getActivePart();
 
-               if (activePart instanceof IViewPart) {
-                       ISelection selector = ((IViewPart) activePart).getViewSite()
-                                       .getSelectionProvider().getSelection();
-                       if (selector != null && selector instanceof IStructuredSelection) {
-                               Iterator<?> it = ((IStructuredSelection) selector).iterator();
-                               Object element = it.next();
-                               if (element instanceof ModularDistBaseElem) {
-                                       ModularDistBaseElem elem = (ModularDistBaseElem) element;
-                                       // Session newSession = null;
-                                       try {
-                                               Node cBase = elem.getCategoryBase();
-                                               String catBasePath = cBase.getPath();
-                                               // newSession = ((WorkspaceElem) elem.getParent())
-                                               // .getNewSession();
-
-                                               String wkspName = ((WorkspaceElem) elem.getParent())
-                                                               .getWorkspaceName();
-                                               Repository repository = ((WorkspaceElem) elem
-                                                               .getParent()).getRepoElem().getRepository();
-                                               Credentials credentials = ((WorkspaceElem) elem
-                                                               .getParent()).getRepoElem().getCredentials();
+               String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
+               String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+               String modulePath = event.getParameter(PARAM_MODULE_PATH);
 
-                                               GenerateBinariesWizard wizard = new GenerateBinariesWizard(
-                                                               repository, credentials, wkspName, catBasePath);
+               GenerateBinariesWizard wizard = new GenerateBinariesWizard(repoService,
+                               repoNodePath, workspaceName, modulePath);
 
-                                               WizardDialog dialog = new WizardDialog(
-                                                               HandlerUtil.getActiveShell(event), wizard);
-                                               int result = dialog.open();
+               WizardDialog dialog = new WizardDialog(
+                               HandlerUtil.getActiveShell(event), wizard);
+               int result = dialog.open();
 
-                                               if (result == Dialog.OK)
-                                                       CommandHelpers
-                                                                       .callCommand(RefreshDistributionsView.ID);
-                                       } catch (RepositoryException re) {
-                                               throw new SlcException(
-                                                               "Unable to duplicate session for node " + elem,
-                                                               re);
-                                               // } finally {
-                                               // JcrUtils.logoutQuietly(newSession);
-                                       }
-                               }
+               if (result == Dialog.OK
+                               && (activePart instanceof RefreshDistributionsView))
+                       CommandHelpers.callCommand(RefreshDistributionsView.ID);
 
-                       }
-               }
                return null;
        }
+       
+       /* DEPENDENCY INJECTION */
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
+       }
 }
\ No newline at end of file
index 85d047a95d5d18dd394042af1afaedf2606daf71..9250b25e69d92606e0b3d097d460099ef396f785 100644 (file)
 package org.argeo.slc.client.ui.dist.commands;
 
 import javax.jcr.Node;
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 
-import org.argeo.jcr.ArgeoNames;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.RepoService;
 import org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor;
 import org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor;
 import org.argeo.slc.client.ui.dist.editors.ModuleEditorInput;
 import org.argeo.slc.jcr.SlcTypes;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -56,11 +52,7 @@ public class OpenModuleEditor extends AbstractHandler {
        public final static String PARAM_MODULE_PATH = "param.modulePath";
 
        /* DEPENDENCY INJECTION */
-       private Repository localRepository;
-       // We must log in the corresponding repository to get the node and be able
-       // to decide which editor to open depending on its mixin
-       private RepositoryFactory repositoryFactory;
-       private Keyring keyring;
+       private RepoService repoService;
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
                String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
@@ -68,43 +60,22 @@ public class OpenModuleEditor extends AbstractHandler {
                String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
                String modulePath = event.getParameter(PARAM_MODULE_PATH);
 
-               Session localSession = null;
                Session businessSession = null;
-               Node repoNode = null;
-
                try {
-                       try {
-                               localSession = localRepository.login();
-                               if (repoNodePath != null
-                                               && localSession.nodeExists(repoNodePath))
-                                       repoNode = localSession.getNode(repoNodePath);
-
-                               businessSession = RepoUtils.getCorrespondingSession(
-                                               repositoryFactory, keyring, repoNode, repoUri,
-                                               workspaceName);
-                               if (repoUri == null && repoNode != null)
-                                       repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
-                                                       .getString();
+                       businessSession = repoService.getRemoteSession(repoNodePath,
+                                       repoUri, workspaceName);
 
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot log to workspace "
-                                               + workspaceName + " for repo defined in "
-                                               + repoNodePath, e);
-                       } finally {
-                               JcrUtils.logoutQuietly(localSession);
-                       }
-
-                       ModuleEditorInput wei = new ModuleEditorInput(repoNodePath,
+                       Node module = businessSession.getNode(modulePath);
+                       ModuleEditorInput mei = new ModuleEditorInput(repoNodePath,
                                        repoUri, workspaceName, modulePath);
-                       Node artifact = businessSession.getNode(modulePath);
 
-                       // Choose correct editor based on the artifact mixin
-                       if (artifact.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION))
+                       // Choose correct editor based on its mixin
+                       if (module.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION))
                                HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
-                                               .openEditor(wei, ModularDistVersionEditor.ID);
+                                               .openEditor(mei, ModularDistVersionEditor.ID);
                        else
                                HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
-                                               .openEditor(wei, ArtifactVersionEditor.ID);
+                                               .openEditor(mei, ArtifactVersionEditor.ID);
                } catch (RepositoryException e) {
                        throw new SlcException("Unexpected error while "
                                        + "getting repoNode info for repoNode at path "
@@ -121,16 +92,7 @@ public class OpenModuleEditor extends AbstractHandler {
        }
 
        /* DEPENDENCY INJECTION */
-       public void setLocalRepository(Repository localRepository) {
-               this.localRepository = localRepository;
-       }
-
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
        }
-
 }
\ No newline at end of file
index 5136a9128afa4d6ba745e8575f31a03a841bf7e8..c280a53e00f8b78d23d4032f2ba99e2dbbbfe999 100644 (file)
@@ -40,56 +40,36 @@ public class DistTreeDoubleClickListener implements IDoubleClickListener {
                                treeViewer.refresh(obj);
                        }
                } else if (obj instanceof WorkspaceElem) {
-                       //WorkspaceElem wn = (WorkspaceElem) obj;
-                       // if (!wn.isConnected()) {
-                       // wn.login();
-                       // treeViewer.refresh(obj);
-                       // } else {
                        WorkspaceElem we = (WorkspaceElem) obj;
-                       Node repoNode = null;
-                       try {
-                               RepoElem repoElem = we.getRepoElem();
-                               Map<String, String> params = new HashMap<String, String>();
+                       RepoElem repoElem = we.getRepoElem();
+                       Map<String, String> params = new HashMap<String, String>();
+                       params.put(OpenWorkspaceEditor.PARAM_REPO_NODE_PATH,
+                                       repoElem.getRepoNodePath());
+                       params.put(OpenWorkspaceEditor.PARAM_REPO_URI, repoElem.getUri());
+                       params.put(OpenWorkspaceEditor.PARAM_WORKSPACE_NAME,
+                                       we.getWorkspaceName());
+                       CommandUtils.callCommand(OpenWorkspaceEditor.ID, params);
 
-                               repoNode = repoElem.getRepoNode();
-                               if (repoNode != null)
-                                       params.put(OpenWorkspaceEditor.PARAM_REPO_NODE_PATH,
-                                                       repoNode.getPath());
-                               params.put(OpenWorkspaceEditor.PARAM_REPO_URI,
-                                               repoElem.getUri());
-                               params.put(OpenWorkspaceEditor.PARAM_WORKSPACE_NAME,
-                                               we.getWorkspaceName());
-                               CommandUtils.callCommand(OpenWorkspaceEditor.ID, params);
-                       } catch (RepositoryException re) {
-                               throw new SlcException("Cannot get path for node " + repoNode
-                                               + " while " + "setting parameters of command "
-                                               + "OpenWorkspaceEditor", re);
-                       }
-                       // }
                } else if (obj instanceof ModularDistVersionElem) {
                        ModularDistVersionElem modDistElem = (ModularDistVersionElem) obj;
                        WorkspaceElem wkspElem = modDistElem.getWorkspaceElem();
-                       Node repoNode = null;
                        Node moduleNode = modDistElem.getModularDistVersionNode();
+                       RepoElem repoElem = wkspElem.getRepoElem();
+                       Map<String, String> params = new HashMap<String, String>();
+                       params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+                                       repoElem.getRepoNodePath());
+                       params.put(OpenModuleEditor.PARAM_REPO_URI, repoElem.getUri());
+                       params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+                                       wkspElem.getWorkspaceName());
                        try {
-                               RepoElem repoElem = wkspElem.getRepoElem();
-                               Map<String, String> params = new HashMap<String, String>();
-                               repoNode = repoElem.getRepoNode();
-                               if (repoNode != null)
-                                       params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
-                                                       repoNode.getPath());
-                               params.put(OpenModuleEditor.PARAM_REPO_URI, repoElem.getUri());
-                               params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
-                                               wkspElem.getWorkspaceName());
                                params.put(OpenModuleEditor.PARAM_MODULE_PATH,
                                                moduleNode.getPath());
-                               CommandUtils.callCommand(OpenModuleEditor.ID, params);
                        } catch (RepositoryException re) {
-                               throw new SlcException("Cannot get path for node " + repoNode
-                                               + " or " + moduleNode
+                               throw new SlcException("Cannot get path for node " + moduleNode
                                                + " while setting parameters for "
                                                + "command OpenModuleEditor", re);
                        }
+                       CommandUtils.callCommand(OpenModuleEditor.ID, params);
                }
        }
 }
\ No newline at end of file
index 37bff6bd717b1f0c55264c341b6755846847b41e..4ce4b77a9980dcea34d3fda19056cdada177d74e 100644 (file)
@@ -3,7 +3,7 @@ package org.argeo.slc.client.ui.dist.controllers;
 import org.argeo.eclipse.ui.jcr.JcrImages;
 import org.argeo.slc.client.ui.dist.DistImages;
 import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistBaseElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
 import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
 import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
@@ -39,7 +39,7 @@ public class DistTreeLabelProvider extends ColumnLabelProvider {
                        return DistImages.IMG_WKSP_GROUP;
                // else if (element instanceof GroupBaseElem)
                // return DistImages.IMG_GROUP_BASE;
-               else if (element instanceof ModularDistBaseElem)
+               else if (element instanceof ModularDistVersionBaseElem)
                        return DistImages.IMG_MODULAR_DIST_BASE;
                else if (element instanceof ModularDistVersionElem)
                        return DistImages.IMG_MODULAR_DIST_VERSION;
index 549dc4046e4e0209c7173d0a3bb4a23b7a178fef..ad9a33b756382dc3c14a778a195ea59953e1719c 100644 (file)
 package org.argeo.slc.client.ui.dist.editors;
 
 import javax.jcr.Node;
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 
 import org.argeo.ArgeoException;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.RepoService;
 import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorSite;
@@ -42,49 +39,41 @@ public class ArtifactVersionEditor extends FormEditor implements SlcNames {
        // LogFactory.getLog(ArtifactEditor.class);
        public final static String ID = DistPlugin.ID + ".artifactVersionEditor";
 
-       private ModuleEditorInput editorInput;
-
        /* DEPENDENCY INJECTION */
-       private RepositoryFactory repositoryFactory;
-       private Repository localRepository;
-       private Keyring keyring;
-
-       // Business objects
-       private Node repoNode;
-       // Session that provides the node in the home of the local repository
-       private Session localSession = null;
-       // The business Session on an optionally remote repository
+       private RepoService repoService;
+
+       // Business Objects
        private Session businessSession;
        private Node artifact;
 
+       private ModuleEditorInput editorInput;
+
        @Override
        public void init(IEditorSite site, IEditorInput input)
                        throws PartInitException {
                editorInput = (ModuleEditorInput) input;
+               businessSession = repoService.getRemoteSession(
+                               editorInput.getRepoNodePath(), editorInput.getUri(),
+                               editorInput.getWorkspaceName());
                try {
-                       localSession = localRepository.login();
-                       if (editorInput.getRepoNodePath() != null
-                                       && localSession.nodeExists(editorInput.getRepoNodePath()))
-                               repoNode = localSession.getNode(editorInput.getRepoNodePath());
-                       businessSession = RepoUtils.getCorrespondingSession(
-                                       repositoryFactory, keyring, repoNode, editorInput.getUri(),
-                                       editorInput.getWorkspaceName());
                        artifact = businessSession.getNode(editorInput.getModulePath());
                } catch (RepositoryException e) {
                        throw new PartInitException(
                                        "Unable to initialise editor for artifact "
                                                        + editorInput.getModulePath() + " in workspace "
-                                                       + editorInput.getWorkspaceName()
-                                                       + " of repository " + editorInput.getUri(), e);
+                                                       + editorInput.getWorkspaceName(), e);
                }
-               setPartName(getFormattedName());
                super.init(site, input);
        }
 
        /** Override to provide a specific part name */
        protected String getFormattedName() {
                try {
-                       String partName = artifact.getProperty(SLC_ARTIFACT_ID).getString();
+                       String partName = null;
+                       if (artifact.hasProperty(SLC_ARTIFACT_ID))
+                               partName = artifact.getProperty(SLC_ARTIFACT_ID).getString();
+                       else
+                               partName = artifact.getName();
 
                        if (partName.length() > 10) {
                                partName = "..." + partName.substring(partName.length() - 10);
@@ -99,12 +88,15 @@ public class ArtifactVersionEditor extends FormEditor implements SlcNames {
 
        @Override
        protected void addPages() {
+               setPartName(getFormattedName());
+
                try {
                        addPage(new BundleDetailsPage(this, "Details ", artifact));
                        addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact));
                } catch (PartInitException e) {
                        throw new ArgeoException("Cannot add distribution editor pages", e);
                }
+
        }
 
        @Override
@@ -114,7 +106,6 @@ public class ArtifactVersionEditor extends FormEditor implements SlcNames {
        @Override
        public void dispose() {
                JcrUtils.logoutQuietly(businessSession);
-               JcrUtils.logoutQuietly(localSession);
                super.dispose();
        }
 
@@ -127,8 +118,8 @@ public class ArtifactVersionEditor extends FormEditor implements SlcNames {
                return false;
        }
 
-       protected Node getRepoNode() {
-               return repoNode;
+       protected RepoService getRepoService() {
+               return repoService;
        }
 
        protected Node getArtifact() {
@@ -136,15 +127,7 @@ public class ArtifactVersionEditor extends FormEditor implements SlcNames {
        }
 
        /* DEPENDENCY INJECTION */
-       public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
-               this.repositoryFactory = repositoryFactory;
-       }
-
-       public void setKeyring(Keyring keyring) {
-               this.keyring = keyring;
-       }
-
-       public void setLocalRepository(Repository localRepository) {
-               this.localRepository = localRepository;
+       public void setRepoService(RepoService repoService) {
+               this.repoService = repoService;
        }
 }
\ No newline at end of file
index 0d3220aafc8a62d079301f1c417ad9eba427d2cd..0a34a62da0fdeda63d5690b48b9d9a72b75d5b8f 100644 (file)
@@ -64,7 +64,7 @@ public class DistWorkspaceEditor extends FormEditor implements SlcNames {
                                        && localSession.nodeExists(editorInput.getRepoNodePath()))
                                repoNode = localSession.getNode(editorInput.getRepoNodePath());
 
-                       businessSession = RepoUtils.getCorrespondingSession(
+                       businessSession = RepoUtils.getRemoteSession(
                                        repositoryFactory, keyring, repoNode, editorInput.getUri(),
                                        editorInput.getWorkspaceName());
                } catch (RepositoryException e) {
index f80c5e92861fbb1aeff7b88aeb6733c5b0c29b5e..284347bc370e407668c839a72159582a3f9e432a 100644 (file)
@@ -15,6 +15,8 @@
  */
 package org.argeo.slc.client.ui.dist.editors;
 
+import javax.jcr.RepositoryException;
+
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.eclipse.ui.IEditorInput;
@@ -34,13 +36,13 @@ public class ModularDistVersionEditor extends ArtifactVersionEditor {
        public void init(IEditorSite site, IEditorInput input)
                        throws PartInitException {
                super.init(site, input);
-               // setPartName("Editing distrib");
        }
 
        @Override
        protected void addPages() {
                try {
-                       addPage(new ModularDistVersionOverviewPage(this, "Modules ", getArtifact()));
+                       addPage(new ModularDistVersionOverviewPage(this, "Modules ",
+                                       getArtifact()));
                        addPage(new RunInOsgiPage(this, "Run as OSGi ", getArtifact()));
                        super.addPages();
                } catch (PartInitException e) {
@@ -49,4 +51,23 @@ public class ModularDistVersionEditor extends ArtifactVersionEditor {
                        // throw new SlcException("Cannot get artifact session", e);
                }
        }
+
+       protected String getFormattedName() {
+               try {
+                       String partName = null;
+                       if (getArtifact().hasProperty(SLC_NAME))
+                               partName = getArtifact().getProperty(SLC_NAME).getString();
+                       else
+                               partName = getArtifact().getName();
+
+                       if (partName.length() > 10) {
+                               partName = "..." + partName.substring(partName.length() - 10);
+                       }
+                       return partName;
+               } catch (RepositoryException re) {
+                       throw new SlcException("unable to get slc:name property for node "
+                                       + getArtifact(), re);
+               }
+       }
+
 }
\ No newline at end of file
index 38b3a8b463e01efcf04fc91b91da55b0aa95a5de..fb8229672aa1becae714bef38bc74245df3c1a1a 100644 (file)
@@ -130,8 +130,8 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                                        .getProperty(SlcNames.SLC_NAME).getString() : "");
                        form.setMessage(
                                        modularDistribution
-                                                       .hasProperty(SlcNames.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
-                                                       .getProperty(SlcNames.SLC_BUNDLE_DESCRIPTION)
+                                                       .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
+                                                       .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
                                                        .getString() : "", IMessageProvider.NONE);
                } catch (RepositoryException re) {
                        throw new SlcException("Unable to get bundle name for node "
index bc15959dcf3c323c589f2d0b5a739e596c95e09f..8c297259eb839c45e56f3f0c286ebc94aa1d8831 100644 (file)
@@ -37,8 +37,9 @@ public class ModuleEditorInput implements IEditorInput, SlcNames {
                        String workspaceName, String artifactPath) {
                if (workspaceName == null)
                        throw new SlcException("Workspace name cannot be null");
-               if (uri == null)
-                       throw new SlcException("URI for repository cannot be null");
+               if (uri == null && repoNodePath == null)
+                       throw new SlcException("Define at least one of the 2 "
+                                       + "parameters URI or Repo Node Path");
                if (artifactPath == null)
                        throw new SlcException("Module path cannot be null");
                this.repoNodePath = repoNodePath;
@@ -105,12 +106,15 @@ public class ModuleEditorInput implements IEditorInput, SlcNames {
                        return false;
                if (!workspaceName.equals(other.getWorkspaceName()))
                        return false;
-               if (!uri.equals(other.getUri()))
+
+               if (uri == null && other.getUri() != null
+                               || !uri.equals(other.getUri()))
+                       return false;
+
+               if (repoNodePath == null && other.getRepoNodePath() != null
+                               || !repoNodePath.equals(other.getRepoNodePath()))
                        return false;
 
-               if (repoNodePath == null)
-                       return other.getRepoNodePath() == null;
-               else
-                       return repoNodePath.equals(other.getRepoNodePath());
+               return true;
        }
 }
\ No newline at end of file
index c8b87c0a455753cabd58c50aff4e0fa7da61e3a5..c82312e8b9e1bdd0058908c9ef97a8f0de80a9e9 100644 (file)
@@ -16,7 +16,9 @@
 package org.argeo.slc.client.ui.dist.editors;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -24,7 +26,6 @@ import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.observation.Event;
-import javax.jcr.observation.ObservationManager;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.Constraint;
@@ -42,10 +43,11 @@ import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistConstants;
 import org.argeo.slc.client.ui.dist.DistImages;
 import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.MarkAsRelevantCategory;
+import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
 import org.argeo.slc.client.ui.dist.utils.NodeViewerComparator;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
+import org.argeo.slc.repo.RepoConstants;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
@@ -100,8 +102,9 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
        private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
 
        // Observes changes
-       private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE };
-       private CategoryObserver categoriesObserver;
+       // private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE
+       // };
+       // private CategoryObserver categoriesObserver;
 
        public WkspCategoryBaseListPage(FormEditor formEditor, String title,
                        Session session) {
@@ -135,18 +138,18 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                createTableViewer(tableCmp);
 
-               categoriesObserver = new CategoryObserver(viewer.getTable()
-                               .getDisplay());
-               try {
-                       ObservationManager observationManager = session.getWorkspace()
-                                       .getObservationManager();
-                       // FIXME Will not be notified if empty result is deleted
-                       observationManager.addEventListener(categoriesObserver,
-                                       Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
-                                       false);
-               } catch (RepositoryException e) {
-                       throw new SlcException("Cannot register listeners", e);
-               }
+               // categoriesObserver = new CategoryObserver(viewer.getTable()
+               // .getDisplay());
+               // try {
+               // ObservationManager observationManager = session.getWorkspace()
+               // .getObservationManager();
+               // // FIXME Will not be notified if empty result is deleted
+               // observationManager.addEventListener(categoriesObserver,
+               // Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
+               // false);
+               // } catch (RepositoryException e) {
+               // throw new SlcException("Cannot register listeners", e);
+               // }
 
                refresh();
        }
@@ -281,13 +284,14 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                // Version
                col = new TableViewerColumn(viewer, SWT.NONE);
                col.getColumn().setWidth(80);
-               col.getColumn().setText("Relevant");
+               col.getColumn().setText("Has binaries");
                col.setLabelProvider(new ColumnLabelProvider() {
                        @Override
                        public String getText(Object element) {
                                try {
-                                       return ((Node) element)
-                                                       .isNodeType(SlcTypes.SLC_CATEGORY) ? "Yes"
+                                       Node currNode = (Node) element;
+
+                                       return currNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID) ? "Yes"
                                                        : "No";
                                } catch (RepositoryException e) {
                                        throw new SlcException("unable to check type of node "
@@ -341,29 +345,46 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                                .getFirstElement();
                Node currSelected = (Node) firstElement;
 
-               boolean isRelevant = false;
-               try {
-                       isRelevant = currSelected
-                                       .isNodeType(SlcTypes.SLC_CATEGORY);
-                       boolean canEdit = currSelected
-                                       .canAddMixin(SlcTypes.SLC_CATEGORY);
+               DistWkspEditorInput input = (DistWkspEditorInput) getEditorInput();
 
+               Map<String, String> params = new HashMap<String, String>();
+               params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
+                               input.getRepoNodePath());
+               try {
+                       params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
+                                       currSelected.getPath());
                } catch (RepositoryException e) {
-                       throw new SlcException("unable to check type of node "
-                                       + firstElement, e);
-               }
-               // Add
-               if (isRelevant) {// Remove
-                       CommandUtils.refreshCommand(menuManager, window,
-                                       MarkAsRelevantCategory.ID,
-                                       MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
-                                       MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
-               } else {
-                       CommandUtils.refreshCommand(menuManager, window,
-                                       MarkAsRelevantCategory.ID,
-                                       MarkAsRelevantCategory.DEFAULT_LABEL,
-                                       MarkAsRelevantCategory.DEFAULT_ICON, true);
+                       throw new SlcException("Unable to get path for " + currSelected, e);
                }
+               params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
+                               input.getWorkspaceName());
+
+               CommandUtils.refreshParametrizedCommand(menuManager, window,
+                               OpenGenerateBinariesWizard.ID,
+                               OpenGenerateBinariesWizard.DEFAULT_LABEL,
+                               OpenGenerateBinariesWizard.DEFAULT_ICON, true, params);
+
+               // boolean isRelevant = false;
+               // try {
+               // isRelevant = currSelected.isNodeType(SlcTypes.SLC_CATEGORY);
+               // boolean canEdit = currSelected.canAddMixin(SlcTypes.SLC_CATEGORY);
+               //
+               // } catch (RepositoryException e) {
+               // throw new SlcException("unable to check type of node "
+               // + firstElement, e);
+               // }
+               // // Add
+               // if (isRelevant) {// Remove
+               // CommandUtils.refreshCommand(menuManager, window,
+               // MarkAsRelevantCategory.ID,
+               // MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
+               // MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
+               // } else {
+               // CommandUtils.refreshCommand(menuManager, window,
+               // MarkAsRelevantCategory.ID,
+               // MarkAsRelevantCategory.DEFAULT_LABEL,
+               // MarkAsRelevantCategory.DEFAULT_ICON, true);
+               // }
        }
 
        private SelectionAdapter getSelectionAdapter(final int index) {
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/ModularDistBaseElem.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/ModularDistBaseElem.java
deleted file mode 100644 (file)
index b856594..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.ArgeoException;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-
-/**
- * Abstract the base of a given modular distribution set i.e. the parent of all
- * versions of a given modular distribution
- */
-public class ModularDistBaseElem extends DistParentElem {
-
-       final static public String AETHER_CATEGORY_BASE = "categoryBase";
-       final static public String AETHER_BINARIES_TYPE = "binaries";
-       final static public String AETHER_DEP_TYPE = "dep";
-       private String type;
-       private Node modularDistBase;
-
-       public ModularDistBaseElem(WorkspaceElem wkspElem, String name,
-                       Node modularDistBase, String type) {
-               super(name, wkspElem.inHome(), wkspElem.isReadOnly());
-               setParent(wkspElem);
-               this.modularDistBase = modularDistBase;
-               this.type = type;
-       }
-
-       public Node getCategoryBase() {
-               // TODO clean this
-               if (type.equals(AETHER_CATEGORY_BASE))
-                       return modularDistBase;
-               else
-                       try {
-                               return modularDistBase.getParent();
-                       } catch (RepositoryException e) {
-                               throw new SlcException("unable tyo get parent node for "
-                                               + modularDistBase, e);
-                       }
-       }
-
-       /**
-        * Override normal behaviour to initialise children only when first
-        * requested
-        */
-       @Override
-       public synchronized boolean hasChildren() {
-               if (isLoaded()) {
-                       return super.hasChildren();
-               } else {
-                       return true;
-               }
-       };
-
-       /**
-        * Override normal behaviour to initialise children only when first
-        * requested
-        */
-       @Override
-       public synchronized Object[] getChildren() {
-               if (isLoaded()) {
-                       return super.getChildren();
-               } else {
-                       try {
-                               NodeIterator ni = getDistVersions();
-                               while (ni != null && ni.hasNext()) {
-                                       Node curNode = ni.nextNode();
-                                       if (curNode.hasProperty(SlcNames.SLC_ARTIFACT_VERSION))
-                                               addChild(new ModularDistVersionElem(this, curNode
-                                                               .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
-                                                               .getString(), curNode));
-                               }
-                               return super.getChildren();
-                       } catch (RepositoryException re) {
-                               throw new ArgeoException("Unable to retrieve children for "
-                                               + modularDistBase, re);
-                       }
-               }
-       }
-
-       private NodeIterator getDistVersions() {
-               try {
-                       if (AETHER_CATEGORY_BASE.equals(type))
-                               return null;
-
-                       QueryManager queryManager = modularDistBase.getSession()
-                                       .getWorkspace().getQueryManager();
-                       QueryObjectModelFactory factory = queryManager.getQOMFactory();
-                       Selector source = factory.selector(
-                                       SlcTypes.SLC_MODULAR_DISTRIBUTION,
-                                       SlcTypes.SLC_MODULAR_DISTRIBUTION);
-                       Constraint constraint = factory.descendantNode(
-                                       source.getSelectorName(), modularDistBase.getPath());
-                       // Ordering order = factory.descending(factory.propertyValue(
-                       // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
-                       // Ordering[] orderings = { order };
-                       QueryObjectModel query = factory.createQuery(source, constraint,
-                                       null, null);
-                       QueryResult queryResult = query.execute();
-                       return queryResult.getNodes();
-               } catch (RepositoryException e) {
-                       throw new SlcException(
-                                       "Unable to version for modular distribution: " + getName(),
-                                       e);
-               }
-       }
-
-       public String getType() {
-               return type;
-       }
-
-}
\ No newline at end of file
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/ModularDistVersionBaseElem.java
new file mode 100644 (file)
index 0000000..af42d87
--- /dev/null
@@ -0,0 +1,124 @@
+package org.argeo.slc.client.ui.dist.model;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+
+import org.argeo.ArgeoException;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+
+/**
+ * Abstract the base of a given modular distribution set i.e. the parent of all
+ * versions of a given modular distribution
+ */
+public class ModularDistVersionBaseElem extends DistParentElem {
+
+       // final static public String AETHER_CATEGORY_BASE = "categoryBase";
+       final static public String AETHER_BINARIES_TYPE = "binaries";
+       final static public String AETHER_DEP_TYPE = "dep";
+       private String type;
+       private Node modularDistVersionBase;
+
+       public ModularDistVersionBaseElem(WorkspaceElem wkspElem, String name,
+                       Node modularDistVersionBase, String type) {
+               super(name, wkspElem.inHome(), wkspElem.isReadOnly());
+               setParent(wkspElem);
+               this.modularDistVersionBase = modularDistVersionBase;
+               this.type = type;
+       }
+
+       public Node getModularDistBase() {
+               // // TODO clean this
+               // if (type.equals(AETHER_CATEGORY_BASE))
+               // return modularDistVersionBase;
+               // else
+               try {
+                       return modularDistVersionBase.getParent();
+               } catch (RepositoryException e) {
+                       throw new SlcException("unable to get parent node for "
+                                       + modularDistVersionBase, e);
+               }
+       }
+
+       public WorkspaceElem getWkspElem() {
+               return (WorkspaceElem) getParent();
+       }
+
+       /**
+        * Override normal behaviour to initialise children only when first
+        * requested
+        */
+       @Override
+       public synchronized boolean hasChildren() {
+               if (isLoaded()) {
+                       return super.hasChildren();
+               } else {
+                       return true;
+               }
+       };
+
+       /**
+        * Override normal behaviour to initialise children only when first
+        * requested
+        */
+       @Override
+       public synchronized Object[] getChildren() {
+               if (isLoaded()) {
+                       return super.getChildren();
+               } else {
+                       try {
+                               NodeIterator ni = getDistVersions();
+                               while (ni != null && ni.hasNext()) {
+                                       Node curNode = ni.nextNode();
+                                       if (curNode.hasProperty(SlcNames.SLC_ARTIFACT_VERSION))
+                                               addChild(new ModularDistVersionElem(this, curNode
+                                                               .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
+                                                               .getString(), curNode));
+                               }
+                               return super.getChildren();
+                       } catch (RepositoryException re) {
+                               throw new ArgeoException("Unable to retrieve children for "
+                                               + modularDistVersionBase, re);
+                       }
+               }
+       }
+
+       private NodeIterator getDistVersions() {
+               try {
+                       // if (AETHER_CATEGORY_BASE.equals(type))
+                       // return null;
+
+                       QueryManager queryManager = modularDistVersionBase.getSession()
+                                       .getWorkspace().getQueryManager();
+                       QueryObjectModelFactory factory = queryManager.getQOMFactory();
+                       Selector source = factory.selector(
+                                       SlcTypes.SLC_MODULAR_DISTRIBUTION,
+                                       SlcTypes.SLC_MODULAR_DISTRIBUTION);
+                       Constraint constraint = factory.descendantNode(
+                                       source.getSelectorName(), modularDistVersionBase.getPath());
+                       // Ordering order = factory.descending(factory.propertyValue(
+                       // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
+                       // Ordering[] orderings = { order };
+                       QueryObjectModel query = factory.createQuery(source, constraint,
+                                       null, null);
+                       QueryResult queryResult = query.execute();
+                       return queryResult.getNodes();
+               } catch (RepositoryException e) {
+                       throw new SlcException(
+                                       "Unable to version for modular distribution: " + getName(),
+                                       e);
+               }
+       }
+
+       public String getType() {
+               return type;
+       }
+}
\ No newline at end of file
index 54a82e812d161ad50b06fdb50457cb76e236cf25..23c757895ed70d87479863ca360e2b0e47f4e260 100644 (file)
@@ -9,7 +9,7 @@ import javax.jcr.Node;
 public class ModularDistVersionElem extends DistParentElem {
        private final Node modularDistVersionNode;
 
-       public ModularDistVersionElem(ModularDistBaseElem modularDistGroupElem,
+       public ModularDistVersionElem(ModularDistVersionBaseElem modularDistGroupElem,
                        String version, Node modularDistVersionNode) {
                super(version, modularDistGroupElem.inHome(), modularDistGroupElem
                                .isReadOnly());
index 3dc56ed2bb1c844a4cd52a13490a7dadb4360a1a..28841c8695aaf51195a6fe881e7af9756ba3dfd6 100644 (file)
@@ -199,20 +199,32 @@ public class RepoElem extends DistParentElem {
                return uri;
        }
 
+       public String getRepoNodePath() {
+               if (repoNode == null)
+                       return null;
+               else
+                       try {
+                               return repoNode.getPath();
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot get node path for repository "
+                                               + label, e);
+                       }
+       }
+
        /**
         * Exposes the local repoNode that completely define a connection to a
         * repository (including a set of credentials). Might return null in case of
         * an anonymous user
         */
-       public Node getRepoNode() {
+       protected Node getRepoNode() {
                return repoNode;
        }
 
-       public Repository getRepository() {
+       protected Repository getRepository() {
                return repository;
        }
-       
-       public Credentials getCredentials() {
+
+       protected Credentials getCredentials() {
                return credentials;
        }
 
index c3088ebb22e8932382bd50f0b5b82a0c9e8cc367..e35c66da4515f3f799bb2872bff04282eff1d65d 100644 (file)
@@ -4,6 +4,7 @@ import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 
 import org.argeo.ArgeoException;
@@ -82,8 +83,17 @@ public class WorkspaceElem extends DistParentElem {
                                                                "select * from ["
                                                                                + SlcTypes.SLC_MODULAR_DISTRIBUTION
                                                                                + "]", Query.JCR_SQL2);
-                               NodeIterator distributions = groupQuery.execute().getNodes();
-                               distribs: while (distributions.hasNext()) {
+                               NodeIterator distributions = null;
+                               try {
+                                       distributions = groupQuery.execute().getNodes();
+                               } catch (InvalidQueryException iqe) {
+                                       // For legacy only does not throw an exception while
+                                       // browsing
+                                       // legacy repositories that does not know
+                                       // SLC_MODULAR_DISTRIBUTION type
+                               }
+                               distribs: while (distributions != null
+                                               && distributions.hasNext()) {
                                        Node currDist = distributions.nextNode();
                                        Node distBase = currDist.getParent().getParent();
                                        if (!distBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
@@ -95,35 +105,17 @@ public class WorkspaceElem extends DistParentElem {
 
                                        String name;
                                        String type;
-                                       if (ModularDistBaseElem.AETHER_BINARIES_TYPE
+                                       if (ModularDistVersionBaseElem.AETHER_BINARIES_TYPE
                                                        .equals(artifactId)) {
                                                name = groupId;
-                                               type = ModularDistBaseElem.AETHER_BINARIES_TYPE;
+                                               type = ModularDistVersionBaseElem.AETHER_BINARIES_TYPE;
                                        } else {
                                                name = artifactId;
-                                               type = ModularDistBaseElem.AETHER_DEP_TYPE;
+                                               type = ModularDistVersionBaseElem.AETHER_DEP_TYPE;
                                        }
                                        if (getChildByName(name) == null)
-                                               addChild(new ModularDistBaseElem(WorkspaceElem.this,
-                                                               name, distBase, type));
-                               }
-                               // Add empty group base that have been marked as relevant
-                               groupQuery = currSession
-                                               .getWorkspace()
-                                               .getQueryManager()
-                                               .createQuery(
-                                                               "select * from ["
-                                                                               + SlcTypes.SLC_CATEGORY + "]",
-                                                               Query.JCR_SQL2);
-                               distributions = groupQuery.execute().getNodes();
-                               while (distributions.hasNext()) {
-                                       Node distBase = distributions.nextNode();
-                                       String groupBaseId = distBase.getProperty(
-                                                       SlcNames.SLC_GROUP_BASE_ID).getString();
-                                       if (getChildByName(groupBaseId) == null)
-                                               addChild(new ModularDistBaseElem(WorkspaceElem.this,
-                                                               groupBaseId, distBase,
-                                                               ModularDistBaseElem.AETHER_CATEGORY_BASE));
+                                               addChild(new ModularDistVersionBaseElem(
+                                                               WorkspaceElem.this, name, distBase, type));
                                }
                                return super.getChildren();
                        } catch (RepositoryException e) {
index 84cb8e5efe6f5381eb7ee5b97b7a117f29520868..677bed994e0036b8962a03ad30c08eb54ffbdecf 100644 (file)
@@ -46,7 +46,7 @@ import org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
 import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
 import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistBaseElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
 import org.argeo.slc.client.ui.dist.model.RepoElem;
 import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
 import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
@@ -128,57 +128,58 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
                                .getActiveWorkbenchWindow();
 
+               // Most of the implemented commands support only one selected
+               // element
+               boolean singleElement = ((IStructuredSelection) viewer.getSelection())
+                               .size() == 1;
+               // Get Current selected item :
+               Object firstElement = ((IStructuredSelection) viewer.getSelection())
+                               .getFirstElement();
+
                try {
-                       // Most of the implemented commands support only one selected
-                       // element
-                       boolean singleElement = ((IStructuredSelection) viewer
-                                       .getSelection()).size() == 1;
-                       // Get Current selected item :
-                       Object firstElement = ((IStructuredSelection) viewer.getSelection())
-                                       .getFirstElement();
 
                        if (firstElement instanceof TreeParent
                                        || firstElement instanceof DistParentElem) {
 
                                String targetRepoPath = null, workspaceName = null, workspacePrefix = null;
+                               String modularDistBasePath = null;
                                // String targetRepoUri = null;
                                // Build conditions depending on element type
-                               boolean isDistribElem = false, isModularDistBaseElem = false, isRepoElem = false, isDistribGroupElem = false;
+                               boolean isDistribElem = false, isModularDistVersionBaseElem = false, isRepoElem = false, isDistribGroupElem = false;
                                boolean isLocal = false, isReadOnly = true;
 
                                RepoElem re = null;
 
-                               if (firstElement instanceof WorkspaceElem) {
-                                       WorkspaceElem de = (WorkspaceElem) firstElement;
-                                       re = (RepoElem) de.getParent().getParent();
-                                       isDistribElem = true;
-                                       isReadOnly = de.isReadOnly();
-                                       workspaceName = de.getWorkspaceName();
-                                       isLocal = de.inHome();
-                               } else if (firstElement instanceof RepoElem) {
+                               if (firstElement instanceof RepoElem) {
                                        re = (RepoElem) firstElement;
                                        isRepoElem = true;
                                        isLocal = re.inHome();
                                        isReadOnly = re.isReadOnly();
-                               } else if (firstElement instanceof ModularDistBaseElem) {
-                                       ModularDistBaseElem mdbe = (ModularDistBaseElem) firstElement;
-                                       re = (RepoElem) mdbe.getParent().getParent().getParent();
-                                       isModularDistBaseElem = true;
-                                       isLocal = re.inHome();
-                                       isReadOnly = re.isReadOnly();
                                } else if (firstElement instanceof WkspGroupElem) {
                                        WkspGroupElem wge = (WkspGroupElem) firstElement;
                                        isReadOnly = wge.isReadOnly();
                                        isDistribGroupElem = true;
                                        re = (RepoElem) wge.getParent();
                                        workspacePrefix = wge.getName();
+                               } else if (firstElement instanceof WorkspaceElem) {
+                                       WorkspaceElem we = (WorkspaceElem) firstElement;
+                                       re = we.getRepoElem();
+                                       isDistribElem = true;
+                                       isReadOnly = we.isReadOnly();
+                                       workspaceName = we.getWorkspaceName();
+                                       isLocal = we.inHome();
+                               } else if (firstElement instanceof ModularDistVersionBaseElem) {
+                                       ModularDistVersionBaseElem mdbe = (ModularDistVersionBaseElem) firstElement;
+                                       isModularDistVersionBaseElem = true;
+                                       re = mdbe.getWkspElem().getRepoElem();
+                                       isLocal = re.inHome();
+                                       isReadOnly = re.isReadOnly();
+                                       workspaceName = mdbe.getWkspElem().getWorkspaceName();
+                                       modularDistBasePath = mdbe.getModularDistBase().getPath();
                                }
 
-                               // TODO add case for goups
-
                                if (re != null) {
-                                       // targetRepoUri = re.getUri();
-                                       targetRepoPath = re.getRepoNode().getPath();
+                                       targetRepoPath = re.getRepoNodePath();
                                }
 
                                // Display repo info
@@ -198,18 +199,19 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                                CreateWorkspace.ID, CreateWorkspace.DEFAULT_LABEL,
                                                CreateWorkspace.DEFAULT_ICON,
                                                (isRepoElem || isDistribGroupElem) && singleElement
-                                                               && !isReadOnly  && !isLocal, params);
+                                                               && !isReadOnly && !isLocal, params);
 
                                // TODO Manage the case where it is not a java workspace
                                params = new HashMap<String, String>();
                                params.put(CreateLocalJavaWorkspace.PARAM_WORKSPACE_PREFIX,
                                                workspacePrefix);
                                CommandUtils.refreshParametrizedCommand(menuManager, window,
-                                               CreateLocalJavaWorkspace.ID, CreateLocalJavaWorkspace.DEFAULT_LABEL,
+                                               CreateLocalJavaWorkspace.ID,
+                                               CreateLocalJavaWorkspace.DEFAULT_LABEL,
                                                CreateLocalJavaWorkspace.DEFAULT_ICON,
                                                (isRepoElem || isDistribGroupElem) && singleElement
                                                                && !isReadOnly && isLocal, params);
-                               
+
                                // Register a remote repository
                                CommandUtils.refreshCommand(menuManager, window,
                                                RegisterRepository.ID,
@@ -255,14 +257,15 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                                CopyWorkspace.ID, CopyWorkspace.DEFAULT_LABEL,
                                                CopyWorkspace.DEFAULT_ICON, isDistribElem
                                                                && singleElement && !isLocal, params);
-                               
+
                                params = new HashMap<String, String>();
                                params.put(CopyLocalJavaWorkspace.PARAM_SOURCE_WORKSPACE_NAME,
                                                workspaceName);
                                CommandUtils.refreshParametrizedCommand(menuManager, window,
-                                               CopyLocalJavaWorkspace.ID, CopyLocalJavaWorkspace.DEFAULT_LABEL,
+                                               CopyLocalJavaWorkspace.ID,
+                                               CopyLocalJavaWorkspace.DEFAULT_LABEL,
                                                CopyLocalJavaWorkspace.DEFAULT_ICON, isDistribElem
-                                                               && singleElement&& isLocal, params);
+                                                               && singleElement && isLocal, params);
 
                                // Clear Workspace
                                params = new HashMap<String, String>();
@@ -310,13 +313,22 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                CommandUtils.refreshParametrizedCommand(submenu, window,
                                                RunInOsgi.ID, RunInOsgi.DEFAULT_LABEL,
                                                RunInOsgi.DEFAULT_ICON, isDistribElem && singleElement
-                                                               && isLocal, params);// Run in OSGi
+                                                               && isLocal, params);
 
-                               CommandUtils.refreshCommand(submenu, window,
+                               // Open generate binaries
+                               params = new HashMap<String, String>();
+                               params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
+                                               targetRepoPath);
+                               params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
+                                               modularDistBasePath);
+                               params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
+                                               workspaceName);
+
+                               CommandUtils.refreshParametrizedCommand(submenu, window,
                                                OpenGenerateBinariesWizard.ID,
                                                OpenGenerateBinariesWizard.DEFAULT_LABEL,
                                                OpenGenerateBinariesWizard.DEFAULT_ICON,
-                                               isModularDistBaseElem && !isReadOnly);
+                                               isModularDistVersionBaseElem && !isReadOnly, params);
 
                                if (submenu.getSize() > 0)
                                        menuManager.add(submenu);
@@ -332,7 +344,7 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                        }
                } catch (RepositoryException e) {
                        throw new SlcException("unexpected errror while "
-                                       + "building context menu", e);
+                                       + "building context menu for element " + firstElement, e);
                }
        }
 
index 136eae150c8c178b79f5d53fb2f07362664346b4..a76d38d146e0c623ffd73cd0f1e3bd17d6dd9820 100644 (file)
@@ -18,10 +18,8 @@ package org.argeo.slc.client.ui.dist.wizards;
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.jcr.Credentials;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
@@ -33,6 +31,7 @@ import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.client.ui.dist.PrivilegedJob;
+import org.argeo.slc.client.ui.dist.RepoService;
 import org.argeo.slc.client.ui.dist.utils.ViewerUtils;
 import org.argeo.slc.jcr.SlcTypes;
 import org.argeo.slc.repo.RepoConstants;
@@ -71,10 +70,10 @@ public class GenerateBinariesWizard extends Wizard {
                        .getLog(GenerateBinariesWizard.class);
 
        // Business objects
-       private String groupNodePath;
-       private Repository repository;
-       private Credentials credentials;
+       private final RepoService repoService;
+       private final String repoNodePath;
        private String wkspName;
+       private String groupNodePath;
 
        // The pages
        private RecapPage recapPage;
@@ -84,11 +83,11 @@ public class GenerateBinariesWizard extends Wizard {
        private Text latestVersionTxt;
        private Text highestArtifactVersionTxt;
 
-       public GenerateBinariesWizard(Repository repository,
-                       Credentials credentials, String wkspName, String groupNodePath) {
+       public GenerateBinariesWizard(RepoService repoService, String repoNodePath,
+                       String wkspName, String groupNodePath) {
                super();
-               this.repository = repository;
-               this.credentials = credentials;
+               this.repoService = repoService;
+               this.repoNodePath = repoNodePath;
                this.wkspName = wkspName;
                this.groupNodePath = groupNodePath;
        }
@@ -123,8 +122,8 @@ public class GenerateBinariesWizard extends Wizard {
                                        "Confirm Launch", msg);
 
                        if (result) {
-                               GenerateBinaryJob job = new GenerateBinaryJob(repository,
-                                               credentials, wkspName, groupNodePath,
+                               GenerateBinaryJob job = new GenerateBinaryJob(repoService,
+                                               repoNodePath, wkspName, groupNodePath,
                                                versionTxt.getText());
                                job.setUser(true);
                                job.schedule();
@@ -159,7 +158,8 @@ public class GenerateBinariesWizard extends Wizard {
                private void refreshValues() {
                        Session session = null;
                        try {
-                               session = repository.login(credentials, wkspName);
+                               session = repoService.getRemoteSession(repoNodePath, null,
+                                               wkspName);
                                Node groupNode = session.getNode(groupNodePath);
                                GenerateBinaries gb = GenerateBinaries.preProcessGroupNode(
                                                groupNode, null);
@@ -283,19 +283,18 @@ public class GenerateBinariesWizard extends Wizard {
         */
        private class GenerateBinaryJob extends PrivilegedJob {
 
-               private final Repository repository;
-               private final Credentials credentials;
+               private final RepoService repoService;
+               private final String repoNodePath;
                private final String wkspName;
                private final String groupNodePath;
                private final String version;
 
-               public GenerateBinaryJob(Repository repository,
-                               Credentials credentials, String wkspName, String groupNodePath,
-                               String version) {
+               public GenerateBinaryJob(RepoService repoService, String repoNodePath,
+                               String wkspName, String groupNodePath, String version) {
                        super("Fetch");
                        this.version = version;
-                       this.repository = repository;
-                       this.credentials = credentials;
+                       this.repoService = repoService;
+                       this.repoNodePath = repoNodePath;
                        this.wkspName = wkspName;
                        this.groupNodePath = groupNodePath;
                }
@@ -305,7 +304,8 @@ public class GenerateBinariesWizard extends Wizard {
                        Session session = null;
                        try {
                                ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
-                               session = repository.login(credentials, wkspName);
+                               session = repoService.getRemoteSession(repoNodePath, null,
+                                               wkspName);
                                Node groupBaseNode = session.getNode(groupNodePath);
                                GenerateBinaries.processGroupNode(groupBaseNode, version,
                                                monitor);
index fa4fa0c70cfb03a0424a0c0565c7c541c7339533..b0e65bce51612e757daedc4265c343ad9b620f9e 100644 (file)
@@ -420,14 +420,13 @@ public class RepoUtils implements ArgeoNames, SlcNames {
        /**
         * Shortcut to retrieve a session given variable information: Handle the
         * case where we only have an URI of the repository, that we want to connect
-        * as anonymous or the case of a identified connexion to a local or remote
+        * as anonymous or the case of a identified connection to a local or remote
         * repository.
         * 
         * Callers must close the session once it has been used
         */
-       public static Session getCorrespondingSession(
-                       RepositoryFactory repositoryFactory, Keyring keyring,
-                       Node repoNode, String uri, String workspaceName) {
+       public static Session getRemoteSession(RepositoryFactory repositoryFactory,
+                       Keyring keyring, Node repoNode, String uri, String workspaceName) {
                try {
                        if (repoNode == null && uri == null)
                                throw new SlcException(
@@ -453,6 +452,35 @@ public class RepoUtils implements ArgeoNames, SlcNames {
                }
        }
 
+       /**
+        * Shortcut to retrieve a session on a remote Jrc Repository from
+        * information stored in a local argeo node or from an URI: Handle the case
+        * where we only have an URI of the repository, that we want to connect as
+        * anonymous or the case of a identified connection to a local or remote
+        * repository.
+        * 
+        * Callers must close the session once it has been used
+        */
+       public static Session getRemoteSession(RepositoryFactory repositoryFactory,
+                       Keyring keyring, Repository localRepository, String repoNodePath,
+                       String uri, String workspaceName) {
+               Session localSession = null;
+               Node repoNode = null;
+               try {
+                       localSession = localRepository.login();
+                       if (repoNodePath != null && localSession.nodeExists(repoNodePath))
+                               repoNode = localSession.getNode(repoNodePath);
+
+                       return RepoUtils.getRemoteSession(repositoryFactory, keyring,
+                                       repoNode, uri, workspaceName);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot log to workspace " + workspaceName
+                                       + " for repo defined in " + repoNodePath, e);
+               } finally {
+                       JcrUtils.logoutQuietly(localSession);
+               }
+       }
+
        /**
         * Write group indexes: 'binaries' lists all bundles and their versions,
         * 'sources' list theire sources, and 'sdk' aggregates both.
index 1acaf98239372d1d51ebd0b43e05aa37ffeb1228..271e85eee85d43ee4310b394942843121ee392b7 100644 (file)
@@ -27,8 +27,8 @@ mixin
 - slc:groupBaseId (STRING) m
 
 // Mark a given group base as relevant to create modular distribution in the current workspace  
-[slc:category]
-mixin
+// [slc:category]
+// mixin
 
 [slc:distribution] > slc:artifactVersion
 mixin
@@ -38,8 +38,7 @@ mixin
 [slc:modularDistributionBase]
 mixin
 
-// Inherit from > slc:categorizedNameVersion ??
-// (not possible without migration)
+// Question: Extend slc:categorizedNameVersion ? (not possible without migration)
 [slc:modularDistribution] 
 mixin
 + slc:modules (nt:unstructured) m
index c12f86c85a674fd304346027b64917821c556ef4..15213fc0a53249e5c2886087a02d072f0a5e6d72 100644 (file)
@@ -105,7 +105,6 @@ public interface SlcNames {
        // shared OSGi
        public final static String SLC_SYMBOLIC_NAME = "slc:symbolic-name";
        public final static String SLC_BUNDLE_VERSION = "slc:bundle-version";
-       public final static String SLC_BUNDLE_DESCRIPTION = "slc:Bundle-Description";
 
        // slc:osgiBaseVersion
        public final static String SLC_MAJOR = "slc:major";
index 177dbb369d4d9862ed87a54fad6cd5755c365e63..5cb6a1361c43fa3b950b765491020e7a611e741b 100644 (file)
@@ -69,7 +69,7 @@ public interface SlcTypes {
        public final static String SLC_FRAGMENT_HOST = "slc:fragmentHost";
 
        // Distribution management
-       public final static String SLC_CATEGORY = "slc:category";
+       // public final static String SLC_CATEGORY = "slc:category";
        public final static String SLC_MODULAR_DISTRIBUTION_BASE = "slc:modularDistributionBase";
        public final static String SLC_MODULAR_DISTRIBUTION = "slc:modularDistribution";
        public final static String SLC_MODULE_COORDINATES = "slc:moduleCoordinates";