import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.repo.ArtifactIndexer;
import org.argeo.slc.repo.JarFileIndexer;
+import org.argeo.slc.repo.ModularDistributionIndexer;
import org.argeo.slc.repo.PdeSourcesIndexer;
import org.argeo.slc.repo.RepoConstants;
import org.argeo.slc.repo.RepoUtils;
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 {
+ // Relevant default node indexers
+ private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer();
+ // WARNING Order is important: must be called in the following order.
+ private ModularDistributionIndexer modularDistributionIndexer = new ModularDistributionIndexer();
+ private JarFileIndexer jarFileIndexer = new JarFileIndexer();
+ private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+ 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 ?";
@Override
protected IStatus run(IProgressMonitor progressMonitor) {
-
try {
ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
- // normalize artifacts
+ // Normalize artifacts
Query countQuery = session
.getWorkspace()
.getQueryManager()
+ 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);
if (jarFileIndexer.support(node.getPath()))
if (artifactIndexer.support(node.getPath())) {
monitor.subTask(node.getName());
- artifactIndexer.index(node);
+ modularDistributionIndexer.index(node);
jarFileIndexer.index(node);
- node.getSession().save();
+ artifactIndexer.index(node);
+ if (node.getSession().hasPendingChanges()) {
+ node.getSession().save();
+ if (log.isDebugEnabled())
+ log.debug("Processed jar artifact "
+ + node.getPath());
+ }
monitor.worked(1);
- if (log.isDebugEnabled())
- log.debug("Processed artifact "
- + node.getPath());
}
+ } else if (node.getName().endsWith(".pom")) {
+ // Removed: we do not support binaries concept anymore.
+ // 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());
+ }
+ monitor.worked(1);
} else {
monitor.worked(1);
}
@Override
protected void leaving(Node node, int level) throws RepositoryException {
}
-
}
/* DEPENDENCY INJECTION */