]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Work on index policies.
authorBruno Sinou <bsinou@argeo.org>
Wed, 19 Mar 2014 21:10:07 +0000 (21:10 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 19 Mar 2014 21:10:07 +0000 (21:10 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6899 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

29 files changed:
modules/org.argeo.slc.server.repo/META-INF/spring/services.xml
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/commands.xml
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.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/commands/CopyLocalJavaWorkspace.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CopyWorkspace.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java [new file with mode: 0644]
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CreateWorkspace.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/MarkAsRelevantCategory.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.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/editors/ModularDistVersionOverviewPage.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
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/DistributionBundleIndexer.java [deleted file]
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/JarFileIndexer.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/ModularDistributionIndexer.java [new file with mode: 0644]
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/PdeSourcesIndexer.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/GenerateBinaries.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/OsgiFactoryImpl.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
runtime/org.argeo.slc.support.jcr/src/main/resources/org/argeo/slc/jcr/slc.cnd

index 93fb545b146d7e1700c65b09e86ee63436109047..a4b2c26e02bf5111a9ae02d2b96abaf1539b2639 100644 (file)
@@ -27,7 +27,8 @@
                        <list>
                                <bean class="org.argeo.slc.repo.ArtifactIndexer" />
                                <bean class="org.argeo.slc.repo.JarFileIndexer" />
-                               <bean class="org.argeo.slc.repo.DistributionBundleIndexer" />
+                               <bean class="org.argeo.slc.repo.ModularDistributionIndexer" />
+                               <bean class="org.argeo.slc.repo.PdeSourcesIndexer" />
                        </list>
                </property>
                <property name="jcrRepository" ref="javaRepository" />
index 5c59eae2781cfdfb2ba863e0c8a62c64c125749d..d5e75b8a9af7a1aeebe9eb53d2f03eeb503d0720 100644 (file)
@@ -42,7 +42,8 @@
 
 
        <!-- WORKSPACE MANAGEMENT -->
-       <bean id="openWorkspaceEditor" class="org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor"
+       <bean id="openWorkspaceEditor"
+               class="org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor"
                scope="prototype">
                <property name="localRepository" ref="nodeRepository" />
        </bean>
                <property name="keyring" ref="keyring" />
        </bean>
 
+       <bean id="copyLocalJavaWorkspace"
+               class="org.argeo.slc.client.ui.dist.commands.CopyLocalJavaWorkspace">
+               <property name="javaRepoManager">
+                       <bean factory-bean="slcRepoManager" factory-method="getJavaRepoManager" />
+               </property>
+               <property name="nodeRepository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="createLocalJavaWorkspace"
+               class="org.argeo.slc.client.ui.dist.commands.CreateLocalJavaWorkspace">
+               <property name="javaRepoManager">
+                       <bean factory-bean="slcRepoManager" factory-method="getJavaRepoManager" />
+               </property>
+       </bean>
+
+
        <bean id="mergeWorkspaces" class="org.argeo.slc.client.ui.dist.commands.MergeWorkspaces">
                <property name="repositoryFactory" ref="repositoryFactory" />
                <property name="nodeRepository" ref="nodeRepository" />
index 3ddc3521f4a234526c15394d0f0896e2103ca977..1d2cd11c4f354095c2fabd600b63bc959efbfc2c 100644 (file)
                <property name="workspace" value="org.argeo.tp-1.3.1" />
        </bean>
 
-<!--   <bean id="nodeSession" class="org.argeo.jcr.spring.ThreadBoundSession"> -->
-<!--           <property name="repository" ref="nodeRepository" /> -->
-<!--   </bean> -->
-
-<!--   <bean id="keyring" class="org.argeo.security.jcr.JcrKeyring"> -->
-<!--           <property name="session" ref="nodeSession" /> -->
-<!--           <property name="defaultCallbackHandler" ref="defaultCallbackHandler" /> -->
-<!--   </bean> -->
-
+       <!-- For the record <property name="session"> <bean factory-bean="repository" 
+               factory-method="login" /> </property> -->
 </beans>
index 62036aac8439b848bd5352bd539bc295971c15e7..e8bc02d240e04e371946d2f3348cda1e4ca9dd75 100644 (file)
@@ -16,4 +16,6 @@
 \r
        <reference id="nodeRepository" interface="javax.jcr.Repository"\r
                filter="(argeo.jcr.repository.alias=node)" />\r
+\r
+       <reference id="slcRepoManager" interface="org.argeo.slc.repo.SlcRepoManager" />\r
 </beans:beans>
\ No newline at end of file
index 58623ebf51220747e6c75d436a2886328303ae47..530833b99be8b549a23ce20c481339c84e118ecd 100644 (file)
                        </commandParameter>
        </command>
        
+               <command
+            id="org.argeo.slc.client.ui.dist.mergeWorkspaces"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Copy chosen Workspace">
+            <commandParameter
+                       id="srcWkspName"
+                       name="Source Workspace Name">
+                       </commandParameter>
+          <commandParameter
+                       id="srcRepoPath"
+                       name="Source Repo Node path ">
+                       </commandParameter>
+           <commandParameter
+                       id="targetWkspName"
+                       name="Target Workspace Name">
+                       </commandParameter>
+            <commandParameter
+                       id="targetRepoPath"
+                       name="Target repo node path">
+                       </commandParameter>
+       </command>
+       
        <!-- Workspaces CRUD --> 
+               <!-- Generic new and copy workspace -->
                <command
             id="org.argeo.slc.client.ui.dist.createWorkspace"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
                        name="Target repo node path">
                        </commandParameter>
        </command>
-               <command
-                       id="org.argeo.slc.client.ui.dist.deleteWorkspace"
-                       defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-                       name="Delete chosen Workspace">
-                       <commandParameter
-                               id="workspaceName"
-                               name="Workspace name">
-                       </commandParameter>
-                       <commandParameter
-                               id="targetRepoPath"
-                               name="Target repo node path">
-                       </commandParameter>
-       </command>
-       
-               <command
+       <command
             id="org.argeo.slc.client.ui.dist.copyWorkspace"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="Copy chosen Workspace">
                        name="Target repo node path">
                        </commandParameter>
        </command>
-       
+       <!-- Specific for local java workspaces --> 
        <command
-            id="org.argeo.slc.client.ui.dist.mergeWorkspaces"
+            id="org.argeo.slc.client.ui.dist.createLocalJavaWorkspace"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            name="Copy chosen Workspace">
+            name="Create Local Java Workspace">
             <commandParameter
-                       id="srcWkspName"
-                       name="Source Workspace Name">
-                       </commandParameter>
-          <commandParameter
-                       id="srcRepoPath"
-                       name="Source Repo Node path ">
-                       </commandParameter>
-           <commandParameter
-                       id="targetWkspName"
-                       name="Target Workspace Name">
+                       id="workspacePrefix"
+                       name="Workspace prefix">
                        </commandParameter>
+       </command>
+               <command
+            id="org.argeo.slc.client.ui.dist.copyLocalJavaWorkspace"
+            defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+            name="Copy chosen local Java Workspace">
             <commandParameter
-                       id="targetRepoPath"
-                       name="Target repo node path">
+                       id="srcWkspName"
+                       name="Source Workspace Name">
                        </commandParameter>
        </command>
+               
+               <!-- Not terminated delete command - does not really work -->
+       <command
+                       id="org.argeo.slc.client.ui.dist.deleteWorkspace"
+                       defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+                       name="Delete chosen Workspace">
+                       <commandParameter
+                               id="workspaceName"
+                               name="Workspace name">
+                       </commandParameter>
+                       <commandParameter
+                               id="targetRepoPath"
+                               name="Target repo node path">
+                       </commandParameter>
+       </command>
        
-               <!-- Advanced commands --> 
+               <!-- Advanced commands --> 
                <command
             id="org.argeo.slc.client.ui.dist.doNothing"
             defaultHandler="org.argeo.slc.client.ui.dist.commands.DoNothing"
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CopyLocalJavaWorkspace.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CopyLocalJavaWorkspace.java
new file mode 100644 (file)
index 0000000..fa5ec4a
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.commands;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.Privilege;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.argeo.ArgeoMonitor;
+import org.argeo.eclipse.ui.EclipseArgeoMonitor;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.PrivilegedJob;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.repo.JavaRepoManager;
+import org.argeo.slc.repo.RepoUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Create a copy of the chosen workspace in the local Java repository using a
+ * JavaRepoManager.
+ */
+public class CopyLocalJavaWorkspace extends AbstractHandler {
+       private static final Log log = LogFactory
+                       .getLog(CopyLocalJavaWorkspace.class);
+
+       public final static String ID = DistPlugin.ID + ".copyLocalJavaWorkspace";
+       public final static String DEFAULT_LABEL = "Copy Java Workspace...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/addItem.gif");
+
+       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
+
+       // DEPENDENCY INJECTION
+       private Repository nodeRepository;
+       private JavaRepoManager javaRepoManager;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               String wkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
+
+               InputDialog inputDialog = new InputDialog(HandlerUtil
+                               .getActiveWorkbenchWindow(event).getShell(),
+                               "New copy of workspace " + wkspName,
+                               "Choose a name for the workspace to create", "", null);
+               int result = inputDialog.open();
+               if (result == Window.OK) {
+                       String newWorkspaceName = inputDialog.getValue();
+
+                       if (newWorkspaceName == null || newWorkspaceName.trim().equals("")
+                                       || newWorkspaceName.trim().equals(wkspName.trim())) {
+                               ErrorDialog
+                                               .openError(HandlerUtil.getActiveShell(event),
+                                                               "Non valid workspace name", newWorkspaceName
+                                                                               + " is not a valid workspace name.",
+                                                               new Status(IStatus.ERROR, "not valid", 0,
+                                                                               "Error", null));
+                               return null;
+                       }
+                       Job copyWkspJob = new CopyWkspJob(javaRepoManager, nodeRepository,
+                                       wkspName, newWorkspaceName, HandlerUtil
+                                                       .getActiveWorkbenchWindow(event).getShell()
+                                                       .getDisplay());
+                       copyWkspJob.setUser(true);
+                       copyWkspJob.schedule();
+               }
+               return null;
+       }
+
+       private static class CopyWkspJob extends PrivilegedJob {
+
+               private JavaRepoManager javaRepoManager;
+               private Repository localRepository;
+               private String srcWkspName;
+               private String targetWkspName;
+               private Display display;
+
+               public CopyWkspJob(JavaRepoManager javaRepoManager,
+                               Repository localRepository, String srcWkspName,
+                               String targetWkspName, Display display) {
+                       super("Duplicate workspace");
+                       this.javaRepoManager = javaRepoManager;
+                       this.localRepository = localRepository;
+                       this.srcWkspName = srcWkspName;
+                       this.targetWkspName = targetWkspName;
+                       this.display = display;
+               }
+
+               @Override
+               protected IStatus doRun(IProgressMonitor progressMonitor) {
+                       long begin = System.currentTimeMillis();
+
+                       ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
+                       monitor.beginTask("Copy workspace", -1);
+                       monitor.subTask("Copying nodes");
+
+                       Session srcSession = null;
+                       Session targetSession = null;
+                       try {
+                               // Initialize source
+                               srcSession = localRepository.login(srcWkspName);
+                               Node srcRootNode = srcSession.getRootNode();
+
+                               // Create the workspace -
+                               // FIXME will throw an error if workspace already exists
+                               javaRepoManager.createWorkspace(targetWkspName);
+                               targetSession = localRepository.login(targetWkspName);
+                               Node newRootNode = targetSession.getRootNode();
+
+                               RepoUtils.copy(srcRootNode, newRootNode);
+                               targetSession.save();
+                               JcrUtils.addPrivilege(targetSession, "/",
+                                               SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
+                               monitor.worked(1);
+
+                               display.asyncExec(new Runnable() {
+                                       public void run() {
+                                               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+                                       }
+                               });
+
+                       } catch (RepositoryException re) {
+                               throw new ArgeoException(
+                                               "Unexpected error while creating the new workspace.",
+                                               re);
+                       } finally {
+                               JcrUtils.logoutQuietly(srcSession);
+                               JcrUtils.logoutQuietly(targetSession);
+                       }
+
+                       monitor.done();
+                       long duration = (System.currentTimeMillis() - begin) / 1000;// in
+                                                                                                                                               // s
+                       if (log.isDebugEnabled())
+                               log.debug("Duplicated local java workspace " + srcWkspName
+                                               + " to workspace " + targetWkspName + " in "
+                                               + (duration / 60) + "min " + (duration % 60) + "s");
+                       return Status.OK_STATUS;
+               }
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setNodeRepository(Repository nodeRepository) {
+               this.nodeRepository = nodeRepository;
+       }
+
+       public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
+               this.javaRepoManager = javaRepoManager;
+       }
+}
\ No newline at end of file
index e1398b7700901ecd842fa1d7af1fe0e42eb71b70..f547068a237f8ab19df34de9c878d9093cf492a7 100644 (file)
@@ -50,19 +50,19 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
- * Create a copy of the chosen workspace in the current repository.
+ * Create a copy of the chosen workspace in a remote repository.
  */
-
 public class CopyWorkspace extends AbstractHandler {
        private static final Log log = LogFactory.getLog(CopyWorkspace.class);
 
        public final static String ID = DistPlugin.ID + ".copyWorkspace";
        public final static String DEFAULT_LABEL = "Duplicate...";
-       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
-       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
        public final static ImageDescriptor DEFAULT_ICON = DistPlugin
                        .getImageDescriptor("icons/addItem.gif");
 
+       public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
+       public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
+       
        // DEPENDENCY INJECTION
        private RepositoryFactory repositoryFactory;
        private Keyring keyring;
@@ -98,47 +98,6 @@ public class CopyWorkspace extends AbstractHandler {
                        copyWkspJob.setUser(true);
                        copyWkspJob.schedule();
                }
-
-               // Session nodeSession = null;
-               // Session srcSession = null;
-               // Session newSession = null;
-               // try {
-               // nodeSession = nodeRepository.login();
-               // Node repoNode = nodeSession.getNode(targetRepoPath);
-               // Repository repository = RepoUtils.getRepository(repositoryFactory,
-               // keyring, repoNode);
-               // Credentials credentials = RepoUtils.getRepositoryCredentials(
-               // keyring, repoNode);
-               //
-               // InputDialog inputDialog = new InputDialog(HandlerUtil
-               // .getActiveWorkbenchWindow(event).getShell(),
-               // "New copy of workspace " + wkspName,
-               // "Choose a name for the workspace to create", "", null);
-               // int result = inputDialog.open();
-               // if (result == Window.OK) {
-               // String newWorkspaceName = inputDialog.getValue();
-               // srcSession = repository.login(credentials, wkspName);
-               //
-               // // Create the workspace
-               // srcSession.getWorkspace().createWorkspace(newWorkspaceName);
-               // Node srcRootNode = srcSession.getRootNode();
-               // // log in the newly created workspace
-               // newSession = repository.login(credentials, newWorkspaceName);
-               // Node newRootNode = newSession.getRootNode();
-               // RepoUtils.copy(srcRootNode, newRootNode);
-               // newSession.save();
-               // JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
-               // Privilege.JCR_ALL);
-               // CommandHelpers.callCommand(RefreshDistributionsView.ID);
-               // }
-               // } catch (RepositoryException re) {
-               // throw new ArgeoException(
-               // "Unexpected error while creating the new workspace.", re);
-               // } finally {
-               // JcrUtils.logoutQuietly(newSession);
-               // JcrUtils.logoutQuietly(srcSession);
-               // JcrUtils.logoutQuietly(nodeSession);
-               // }
                return null;
        }
 
diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/CreateLocalJavaWorkspace.java
new file mode 100644 (file)
index 0000000..f15ee77
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.client.ui.dist.commands;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.ErrorFeedback;
+import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
+import org.argeo.slc.repo.JavaRepoManager;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Create a new empty workspace in the default local java repository.
+ */
+public class CreateLocalJavaWorkspace extends AbstractHandler {
+       private static final Log log = LogFactory
+                       .getLog(CreateLocalJavaWorkspace.class);
+
+       // Exposes commands meta-info
+       public final static String ID = DistPlugin.ID + ".createLocalJavaWorkspace";
+       public final static String DEFAULT_LABEL = "Create local Java workspace...";
+       public final static ImageDescriptor DEFAULT_ICON = DistPlugin
+                       .getImageDescriptor("icons/addItem.gif");
+
+       // Parameters
+       public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
+
+       /* DEPENDENCY INJECTION */
+       private JavaRepoManager javaRepoManager;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+
+               String prefix = event.getParameter(PARAM_WORKSPACE_PREFIX);
+               // TODO : add an input validator
+               InputDialog inputDialog = new InputDialog(HandlerUtil
+                               .getActiveWorkbenchWindow(event).getShell(), "Workspace name?",
+                               "Choose a name for the workspace to create",
+                               prefix == null ? "" : prefix + "-", null);
+               int result = inputDialog.open();
+
+               String enteredName = inputDialog.getValue();
+               final String legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
+               char[] arr = enteredName.toUpperCase().toCharArray();
+               int count = 0;
+               for (int i = 0; i < arr.length; i++) {
+                       if (legalChars.indexOf(arr[i]) == -1)
+                               count = count + 7;
+                       else
+                               count++;
+               }
+
+               if (count > 60) {
+                       ErrorFeedback.show("Workspace name '" + enteredName
+                                       + "' is too long or contains"
+                                       + " too many special characters such as '.' or '-'.");
+                       return null;
+               }
+
+               String workspaceName = enteredName;
+               // Canceled by user
+               if (result == Dialog.CANCEL || workspaceName == null
+                               || "".equals(workspaceName.trim()))
+                       return null;
+
+               // FIXME will throw an exception if this workspace name is already used.
+               javaRepoManager.createWorkspace(workspaceName);
+
+               CommandHelpers.callCommand(RefreshDistributionsView.ID);
+               if (log.isTraceEnabled())
+                       log.trace("WORKSPACE " + workspaceName + " CREATED");
+
+               return null;
+       }
+
+       /* DEPENDENCY INJECTION */
+       public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
+               this.javaRepoManager = javaRepoManager;
+       }
+}
\ No newline at end of file
index 681e0fed79dd586dd9075d99108ab4e5b34556ca..95dee2b6e655d9c6f589196f878b3a8b84c0eb66 100644 (file)
@@ -41,7 +41,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
- * Create a new empty workspace in the current repository.
+ * Create a new empty workspace in a remote repository.
  */
 public class CreateWorkspace extends AbstractHandler {
        private static final Log log = LogFactory.getLog(CreateWorkspace.class);
@@ -81,7 +81,7 @@ public class CreateWorkspace extends AbstractHandler {
                                        .getActiveWorkbenchWindow(event).getShell(),
                                        "Workspace name?",
                                        "Choose a name for the workspace to create",
-                                       prefix == null ? "" : prefix + "_", null);
+                                       prefix == null ? "" : prefix + "-", null);
                        int result = inputDialog.open();
 
                        String enteredName = inputDialog.getValue();
index ae617087f6e998955568bd40091f88dad194c448..f4f8bcbc3db57b8e4761342519894f953b2c0075 100644 (file)
@@ -61,13 +61,13 @@ public class MarkAsRelevantCategory extends AbstractHandler {
                                                        .iterator();
 
                                        Node node = (Node) it.next();
-                                       if (node.isNodeType(SlcTypes.SLC_RELEVANT_CATEGORY)) {
+                                       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_RELEVANT_CATEGORY);
+                                                       node.removeMixin(SlcTypes.SLC_CATEGORY);
                                                        node.getSession().save();
                                                }
                                        } else {
@@ -77,7 +77,7 @@ public class MarkAsRelevantCategory extends AbstractHandler {
                                                if (MessageDialog.openConfirm(DistPlugin.getDefault()
                                                                .getWorkbench().getDisplay().getActiveShell(),
                                                                "Confirm", msg)) {
-                                                       node.addMixin(SlcTypes.SLC_RELEVANT_CATEGORY);
+                                                       node.addMixin(SlcTypes.SLC_CATEGORY);
                                                        node.getSession().save();
                                                }
                                        }
index d70d904f9bfdaf5028b6c6fed1f46018defdca53..7f3f3b5a3968d090ee9c649eff823b4a21c25bf1 100644 (file)
@@ -36,7 +36,7 @@ import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.DistributionBundleIndexer;
+import org.argeo.slc.repo.ModularDistributionIndexer;
 import org.argeo.slc.repo.JarFileIndexer;
 import org.argeo.slc.repo.PdeSourcesIndexer;
 import org.argeo.slc.repo.RepoConstants;
@@ -74,12 +74,11 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
        private Keyring keyring;
        private Repository repository;
 
-       // RElevant default node indexers 
+       // Relevant default node indexers
        private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
        private JarFileIndexer jarFileIndexer = new JarFileIndexer();
-       private DistributionBundleIndexer distBundleIndexer = new DistributionBundleIndexer();
-       private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer(
-                       artifactIndexer, jarFileIndexer);
+       private ModularDistributionIndexer distBundleIndexer = new ModularDistributionIndexer();
+       private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer();
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
                String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
@@ -201,11 +200,15 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
                                                        monitor.worked(1);
                                                }
                                } else if (node.getName().endsWith(".pom")) {
-                                       distBundleIndexer.index(node);
+                                       if (distBundleIndexer.support(node.getPath()))
+                                               distBundleIndexer.index(node);
+                                       if (artifactIndexer.support(node.getPath()))
+                                               artifactIndexer.index(node);
                                        if (node.getSession().hasPendingChanges()) {
                                                node.getSession().save();
                                                if (log.isDebugEnabled())
-                                                       log.debug("Processed pom artifact " + node.getPath());
+                                                       log.debug("Processed pom artifact "
+                                                                       + node.getPath());
                                        }
                                        monitor.worked(1);
                                } else {
index 288475f23e8c9170a8352aab4f31fe3f5270e3ab..1c2ad68c33b33c29eda85f397d7d1cf8c6ef8185 100644 (file)
@@ -17,9 +17,10 @@ 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 javax.jcr.Session;
 
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
@@ -62,14 +63,22 @@ public class OpenGenerateBinariesWizard extends AbstractHandler {
                                Object element = it.next();
                                if (element instanceof ModularDistBaseElem) {
                                        ModularDistBaseElem elem = (ModularDistBaseElem) element;
-                                       Session newSession = null;
+                                       // Session newSession = null;
                                        try {
                                                Node cBase = elem.getCategoryBase();
-                                               String path = cBase.getPath();
-                                               newSession = ((WorkspaceElem) elem.getParent())
-                                                               .getNewSession();
+                                               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();
+
                                                GenerateBinariesWizard wizard = new GenerateBinariesWizard(
-                                                               newSession.getNode(path));
+                                                               repository, credentials, wkspName, catBasePath);
 
                                                WizardDialog dialog = new WizardDialog(
                                                                HandlerUtil.getActiveShell(event), wizard);
@@ -82,6 +91,8 @@ public class OpenGenerateBinariesWizard extends AbstractHandler {
                                                throw new SlcException(
                                                                "Unable to duplicate session for node " + elem,
                                                                re);
+                                               // } finally {
+                                               // JcrUtils.logoutQuietly(newSession);
                                        }
                                }
 
index 66df95cc6bb945bb9fbc75828ee91957bec654f8..38b3a8b463e01efcf04fc91b91da55b0aa95a5de 100644 (file)
@@ -126,10 +126,8 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                layout.verticalSpacing = 0;
                body.setLayout(layout);
                try {
-                       form.setText(modularDistribution
-                                       .hasProperty(DistConstants.SLC_BUNDLE_NAME) ? modularDistribution
-                                       .getProperty(DistConstants.SLC_BUNDLE_NAME).getString()
-                                       : "");
+                       form.setText(modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
+                                       .getProperty(SlcNames.SLC_NAME).getString() : "");
                        form.setMessage(
                                        modularDistribution
                                                        .hasProperty(SlcNames.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
@@ -162,22 +160,19 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                        createLT(
                                        parent,
                                        "Category",
-                                       modularDistribution.hasProperty(SlcNames.SLC_GROUP_ID) ? modularDistribution
-                                                       .getProperty(SlcNames.SLC_GROUP_ID).getString()
+                                       modularDistribution.hasProperty(SlcNames.SLC_CATEGORY) ? modularDistribution
+                                                       .getProperty(SlcNames.SLC_CATEGORY).getString()
                                                        : "");
                        createLT(
                                        parent,
                                        "Name",
-                                       modularDistribution.hasProperty(SlcNames.SLC_SYMBOLIC_NAME) ? modularDistribution
-                                                       .getProperty(SlcNames.SLC_SYMBOLIC_NAME)
-                                                       .getString() : "");
+                                       modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
+                                                       .getProperty(SlcNames.SLC_NAME).getString() : "");
                        createLT(
                                        parent,
                                        "Version",
-                                       modularDistribution
-                                                       .hasProperty(SlcNames.SLC_BUNDLE_VERSION) ? modularDistribution
-                                                       .getProperty(SlcNames.SLC_BUNDLE_VERSION)
-                                                       .getString() : "");
+                                       modularDistribution.hasProperty(SlcNames.SLC_VERSION) ? modularDistribution
+                                                       .getProperty(SlcNames.SLC_VERSION).getString() : "");
 
                        // 2nd Line: Vendor, licence, sources
                        createLT(
@@ -186,7 +181,7 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                                        modularDistribution
                                                        .hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? modularDistribution
                                                        .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
-                                                       .getString() : "");
+                                                       .getString() : "N/A");
 
                        createHyperlink(parent, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
                        addSourceSourcesLink(parent);
@@ -237,7 +232,7 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                                }
                        });
                } else
-                       tk.createLabel(parent, "", SWT.NONE);
+                       tk.createLabel(parent, "N/A", SWT.NONE);
        }
 
        // helper to check if sources are available
@@ -252,12 +247,16 @@ public class ModularDistVersionOverviewPage extends FormPage implements
                                Node sourcesNode = modularDistribution.getSession().getNode(
                                                srcPath);
 
+                               String srcName = null;
+                               if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
+                                       srcName = sourcesNode.getProperty(
+                                                       SlcNames.SLC_SYMBOLIC_NAME).getString();
+                               else
+                                       srcName = sourcesNode.getName();
                                Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
                                label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
                                                false));
-
-                               final Hyperlink link = tk.createHyperlink(parent, sourcesNode
-                                               .getProperty(SlcNames.SLC_SYMBOLIC_NAME).getString(),
+                               final Hyperlink link = tk.createHyperlink(parent, srcName,
                                                SWT.NONE);
                                link.addHyperlinkListener(new AbstractHyperlinkListener() {
                                        @Override
index 6479eb5343b6814f8dadd007ecb9d5377bb50a85..c8b87c0a455753cabd58c50aff4e0fa7da61e3a5 100644 (file)
@@ -287,7 +287,7 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                        public String getText(Object element) {
                                try {
                                        return ((Node) element)
-                                                       .isNodeType(SlcTypes.SLC_RELEVANT_CATEGORY) ? "Yes"
+                                                       .isNodeType(SlcTypes.SLC_CATEGORY) ? "Yes"
                                                        : "No";
                                } catch (RepositoryException e) {
                                        throw new SlcException("unable to check type of node "
@@ -344,9 +344,9 @@ public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
                boolean isRelevant = false;
                try {
                        isRelevant = currSelected
-                                       .isNodeType(SlcTypes.SLC_RELEVANT_CATEGORY);
+                                       .isNodeType(SlcTypes.SLC_CATEGORY);
                        boolean canEdit = currSelected
-                                       .canAddMixin(SlcTypes.SLC_RELEVANT_CATEGORY);
+                                       .canAddMixin(SlcTypes.SLC_CATEGORY);
 
                } catch (RepositoryException e) {
                        throw new SlcException("unable to check type of node "
index 54fdf107054c38aa083b3d760d3f479c93733dc5..b85659440e3156bf93b90897c3458c2b769c6b85 100644 (file)
@@ -49,7 +49,8 @@ public class ModularDistBaseElem extends DistParentElem {
        }
 
        /**
-        * Override normal behaviour to initialise children only when first requested
+        * Override normal behaviour to initialise children only when first
+        * requested
         */
        @Override
        public synchronized boolean hasChildren() {
@@ -61,7 +62,8 @@ public class ModularDistBaseElem extends DistParentElem {
        };
 
        /**
-        * Override normal behaviour to initialise children only when first requested
+        * Override normal behaviour to initialise children only when first
+        * requested
         */
        @Override
        public synchronized Object[] getChildren() {
@@ -72,15 +74,15 @@ public class ModularDistBaseElem extends DistParentElem {
                                NodeIterator ni = getDistVersions();
                                while (ni != null && ni.hasNext()) {
                                        Node curNode = ni.nextNode();
-                                       addChild(new ModularDistVersionElem(this, curNode
-                                                       .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
-                                                       .getString(), curNode));
+                                       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);
+                               throw new ArgeoException("Unable to retrieve children for "
+                                               + modularDistBase, re);
                        }
                }
        }
index 0567b31939fd53410ec3481532497d7275e2fc81..c3088ebb22e8932382bd50f0b5b82a0c9e8cc367 100644 (file)
@@ -113,7 +113,7 @@ public class WorkspaceElem extends DistParentElem {
                                                .getQueryManager()
                                                .createQuery(
                                                                "select * from ["
-                                                                               + SlcTypes.SLC_RELEVANT_CATEGORY + "]",
+                                                                               + SlcTypes.SLC_CATEGORY + "]",
                                                                Query.JCR_SQL2);
                                distributions = groupQuery.execute().getNodes();
                                while (distributions.hasNext()) {
index 2838863173137385986c2816d043bc8193b2fecc..84cb8e5efe6f5381eb7ee5b97b7a117f29520868 100644 (file)
@@ -26,17 +26,17 @@ import org.argeo.eclipse.ui.utils.CommandUtils;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.commands.CopyLocalJavaWorkspace;
 import org.argeo.slc.client.ui.dist.commands.CopyWorkspace;
+import org.argeo.slc.client.ui.dist.commands.CreateLocalJavaWorkspace;
 import org.argeo.slc.client.ui.dist.commands.CreateWorkspace;
 import org.argeo.slc.client.ui.dist.commands.DeleteWorkspace;
 import org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation;
 import org.argeo.slc.client.ui.dist.commands.Fetch;
-import org.argeo.slc.client.ui.dist.commands.MergeWorkspaces;
 import org.argeo.slc.client.ui.dist.commands.NormalizeDistribution;
 import org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace;
 import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
 import org.argeo.slc.client.ui.dist.commands.PublishWorkspace;
-import org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView;
 import org.argeo.slc.client.ui.dist.commands.RegisterRepository;
 import org.argeo.slc.client.ui.dist.commands.RunInOsgi;
 import org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo;
@@ -50,26 +50,16 @@ import org.argeo.slc.client.ui.dist.model.ModularDistBaseElem;
 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;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
 import org.argeo.slc.jcr.SlcNames;
 import org.eclipse.jface.action.IContributionItem;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceAdapter;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Tree;
@@ -119,12 +109,6 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                // Enable retrieving current tree selected items from outside the view
                getSite().setSelectionProvider(viewer);
 
-               // Drag and drop
-               Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
-               int operations = DND.DROP_COPY | DND.DROP_MOVE;
-               viewer.addDragSupport(operations, tt, new ViewDragListener());
-               viewer.addDropSupport(operations, tt, new ViewDropListener(viewer));
-
                MenuManager menuManager = new MenuManager();
                Menu menu = menuManager.createContextMenu(viewer.getTree());
                menuManager.addMenuListener(new IMenuListener() {
@@ -214,8 +198,18 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                                CreateWorkspace.ID, CreateWorkspace.DEFAULT_LABEL,
                                                CreateWorkspace.DEFAULT_ICON,
                                                (isRepoElem || isDistribGroupElem) && singleElement
-                                                               && !isReadOnly, 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.DEFAULT_ICON,
+                                               (isRepoElem || isDistribGroupElem) && singleElement
+                                                               && !isReadOnly && isLocal, params);
+                               
                                // Register a remote repository
                                CommandUtils.refreshCommand(menuManager, window,
                                                RegisterRepository.ID,
@@ -260,7 +254,15 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                CommandUtils.refreshParametrizedCommand(menuManager, window,
                                                CopyWorkspace.ID, CopyWorkspace.DEFAULT_LABEL,
                                                CopyWorkspace.DEFAULT_ICON, isDistribElem
-                                                               && singleElement, params);
+                                                               && 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.DEFAULT_ICON, isDistribElem
+                                                               && singleElement&& isLocal, params);
 
                                // Clear Workspace
                                params = new HashMap<String, String>();
@@ -347,78 +349,6 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                viewer.expandToLevel(2);
        }
 
-       /** Listens to drag */
-       class ViewDragListener extends DragSourceAdapter {
-               public void dragSetData(DragSourceEvent event) {
-                       IStructuredSelection selection = (IStructuredSelection) viewer
-                                       .getSelection();
-                       if (selection.getFirstElement() instanceof WorkspaceElem) {
-                               WorkspaceElem de = (WorkspaceElem) selection.getFirstElement();
-                               if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
-                                       event.data = ((RepoElem) de.getParent().getParent())
-                                                       .getUri() + "/" + de.getWorkspaceName();
-                               }
-                       }
-               }
-       }
-
-       /** Listens to drop */
-       class ViewDropListener extends ViewerDropAdapter {
-
-               public ViewDropListener(Viewer viewer) {
-                       super(viewer);
-               }
-
-               @Override
-               public boolean performDrop(Object data) {
-                       WorkspaceElem sourceWksp = (WorkspaceElem) getSelectedObject();
-                       RepoElem targetRepo = (RepoElem) getCurrentTarget();
-
-                       Boolean ok = MessageDialog.openConfirm(
-                                       getSite().getShell(),
-                                       "Confirm distribution merge",
-                                       "Do you want to merge "
-                                                       + sourceWksp.getWorkspaceName()
-                                                       + " (from repo "
-                                                       + ((RepoElem) sourceWksp.getParent().getParent())
-                                                                       .getLabel() + ") to repo "
-                                                       + targetRepo.getLabel() + "?");
-                       if (!ok)
-                               return false;
-
-                       try {
-                               Map<String, String> params = new HashMap<String, String>();
-                               params.put(MergeWorkspaces.PARAM_TARGET_REPO_PATH, targetRepo
-                                               .getRepoNode().getPath());
-                               params.put(MergeWorkspaces.PARAM_SOURCE_REPO_PATH,
-                                               ((RepoElem) sourceWksp.getParent().getParent())
-                                                               .getRepoNode().getPath());
-                               params.put(MergeWorkspaces.PARAM_SOURCE_WORKSPACE_NAME,
-                                               sourceWksp.getWorkspaceName());
-                               CommandHelpers.callCommand(RefreshDistributionsView.ID, params);
-                               return true;
-                       } catch (RepositoryException e) {
-                               throw new SlcException("Cannot process drop from " + sourceWksp
-                                               + " to " + targetRepo, e);
-                       }
-               }
-
-               @Override
-               public boolean validateDrop(Object target, int operation,
-                               TransferData transferType) {
-                       if (target instanceof RepoElem) {
-                               if (getSelectedObject() instanceof WorkspaceElem) {
-                                       // check if not same repository
-                                       String srcRepoUri = ((RepoElem) ((WorkspaceElem) getSelectedObject())
-                                                       .getParent().getParent()).getUri();
-                                       String targetRepoUri = ((RepoElem) target).getUri();
-                                       return !targetRepoUri.equals(srcRepoUri);
-                               }
-                       }
-                       return false;
-               }
-       }
-
        /*
         * DEPENDENCY INJECTION
         */
index e0474a0901273d0ab678bd463dc6cd72d8b33352..136eae150c8c178b79f5d53fb2f07362664346b4 100644 (file)
@@ -18,14 +18,18 @@ 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;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.ArgeoMonitor;
 import org.argeo.eclipse.ui.EclipseArgeoMonitor;
+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;
@@ -34,7 +38,6 @@ import org.argeo.slc.jcr.SlcTypes;
 import org.argeo.slc.repo.RepoConstants;
 import org.argeo.slc.repo.RepoUtils;
 import org.argeo.slc.repo.maven.GenerateBinaries;
-import org.argeo.slc.repo.maven.IndexDistribution;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -60,30 +63,34 @@ import org.eclipse.swt.widgets.Text;
 import org.sonatype.aether.artifact.Artifact;
 
 /**
- * Defines parameters to generate binaries (e.g. a specific modular
- * distribution) using a {@link IndexDistribution} object
+ * Define parameters to asynchronously generate binaries, sources and sdk pom
+ * artifacts for this group using a {@link GenerateBinaries} runnable
  */
 public class GenerateBinariesWizard extends Wizard {
        private final static Log log = LogFactory
                        .getLog(GenerateBinariesWizard.class);
 
        // Business objects
-       private Node groupNode;
+       private String groupNodePath;
+       private Repository repository;
+       private Credentials credentials;
+       private String wkspName;
 
        // The pages
        private RecapPage recapPage;
 
        // Controls with parameters
-       private Button overridePomsBtn;
        private Text versionTxt;
        private Text latestVersionTxt;
        private Text highestArtifactVersionTxt;
 
-       // private CheckboxTableViewer wkspViewer;
-
-       public GenerateBinariesWizard(Node groupNode) {
+       public GenerateBinariesWizard(Repository repository,
+                       Credentials credentials, String wkspName, String groupNodePath) {
                super();
-               this.groupNode = groupNode;
+               this.repository = repository;
+               this.credentials = credentials;
+               this.wkspName = wkspName;
+               this.groupNodePath = groupNodePath;
        }
 
        @Override
@@ -107,15 +114,18 @@ public class GenerateBinariesWizard extends Wizard {
                if (!canFinish())
                        return false;
                try {
-                       String msg = "Your are about to normalize group, do you really want to proceed ?";
+                       String msg = "Your are about to generate binaries, sources and sdk "
+                                       + "pom artifacts for this group, "
+                                       + "do you really want to proceed ?";
 
                        boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
                                        .getWorkbench().getDisplay().getActiveShell(),
-                                       "Confirm Process Launch", msg);
+                                       "Confirm Launch", msg);
 
                        if (result) {
-                               GenerateBinaryJob job = new GenerateBinaryJob(groupNode,
-                                               versionTxt.getText(), overridePomsBtn.getSelection());
+                               GenerateBinaryJob job = new GenerateBinaryJob(repository,
+                                               credentials, wkspName, groupNodePath,
+                                               versionTxt.getText());
                                job.setUser(true);
                                job.schedule();
                        }
@@ -143,20 +153,14 @@ public class GenerateBinariesWizard extends Wizard {
                }
 
                public IWizardPage getNextPage() {
-                       // always last....
-                       return null;
-               }
-
-               @Override
-               public void setVisible(boolean visible) {
-                       if (visible) {
-
-                       }
-                       super.setVisible(visible);
+                       return null; // always last
                }
 
                private void refreshValues() {
+                       Session session = null;
                        try {
+                               session = repository.login(credentials, wkspName);
+                               Node groupNode = session.getNode(groupNodePath);
                                GenerateBinaries gb = GenerateBinaries.preProcessGroupNode(
                                                groupNode, null);
 
@@ -187,31 +191,40 @@ public class GenerateBinariesWizard extends Wizard {
                                                }
                                        }
                                        if (currHighestVersion != null)
-                                               latestVersionTxt.setText(highestVersion
+                                               latestVersionTxt.setText(currHighestVersion
                                                                .getBaseVersion());
                                }
-
                                recapViewer.setInput(binaries);
                                recapViewer.refresh();
                        } catch (RepositoryException re) {
                                throw new SlcException("Unable to get repositories URIs", re);
+                       } finally {
+                               JcrUtils.logoutQuietly(session);
                        }
                }
 
                public void createControl(Composite parent) {
+                       setMessage("Configure Maven Indexing", IMessageProvider.NONE);
+
                        Composite composite = new Composite(parent, SWT.NO_FOCUS);
                        composite.setLayout(new GridLayout(2, false));
 
                        versionTxt = createLT(composite, "Version");
+                       versionTxt
+                                       .setToolTipText("Enter a version for the new Modular Distribution");
+
                        latestVersionTxt = createLT(composite, "Latest version");
                        latestVersionTxt.setEditable(false);
+                       latestVersionTxt
+                                       .setToolTipText("The actual latest version of this modular distribution");
+
                        highestArtifactVersionTxt = createLT(composite,
                                        "Highest version in current category");
                        highestArtifactVersionTxt.setEditable(false);
+                       highestArtifactVersionTxt
+                                       .setToolTipText("The highest version among all version of the below listed modules.");
 
-                       overridePomsBtn = createLC(composite, "Override POMs");
-                       setMessage("Configure Maven Indexing", IMessageProvider.NONE);
-
+                       // Creates the table
                        Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL
                                        | SWT.BORDER);
                        table.setLinesVisible(true);
@@ -220,7 +233,6 @@ public class GenerateBinariesWizard extends Wizard {
                                        1));
                        recapViewer = new TableViewer(table);
 
-                       // Artifact columns
                        TableViewerColumn column = ViewerUtils.createTableViewerColumn(
                                        recapViewer, "Name", SWT.NONE, 250);
                        column.setLabelProvider(new ColumnLabelProvider() {
@@ -242,6 +254,7 @@ public class GenerateBinariesWizard extends Wizard {
                        recapViewer.setContentProvider(new IStructuredContentProvider() {
                                List<Artifact> artifacts;
 
+                               @SuppressWarnings("unchecked")
                                public void inputChanged(Viewer viewer, Object oldInput,
                                                Object newInput) {
                                        artifacts = (List<Artifact>) newInput;
@@ -264,52 +277,45 @@ public class GenerateBinariesWizard extends Wizard {
                }
        }
 
-       /** Creates label and text. */
-       protected Text createLT(Composite parent, String label) {
-               new Label(parent, SWT.NONE).setText(label);
-               Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER
-                               | SWT.NONE);
-               text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               return text;
-       }
-
-       /** Creates label and check. */
-       protected Button createLC(Composite parent, String label) {
-               new Label(parent, SWT.NONE).setText(label);
-               Button check = new Button(parent, SWT.CHECK);
-               check.setSelection(false);
-               check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               return check;
-       }
-
        /**
-        * Define the privileged job that will be run asynchronously to real
-        * indexing
+        * Define the privileged job that will be run asynchronously generate
+        * corresponding artifacts
         */
        private class GenerateBinaryJob extends PrivilegedJob {
-               private Node groupBaseNode;
-               private String version;
-               private boolean overridePoms;
 
-               public GenerateBinaryJob(Node groupBaseNode, String version,
-                               boolean overridePoms) {
+               private final Repository repository;
+               private final Credentials credentials;
+               private final String wkspName;
+               private final String groupNodePath;
+               private final String version;
+
+               public GenerateBinaryJob(Repository repository,
+                               Credentials credentials, String wkspName, String groupNodePath,
+                               String version) {
                        super("Fetch");
-                       this.groupBaseNode = groupBaseNode;
                        this.version = version;
-                       this.overridePoms = overridePoms;
+                       this.repository = repository;
+                       this.credentials = credentials;
+                       this.wkspName = wkspName;
+                       this.groupNodePath = groupNodePath;
                }
 
                @Override
                protected IStatus doRun(IProgressMonitor progressMonitor) {
+                       Session session = null;
                        try {
                                ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
+                               session = repository.login(credentials, wkspName);
+                               Node groupBaseNode = session.getNode(groupNodePath);
                                GenerateBinaries.processGroupNode(groupBaseNode, version,
-                                               overridePoms, monitor);
+                                               monitor);
                        } catch (Exception e) {
                                if (log.isDebugEnabled())
                                        e.printStackTrace();
                                return new Status(IStatus.ERROR, DistPlugin.ID,
                                                "Cannot normalize group", e);
+                       } finally {
+                               JcrUtils.logoutQuietly(session);
                        }
                        return Status.OK_STATUS;
                }
@@ -317,4 +323,21 @@ public class GenerateBinariesWizard extends Wizard {
 
        // ////////////////////////////
        // // Helpers
+       /** Creates label and text. */
+       protected Text createLT(Composite parent, String label) {
+               new Label(parent, SWT.NONE).setText(label);
+               Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER
+                               | SWT.NONE);
+               text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               return text;
+       }
+
+       /** Creates label and check. */
+       protected Button createLC(Composite parent, String label) {
+               new Label(parent, SWT.NONE).setText(label);
+               Button check = new Button(parent, SWT.CHECK);
+               check.setSelection(false);
+               check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               return check;
+       }
 }
\ No newline at end of file
diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/DistributionBundleIndexer.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/DistributionBundleIndexer.java
deleted file mode 100644 (file)
index 90d5a39..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-package org.argeo.slc.repo;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.nodetype.NodeType;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.aether.AetherUtils;
-import org.argeo.slc.aether.ArtifactIdComparator;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * Create or update JCR meta-data for modularDistribution bundles: <list><li>
- * .jar: dependency artifacts with csv index</li> <li>.pom: group index artifact
- * (binaries, sources) with tag dependency management</li> </list>
- */
-public class DistributionBundleIndexer implements NodeIndexer {
-       private final static Log log = LogFactory
-                       .getLog(DistributionBundleIndexer.class);
-
-       private final static String INDEX_FILE_NAME = "modularDistribution.csv";
-       private final static List<String> BINARIES_ARTIFACTS_NAME;
-       static {
-               List<String> tmpList = new ArrayList<String>();
-               tmpList.add(RepoConstants.BINARIES_ARTIFACT_ID);
-               //tmpList.add(RepoConstants.SOURCES_ARTIFACT_ID);
-               //tmpList.add(RepoConstants.SDK_ARTIFACT_ID);
-               BINARIES_ARTIFACTS_NAME = Collections.unmodifiableList(tmpList);
-       }
-
-       private Manifest manifest;
-       // private String symbolicName;
-       // private String version;
-
-       // private List<Artifact> artifacts;
-       private String separator = ",";
-
-       private Comparator<Artifact> artifactComparator = new ArtifactIdComparator();
-
-       // private Set<Artifact> artifacts = new
-       // TreeSet<Artifact>(artifactComparator);
-
-       public Boolean support(String path) {
-               if (FilenameUtils.getExtension(path).equals("jar"))
-                       return true;
-
-               if (FilenameUtils.getExtension(path).equals("pom")
-                               && BINARIES_ARTIFACTS_NAME.contains(FilenameUtils.getName(path)
-                                               .split("-")[0]))
-                       return true;
-               return false;
-       }
-
-       public void index(Node fileNode) {
-               // JarInputStream jarIn = null;
-               Binary fileBinary = null;
-               try {
-
-                       String fileNodePath = fileNode.getPath();
-                       if (!support(fileNodePath))
-                               return;
-
-                       if (!fileNode.isNodeType(NodeType.NT_FILE))
-                               return;
-
-                       // Session jcrSession = fileNode.getSession();
-                       Node contentNode = fileNode.getNode(Node.JCR_CONTENT);
-                       fileBinary = contentNode.getProperty(Property.JCR_DATA).getBinary();
-
-                       Set<Artifact> artifacts = new TreeSet<Artifact>(artifactComparator);
-
-                       if (FilenameUtils.getExtension(fileNode.getPath()).equals("jar"))
-                               listModulesFromCsvIndex(artifacts, fileNode, fileBinary);
-                       else if (FilenameUtils.getExtension(fileNode.getPath()).equals(
-                                       "pom"))
-                               listModulesFromPomIndex(artifacts, fileNode, fileBinary);
-
-                       if (artifacts.isEmpty())
-                               return; // no modules found
-                       else {
-                               Node modules;
-                               if (fileNode.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION)) {
-                                       modules = fileNode.getNode(SlcNames.SLC_MODULES);
-                               } else {
-                                       fileNode.addMixin(SlcTypes.SLC_MODULAR_DISTRIBUTION);
-                                       modules = JcrUtils.mkdirs(fileNode, SlcNames.SLC_MODULES,
-                                                       NodeType.NT_UNSTRUCTURED);
-                               }
-
-                               for (Artifact artifact : artifacts) {
-                                       // TODO clean this once an overwrite policy has been
-                                       // decided.
-                                       if (!modules.hasNode(artifact.getArtifactId())) {
-                                               Node moduleCoord = modules.addNode(
-                                                               artifact.getArtifactId(),
-                                                               SlcTypes.SLC_MODULE_COORDINATES);
-                                               moduleCoord.setProperty(SlcNames.SLC_NAME,
-                                                               artifact.getArtifactId());
-                                               moduleCoord.setProperty(SlcNames.SLC_VERSION,
-                                                               artifact.getVersion());
-                                               String groupId = artifact.getGroupId();
-                                               if (groupId != null && !"".equals(groupId.trim()))
-                                                       moduleCoord.setProperty(SlcNames.SLC_CATEGORY,
-                                                                       artifact.getGroupId());
-                                       }
-                               }
-
-                       }
-
-                       // find base URL
-                       // won't work if distribution artifact is not listed
-                       // for (int i = 0; i < artifacts.size(); i++) {
-                       // OsgiArtifact osgiArtifact = artifacts.get(i);
-                       // if (osgiArtifact.getSymbolicName().equals(symbolicName)
-                       // && osgiArtifact.getVersion().equals(version)) {
-                       // String relativeUrl = osgiArtifact.getRelativeUrl();
-                       // if (url.endsWith(relativeUrl)) {
-                       // baseUrl = url.substring(0, url.length()
-                       // - osgiArtifact.getRelativeUrl().length());
-                       // break;
-                       // }
-                       // }
-                       // }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot list dependencies from " + fileNode,
-                                       e);
-               }
-       }
-
-       protected void listModulesFromCsvIndex(Set<Artifact> artifacts,
-                       Node fileNode, Binary fileBinary) {
-               // List<Artifact> artifacts = new ArrayList<Artifact>();
-               JarInputStream jarIn = null;
-               BufferedReader reader = null;
-
-               try {
-                       jarIn = new JarInputStream(fileBinary.getStream());
-
-                       // meta data
-                       // symbolicName = manifest.getMainAttributes().getValue(
-                       // Constants.BUNDLE_SYMBOLICNAME);
-                       // version = manifest.getMainAttributes().getValue(
-                       // Constants.BUNDLE_VERSION);
-
-                       manifest = jarIn.getManifest();
-                       if (manifest == null) {
-                               log.error(fileNode + " has no MANIFEST");
-                               return;
-                       }
-
-                       JarEntry indexEntry;
-                       while ((indexEntry = jarIn.getNextJarEntry()) != null) {
-                               String entryName = indexEntry.getName();
-                               if (entryName.equals(INDEX_FILE_NAME)) {
-                                       break;
-                               }
-                               jarIn.closeEntry();
-                       }
-
-                       if (indexEntry == null)
-                               return; // Not a modular definition artifact
-
-                       reader = new BufferedReader(new InputStreamReader(jarIn));
-                       String line = null;
-                       while ((line = reader.readLine()) != null) {
-                               StringTokenizer st = new StringTokenizer(line, separator);
-                               st.nextToken(); // moduleName
-                               st.nextToken(); // moduleVersion
-                               String relativeUrl = st.nextToken();
-
-                               artifacts.add(AetherUtils.convertPathToArtifact(relativeUrl,
-                                               null));
-                               if (log.isTraceEnabled())
-                                       log.debug("Processed dependency: " + line);
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot list artifacts", e);
-               } finally {
-                       IOUtils.closeQuietly(jarIn);
-                       IOUtils.closeQuietly(reader);
-               }
-       }
-
-       protected void listModulesFromPomIndex(Set<Artifact> artifacts,
-                       Node fileNode, Binary fileBinary) {
-               InputStream input = null;
-               try {
-                       input = fileBinary.getStream();
-
-                       DocumentBuilder documentBuilder = DocumentBuilderFactory
-                                       .newInstance().newDocumentBuilder();
-                       Document doc = documentBuilder.parse(input);
-
-                       // properties
-                       Properties props = new Properties();
-                       // props.setProperty("project.version",
-                       // pomArtifact.getBaseVersion());
-                       NodeList properties = doc.getElementsByTagName("properties");
-                       if (properties.getLength() > 0) {
-                               NodeList propertiesElems = properties.item(0).getChildNodes();
-                               for (int i = 0; i < propertiesElems.getLength(); i++) {
-                                       if (propertiesElems.item(i) instanceof Element) {
-                                               Element property = (Element) propertiesElems.item(i);
-                                               props.put(property.getNodeName(),
-                                                               property.getTextContent());
-                                       }
-                               }
-                       }
-
-                       // full coordinates are under <dependencyManagement><dependencies>
-                       NodeList dependencies = ((Element) doc.getElementsByTagName(
-                                       "dependencyManagement").item(0))
-                                       .getElementsByTagName("dependency");
-                       for (int i = 0; i < dependencies.getLength(); i++) {
-                               Element dependency = (Element) dependencies.item(i);
-                               String groupId = dependency.getElementsByTagName("groupId")
-                                               .item(0).getTextContent().trim();
-                               String artifactId = dependency
-                                               .getElementsByTagName("artifactId").item(0)
-                                               .getTextContent().trim();
-                               String version = dependency.getElementsByTagName("version")
-                                               .item(0).getTextContent().trim();
-                               // if (version.startsWith("${")) {
-                               // String versionKey = version.substring(0,
-                               // version.length() - 1).substring(2);
-                               // if (!props.containsKey(versionKey))
-                               // throw new SlcException("Cannot interpret version "
-                               // + version);
-                               // version = props.getProperty(versionKey);
-                               // }
-                               // NodeList scopes = dependency.getElementsByTagName("scope");
-                               // if (scopes.getLength() > 0
-                               // && scopes.item(0).getTextContent().equals("import")) {
-                               // // recurse
-                               // gatherPomDependencies(aetherTemplate, artifacts,
-                               // new DefaultArtifact(groupId, artifactId, "pom",
-                               // version));
-                               // } else {
-                               // TODO: deal with scope?
-                               // TODO: deal with type
-                               String type = "jar";
-                               Artifact artifact = new DefaultArtifact(groupId, artifactId,
-                                               type, version);
-                               artifacts.add(artifact);
-                               // }
-                       }
-               } catch (Exception e) {
-                       throw new SlcException("Cannot process pom " + fileNode, e);
-               } finally {
-                       IOUtils.closeQuietly(input);
-               }
-       }
-
-       /** Separator used to parse the tabular file, default is "," */
-       public void setSeparator(String modulesUrlSeparator) {
-               this.separator = modulesUrlSeparator;
-       }
-
-       /** One of the listed artifact */
-       protected static class OsgiArtifact {
-               private final String category;
-               private final String symbolicName;
-               private final String version;
-               private final String relativeUrl;
-
-               public OsgiArtifact(String category, String symbolicName,
-                               String version, String relativeUrl) {
-                       super();
-                       this.category = category;
-                       this.symbolicName = symbolicName;
-                       this.version = version;
-                       this.relativeUrl = relativeUrl;
-               }
-
-               public String getCategory() {
-                       return category;
-               }
-
-               public String getSymbolicName() {
-                       return symbolicName;
-               }
-
-               public String getVersion() {
-                       return version;
-               }
-
-               public String getRelativeUrl() {
-                       return relativeUrl;
-               }
-
-       }
-}
index 7e41168aa1405500dd1058043a2ed101ab9b8282..06e7129b48adc4f326909b6a130af7b3af98a53f 100644 (file)
@@ -110,9 +110,10 @@ public class JarFileIndexer implements NodeIndexer, SlcNames {
 
                        fileNode.setProperty(SlcNames.SLC_MANIFEST, manifestBinary);
                        Attributes attrs = manifest.getMainAttributes();
-                       if (log.isTraceEnabled())
-                               for (Object key : attrs.keySet())
-                                       log.trace(key + ": " + attrs.getValue(key.toString()));
+                       
+                       // if (log.isTraceEnabled())
+                       // for (Object key : attrs.keySet())
+                       // log.trace(key + ": " + attrs.getValue(key.toString()));
 
                        // standard J2SE MANIFEST attributes
                        addAttr(Attributes.Name.MANIFEST_VERSION, fileNode, attrs);
diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/ModularDistributionIndexer.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/ModularDistributionIndexer.java
new file mode 100644 (file)
index 0000000..7fee5a3
--- /dev/null
@@ -0,0 +1,326 @@
+package org.argeo.slc.repo;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.nodetype.NodeType;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.CategorizedNameVersion;
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.aether.AetherUtils;
+import org.argeo.slc.aether.ArtifactIdComparator;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+import org.osgi.framework.Constants;
+import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Create or update JCR meta-data for an SLC Modular Distribution
+ * 
+ * Currently, following types are managed: <list><li>* .jar: dependency
+ * artifacts with csv index</li> <li>.pom: artifact (binaries) that indexes a
+ * group, the .pom file contains a tag "dependencyManagement" that list all
+ * modules</li> </list>
+ */
+public class ModularDistributionIndexer implements NodeIndexer, SlcNames {
+       private final static Log log = LogFactory
+                       .getLog(ModularDistributionIndexer.class);
+
+       // Constants for csv indexing
+       private final static String INDEX_FILE_NAME = "modularDistribution.csv";
+       private String separator = ",";
+
+       // Artifact indexing
+       private final static List<String> BINARIES_ARTIFACTS_NAME;
+       static {
+               List<String> tmpList = new ArrayList<String>();
+               tmpList.add(RepoConstants.BINARIES_ARTIFACT_ID);
+               // tmpList.add(RepoConstants.SOURCES_ARTIFACT_ID);
+               // tmpList.add(RepoConstants.SDK_ARTIFACT_ID);
+               BINARIES_ARTIFACTS_NAME = Collections.unmodifiableList(tmpList);
+       }
+
+       private Manifest manifest;
+       // private String symbolicName;
+       // private String version;
+       // private List<Artifact> artifacts;
+
+       private Comparator<Artifact> artifactComparator = new ArtifactIdComparator();
+
+       // private Set<Artifact> artifacts = new
+       // TreeSet<Artifact>(artifactComparator);
+
+       public Boolean support(String path) {
+               if (FilenameUtils.getExtension(path).equals("jar"))
+                       return true;
+
+               if (FilenameUtils.getExtension(path).equals("pom")
+                               && BINARIES_ARTIFACTS_NAME.contains(FilenameUtils.getName(path)
+                                               .split("-")[0]))
+                       return true;
+               return false;
+       }
+
+       public void index(Node fileNode) {
+               // JarInputStream jarIn = null;
+               Binary fileBinary = null;
+               try {
+
+                       String fileNodePath = fileNode.getPath();
+                       if (!support(fileNodePath))
+                               return;
+
+                       if (!fileNode.isNodeType(NodeType.NT_FILE))
+                               return;
+
+                       // Session jcrSession = fileNode.getSession();
+                       Node contentNode = fileNode.getNode(Node.JCR_CONTENT);
+                       fileBinary = contentNode.getProperty(Property.JCR_DATA).getBinary();
+
+                       Set<Artifact> artifacts = new TreeSet<Artifact>(artifactComparator);
+
+                       MyCategorizedNameVersion currCatNV = null;
+
+                       if (FilenameUtils.getExtension(fileNode.getPath()).equals("jar"))
+                               currCatNV = listModulesFromCsvIndex(artifacts, fileNode,
+                                               fileBinary);
+                       else if (FilenameUtils.getExtension(fileNode.getPath()).equals(
+                                       "pom"))
+                               currCatNV = listModulesFromPomIndex(artifacts, fileNode,
+                                               fileBinary);
+
+                       if (artifacts.isEmpty())
+                               return; // no modules found
+                       else {
+                               Node modules;
+                               if (fileNode.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION)) {
+                                       modules = fileNode.getNode(SlcNames.SLC_MODULES);
+                               } else {
+                                       fileNode.addMixin(SlcTypes.SLC_MODULAR_DISTRIBUTION);
+                                       fileNode.addMixin(SlcTypes.SLC_CATEGORIZED_NAME_VERSION);
+                                       if (currCatNV.getCategory() != null)
+                                               fileNode.setProperty(SLC_CATEGORY,
+                                                               currCatNV.getCategory());
+                                       fileNode.setProperty(SLC_NAME, currCatNV.getName());
+                                       fileNode.setProperty(SLC_VERSION, currCatNV.getVersion());
+                                       modules = JcrUtils.mkdirs(fileNode, SlcNames.SLC_MODULES,
+                                                       NodeType.NT_UNSTRUCTURED);
+                               }
+
+                               for (Artifact artifact : artifacts) {
+                                       // TODO clean this once an overwrite policy has been
+                                       // decided.
+                                       if (!modules.hasNode(artifact.getArtifactId())) {
+                                               Node moduleCoord = modules.addNode(
+                                                               artifact.getArtifactId(),
+                                                               SlcTypes.SLC_MODULE_COORDINATES);
+                                               moduleCoord.setProperty(SlcNames.SLC_NAME,
+                                                               artifact.getArtifactId());
+                                               moduleCoord.setProperty(SlcNames.SLC_VERSION,
+                                                               artifact.getVersion());
+                                               String groupId = artifact.getGroupId();
+                                               if (groupId != null && !"".equals(groupId.trim()))
+                                                       moduleCoord.setProperty(SlcNames.SLC_CATEGORY,
+                                                                       artifact.getGroupId());
+                                       }
+                               }
+                       }
+
+                       if (log.isTraceEnabled())
+                               log.trace("Indexed " + fileNode + " as modular distribution");
+               } catch (Exception e) {
+                       throw new SlcException("Cannot list dependencies from " + fileNode,
+                                       e);
+               }
+       }
+
+       protected MyCategorizedNameVersion listModulesFromCsvIndex(
+                       Set<Artifact> artifacts, Node fileNode, Binary fileBinary) {
+               JarInputStream jarIn = null;
+               BufferedReader reader = null;
+               try {
+                       jarIn = new JarInputStream(fileBinary.getStream());
+
+                       // meta data
+                       manifest = jarIn.getManifest();
+                       if (manifest == null) {
+                               log.error(fileNode + " has no MANIFEST");
+                               return null;
+                       }
+                       String symbolicName = manifest.getMainAttributes().getValue(
+                                       Constants.BUNDLE_SYMBOLICNAME);
+                       String version = manifest.getMainAttributes().getValue(
+                                       Constants.BUNDLE_VERSION);
+                       String category = manifest.getMainAttributes().getValue(
+                                       "SLC-GroupId");
+
+                       // Retrieve the index file
+                       JarEntry indexEntry;
+                       while ((indexEntry = jarIn.getNextJarEntry()) != null) {
+                               String entryName = indexEntry.getName();
+                               if (entryName.equals(INDEX_FILE_NAME)) {
+                                       break;
+                               }
+                               try {
+                                       jarIn.closeEntry();
+                               } catch (SecurityException se) {
+                                       log.error("Invalid signature file digest "
+                                                       + "for Manifest main attributes: " + entryName
+                                                       + " while looking for an index in bundle "
+                                                       + symbolicName);
+                               }
+                       }
+                       if (indexEntry == null)
+                               return null; // Not a modular definition artifact
+
+                       // Process the index
+                       reader = new BufferedReader(new InputStreamReader(jarIn));
+                       String line = null;
+                       while ((line = reader.readLine()) != null) {
+                               StringTokenizer st = new StringTokenizer(line, separator);
+                               st.nextToken(); // moduleName
+                               st.nextToken(); // moduleVersion
+                               String relativeUrl = st.nextToken();
+                               artifacts.add(AetherUtils.convertPathToArtifact(relativeUrl,
+                                               null));
+                               if (log.isTraceEnabled())
+                                       log.debug("Processed dependency: " + line);
+                       }
+
+                       return new MyCategorizedNameVersion(category, symbolicName, version);
+               } catch (Exception e) {
+                       throw new SlcException("Cannot list artifacts", e);
+               } finally {
+                       IOUtils.closeQuietly(jarIn);
+                       IOUtils.closeQuietly(reader);
+               }
+       }
+
+       protected MyCategorizedNameVersion listModulesFromPomIndex(
+                       Set<Artifact> artifacts, Node fileNode, Binary fileBinary) {
+               InputStream input = null;
+               try {
+                       input = fileBinary.getStream();
+
+                       DocumentBuilder documentBuilder = DocumentBuilderFactory
+                                       .newInstance().newDocumentBuilder();
+                       Document doc = documentBuilder.parse(input);
+
+                       // properties
+                       Properties props = new Properties();
+                       // props.setProperty("project.version",
+                       // pomArtifact.getBaseVersion());
+                       NodeList properties = doc.getElementsByTagName("properties");
+                       if (properties.getLength() > 0) {
+                               NodeList propertiesElems = properties.item(0).getChildNodes();
+                               for (int i = 0; i < propertiesElems.getLength(); i++) {
+                                       if (propertiesElems.item(i) instanceof Element) {
+                                               Element property = (Element) propertiesElems.item(i);
+                                               props.put(property.getNodeName(),
+                                                               property.getTextContent());
+                                       }
+                               }
+                       }
+
+                       // full coordinates are under <dependencyManagement><dependencies>
+                       NodeList dependencies = ((Element) doc.getElementsByTagName(
+                                       "dependencyManagement").item(0))
+                                       .getElementsByTagName("dependency");
+                       for (int i = 0; i < dependencies.getLength(); i++) {
+                               Element dependency = (Element) dependencies.item(i);
+                               String groupId = dependency.getElementsByTagName("groupId")
+                                               .item(0).getTextContent().trim();
+                               String artifactId = dependency
+                                               .getElementsByTagName("artifactId").item(0)
+                                               .getTextContent().trim();
+                               String version = dependency.getElementsByTagName("version")
+                                               .item(0).getTextContent().trim();
+                               // if (version.startsWith("${")) {
+                               // String versionKey = version.substring(0,
+                               // version.length() - 1).substring(2);
+                               // if (!props.containsKey(versionKey))
+                               // throw new SlcException("Cannot interpret version "
+                               // + version);
+                               // version = props.getProperty(versionKey);
+                               // }
+                               // NodeList scopes = dependency.getElementsByTagName("scope");
+                               // if (scopes.getLength() > 0
+                               // && scopes.item(0).getTextContent().equals("import")) {
+                               // // recurse
+                               // gatherPomDependencies(aetherTemplate, artifacts,
+                               // new DefaultArtifact(groupId, artifactId, "pom",
+                               // version));
+                               // } else {
+                               // TODO: deal with scope?
+                               // TODO: deal with type
+                               String type = "jar";
+                               Artifact artifact = new DefaultArtifact(groupId, artifactId,
+                                               type, version);
+                               artifacts.add(artifact);
+                               // }
+                       }
+
+                       String groupId = doc.getElementsByTagName("groupId").item(0)
+                                       .getTextContent().trim();
+                       String artifactId = doc.getElementsByTagName("artifactId").item(0)
+                                       .getTextContent().trim();
+                       String version = doc.getElementsByTagName("version").item(0)
+                                       .getTextContent().trim();
+
+                       return new MyCategorizedNameVersion(groupId, artifactId, version);
+
+               } catch (Exception e) {
+                       throw new SlcException("Cannot process pom " + fileNode, e);
+               } finally {
+                       IOUtils.closeQuietly(input);
+               }
+       }
+
+       /** Separator used to parse the tabular file, default is "," */
+       public void setSeparator(String modulesUrlSeparator) {
+               this.separator = modulesUrlSeparator;
+       }
+
+       /** The created modular distribution */
+       private static class MyCategorizedNameVersion extends DefaultNameVersion
+                       implements CategorizedNameVersion {
+               private final String category;
+
+               public MyCategorizedNameVersion(String category, String name,
+                               String version) {
+                       super(name, version);
+                       this.category = category;
+               }
+
+               public String getCategory() {
+                       return category;
+               }
+       }
+}
\ No newline at end of file
index 589bd89241d5d488a7d08ecda4f27e33d213210f..97ca286ce31e10f27e3661954f4d2237d27f5aca 100644 (file)
@@ -22,6 +22,8 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.NameVersion;
 import org.argeo.slc.SlcException;
@@ -35,18 +37,19 @@ import org.sonatype.aether.util.artifact.DefaultArtifact;
  * "...-sources.jar"
  */
 public class PdeSourcesIndexer implements NodeIndexer {
-       // private Log log = LogFactory.getLog(PdeSourcesIndexer.class);
+       private Log log = LogFactory.getLog(PdeSourcesIndexer.class);
 
        private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
 
-       private ArtifactIndexer artifactIndexer;
-       private JarFileIndexer jarFileIndexer;
+       // private ArtifactIndexer artifactIndexer;
+       // private JarFileIndexer jarFileIndexer;
 
-       public PdeSourcesIndexer(ArtifactIndexer artifactIndexer,
-                       JarFileIndexer jarFileIndexer) {
-               this.artifactIndexer = artifactIndexer;
-               this.jarFileIndexer = jarFileIndexer;
-       }
+       // public PdeSourcesIndexer(){
+       // // ArtifactIndexer artifactIndexer,
+       // // JarFileIndexer jarFileIndexer) {
+       // // this.artifactIndexer = artifactIndexer;
+       // // this.jarFileIndexer = jarFileIndexer;
+       // }
 
        public Boolean support(String path) {
                // TODO implement clean management of same name siblings
@@ -60,6 +63,9 @@ public class PdeSourcesIndexer implements NodeIndexer {
 
        public void index(Node sourcesNode) {
                try {
+                       if (!support(sourcesNode.getPath()))
+                               return;
+
                        packageSourcesAsPdeSource(sourcesNode);
                } catch (Exception e) {
                        throw new SlcException("Cannot generate pde sources for node "
@@ -99,8 +105,8 @@ public class PdeSourcesIndexer implements NodeIndexer {
                                        .artifactParentPath(artifactBasePath, pdeSourceArtifact);
                        String targetSourceFileName = MavenConventionsUtils
                                        .artifactFileName(pdeSourceArtifact);
-                       String targetSourceJarPath = targetSourceParentPath + '/'
-                                       + targetSourceFileName;
+                       // String targetSourceJarPath = targetSourceParentPath + '/'
+                       // + targetSourceFileName;
 
                        Node targetSourceParentNode = JcrUtils.mkfolders(session,
                                        targetSourceParentPath);
@@ -112,9 +118,15 @@ public class PdeSourcesIndexer implements NodeIndexer {
                                        targetSourceFileName, targetJarBytes);
 
                        // reindex
-                       Node targetSourceJarNode = session.getNode(targetSourceJarPath);
-                       artifactIndexer.index(targetSourceJarNode);
-                       jarFileIndexer.index(targetSourceJarNode);
+                       // Automagically done via the various listeners or manually
+                       // triggered.
+                       // Node targetSourceJarNode = session.getNode(targetSourceJarPath);
+                       // artifactIndexer.index(targetSourceJarNode);
+                       // jarFileIndexer.index(targetSourceJarNode);
+                       if (log.isTraceEnabled())
+                               log.trace("Created pde source artifact " + pdeSourceArtifact
+                                               + " from " + sourcesNode);
+
                } catch (RepositoryException e) {
                        throw new SlcException("Cannot add PDE sources for " + sourcesNode,
                                        e);
index 6bcf01a25f45cfcd5ee47f817dffa6fe08da5ade..ed22006ad18178ac7d5efc72778ff0521d1d77b0 100644 (file)
@@ -16,9 +16,7 @@
 package org.argeo.slc.repo.maven;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.TreeSet;
@@ -30,7 +28,6 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
-import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.ArgeoMonitor;
@@ -42,15 +39,13 @@ import org.argeo.slc.jcr.SlcTypes;
 import org.argeo.slc.repo.ArtifactIndexer;
 import org.argeo.slc.repo.RepoConstants;
 import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.osgi.OsgiProfile;
-import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 import org.sonatype.aether.artifact.Artifact;
 import org.sonatype.aether.util.artifact.DefaultArtifact;
 
 /**
- * Make sure that all JCR metadata and Maven metadata are consistent for this
- * group of OSGi bundles.
+ * Generates binaries-, sources- and sdk-version.pom artifacts for a given
+ * group.
  */
 public class GenerateBinaries implements Runnable, SlcNames {
        private final static Log log = LogFactory.getLog(GenerateBinaries.class);
@@ -63,35 +58,30 @@ public class GenerateBinaries implements Runnable, SlcNames {
        // Business info
        private String groupId;
        private String parentPomCoordinates;
-       private Boolean overridePoms = false;
        private String version = null;
 
        // Constants
        private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
        private List<String> excludedSuffixes = new ArrayList<String>();
-       /** TODO make it more generic */
-       private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6
-                       .getSystemPackages();
 
-       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
-
-       // Local indexes
-       private Map<String, String> packagesToSymbolicNames = new HashMap<String, String>();
-       private Map<String, Node> symbolicNamesToNodes = new HashMap<String, Node>();
+       // Indexes
        private Set<Artifact> binaries = new TreeSet<Artifact>(
                        new ArtifactIdComparator());
        private Set<Artifact> sources = new TreeSet<Artifact>(
                        new ArtifactIdComparator());
+       
+       // local cache
+       private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
        private Node allArtifactsHighestVersion;
 
        public void run() {
                Session session = null;
                try {
-                       session = repository.login(workspace);
+                       session = repository.login(credentials, workspace);
                        Node groupNode = session.getNode(MavenConventionsUtils.groupPath(
                                        artifactBasePath, groupId));
                        internalPreProcessing(groupNode, null);
-                       processGroupNode(groupNode, null);
+                       internalProcessing(groupNode, null);
                } catch (Exception e) {
                        throw new SlcException("Cannot normalize group " + groupId + " in "
                                        + workspace, e);
@@ -100,8 +90,16 @@ public class GenerateBinaries implements Runnable, SlcNames {
                }
        }
 
+       /**
+        * Generates binaries-, sources- and sdk-version.pom artifacts for the given
+        * version (or the highest of all children version if none is precised).
+        * 
+        * By default, it includes each latest version of all artifact of this group. 
+        * 
+        * The 3 generated artifacts are then marked as modular distributions and indexed.
+        */
        public static void processGroupNode(Node groupNode, String version,
-                       Boolean overridePoms, ArgeoMonitor monitor)
+                       ArgeoMonitor monitor)
                        throws RepositoryException {
                // TODO set artifactsBase based on group node
                GenerateBinaries gb = new GenerateBinaries();
@@ -109,10 +107,9 @@ public class GenerateBinaries implements Runnable, SlcNames {
                                .getString();
                gb.setGroupId(groupId);
                gb.setVersion(version);
-               gb.setOverridePoms(overridePoms);
                // TODO use already done pre-processing
                gb.internalPreProcessing(groupNode, monitor);
-               gb.processGroupNode(groupNode, monitor);
+               gb.internalProcessing(groupNode, monitor);
        }
 
        /** Only builds local indexes. Does not change anything in the local Session */
@@ -139,15 +136,26 @@ public class GenerateBinaries implements Runnable, SlcNames {
                                .asArtifact(allArtifactsHighestVersion);
        }
 
+       // //////////////////////////////////////
+       // INTERNAL METHODS
+
+       /**
+        * Browse all children of a Node considered as a folder that follows Aether
+        * conventions i.e that has Aether's artifact base as children.
+        * 
+        * Each of such child contains a set of Aether artifact versions. This
+        * methods build the binaries {@code Set<Artifact>} and other indexes. It
+        * does not impact the
+        */
        protected void internalPreProcessing(Node groupNode, ArgeoMonitor monitor)
                        throws RepositoryException {
                if (monitor != null)
                        monitor.subTask("Pre processing group " + groupId);
 
                // Process all direct children nodes,
-               // gathering latest versions of all artifact base
+               // gathering latest versions of each artifact
                allArtifactsHighestVersion = null;
-               // Session session = groupNode.getSession();
+
                aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases
                                .hasNext();) {
                        Node aBase = aBases.nextNode();
@@ -157,6 +165,7 @@ public class GenerateBinaries implements Runnable, SlcNames {
                                        continue aBases;
                                else {
                                        // retrieve relevant child node
+                                       // Information is stored on the NT_FILE child node.
                                        for (NodeIterator files = highestAVersion.getNodes(); files
                                                        .hasNext();) {
                                                Node file = files.nextNode();
@@ -169,15 +178,15 @@ public class GenerateBinaries implements Runnable, SlcNames {
                                }
                        }
                }
-               if (log.isDebugEnabled()) {
-                       int bundleCount = symbolicNamesToNodes.size();
-                       log.debug("" + bundleCount + " bundles have been indexed for "
-                                       + groupId);
-               }
+//             if (log.isDebugEnabled()) {
+//                     int bundleCount = symbolicNamesToNodes.size();
+//                     log.debug("" + bundleCount + " bundles have been indexed for "
+//                                     + groupId);
+//             }
        }
 
        /** Does the real job : writes JCR META-DATA and generates binaries */
-       protected void processGroupNode(Node groupNode, ArgeoMonitor monitor)
+       protected void internalProcessing(Node groupNode, ArgeoMonitor monitor)
                        throws RepositoryException {
                if (monitor != null)
                        monitor.subTask("Processing group " + groupId);
@@ -196,34 +205,132 @@ public class GenerateBinaries implements Runnable, SlcNames {
                                throw new SlcException("Group version " + version
                                                + " is empty.");
 
-               int bundleCount = symbolicNamesToNodes.size();
-
-               int count = 1;
-               for (Node bundleNode : symbolicNamesToNodes.values()) {
-                       if (log.isDebugEnabled())
-                               log.debug("Processing " + bundleNode.getName() + " ( " + count
-                                               + "/" + bundleCount + " )");
-
-                       processBundleArtifact(bundleNode);
-                       bundleNode.getSession().save();
-                       count++;
-               }
+//             int bundleCount = symbolicNamesToNodes.size();
+//
+//             int count = 1;
+//             for (Node bundleNode : symbolicNamesToNodes.values()) {
+//                     if (log.isDebugEnabled())
+//                             log.debug("Processing " + bundleNode.getName() + " ( " + count
+//                                             + "/" + bundleCount + " )");
+//
+//                     // processBundleArtifact(bundleNode);
+//                     // bundleNode.getSession().save();
+//                     count++;
+//             }
 
                // indexes
                Set<Artifact> indexes = new TreeSet<Artifact>(
                                new ArtifactIdComparator());
-               Artifact indexArtifact = writeIndex(session,
-                               RepoConstants.BINARIES_ARTIFACT_ID, binaries);
+
+               Artifact indexArtifact;
+               indexArtifact = writeIndex(session, RepoConstants.BINARIES_ARTIFACT_ID,
+                               binaries);
                indexes.add(indexArtifact);
+
                indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID,
                                sources);
                indexes.add(indexArtifact);
+
                // sdk
                writeIndex(session, RepoConstants.SDK_ARTIFACT_ID, indexes);
+
                if (monitor != null)
                        monitor.worked(1);
        }
 
+       protected void preProcessBundleArtifact(Node bundleNode)
+                       throws RepositoryException {
+
+               String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
+               // Sanity check.
+               if (symbolicName == null)
+                       log.warn("Symbolic name is null for bundle " + bundleNode);
+
+               // Manage source bundles
+               if (symbolicName.endsWith(".source")) {
+                       // TODO make a shared node with classifier 'sources'?
+                       String bundleName = RepoUtils
+                                       .extractBundleNameFromSourceName(symbolicName);
+                       for (String excludedSuffix : excludedSuffixes) {
+                               if (bundleName.endsWith(excludedSuffix))
+                                       return;// skip adding to sources
+                       }
+                       sources.add(RepoUtils.asArtifact(bundleNode));
+                       return;
+               }
+
+               // // Build indexes
+               // NodeIterator exportPackages = bundleNode.getNodes(SLC_
+               // + Constants.EXPORT_PACKAGE);
+               // while (exportPackages.hasNext()) {
+               // Node exportPackage = exportPackages.nextNode();
+               // String pkg = JcrUtils.get(exportPackage, SLC_NAME);
+               // packagesToSymbolicNames.put(pkg, symbolicName);
+               // }
+               //
+               // symbolicNamesToNodes.put(symbolicName, bundleNode);
+               // for (String excludedSuffix : excludedSuffixes) {
+               // if (symbolicName.endsWith(excludedSuffix))
+               // return;// skip adding to binaries
+               // }
+
+               binaries.add(RepoUtils.asArtifact(bundleNode));
+
+               // Extra check. to remove
+               if (bundleNode.getSession().hasPendingChanges())
+                       throw new SlcException("Pending changes in the session, "
+                                       + "this should not be true here.");
+       }
+
+       // protected void processBundleArtifact(Node bundleNode)
+       // throws RepositoryException {
+       // Node artifactFolder = bundleNode.getParent();
+       // String baseName = FilenameUtils.getBaseName(bundleNode.getName());
+       //
+       // // pom
+       // String pomName = baseName + ".pom";
+       // if (artifactFolder.hasNode(pomName) && !overridePoms)
+       // return;// skip
+       //
+       // String pom = generatePomForBundle(bundleNode);
+       // Node pomNode = JcrUtils.copyBytesAsFile(artifactFolder, pomName,
+       // pom.getBytes());
+       // // checksum
+       // String bundleSha = JcrUtils.checksumFile(bundleNode, "SHA-1");
+       // JcrUtils.copyBytesAsFile(artifactFolder,
+       // bundleNode.getName() + ".sha1", bundleSha.getBytes());
+       // String pomSha = JcrUtils.checksumFile(pomNode, "SHA-1");
+       // JcrUtils.copyBytesAsFile(artifactFolder, pomNode.getName() + ".sha1",
+       // pomSha.getBytes());
+       // }
+
+       // ////////////////////
+       // LOCAL WRITERS
+       //
+
+       private Artifact writeIndex(Session session, String artifactId,
+                       Set<Artifact> artifacts) throws RepositoryException {
+               Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
+                               version);
+               Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(
+                               parentPomCoordinates) : null;
+               String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
+                               artifacts, parentArtifact);
+               Node node = RepoUtils.copyBytesAsArtifact(
+                               session.getNode(artifactBasePath), artifact, pom.getBytes());
+               artifactIndexer.index(node);
+
+               // TODO factorize
+               String pomSha = JcrUtils.checksumFile(node, "SHA-1");
+               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
+                               pomSha.getBytes());
+               String pomMd5 = JcrUtils.checksumFile(node, "MD5");
+               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
+                               pomMd5.getBytes());
+               session.save();
+               return artifact;
+       }
+
        // Helpers
        private Node getArtifactLatestVersion(Node artifactBase) {
                try {
@@ -312,219 +419,141 @@ public class GenerateBinaries implements Runnable, SlcNames {
                return tmpVersion;
        }
 
-       protected void preProcessBundleArtifact(Node bundleNode)
-                       throws RepositoryException {
-
-               String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
-               if (symbolicName.endsWith(".source")) {
-                       // TODO make a shared node with classifier 'sources'?
-                       String bundleName = RepoUtils
-                                       .extractBundleNameFromSourceName(symbolicName);
-                       for (String excludedSuffix : excludedSuffixes) {
-                               if (bundleName.endsWith(excludedSuffix))
-                                       return;// skip adding to sources
-                       }
-                       sources.add(RepoUtils.asArtifact(bundleNode));
-                       return;
-               }
-
-               NodeIterator exportPackages = bundleNode.getNodes(SLC_
-                               + Constants.EXPORT_PACKAGE);
-               while (exportPackages.hasNext()) {
-                       Node exportPackage = exportPackages.nextNode();
-                       String pkg = JcrUtils.get(exportPackage, SLC_NAME);
-                       packagesToSymbolicNames.put(pkg, symbolicName);
-               }
-
-               symbolicNamesToNodes.put(symbolicName, bundleNode);
-               for (String excludedSuffix : excludedSuffixes) {
-                       if (symbolicName.endsWith(excludedSuffix))
-                               return;// skip adding to binaries
-               }
-               binaries.add(RepoUtils.asArtifact(bundleNode));
-
-               if (bundleNode.getSession().hasPendingChanges())
-                       throw new SlcException("Pending changes in the session, "
-                                       + "this should not be true here.");
-               // bundleNode.getSession().save();
-       }
-
-       protected void processBundleArtifact(Node bundleNode)
-                       throws RepositoryException {
-               Node artifactFolder = bundleNode.getParent();
-               String baseName = FilenameUtils.getBaseName(bundleNode.getName());
-
-               // pom
-               String pomName = baseName + ".pom";
-               if (artifactFolder.hasNode(pomName) && !overridePoms)
-                       return;// skip
-
-               String pom = generatePomForBundle(bundleNode);
-               Node pomNode = JcrUtils.copyBytesAsFile(artifactFolder, pomName,
-                               pom.getBytes());
-               // checksum
-               String bundleSha = JcrUtils.checksumFile(bundleNode, "SHA-1");
-               JcrUtils.copyBytesAsFile(artifactFolder,
-                               bundleNode.getName() + ".sha1", bundleSha.getBytes());
-               String pomSha = JcrUtils.checksumFile(pomNode, "SHA-1");
-               JcrUtils.copyBytesAsFile(artifactFolder, pomNode.getName() + ".sha1",
-                               pomSha.getBytes());
-       }
-
-       // Writers
-       private Artifact writeIndex(Session session, String artifactId,
-                       Set<Artifact> artifacts) throws RepositoryException {
-               Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
-                               version);
-               Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(
-                               parentPomCoordinates) : null;
-               String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
-                               artifacts, parentArtifact);
-               Node node = RepoUtils.copyBytesAsArtifact(
-                               session.getNode(artifactBasePath), artifact, pom.getBytes());
-               artifactIndexer.index(node);
-
-               // TODO factorize
-               String pomSha = JcrUtils.checksumFile(node, "SHA-1");
-               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
-                               pomSha.getBytes());
-               String pomMd5 = JcrUtils.checksumFile(node, "MD5");
-               JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
-                               pomMd5.getBytes());
-               session.save();
-               return artifact;
-       }
-
-       private String generatePomForBundle(Node n) throws RepositoryException {
-               String ownSymbolicName = JcrUtils.get(n, SLC_SYMBOLIC_NAME);
-
-               StringBuffer p = new StringBuffer();
-
-               // XML header
-               p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-               p.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
-               p.append("<modelVersion>4.0.0</modelVersion>");
-
-               // Artifact
-               p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
-                               .append("</groupId>\n");
-               p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
-                               .append("</artifactId>\n");
-               p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
-                               .append("</version>\n");
-               p.append("<packaging>pom</packaging>\n");
-               if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
-                       p.append("<name>")
-                                       .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
-                                       .append("</name>\n");
-               if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
-                       p.append("<description>")
-                                       .append(JcrUtils
-                                                       .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
-                                       .append("</description>\n");
-
-               // Dependencies
-               Set<String> dependenciesSymbolicNames = new TreeSet<String>();
-               Set<String> optionalSymbolicNames = new TreeSet<String>();
-               NodeIterator importPackages = n.getNodes(SLC_
-                               + Constants.IMPORT_PACKAGE);
-               while (importPackages.hasNext()) {
-                       Node importPackage = importPackages.nextNode();
-                       String pkg = JcrUtils.get(importPackage, SLC_NAME);
-                       if (packagesToSymbolicNames.containsKey(pkg)) {
-                               String dependencySymbolicName = packagesToSymbolicNames
-                                               .get(pkg);
-                               if (JcrUtils.check(importPackage, SLC_OPTIONAL))
-                                       optionalSymbolicNames.add(dependencySymbolicName);
-                               else
-                                       dependenciesSymbolicNames.add(dependencySymbolicName);
-                       } else {
-                               if (!JcrUtils.check(importPackage, SLC_OPTIONAL)
-                                               && !systemPackages.contains(pkg))
-                                       log.warn("No bundle found for pkg " + pkg);
-                       }
-               }
-
-               if (n.hasNode(SLC_ + Constants.FRAGMENT_HOST)) {
-                       String fragmentHost = JcrUtils.get(
-                                       n.getNode(SLC_ + Constants.FRAGMENT_HOST),
-                                       SLC_SYMBOLIC_NAME);
-                       dependenciesSymbolicNames.add(fragmentHost);
-               }
-
-               // TODO require bundles
-
-               List<Node> dependencyNodes = new ArrayList<Node>();
-               for (String depSymbName : dependenciesSymbolicNames) {
-                       if (depSymbName.equals(ownSymbolicName))
-                               continue;// skip self
-
-                       if (symbolicNamesToNodes.containsKey(depSymbName))
-                               dependencyNodes.add(symbolicNamesToNodes.get(depSymbName));
-                       else
-                               log.warn("Could not find node for " + depSymbName);
-               }
-               List<Node> optionalDependencyNodes = new ArrayList<Node>();
-               for (String depSymbName : optionalSymbolicNames) {
-                       if (symbolicNamesToNodes.containsKey(depSymbName))
-                               optionalDependencyNodes.add(symbolicNamesToNodes
-                                               .get(depSymbName));
-                       else
-                               log.warn("Could not find node for " + depSymbName);
-               }
-
-               p.append("<dependencies>\n");
-               for (Node dependencyNode : dependencyNodes) {
-                       p.append("<dependency>\n");
-                       p.append("\t<groupId>")
-                                       .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
-                                       .append("</groupId>\n");
-                       p.append("\t<artifactId>")
-                                       .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
-                                       .append("</artifactId>\n");
-                       p.append("</dependency>\n");
-               }
-
-               if (optionalDependencyNodes.size() > 0)
-                       p.append("<!-- OPTIONAL -->\n");
-               for (Node dependencyNode : optionalDependencyNodes) {
-                       p.append("<dependency>\n");
-                       p.append("\t<groupId>")
-                                       .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
-                                       .append("</groupId>\n");
-                       p.append("\t<artifactId>")
-                                       .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
-                                       .append("</artifactId>\n");
-                       p.append("\t<optional>true</optional>\n");
-                       p.append("</dependency>\n");
-               }
-               p.append("</dependencies>\n");
-
-               // Dependency management
-               p.append("<dependencyManagement>\n");
-               p.append("<dependencies>\n");
-               p.append("<dependency>\n");
-               p.append("\t<groupId>").append(groupId).append("</groupId>\n");
-               p.append("\t<artifactId>")
-                               .append(ownSymbolicName.endsWith(".source") ? RepoConstants.SOURCES_ARTIFACT_ID
-                                               : RepoConstants.BINARIES_ARTIFACT_ID)
-                               .append("</artifactId>\n");
-               p.append("\t<version>").append(version).append("</version>\n");
-               p.append("\t<type>pom</type>\n");
-               p.append("\t<scope>import</scope>\n");
-               p.append("</dependency>\n");
-               p.append("</dependencies>\n");
-               p.append("</dependencyManagement>\n");
-
-               p.append("</project>\n");
-               return p.toString();
-       }
+       // private String generatePomForBundle(Node n) throws RepositoryException {
+       // String ownSymbolicName = JcrUtils.get(n, SLC_SYMBOLIC_NAME);
+       //
+       // StringBuffer p = new StringBuffer();
+       //
+       // // XML header
+       // p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+       // p.append("<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n");
+       // p.append("<modelVersion>4.0.0</modelVersion>");
+       //
+       // // Artifact
+       // p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
+       // .append("</groupId>\n");
+       // p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
+       // .append("</artifactId>\n");
+       // p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
+       // .append("</version>\n");
+       // p.append("<packaging>pom</packaging>\n");
+       // if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
+       // p.append("<name>")
+       // .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
+       // .append("</name>\n");
+       // if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
+       // p.append("<description>")
+       // .append(JcrUtils
+       // .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
+       // .append("</description>\n");
+       //
+       // // Dependencies
+       // Set<String> dependenciesSymbolicNames = new TreeSet<String>();
+       // Set<String> optionalSymbolicNames = new TreeSet<String>();
+       // NodeIterator importPackages = n.getNodes(SLC_
+       // + Constants.IMPORT_PACKAGE);
+       // while (importPackages.hasNext()) {
+       // Node importPackage = importPackages.nextNode();
+       // String pkg = JcrUtils.get(importPackage, SLC_NAME);
+       // if (packagesToSymbolicNames.containsKey(pkg)) {
+       // String dependencySymbolicName = packagesToSymbolicNames
+       // .get(pkg);
+       // if (JcrUtils.check(importPackage, SLC_OPTIONAL))
+       // optionalSymbolicNames.add(dependencySymbolicName);
+       // else
+       // dependenciesSymbolicNames.add(dependencySymbolicName);
+       // } else {
+       // if (!JcrUtils.check(importPackage, SLC_OPTIONAL)
+       // && !systemPackages.contains(pkg))
+       // log.warn("No bundle found for pkg " + pkg);
+       // }
+       // }
+       //
+       // if (n.hasNode(SLC_ + Constants.FRAGMENT_HOST)) {
+       // String fragmentHost = JcrUtils.get(
+       // n.getNode(SLC_ + Constants.FRAGMENT_HOST),
+       // SLC_SYMBOLIC_NAME);
+       // dependenciesSymbolicNames.add(fragmentHost);
+       // }
+       //
+       // // TODO require bundles
+       //
+       // List<Node> dependencyNodes = new ArrayList<Node>();
+       // for (String depSymbName : dependenciesSymbolicNames) {
+       // if (depSymbName.equals(ownSymbolicName))
+       // continue;// skip self
+       //
+       // if (symbolicNamesToNodes.containsKey(depSymbName))
+       // dependencyNodes.add(symbolicNamesToNodes.get(depSymbName));
+       // else
+       // log.warn("Could not find node for " + depSymbName);
+       // }
+       // List<Node> optionalDependencyNodes = new ArrayList<Node>();
+       // for (String depSymbName : optionalSymbolicNames) {
+       // if (symbolicNamesToNodes.containsKey(depSymbName))
+       // optionalDependencyNodes.add(symbolicNamesToNodes
+       // .get(depSymbName));
+       // else
+       // log.warn("Could not find node for " + depSymbName);
+       // }
+       //
+       // p.append("<dependencies>\n");
+       // for (Node dependencyNode : dependencyNodes) {
+       // p.append("<dependency>\n");
+       // p.append("\t<groupId>")
+       // .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
+       // .append("</groupId>\n");
+       // p.append("\t<artifactId>")
+       // .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
+       // .append("</artifactId>\n");
+       // p.append("</dependency>\n");
+       // }
+       //
+       // if (optionalDependencyNodes.size() > 0)
+       // p.append("<!-- OPTIONAL -->\n");
+       // for (Node dependencyNode : optionalDependencyNodes) {
+       // p.append("<dependency>\n");
+       // p.append("\t<groupId>")
+       // .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
+       // .append("</groupId>\n");
+       // p.append("\t<artifactId>")
+       // .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
+       // .append("</artifactId>\n");
+       // p.append("\t<optional>true</optional>\n");
+       // p.append("</dependency>\n");
+       // }
+       // p.append("</dependencies>\n");
+       //
+       // // Dependency management
+       // p.append("<dependencyManagement>\n");
+       // p.append("<dependencies>\n");
+       // p.append("<dependency>\n");
+       // p.append("\t<groupId>").append(groupId).append("</groupId>\n");
+       // p.append("\t<artifactId>")
+       // .append(ownSymbolicName.endsWith(".source") ?
+       // RepoConstants.SOURCES_ARTIFACT_ID
+       // : RepoConstants.BINARIES_ARTIFACT_ID)
+       // .append("</artifactId>\n");
+       // p.append("\t<version>").append(version).append("</version>\n");
+       // p.append("\t<type>pom</type>\n");
+       // p.append("\t<scope>import</scope>\n");
+       // p.append("</dependency>\n");
+       // p.append("</dependencies>\n");
+       // p.append("</dependencyManagement>\n");
+       //
+       // p.append("</project>\n");
+       // return p.toString();
+       // }
 
        /* SETTERS */
        public void setRepository(Repository repository) {
                this.repository = repository;
        }
 
+       public void setCredentials(Credentials credentials) {
+               this.credentials = credentials;
+       }
+
        public void setWorkspace(String workspace) {
                this.workspace = workspace;
        }
@@ -549,10 +578,6 @@ public class GenerateBinaries implements Runnable, SlcNames {
                this.excludedSuffixes = excludedSuffixes;
        }
 
-       public void setOverridePoms(Boolean overridePoms) {
-               this.overridePoms = overridePoms;
-       }
-
        public void setArtifactIndexer(ArtifactIndexer artifactIndexer) {
                this.artifactIndexer = artifactIndexer;
        }
index 34e1aee249e0d24fee5d3c76190bb59b64efc536..716bf345c4f83caaacb92365d4c23cd2534eefd2 100644 (file)
@@ -38,6 +38,7 @@ import org.argeo.slc.aether.ArtifactIdComparator;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.jcr.SlcTypes;
 import org.argeo.slc.repo.ArtifactIndexer;
+import org.argeo.slc.repo.NodeIndexer;
 import org.argeo.slc.repo.RepoConstants;
 import org.argeo.slc.repo.RepoUtils;
 import org.argeo.slc.repo.maven.MavenConventionsUtils;
@@ -49,7 +50,11 @@ import org.sonatype.aether.util.artifact.DefaultArtifact;
 /**
  * Make sure that all JCR metadata and Maven metadata are consistent for this
  * group of OSGi bundles.
+ * 
+ * The job is now done via the various {@code NodeIndexer} of the WorkspaceManager.
+ * TODO import dependencies in the workspace.
  */
+@Deprecated
 public class NormalizeGroup implements Runnable, SlcNames {
        private final static Log log = LogFactory.getLog(NormalizeGroup.class);
 
index e6b8b323e624f1e8dcfd3e9223f0c1211dd52da8..86a15ef27076416a678c2d9fe2630468ccbdf846 100644 (file)
@@ -58,6 +58,8 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames {
                Session javaSession = null;
                Session distSession = null;
                try {
+                       // TODO rather user a JavaRepoManager that will also implicitely
+                       // manage the indexing of newly created nodes.
                        javaSession = JcrUtils.loginOrCreateWorkspace(javaRepository,
                                        workspace);
                        distSession = JcrUtils.loginOrCreateWorkspace(distRepository,
@@ -169,7 +171,7 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames {
                                return loadUrlToPath(url, distSession, distPath);
                        } catch (FileNotFoundException e) {
                                if (log.isDebugEnabled())
-                                       log.debug("Cannot download" + url
+                                       log.debug("Cannot download " + url
                                                        + ", trying another mirror");
                        }
                }
index 33d4444a4c8dbfb16afa1972deddfdb14d8799f1..1acaf98239372d1d51ebd0b43e05aa37ffeb1228 100644 (file)
@@ -38,7 +38,9 @@ mixin
 [slc:modularDistributionBase]
 mixin
 
-[slc:modularDistribution]
+// Inherit from > slc:categorizedNameVersion ??
+// (not possible without migration)
+[slc:modularDistribution] 
 mixin
 + slc:modules (nt:unstructured) m
 
index d6ddd19218d7d5c04f4717e6d38789eabd3c0e46..c12f86c85a674fd304346027b64917821c556ef4 100644 (file)
@@ -34,9 +34,9 @@ public interface SlcNames {
        public final static String SLC_AGGREGATED_STATUS = "slc:aggregatedStatus";
 
        public final static String SLC_TYPE = "slc:type";
-       public final static String SLC_CATEGORY = "slc:category";
        public final static String SLC_NAME = "slc:name";
        public final static String SLC_VERSION = "slc:version";
+       public final static String SLC_CATEGORY = "slc:category";
        public final static String SLC_VALUE = "slc:value";
        public final static String SLC_ADDRESS = "slc:address";
        public final static String SLC_METADATA = "slc:metadata";
index 35f971dccc344a2f7a6e34fc70374ffa354c59da..177dbb369d4d9862ed87a54fad6cd5755c365e63 100644 (file)
@@ -18,6 +18,9 @@ package org.argeo.slc.jcr;
 /** JCR node types used by SLC */
 public interface SlcTypes {
 
+       public final static String SLC_NAME_VERSION = "slc:nameVersion";
+       public final static String SLC_CATEGORIZED_NAME_VERSION = "slc:categorizedNameVersion";
+
        public final static String SLC_AGENT_FACTORY = "slc:agentFactory";
        public final static String SLC_AGENT = "slc:agent";
        public final static String SLC_MODULE = "slc:module";
@@ -64,9 +67,9 @@ public interface SlcTypes {
        public final static String SLC_DYNAMIC_IMPORTED_PACKAGE = "slc:dynamicImportedPackage";
        public final static String SLC_REQUIRED_BUNDLE = "slc:requiredBundle";
        public final static String SLC_FRAGMENT_HOST = "slc:fragmentHost";
-       
+
        // Distribution management
-       public final static String SLC_RELEVANT_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";
index d76c517ef2577a9be0bebb03a795a7121ebe9280..6e23cf5e988fd3e9724a6830017d148c6c75248c 100644 (file)
@@ -6,6 +6,11 @@ mixin
 - slc:name (STRING) m
 - slc:version (STRING) m
 
+[slc:categorizedNameVersion] > slc:nameVersion
+mixin
+// define as mandatory?
+- slc:category (STRING)
+
 // AGENT
 [slc:agentFactory] > nt:unstructured, mix:title
 + * (slc:agent)