Created
October 12, 2012 15:31
-
-
Save chirino/3879779 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ svn diff | |
| Index: src/main/java/org/apache/cxf/cwiki/SiteExporter.java | |
| =================================================================== | |
| --- src/main/java/org/apache/cxf/cwiki/SiteExporter.java (revision 1397571) | |
| +++ src/main/java/org/apache/cxf/cwiki/SiteExporter.java (working copy) | |
| @@ -365,33 +365,37 @@ | |
| 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(); | |
| + 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(); | |
| } | |
| - 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"); | |
| - } | |
| el = DOMUtils.getNextElement(el); | |
| } | |
| } | |
| @@ -551,7 +555,10 @@ | |
| 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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment