import java.util.Iterator;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.dist.DistPlugin;
import org.argeo.slc.client.ui.dist.model.ModularDistBaseElem;
+import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
import org.argeo.slc.client.ui.dist.wizards.GenerateBinariesWizard;
import org.eclipse.core.commands.AbstractHandler;
Object element = it.next();
if (element instanceof ModularDistBaseElem) {
ModularDistBaseElem elem = (ModularDistBaseElem) element;
+ Session newSession = null;
+ try {
+ Node cBase = elem.getCategoryBase();
+ String path = cBase.getPath();
+ newSession = ((WorkspaceElem) elem.getParent())
+ .getNewSession();
+ GenerateBinariesWizard wizard = new GenerateBinariesWizard(
+ newSession.getNode(path));
+
+ WizardDialog dialog = new WizardDialog(
+ HandlerUtil.getActiveShell(event), wizard);
+ int result = dialog.open();
- GenerateBinariesWizard wizard = new GenerateBinariesWizard(
- elem.getCategoryBase());
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- int result = dialog.open();
- if (result == Dialog.OK)
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
+ if (result == Dialog.OK)
+ CommandHelpers
+ .callCommand(RefreshDistributionsView.ID);
+ } catch (RepositoryException re) {
+ throw new SlcException(
+ "Unable to duplicate session for node " + elem,
+ re);
+ }
}
}
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.StringTokenizer;
import java.util.TreeSet;
import javax.jcr.Credentials;
.hasNext();) {
Node file = files.nextNode();
if (file.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
- preProcessBundleArtifact(file);
if (log.isDebugEnabled())
- log.debug("Pre-processed " + file.getName());
+ log.debug("Pre-Processing " + file.getName());
+ preProcessBundleArtifact(file);
}
}
}
int count = 1;
for (Node bundleNode : symbolicNamesToNodes.values()) {
+ if (log.isDebugEnabled())
+ log.debug("Processing " + bundleNode.getName() + " ( " + count
+ + "/" + bundleCount + " )");
+
processBundleArtifact(bundleNode);
bundleNode.getSession().save();
- if (log.isDebugEnabled())
- log.debug(count + "/" + bundleCount + " Processed "
- + bundleNode.getName());
count++;
}
String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION)
.getString();
String cleanVersion = rawVersion.replace("-SNAPSHOT", ".SNAPSHOT");
- return new Version(cleanVersion);
+ Version osgiVersion = null;
+ // log invalid version value to enable tracking them
+ try {
+ osgiVersion = new Version(cleanVersion);
+ } catch (IllegalArgumentException e) {
+ log.error("Version string " + cleanVersion + " is invalid ");
+ String twickedVersion = twickInvalidVersion(cleanVersion);
+ osgiVersion = new Version(twickedVersion);
+ log.error("Using " + twickedVersion + " instead");
+ // throw e;
+ }
+ return osgiVersion;
+ }
+
+ private String twickInvalidVersion(String tmpVersion) {
+ String[] tokens = tmpVersion.split("\\.");
+ if (tokens.length == 3 && tokens[2].lastIndexOf("-") > 0) {
+ String newSuffix = tokens[2].replaceFirst("-", ".");
+ tmpVersion = tmpVersion.replaceFirst(tokens[2], newSuffix);
+ } else if (tokens.length > 4) {
+ // FIXME manually remove other "."
+ StringTokenizer st = new StringTokenizer(tmpVersion, ".", true);
+ StringBuilder builder = new StringBuilder();
+ // Major
+ builder.append(st.nextToken()).append(st.nextToken());
+ // Minor
+ builder.append(st.nextToken()).append(st.nextToken());
+ // Micro
+ builder.append(st.nextToken()).append(st.nextToken());
+ // Qualifier
+ builder.append(st.nextToken());
+ while (st.hasMoreTokens()) {
+ // consume delimiter
+ st.nextToken();
+ if (st.hasMoreTokens())
+ builder.append("-").append(st.nextToken());
+ }
+ tmpVersion = builder.toString();
+ }
+ return tmpVersion;
}
protected void preProcessBundleArtifact(Node bundleNode)