]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Repository browsing
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 17 Feb 2011 22:53:08 +0000 (22:53 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 17 Feb 2011 22:53:08 +0000 (22:53 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@4157 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

12 files changed:
eclipse/plugins/org.argeo.slc.client.rcp/plugin.xml
eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/MANIFEST.MF
eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml [new file with mode: 0644]
eclipse/plugins/org.argeo.slc.client.ui.dist/META-INF/spring/views.xml [new file with mode: 0644]
eclipse/plugins/org.argeo.slc.client.ui.dist/plugin.xml
eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/DistributionPerspective.java
eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionView.java [new file with mode: 0644]
eclipse/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/ModulesView.java
modules/server/org.argeo.slc.server.repo/META-INF/spring/maven.xml
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoNames.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java
runtime/org.argeo.slc.repo/src/main/resources/org/argeo/slc/repo/repo.cnd

index feb47027df96c6c8f26d7f40d2d60ab1504c25be..b608f8361b9539062c8ef86f65655c5181bff6d7 100644 (file)
                name="windowImages"
                value="icons/argeo-icon-256.png">
          </property>
+         <property
+               name="appName"
+               value="SLC">
+         </property>
       </product>
    </extension>
 </plugin>
index 632f08d271e34d52289e1cfa21efdb39f42fad8c..d1f0db5b2426aafb19e70330725a10a4e7a3493d 100644 (file)
@@ -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 (file)
index 0000000..15e7cfa
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+       xmlns:osgi="http://www.springframework.org/schema/osgi"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
+       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+       http://www.springframework.org/schema/beans   \r
+       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
+       osgi:default-timeout="30000">\r
+\r
+       <reference id="jcrRepository" interface="javax.jcr.Repository" />\r
+</beans:beans>
\ 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 (file)
index 0000000..021599c
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+       <!-- Views -->
+       <bean id="org.argeo.slc.client.ui.dist.distributionView" class="org.argeo.slc.client.ui.dist.views.DistributionView"
+               scope="prototype">
+               <property name="jcrSession" ref="jcrSession" />
+       </bean>
+
+       <bean id="jcrSession" class="org.argeo.jcr.ThreadBoundJcrSessionFactory">
+               <property name="repository" ref="jcrRepository" />
+               <property name="workspace" value="slc_repo" />
+               <property name="forceDefaultCredentials" value="true" />
+       </bean>
+
+</beans>
index ba72b79923407dcb48cc16231d9de282eb5bf7e7..1cb3bae63159776a45d298578803971d6fb71080 100644 (file)
       <view
             class="org.argeo.slc.client.ui.dist.views.ModulesView"
             id="org.argeo.slc.client.ui.dist.modulesView"
-            name="Modules"
-            restorable="true">
+            name="Modules">
       </view>
+          <view
+                class="org.argeo.eclipse.spring.SpringExtensionFactory"
+                id="org.argeo.slc.client.ui.dist.distributionView"
+                name="Distribution">
+          </view>
    </extension>
 </plugin>
index c31830a2d71370787ea2568c5de0c7c3e483da30..92337995f013fe87600e52f5152924c05b8cc992 100644 (file)
@@ -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 (file)
index 0000000..fae06bb
--- /dev/null
@@ -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 };
+       }
+
+}
index d0fac981d7f209db13b56dc335e44523e717dcbd..6745d91b8641f7ed504cfe39818b8e519b5f7b3e 100644 (file)
@@ -137,31 +137,35 @@ public class ModulesView extends ViewPart {
                                        }
                                }
 
-                               Map<String, Set<String>> traces1 = new TreeMap<String, Set<String>>();
-                               Map<String, ExportedPackage> space1 = dependencySpace(bundle1,
-                                               importedPackages, traces1);
-                               Map<String, Set<String>> traces2 = new TreeMap<String, Set<String>>();
-                               Map<String, ExportedPackage> 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<String, Set<String>> traces1 = new TreeMap<String,
+                               // Set<String>>();
+                               // Map<String, ExportedPackage> space1 =
+                               // dependencySpace(bundle1,
+                               // importedPackages, traces1);
+                               // Map<String, Set<String>> traces2 = new TreeMap<String,
+                               // Set<String>>();
+                               // Map<String, ExportedPackage> 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) {
index d64933cdb45379db0313189a96b79966bb0fb7ab..2cdbbab71338c3bf8571757edf3596eb4f2ab99d 100644 (file)
@@ -11,6 +11,7 @@
        <bean class="org.argeo.slc.repo.maven.ImportMavenDependencies" init-method="run">
                <property name="rootCoordinates"
                        value="org.argeo.dep:versions-all:pom:1.1.3-SNAPSHOT" />
+               <property name="distributionName" value="tp" />
                <property name="aetherTemplate" ref="mavenAetherTemplate" />
                <property name="jcrSession" ref="jcrSession" />
                <property name="excludedArtifacts">
index 4eab86881d7f589fee79f7945dd4b8b5fd178197..0a69b3d00ab08f4303593e31bc76ccdaa726d38a 100644 (file)
@@ -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
index f0fd220d83258ef835a4ab0fd9fbc2202d3f3cfb..a6eb8df50d2eb192140fa77a32cd2f12c5d09205 100644 (file)
@@ -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<String> 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<String> 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<String> packages = parseExportPackage(exportPackages);
+                               List<String> 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<String> parseExportPackage(String str) {
+       /** Parse package list with nested directive with ',' */
+       private List<String> parsePackages(String str) {
                List<String> res = new ArrayList<String>();
                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;
+       }
+
 }
index dd3d493680c298be8367d39fe48b89414487be04..2cb35462a5be4f03c2a653ed8278b06484d599ee 100644 (file)
@@ -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)