cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1526683 - /cxf/branches/2.7.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
Date Thu, 26 Sep 2013 21:06:07 GMT
Author: dkulp
Date: Thu Sep 26 21:06:06 2013
New Revision: 1526683

URL: http://svn.apache.org/r1526683
Log:
Merged revisions 1526680 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1526680 | dkulp | 2013-09-26 17:00:39 -0400 (Thu, 26 Sep 2013) | 2 lines

  [CXF-5286] Use a hash of the URL for the marker file to keep file name shorter and also
allow for all kinds of funky characters.

........

Modified:
    cxf/branches/2.7.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java

Modified: cxf/branches/2.7.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java?rev=1526683&r1=1526682&r2=1526683&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
(original)
+++ cxf/branches/2.7.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
Thu Sep 26 21:06:06 2013
@@ -26,6 +26,7 @@ import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URI;
 import java.net.URL;
+import java.security.MessageDigest;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -609,17 +610,27 @@ public abstract class AbstractCodegenMoh
     protected File getDoneFile(URI basedir, URI wsdlURI, String mojo) {
         String doneFileName = wsdlURI.toString();
 
-        // Strip the basedir from the doneFileName
-        if (doneFileName.startsWith(basedir.toString())) {
-            doneFileName = doneFileName.substring(basedir.toString().length());
-        }
-
-        // If URL to WSDL, replace ? and & since they're invalid chars for file names
-        // Not to mention slashes.
-        doneFileName = doneFileName.replace('?', '_').replace('&', '_').replace('/',
'_').replace('\\', '_')
-            .replace(':', '_');
 
-        return new File(markerDirectory, "." + doneFileName + "." + mojo + ".DONE");
+        try {
+            MessageDigest cript = MessageDigest.getInstance("SHA-1");
+            cript.reset();
+            cript.update(doneFileName.getBytes("utf8"));
+            doneFileName = new javax.xml.bind.annotation.adapters.HexBinaryAdapter().marshal(cript.digest());
+        } catch (Exception e) {
+            //ignore,we'll try and fake it based on the wsdl
+            
+            // Strip the basedir from the doneFileName
+            if (doneFileName.startsWith(basedir.toString())) {
+                doneFileName = doneFileName.substring(basedir.toString().length());
+            }
+            // If URL to WSDL, replace ? and & since they're invalid chars for file names
+            // Not to mention slashes.
+            doneFileName = doneFileName.replace('?', '_').replace('&', '_').replace('/',
'_').replace('\\', '_')
+                .replace(':', '_');
+            doneFileName += ".DONE";
+        }
+        
+        return new File(markerDirectory, "." + doneFileName);
     }
 
     protected abstract File getGeneratedSourceRoot();



Mime
View raw message