[hibernate-commits] Hibernate SVN: r14235 - in entitymanager/branches/v3_2_1_GA_CP: src/java/org/hibernate/ejb and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Dec 7 17:03:59 EST 2007


Author: cbredesen
Date: 2007-12-07 17:03:59 -0500 (Fri, 07 Dec 2007)
New Revision: 14235

Modified:
   entitymanager/branches/v3_2_1_GA_CP/build.xml
   entitymanager/branches/v3_2_1_GA_CP/src/java/org/hibernate/ejb/Version.java
   entitymanager/branches/v3_2_1_GA_CP/src/java/org/hibernate/ejb/packaging/JarVisitor.java
Log:
JBPAPP-262 space in install path makes JPA fail

Modified: entitymanager/branches/v3_2_1_GA_CP/build.xml
===================================================================
--- entitymanager/branches/v3_2_1_GA_CP/build.xml	2007-12-07 22:03:18 UTC (rev 14234)
+++ entitymanager/branches/v3_2_1_GA_CP/build.xml	2007-12-07 22:03:59 UTC (rev 14235)
@@ -16,7 +16,7 @@
     <!-- Name of project and version, used to create filenames -->
     <property name="Name" value="Hibernate EntityManager"/>
     <property name="name" value="hibernate-entitymanager"/>
-    <property name="version" value="3.2.1.GA"/>
+    <property name="version" value="3.2.1.GA_CP02"/>
     <property name="javadoc.packagenames" value="org.hibernate.ejb.*"/>
     <property name="jdbc.dir" value="jdbc"/>
     <property name="copy.test" value="true"/>

Modified: entitymanager/branches/v3_2_1_GA_CP/src/java/org/hibernate/ejb/Version.java
===================================================================
--- entitymanager/branches/v3_2_1_GA_CP/src/java/org/hibernate/ejb/Version.java	2007-12-07 22:03:18 UTC (rev 14234)
+++ entitymanager/branches/v3_2_1_GA_CP/src/java/org/hibernate/ejb/Version.java	2007-12-07 22:03:59 UTC (rev 14235)
@@ -8,7 +8,7 @@
  * @author Emmanuel Bernard
  */
 public class Version {
-	public static final String VERSION = "3.2.1.GA";
+	public static final String VERSION = "3.2.1.GA_CP02";
 	private static Log log = LogFactory.getLog( Version.class );
 
 	static {

Modified: entitymanager/branches/v3_2_1_GA_CP/src/java/org/hibernate/ejb/packaging/JarVisitor.java
===================================================================
--- entitymanager/branches/v3_2_1_GA_CP/src/java/org/hibernate/ejb/packaging/JarVisitor.java	2007-12-07 22:03:18 UTC (rev 14234)
+++ entitymanager/branches/v3_2_1_GA_CP/src/java/org/hibernate/ejb/packaging/JarVisitor.java	2007-12-07 22:03:59 UTC (rev 14235)
@@ -41,8 +41,8 @@
 	/**
 	 * Get the JAR URL of the JAR containing the given entry
 	 *
-	 * @param url
-	 * @param entry
+	 * @param url URL pointing to the known file in the JAR
+	 * @param entry file known to be in the JAR
 	 * @return the JAR URL
 	 * @throws IllegalArgumentException if none URL is found
 	 */
@@ -57,17 +57,28 @@
 
 			if ( "jar".equals( protocol )
 					|| "wsjar".equals( protocol ) ) { //Websphere has it's own way
+				//Original URL is like jar:protocol
 				jarUrl = new URL( file );
+				if ( "file".equals( jarUrl.getProtocol() ) ) {
+					//not escaped, need to voodoo
+					if ( file.indexOf( ' ' ) != -1 ) {
+						//not escaped, need to voodoo
+						jarUrl = new File( jarUrl.getFile() ).toURI().toURL(); //goes by toURI to escape the path
+					}
+				} //otherwise left as is
 			}
-			else if ( "zip".equals( protocol ) ) { //Weblogic has it's own way
+			else if ( "zip".equals( protocol ) //Weblogic has it's own way
+					|| "code-source".equals( url.getProtocol() ) //OC4J prevent ejb.jar access (ie everything without path)
+					|| "file".equals( protocol ) ) { //if no wrapping is done
 				//we have extracted the zip file, so it should be read as a file
-				jarUrl = new URL( "file", null, file );
+				if ( file.indexOf( ' ' ) != -1 ) {
+					//not escaped, need to voodoo
+					jarUrl = new File(file).toURI().toURL(); //goes by toURI to escape the path
+				}
+				else {
+					jarUrl = new File(file).toURL();
+				}
 			}
-			else if ("code-source".equals( url.getProtocol() ) ) {
-				//OC4J prevent ejb.jar access (ie everything without path
-				//fix contributed by the community
-				jarUrl = new File(file).toURL();
-			}
 			else {
 				jarUrl = new URL( protocol, url.getHost(), url.getPort(), file );
 			}
@@ -77,18 +88,18 @@
 					"Unable to determine JAR Url from " + url + ". Cause: " + e.getMessage()
 			);
 		}
+		log.trace("JAR URL from URL Entry: " + url + " >> " + jarUrl);
 		return jarUrl;
 	}
 
 	/**
-	 * Build a JarVisitor on the given JAR URL applying th given filters
+	 * Build a JarVisitor on the given JAR URL applying the given filters
 	 *
 	 * @throws IllegalArgumentException if the URL is malformed
 	 */
 	public static final JarVisitor getVisitor(URL jarUrl, Filter[] filters) throws IllegalArgumentException {
 		String protocol = jarUrl.getProtocol();
 		if ( "jar".equals( protocol ) ) {
-			//FIXME remove this code, this should not happen
 			return new InputStreamZippedJarVisitor( jarUrl, filters );
 		}
 		else if ( StringHelper.isEmpty( protocol ) || "file".equals( protocol ) ) {
@@ -98,7 +109,7 @@
 			}
 			catch (URISyntaxException e) {
 				throw new IllegalArgumentException(
-						"Unable to visit JAR " + jarUrl + ". Cause: " + e.getMessage()
+						"Unable to visit JAR " + jarUrl + ". Cause: " + e.getMessage(), e
 				);
 			}
 			if ( file.isDirectory() ) {




More information about the hibernate-commits mailing list