From: Mathieu Baudier Date: Thu, 17 Feb 2011 22:53:08 +0000 (+0000) Subject: Repository browsing X-Git-Tag: argeo-slc-2.1.7~1025 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=5f38bb8fc715b7fdf124c096a190f15eff42910e;hp=a49b28f9f972f303961d40948b28604140ae3a83;p=gpl%2Fargeo-slc.git Repository browsing git-svn-id: https://svn.argeo.org/slc/trunk@4157 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/eclipse/plugins/org.argeo.slc.client.rcp/plugin.xml b/eclipse/plugins/org.argeo.slc.client.rcp/plugin.xml index feb47027d..b608f8361 100644 --- a/eclipse/plugins/org.argeo.slc.client.rcp/plugin.xml +++ b/eclipse/plugins/org.argeo.slc.client.rcp/plugin.xml @@ -84,6 +84,10 @@ name="windowImages" value="icons/argeo-icon-256.png"> + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/MANIFEST.MF b/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/MANIFEST.MF index 632f08d27..d1f0db5b2 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/MANIFEST.MF +++ b/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/MANIFEST.MF @@ -9,6 +9,10 @@ Require-Bundle: org.eclipse.ui;resolution:=optional, org.eclipse.core.runtime Bundle-Activator: org.argeo.slc.client.ui.dist.DistPlugin Import-Package: aQute.lib.osgi;resolution:=optional, + javax.jcr;version="[2.0.0,3.0.0)", org.apache.commons.logging;version="1.1.1", - org.argeo.eclipse.ui + org.argeo.eclipse.spring, + org.argeo.eclipse.ui, + org.argeo.eclipse.ui.jcr.views, + org.argeo.jcr Bundle-ActivationPolicy: lazy diff --git a/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml b/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml new file mode 100644 index 000000000..15e7cfad6 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml b/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml new file mode 100644 index 000000000..021599cb4 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui.dist/plugin.xml b/eclipse/plugins/org.argeo.slc.client.ui.dist/plugin.xml index ba72b7992..1cb3bae63 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui.dist/plugin.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui.dist/plugin.xml @@ -15,8 +15,12 @@ + name="Modules"> + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistributionPerspective.java b/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistributionPerspective.java index c31830a2d..92337995f 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistributionPerspective.java +++ b/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistributionPerspective.java @@ -13,6 +13,7 @@ public class DistributionPerspective implements IPerspectiveFactory { IFolderLayout main = layout.createFolder("main", IPageLayout.RIGHT, 0.3f, editorArea); + main.addView("org.argeo.slc.client.ui.dist.distributionView"); main.addView("org.argeo.slc.client.ui.dist.modulesView"); } diff --git a/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionView.java b/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionView.java new file mode 100644 index 000000000..fae06bb5a --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionView.java @@ -0,0 +1,12 @@ +package org.argeo.slc.client.ui.dist.views; + +import org.argeo.eclipse.ui.jcr.views.GenericJcrBrowser; + +public class DistributionView extends GenericJcrBrowser { + + @Override + protected int[] getWeights() { + return new int[] { 60, 40 }; + } + +} diff --git a/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/ModulesView.java b/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/ModulesView.java index d0fac981d..6745d91b8 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/ModulesView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/ModulesView.java @@ -137,31 +137,35 @@ public class ModulesView extends ViewPart { } } - Map> traces1 = new TreeMap>(); - Map space1 = dependencySpace(bundle1, - importedPackages, traces1); - Map> traces2 = new TreeMap>(); - Map space2 = dependencySpace(bundle2, - importedPackages, traces2); - for (String key : space1.keySet()) { - if (space2.containsKey(key)) { - ExportedPackage pkg1 = space1.get(key); - ExportedPackage pkg2 = space2.get(key); - if (!pkg1.getVersion().equals(pkg2.getVersion())) { - log.debug("\n##" + pkg1 + " <> " + pkg2); - log.debug("# Traces for " - + bundle1.getSymbolicName()); - for (String trace : traces1.get(pkg1.getName())) { - log.debug(trace); - } - log.debug("# Traces for " - + bundle2.getSymbolicName()); - for (String trace : traces2.get(pkg2.getName())) { - log.debug(trace); - } - } - } - } + // Map> traces1 = new TreeMap>(); + // Map space1 = + // dependencySpace(bundle1, + // importedPackages, traces1); + // Map> traces2 = new TreeMap>(); + // Map space2 = + // dependencySpace(bundle2, + // importedPackages, traces2); + // for (String key : space1.keySet()) { + // if (space2.containsKey(key)) { + // ExportedPackage pkg1 = space1.get(key); + // ExportedPackage pkg2 = space2.get(key); + // if (!pkg1.getVersion().equals(pkg2.getVersion())) { + // log.debug("\n##" + pkg1 + " <> " + pkg2); + // log.debug("# Traces for " + // + bundle1.getSymbolicName()); + // for (String trace : traces1.get(pkg1.getName())) { + // log.debug(trace); + // } + // log.debug("# Traces for " + // + bundle2.getSymbolicName()); + // for (String trace : traces2.get(pkg2.getName())) { + // log.debug(trace); + // } + // } + // } + // } return new Object[] { bundlesNode, mPackageNode, aPackageNode }; } else if (parentElement instanceof TreeParent) { diff --git a/modules/server/org.argeo.slc.server.repo/META-INF/spring/maven.xml b/modules/server/org.argeo.slc.server.repo/META-INF/spring/maven.xml index d64933cdb..2cdbbab71 100644 --- a/modules/server/org.argeo.slc.server.repo/META-INF/spring/maven.xml +++ b/modules/server/org.argeo.slc.server.repo/META-INF/spring/maven.xml @@ -11,6 +11,7 @@ + diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoNames.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoNames.java index 4eab86881..0a69b3d00 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoNames.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoNames.java @@ -8,6 +8,7 @@ public interface RepoNames { public final static String SLC_NAME = "slc:name"; public final static String SLC_VERSION = "slc:version"; public final static String SLC_OPTIONAL = "slc:optional"; + public final static String SLC_AS_STRING = "slc:asString"; // slc:artifact public final static String SLC_ARTIFACT_ID = "slc:artifactId"; @@ -20,7 +21,7 @@ public interface RepoNames { public final static String SLC_MANIFEST = "slc:manifest"; // shared OSGi - public final static String SLC_SYMBOLIC_NAME = "slc:symbolicName"; + public final static String SLC_SYMBOLIC_NAME = "slc:symbolic-name"; public final static String SLC_BUNDLE_VERSION = "slc:bundle-version"; // slc:osgiBaseVersion diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java index f0fd220d8..a6eb8df50 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java @@ -20,6 +20,7 @@ import java.util.jar.Manifest; import javax.jcr.Binary; import javax.jcr.Node; import javax.jcr.NodeIterator; +import javax.jcr.PathNotFoundException; import javax.jcr.Property; import javax.jcr.RepositoryException; import javax.jcr.Session; @@ -55,6 +56,8 @@ public class ImportMavenDependencies implements Runnable { private Session jcrSession; private String artifactBasePath = "/slc/repo/artifacts"; + private String distributionsBasePath = "/slc/repo/distributions"; + private String distributionName; public void run() { log.debug(jcrSession.getUserID()); @@ -118,30 +121,14 @@ public class ImportMavenDependencies implements Runnable { Long begin = System.currentTimeMillis(); try { JcrUtils.mkdirs(jcrSession, artifactBasePath); + JcrUtils.mkdirs(jcrSession, distributionsBasePath + '/' + + distributionName); artifacts: for (Artifact artifact : artifacts) { File file = artifact.getFile(); if (file == null) { log.warn("File not found for " + artifact); - file = new File(System.getProperty("user.home") - + File.separator - + ".m2" - + File.separator - + "repository" - + File.separator - + artifact.getGroupId().replace('.', - File.separatorChar) - + File.separator - + artifact.getArtifactId() - + File.separator - + artifact.getVersion() - + File.separator - + artifact.getArtifactId() - + '-' - + artifact.getVersion() - + (artifact.getClassifier().equals("") ? "" - : '-' + artifact.getClassifier()) + '.' - + artifact.getExtension()); + file = artifactToFile(artifact); if (!file.exists()) { log.warn("Generated file " + file + " for " + artifact @@ -172,6 +159,16 @@ public class ImportMavenDependencies implements Runnable { processOsgiBundle(fileNode); } jcrSession.save(); + + if (!jcrSession + .itemExists(bundleDistributionPath(fileNode)) + && fileNode + .isNodeType(RepoTypes.SLC_BUNDLE_ARTIFACT)) + jcrSession.getWorkspace().clone( + jcrSession.getWorkspace().getName(), + fileNode.getPath(), + bundleDistributionPath(fileNode), false); + if (log.isDebugEnabled()) log.debug("Synchronized " + fileNode); } catch (Exception e) { @@ -194,6 +191,23 @@ public class ImportMavenDependencies implements Runnable { + artifact.getArtifactId() + '/' + artifact.getVersion(); } + protected String bundleDistributionPath(Node fileNode) { + try { + return distributionsBasePath + + '/' + + distributionName + + '/' + + fileNode.getProperty(RepoNames.SLC_SYMBOLIC_NAME) + .getString() + + '_' + + fileNode.getProperty(RepoNames.SLC_BUNDLE_VERSION) + .getString(); + } catch (RepositoryException e) { + throw new SlcException("Cannot create distribution path for " + + fileNode, e); + } + } + protected void processArtifact(Node fileNode, Artifact artifact) { try { fileNode.addMixin(RepoTypes.SLC_ARTIFACT); @@ -213,6 +227,27 @@ public class ImportMavenDependencies implements Runnable { } + protected File artifactToFile(Artifact artifact) { + return new File(System.getProperty("user.home") + + File.separator + + ".m2" + + File.separator + + "repository" + + File.separator + + artifact.getGroupId().replace('.', File.separatorChar) + + File.separator + + artifact.getArtifactId() + + File.separator + + artifact.getVersion() + + File.separator + + artifact.getArtifactId() + + '-' + + artifact.getVersion() + + (artifact.getClassifier().equals("") ? "" + : '-' + artifact.getClassifier()) + '.' + + artifact.getExtension()); + } + protected void processOsgiBundle(Node fileNode) { Binary manifestBinary = null; InputStream manifestIn = null; @@ -233,6 +268,14 @@ public class ImportMavenDependencies implements Runnable { } fileNode.addMixin(RepoTypes.SLC_BUNDLE_ARTIFACT); + + // symbolic name + String symbolicName = attrs.getValue(Constants.BUNDLE_SYMBOLICNAME); + // make sure there is no directive + symbolicName = symbolicName.split(";")[0]; + fileNode.setProperty(RepoNames.SLC_SYMBOLIC_NAME, symbolicName); + + // direct mapping addAttr(Constants.BUNDLE_SYMBOLICNAME, fileNode, attrs); addAttr(Constants.BUNDLE_NAME, fileNode, attrs); addAttr(Constants.BUNDLE_DESCRIPTION, fileNode, attrs); @@ -267,6 +310,8 @@ public class ImportMavenDependencies implements Runnable { // version Version version = new Version( attrs.getValue(Constants.BUNDLE_VERSION)); + fileNode.setProperty(RepoNames.SLC_BUNDLE_VERSION, + version.toString()); cleanSubNodes(fileNode, RepoNames.SLC_ + Constants.BUNDLE_VERSION); Node bundleVersionNode = fileNode.addNode(RepoNames.SLC_ + Constants.BUNDLE_VERSION, RepoTypes.SLC_OSGI_VERSION); @@ -294,7 +339,7 @@ public class ImportMavenDependencies implements Runnable { if (attrs.containsKey(new Name(Constants.IMPORT_PACKAGE))) { String importPackages = attrs .getValue(Constants.IMPORT_PACKAGE); - String[] packages = importPackages.split(","); + List packages = parsePackages(importPackages); for (String pkg : packages) { String[] tokens = pkg.split(";"); Node node = fileNode.addNode(RepoNames.SLC_ @@ -322,7 +367,7 @@ public class ImportMavenDependencies implements Runnable { if (attrs.containsKey(new Name(Constants.DYNAMICIMPORT_PACKAGE))) { String importPackages = attrs .getValue(Constants.DYNAMICIMPORT_PACKAGE); - String[] packages = importPackages.split(","); + List packages = parsePackages(importPackages); for (String pkg : packages) { String[] tokens = pkg.split(";"); Node node = fileNode.addNode(RepoNames.SLC_ @@ -343,7 +388,7 @@ public class ImportMavenDependencies implements Runnable { if (attrs.containsKey(new Name(Constants.EXPORT_PACKAGE))) { String exportPackages = attrs .getValue(Constants.EXPORT_PACKAGE); - List packages = parseExportPackage(exportPackages); + List packages = parsePackages(exportPackages); for (String pkg : packages) { String[] tokens = pkg.split(";"); Node node = fileNode.addNode(RepoNames.SLC_ @@ -413,7 +458,8 @@ public class ImportMavenDependencies implements Runnable { } } - private List parseExportPackage(String str) { + /** Parse package list with nested directive with ',' */ + private List parsePackages(String str) { List res = new ArrayList(); StringBuffer curr = new StringBuffer(""); boolean in = false; @@ -441,8 +487,10 @@ public class ImportMavenDependencies implements Runnable { private void addAttr(Name key, Node node, Attributes attrs) throws RepositoryException { - if (attrs.containsKey(key)) - node.setProperty(RepoNames.SLC_ + key, attrs.getValue(key)); + if (attrs.containsKey(key)) { + String value = attrs.getValue(key); + node.setProperty(RepoNames.SLC_ + key, value); + } } private void cleanSubNodes(Node node, String name) @@ -456,6 +504,7 @@ public class ImportMavenDependencies implements Runnable { protected void mapOsgiVersion(Version version, Node versionNode) throws RepositoryException { + versionNode.setProperty(RepoNames.SLC_AS_STRING, version.toString()); versionNode.setProperty(RepoNames.SLC_MAJOR, version.getMajor()); versionNode.setProperty(RepoNames.SLC_MINOR, version.getMinor()); versionNode.setProperty(RepoNames.SLC_MICRO, version.getMicro()); @@ -650,4 +699,8 @@ public class ImportMavenDependencies implements Runnable { this.jcrSession = jcrSession; } + public void setDistributionName(String distributionName) { + this.distributionName = distributionName; + } + } diff --git a/runtime/org.argeo.slc.repo/src/main/resources/org/argeo/slc/repo/repo.cnd b/runtime/org.argeo.slc.repo/src/main/resources/org/argeo/slc/repo/repo.cnd index dd3d49368..2cb35462a 100644 --- a/runtime/org.argeo.slc.repo/src/main/resources/org/argeo/slc/repo/repo.cnd +++ b/runtime/org.argeo.slc.repo/src/main/resources/org/argeo/slc/repo/repo.cnd @@ -30,9 +30,10 @@ mixin // see http://www.osgi.org/Specifications/Reference [slc:javaPackage] > nt:base -- slc:name (STRING) m +- slc:name (STRING) primary m [slc:osgiBaseVersion] > nt:base +- slc:asString (STRING) primary m - slc:major (LONG) m - slc:minor (LONG) m - slc:micro (LONG) m @@ -53,23 +54,25 @@ mixin - slc:optional (BOOLEAN) ='false' m a [slc:requiredBundle] > nt:base -- slc:symbolicName (STRING) m +- 'slc:symbolic-name' (STRING) primary m - 'slc:bundle-version' (STRING) ='0.0.0' m a - slc:optional (BOOLEAN) ='false' m a [slc:fragmentHost] > nt:base -- slc:symbolicName (STRING) m +- 'slc:symbolic-name' (STRING) m - 'slc:bundle-version' (STRING) ='0.0.0' m a [slc:bundleNativeCode] > nt:base -- slc:path (STRING) m +- slc:path (STRING) primary m - slc:osname (STRING) - slc:processor (STRING) // see http://www.osgi.org/Specifications/ReferenceHeaders [slc:bundle] > nt:base mixin -- 'slc:Bundle-SymbolicName' (STRING) primary m +- 'slc:symbolic-name' (STRING) primary m +- 'slc:bundle-version' (STRING) m +- 'slc:Bundle-SymbolicName' (STRING) m - 'slc:Bundle-Name' (STRING) - 'slc:Bundle-Description' (STRING) - 'slc:Bundle-ManifestVersion' (STRING)