cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1397617 - /cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
Date Fri, 12 Oct 2012 15:42:34 GMT
Author: dkulp
Date: Fri Oct 12 15:42:33 2012
New Revision: 1397617

URL: http://svn.apache.org/viewvc?rev=1397617&view=rev
Log:
Allow stripping of div wrappers

Modified:
    cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1397617&r1=1397616&r2=1397617&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Fri Oct 12 15:42:33 2012
@@ -365,32 +365,36 @@ public class SiteExporter implements Run
         doc = getDispatch().invoke(doc);
         el = DOMUtils.getFirstElement(DOMUtils.getFirstElement(doc.getDocumentElement()));
         while (el != null) {
-            String filename = DOMUtils.getChildContent(el, "fileName");
-            String durl = DOMUtils.getChildContent(el, "url");
-            String aid = DOMUtils.getChildContent(el, "id");
-            
-            p.addAttachment(aid, filename);
-            
-            String dirName = p.createFileName();
-            dirName = dirName.substring(0, dirName.lastIndexOf(".")) + ".data";
-            File file = new File(outputDir, dirName);
-            if (!file.exists()) {
-                callSvn("mkdir", file.getAbsolutePath());
-                file.mkdirs();
-            }
-            file = new File(file, filename);
-            boolean exists = file.exists();
-            FileOutputStream out = new FileOutputStream(file);
-            URL url = new URL(durl);
-            InputStream ins = url.openStream();
-            IOUtils.copy(ins, out);
-            out.close();
-            ins.close();
-            if (!exists) {
-                callSvn("add", file.getAbsolutePath());
-                svnCommitMessage.append("Added: " + dirName + "/" + file.getName() + "\n");
               
-            } else {
-                svnCommitMessage.append("Modified: " + dirName + "/" + file.getName() + "\n");
+            try {
+                String filename = DOMUtils.getChildContent(el, "fileName");
+                String durl = DOMUtils.getChildContent(el, "url");
+                String aid = DOMUtils.getChildContent(el, "id");
+                
+                p.addAttachment(aid, filename);
+                
+                String dirName = p.createFileName();
+                dirName = dirName.substring(0, dirName.lastIndexOf(".")) + ".data";
+                File file = new File(outputDir, dirName);
+                if (!file.exists()) {
+                    callSvn("mkdir", file.getAbsolutePath());
+                    file.mkdirs();
+                }
+                file = new File(file, filename);
+                boolean exists = file.exists();
+                FileOutputStream out = new FileOutputStream(file);
+                URL url = new URL(durl);
+                InputStream ins = url.openStream();
+                IOUtils.copy(ins, out);
+                out.close();
+                ins.close();
+                if (!exists) {
+                    callSvn("add", file.getAbsolutePath());
+                    svnCommitMessage.append("Added: " + dirName + "/" + file.getName() +
"\n");                
+                } else {
+                    svnCommitMessage.append("Modified: " + dirName + "/" + file.getName()
+ "\n");
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
             }
             el = DOMUtils.getNextElement(el);
         }
@@ -551,7 +555,10 @@ public class SiteExporter implements Run
         return content;
     }
 
-    
+    public String unwrap(String v) throws Exception {
+        return v.trim().replaceFirst("^<div[^>]*>", "").replaceFirst("</div>$",
"");
+    }
+
     private static synchronized void doLogin() throws Exception {
         if (loginToken == null) {
             Document doc = XMLUtils.newDocument();



Mime
View raw message