<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" />
<!-- 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" />
<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>
\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
</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"
--- /dev/null
+/*
+ * 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
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;
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;
}
--- /dev/null
+/*
+ * 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
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);
.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();
.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 {
if (MessageDialog.openConfirm(DistPlugin.getDefault()
.getWorkbench().getDisplay().getActiveShell(),
"Confirm", msg)) {
- node.addMixin(SlcTypes.SLC_RELEVANT_CATEGORY);
+ node.addMixin(SlcTypes.SLC_CATEGORY);
node.getSession().save();
}
}
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;
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);
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 {
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;
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);
throw new SlcException(
"Unable to duplicate session for node " + elem,
re);
+ // } finally {
+ // JcrUtils.logoutQuietly(newSession);
}
}
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
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(
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);
}
});
} else
- tk.createLabel(parent, "", SWT.NONE);
+ tk.createLabel(parent, "N/A", SWT.NONE);
}
// helper to check if sources are available
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
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 "
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 "
}
/**
- * 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() {
};
/**
- * 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() {
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);
}
}
}
.getQueryManager()
.createQuery(
"select * from ["
- + SlcTypes.SLC_RELEVANT_CATEGORY + "]",
+ + SlcTypes.SLC_CATEGORY + "]",
Query.JCR_SQL2);
distributions = groupQuery.execute().getNodes();
while (distributions.hasNext()) {
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;
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;
// 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() {
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,
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>();
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
*/
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;
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;
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
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();
}
}
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);
}
}
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);
1));
recapViewer = new TableViewer(table);
- // Artifact columns
TableViewerColumn column = ViewerUtils.createTableViewerColumn(
recapViewer, "Name", SWT.NONE, 250);
column.setLabelProvider(new ColumnLabelProvider() {
recapViewer.setContentProvider(new IStructuredContentProvider() {
List<Artifact> artifacts;
+ @SuppressWarnings("unchecked")
public void inputChanged(Viewer viewer, Object oldInput,
Object newInput) {
artifacts = (List<Artifact>) newInput;
}
}
- /** 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;
}
// ////////////////////////////
// // 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
+++ /dev/null
-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;
- }
-
- }
-}
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);
--- /dev/null
+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
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;
* "...-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
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 "
.artifactParentPath(artifactBasePath, pdeSourceArtifact);
String targetSourceFileName = MavenConventionsUtils
.artifactFileName(pdeSourceArtifact);
- String targetSourceJarPath = targetSourceParentPath + '/'
- + targetSourceFileName;
+ // String targetSourceJarPath = targetSourceParentPath + '/'
+ // + targetSourceFileName;
Node targetSourceParentNode = JcrUtils.mkfolders(session,
targetSourceParentPath);
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);
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;
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;
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);
// 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);
}
}
+ /**
+ * 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();
.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 */
.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();
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();
}
}
}
- 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);
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 {
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;
}
this.excludedSuffixes = excludedSuffixes;
}
- public void setOverridePoms(Boolean overridePoms) {
- this.overridePoms = overridePoms;
- }
-
public void setArtifactIndexer(ArtifactIndexer artifactIndexer) {
this.artifactIndexer = artifactIndexer;
}
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;
/**
* 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);
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,
return loadUrlToPath(url, distSession, distPath);
} catch (FileNotFoundException e) {
if (log.isDebugEnabled())
- log.debug("Cannot download" + url
+ log.debug("Cannot download " + url
+ ", trying another mirror");
}
}
[slc:modularDistributionBase]
mixin
-[slc:modularDistribution]
+// Inherit from > slc:categorizedNameVersion ??
+// (not possible without migration)
+[slc:modularDistribution]
mixin
+ slc:modules (nt:unstructured) m
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";
/** 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";
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";
- 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)