You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by rw...@apache.org on 2011/10/22 09:02:16 UTC

svn commit: r1187662 - in /geronimo/server/branches/3.0-beta-1: framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/repository/

Author: rwonly
Date: Sat Oct 22 07:02:15 2011
New Revision: 1187662

URL: http://svn.apache.org/viewvc?rev=1187662&view=rev
Log:
GERONIMO-5586 modify the algorithm to calculate Artifact

Modified:
    geronimo/server/branches/3.0-beta-1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
    geronimo/server/branches/3.0-beta-1/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/repository/normal.jsp

Modified: geronimo/server/branches/3.0-beta-1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta-1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=1187662&r1=1187661&r2=1187662&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta-1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java (original)
+++ geronimo/server/branches/3.0-beta-1/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Sat Oct 22 07:02:15 2011
@@ -1138,8 +1138,8 @@ public class PluginInstallerGBean implem
         Artifact artifact = calculateArtifact(libFile, libFile.getName(), groupId);
         if (artifact == null)
             throw new IllegalArgumentException("Can not calculate Artifact string, file should be:\n"
-                    + "(1) a file with filename in the form <artifact>-<version>.<type>, for e.g. mylib-1.0.jar;\n"
-                    + "(2) or an OSGi bundle");
+                    + "(1) an OSGi bundle, then the artifactId is its Bundle-SymbolicName and the version is its Bundle-Version;\n"
+                    + "(2) or a file with filename in the form <artifactId>-<version>.<type>, for e.g. mylib-1.0.jar");
         installLibrary(libFile, artifact);
         return artifact;
     }
@@ -1154,7 +1154,7 @@ public class PluginInstallerGBean implem
             // convert to osgi bundle jars using wrap url handler
             URL wrap = new URL("wrap", null, libFile.toURI().toURL().toExternalForm() 
                     + "$Bundle-SymbolicName=" + artifact.getArtifactId() 
-                    + "&Bundle-Version=" + artifact.getVersion().toString().replace("-", "."));
+                    + "&Bundle-Version=" + artifact.getVersion().toString().replace("-", ".")); //need improve the version processing
             InputStream in = null;
             try {
                 in = wrap.openStream();
@@ -1171,13 +1171,12 @@ public class PluginInstallerGBean implem
         try {
             jar = new JarFile(file);
             Manifest manifest = jar.getManifest();
-            if (manifest != null &&
-                    manifest.getMainAttributes().getValue("Bundle-SymbolicName") != null &&
-                    manifest.getMainAttributes().getValue("Bundle-Version") != null) {
-                return new String[]{
-                        manifest.getMainAttributes().getValue("Bundle-SymbolicName"),
-                        manifest.getMainAttributes().getValue("Bundle-Version")
-                        };
+            if (manifest != null){
+                String symbolic = manifest.getMainAttributes().getValue("Bundle-SymbolicName");
+                String version = manifest.getMainAttributes().getValue("Bundle-Version");
+                if (symbolic!=null && version!=null) {
+                    return new String[]{symbolic,version};
+                }
             } 
         } finally {
             if (jar!=null) jar.close();
@@ -1207,30 +1206,23 @@ public class PluginInstallerGBean implem
         String version = null;
         String fileType = null;
         
-        // firstly, try calculate artifact string from the file name
-        Matcher matcher = MAVEN_1_PATTERN_PART.matcher(fileName);
-        if (matcher.matches()) {
-            artifactId = matcher.group(1);
-            version = matcher.group(2);
-            fileType = matcher.group(3);
-            
-            return new Artifact(groupId,artifactId,version,fileType);
+        
+        String[] bundleKey = identifyOSGiBundle(file);
+        if (bundleKey != null){ //try calculate if it is an OSGi bundle
+            artifactId = bundleKey[0]; //Bundle-SymbolicName
+            version = bundleKey[1]; //Bundle-Version
+            fileType = "jar";
+            return new Artifact(groupId, artifactId, version, fileType);
             
-        } else { //else try calculate if it is an OSGi bundle
-            String[] bundleKey = identifyOSGiBundle(file);
-            if (bundleKey != null){
-                artifactId = bundleKey[0]; //Bundle-SymbolicName
-                version = bundleKey[1]; //Bundle-Version
-
-                if (fileName.lastIndexOf(".") != -1) {
-                    fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
-                } else {
-                    fileType = "jar";
-                }
-
-                return new Artifact(groupId, artifactId, version, fileType);
+        } else { // not an OSGi bundle, try calculate artifact string from the file name
+            Matcher matcher = MAVEN_1_PATTERN_PART.matcher(fileName);
+            if (matcher.matches()) {
+                artifactId = matcher.group(1);
+                version = matcher.group(2);
+                fileType = matcher.group(3);
+                return new Artifact(groupId,artifactId,version,fileType);
                 
-            } else {
+            }else{
                 return null;
             }
         }

Modified: geronimo/server/branches/3.0-beta-1/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/repository/normal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta-1/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/repository/normal.jsp?rev=1187662&r1=1187661&r2=1187662&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta-1/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/repository/normal.jsp (original)
+++ geronimo/server/branches/3.0-beta-1/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/repository/normal.jsp Sat Oct 22 07:02:15 2011
@@ -179,8 +179,8 @@ function showHideByCheckbox(cb,target){
       <td>
         The default groupId is "default".<br/>
         The other parts could be calculated automatically, if:<br/>
-        (1) the file name has the following form: &lt;artifact&gt;-&lt;version&gt;.&lt;type&gt;, for e.g. mylib-1.0.jar;<br/>
-        (2) or the file is an OSGi bundle, then the artifactId is its Bundle-SymbolicName and the version is its Bundle-Version; <br/>
+        (1) It is an OSGi bundle, then the artifactId is its Bundle-SymbolicName and the version is its Bundle-Version;<br/>
+        (2) It is a file with filename in the form: &lt;artifactId&gt;-&lt;version&gt;.&lt;type&gt;, for e.g. mylib-1.0.jar, and then it will be converted to an OSGi Bundle using the artifactId as the Bundle-SymbolicName, and using version as the Bundle-Version.<br/>
       </td>
     </tr>
     <tr class="LightBackground">