]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java
Work on the binaries indexer.
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / commands / NormalizeWorkspace.java
index f6f9d06fea52412651de0080c99545ec112a8271..1e1265a1d3a1b2a962527f71a62db83689c48afe 100644 (file)
@@ -36,6 +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.JarFileIndexer;
 import org.argeo.slc.repo.PdeSourcesIndexer;
 import org.argeo.slc.repo.RepoConstants;
@@ -75,6 +76,8 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
 
        private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
        private JarFileIndexer jarFileIndexer = new JarFileIndexer();
+       private DistributionBundleIndexer distBundleIndexer = new DistributionBundleIndexer();
+
        private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer(
                        artifactIndexer, jarFileIndexer);
 
@@ -85,7 +88,8 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
                Session currSession = null;
                NormalizeJob job;
                try {
-                       String msg = "Your are about to normalize workspace: " + wkspName
+                       String msg = "Your are about to normalize workspace: "
+                                       + wkspName
                                        + ".\nThis will index OSGi bundles and Maven artifacts, "
                                        + "it will also convert Maven sources to PDE Sources if needed.\n"
                                        + "Note that no information will be overwritten: "
@@ -139,8 +143,14 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
                                                + session.getWorkspace().getName(),
                                                expectedCount.intValue());
                                NormalizingTraverser tiv = new NormalizingTraverser(monitor);
-                               session.getNode(artifactBasePath).accept(tiv);
+                               Node artifactBaseNode = session.getNode(artifactBasePath);
+                               artifactBaseNode.accept(tiv);
                        } catch (Exception e) {
+                               log.error("Error normalizing workspace "
+                                               + session.getWorkspace().getName() + ": "
+                                               + e.getMessage());
+                               if (log.isErrorEnabled())
+                                       e.printStackTrace();
                                return new Status(IStatus.ERROR, DistPlugin.ID,
                                                "Cannot normalize distribution "
                                                                + session.getWorkspace().getName(), e);
@@ -181,12 +191,23 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
                                                        monitor.subTask(node.getName());
                                                        artifactIndexer.index(node);
                                                        jarFileIndexer.index(node);
-                                                       node.getSession().save();
+                                                       distBundleIndexer.index(node);
+                                                       if (node.getSession().hasPendingChanges()) {
+                                                               node.getSession().save();
+                                                               if (log.isDebugEnabled())
+                                                                       log.debug("Processed artifact "
+                                                                                       + node.getPath());
+                                                       }
                                                        monitor.worked(1);
-                                                       if (log.isDebugEnabled())
-                                                               log.debug("Processed artifact "
-                                                                               + node.getPath());
                                                }
+                               } else if (node.getName().endsWith(".pom")) {
+                                       distBundleIndexer.index(node);
+                                       if (node.getSession().hasPendingChanges()) {
+                                               node.getSession().save();
+                                               if (log.isDebugEnabled())
+                                                       log.debug("Processed artifact " + node.getPath());
+                                       }
+                                       monitor.worked(1);
                                } else {
                                        monitor.worked(1);
                                }