X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=plugins%2Forg.argeo.slc.client.ui.dist%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Fcommands%2FNormalizeWorkspace.java;h=1e1265a1d3a1b2a962527f71a62db83689c48afe;hb=c23b50e8d6286e38e9adfecfc828869a838c5a6f;hp=a9abb5fe82bca38db6d58ead5dd45b5ce6e287e7;hpb=7af5edc4d006d39174dba9665b0f78ccc2f9dfe6;p=gpl%2Fargeo-slc.git diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java index a9abb5fe8..1e1265a1d 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java @@ -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; @@ -60,35 +61,37 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { private final static Log log = LogFactory.getLog(NormalizeWorkspace.class); public final static String ID = DistPlugin.ID + ".normalizeWorkspace"; + public final static ImageDescriptor DEFAULT_ICON = DistPlugin + .getImageDescriptor("icons/normalize.gif"); public final static String PARAM_WORKSPACE_NAME = "workspaceName"; public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath"; - public final static ImageDescriptor DEFAULT_ICON = DistPlugin - .getImageDescriptor("icons/normalize.gif"); private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH; - private ArtifactIndexer artifactIndexer = new ArtifactIndexer(); - private JarFileIndexer jarFileIndexer = new JarFileIndexer(); - private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer( - artifactIndexer, jarFileIndexer); - // DEPENDENCY INJECTION private RepositoryFactory repositoryFactory; private Keyring keyring; private Repository repository; - public Object execute(ExecutionEvent event) throws ExecutionException { + private ArtifactIndexer artifactIndexer = new ArtifactIndexer(); + private JarFileIndexer jarFileIndexer = new JarFileIndexer(); + private DistributionBundleIndexer distBundleIndexer = new DistributionBundleIndexer(); + + private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer( + artifactIndexer, jarFileIndexer); + public Object execute(ExecutionEvent event) throws ExecutionException { String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH); String wkspName = event.getParameter(PARAM_WORKSPACE_NAME); 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 generate pdeSources if needed.\n" + + "it will also convert Maven sources to PDE Sources if needed.\n" + "Note that no information will be overwritten: " + "all existing information are kept." + "\n\n Do you really want to proceed ?"; @@ -126,10 +129,9 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { @Override protected IStatus run(IProgressMonitor progressMonitor) { - try { ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor); - // normalize artifacts + // Normalize artifacts Query countQuery = session .getWorkspace() .getQueryManager() @@ -141,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); @@ -183,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); } @@ -203,7 +222,6 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { @Override protected void leaving(Node node, int level) throws RepositoryException { } - } /* DEPENDENCY INJECTION */