geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1140360 - /geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java
Date Mon, 27 Jun 2011 22:59:08 GMT
Author: djencks
Date: Mon Jun 27 22:59:07 2011
New Revision: 1140360

URL: http://svn.apache.org/viewvc?rev=1140360&view=rev
Log:
GERONIMO-5586 use wrap bundle from console add to repo for non-bundles

Modified:
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java?rev=1140360&r1=1140359&r2=1140360&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java
(original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java
Mon Jun 27 22:59:07 2011
@@ -46,6 +46,8 @@ import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -53,6 +55,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import java.util.SortedSet;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
 
 /**
  * @version $Rev$ $Date$
@@ -175,18 +180,52 @@ public class RepositoryViewPortlet exten
                     set.put(jarName, group + "/" + artifact + "/" + version + "/" + fileType);
                     instance.addAliases(set);
                 }
-                repo.copyToRepository(file, new Artifact(group, artifact, version, fileType),
new FileWriteMonitor() {
-                    public void writeStarted(String fileDescription, int fileSize) {
-                        log.info("Copying into repository " + fileDescription + "...");
-                    }
 
-                    public void writeProgress(int bytes) {
-                    }
+                JarFile jar = new JarFile(file);
+                try {
+                    // only handle non OSGi jar
+                    Manifest manifest = jar.getManifest();
+                    if (manifest != null &&
+                        manifest.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName"))
!= null &&
+                        manifest.getMainAttributes().getValue(new Attributes.Name("Bundle-Version"))
!= null) {
+
+                        URL wrap = new URL("wrap", null, file.toURI().toURL().toExternalForm()
+ "$Bundle-SymbolicName=" + artifact + "&Bundle-Version=" + version.replace("-", "."));
+                        InputStream in = wrap.openStream();
+                        try {
+                            repo.copyToRepository(in, (int)file.getTotalSpace(), new Artifact(group,
artifact, version, fileType), new FileWriteMonitor() {
+                                public void writeStarted(String fileDescription, int fileSize)
{
+                                    log.info("Copying into repository " + fileDescription
+ "...");
+                                }
+
+                                public void writeProgress(int bytes) {
+                                }
+
+                                public void writeComplete(int bytes) {
+                                    log.info("Finished.");
+                                }
+                            });
+                        } finally {
+                            in.close();
+                        }
+                    } else {
+                        repo.copyToRepository(file, new Artifact(group, artifact, version,
fileType), new FileWriteMonitor() {
+                            public void writeStarted(String fileDescription, int fileSize)
{
+                                log.info("Copying into repository " + fileDescription + "...");
+                            }
 
-                    public void writeComplete(int bytes) {
-                        log.info("Finished.");
+                            public void writeProgress(int bytes) {
+                            }
+
+                            public void writeComplete(int bytes) {
+                                log.info("Finished.");
+                            }
+                        });
                     }
-                });
+                } finally {
+                    jar.close();
+                }
+
+
             } catch (FileUploadException e) {
                 throw new PortletException(e);
             } catch (GBeanNotFoundException e) {



Mime
View raw message