Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0453291AE for ; Mon, 27 Feb 2012 08:30:36 +0000 (UTC) Received: (qmail 39552 invoked by uid 500); 27 Feb 2012 08:30:33 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 39502 invoked by uid 500); 27 Feb 2012 08:30:33 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 39493 invoked by uid 99); 27 Feb 2012 08:30:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2012 08:30:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Feb 2012 08:30:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3531623888D2; Mon, 27 Feb 2012 08:30:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1294061 - /geronimo/server/branches/3.0-beta/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java Date: Mon, 27 Feb 2012 08:30:12 -0000 To: scm@geronimo.apache.org From: johnxiao@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120227083012.3531623888D2@eris.apache.org> Author: johnxiao Date: Mon Feb 27 08:30:11 2012 New Revision: 1294061 URL: http://svn.apache.org/viewvc?rev=1294061&view=rev Log: GERONIMO-6288 When deploy a EBA with long symbolicname, showing an error Msg "xxxx already existes in the server" Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java?rev=1294061&r1=1294060&r2=1294061&view=diff ============================================================================== --- geronimo/server/branches/3.0-beta/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java (original) +++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java Mon Feb 27 08:30:11 2012 @@ -18,8 +18,10 @@ package org.apache.geronimo.deployment.p import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.Collection; @@ -28,6 +30,7 @@ import java.util.List; import java.util.Stack; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.jar.Manifest; import javax.enterprise.deploy.spi.TargetModuleID; import javax.xml.parsers.ParserConfigurationException; @@ -56,9 +59,9 @@ public class ConfigIDExtractor { private static final Logger log = LoggerFactory.getLogger(ConfigIDExtractor.class); - private static final String APPLICATION_SYMBOLICNAME="Application-SymbolicName:"; + private static final String APPLICATION_SYMBOLICNAME="Application-SymbolicName"; - private static final String APPLICATION_VERION="Application-Version:"; + private static final String APPLICATION_VERION="Application-Version"; /** * Attempt to calculate the Geronimo ModuleID for a J2EE application @@ -104,7 +107,7 @@ public class ConfigIDExtractor { if (target.getName().endsWith("xml")) { name = extractModuleIdFromPlan(in); } else if (target.getName().endsWith("MF")) { - name = extractModuleIdFromAPPLICATION_MF(in); + name = extractModuleIdFromAPPLICATION_MF(new FileInputStream(target)); } if(name != null) { @@ -149,7 +152,7 @@ public class ConfigIDExtractor { if (entry.getName().endsWith("xml")) { name = extractModuleIdFromPlan(in); } else if (entry.getName().endsWith("MF")) { - name = extractModuleIdFromAPPLICATION_MF(in); + name = extractModuleIdFromAPPLICATION_MF(input.getInputStream(entry)); } if(name != null) { @@ -239,30 +242,14 @@ public class ConfigIDExtractor { } - private static String extractModuleIdFromAPPLICATION_MF(Reader APPLICATION_MF) throws IOException,DeploymentException { + private static String extractModuleIdFromAPPLICATION_MF(InputStream in) throws IOException,DeploymentException { - BufferedReader br = new BufferedReader(APPLICATION_MF); - - String artifactID = null; - String artifactVersion = null; - + Manifest appMf = new Manifest(in); - String line = br.readLine(); - - while (line != null) { - - if (line.startsWith(APPLICATION_SYMBOLICNAME)) { - artifactID = line.substring(APPLICATION_SYMBOLICNAME.length(), line.length()); - } - - if (line.startsWith(APPLICATION_VERION)) { - artifactVersion = line.substring(APPLICATION_VERION.length(), line.length()); - } - - line = br.readLine(); - - } + String artifactID = appMf.getMainAttributes().getValue(APPLICATION_SYMBOLICNAME); + String artifactVersion = appMf.getMainAttributes().getValue(APPLICATION_VERION);; + if (artifactID == null || artifactVersion == null) { throw new DeploymentException("Could not determine artifact or version with APPLICATION.MF of your EBA application"); }