protected XMLWriter initWriter() { if (writer == null) { try { OutputFormat format = AbstractDocumentWriter.createCompactFormat(); format.setSuppressDeclaration(true); writer = new XMLWriter(out, format); } catch (UnsupportedEncodingException e) { // XXX } } return writer; }
protected static void writeXML(Document doc, OutputStream out) throws IOException { OutputFormat format = AbstractDocumentWriter.createPrettyPrint(); XMLWriter writer = new XMLWriter(out, format); writer.write(doc); }
@Override public DocumentTranslationMap write(Collection<ExportedDocument> docs) throws IOException { if (docs == null || docs.isEmpty()) { return null; } String newRepo = null; String oldRepo = null; Map<DocumentRef, DocumentRef> newRefs = new HashMap<DocumentRef, DocumentRef>(); for (ExportedDocument doc : docs) { DocumentTranslationMap newMap = write(doc); if (newMap != null) { newRefs.putAll(newMap.getDocRefMap()); // assume repo will be the same for all docs if (oldRepo == null) { oldRepo = newMap.getOldServerName(); } if (newRepo == null) { newRepo = newMap.getNewServerName(); } } } return new DocumentTranslationMapImpl(oldRepo, newRepo, newRefs); }
@Override public DocumentTranslationMap write(ExportedDocument[] docs) throws IOException { if (docs == null || docs.length == 0) { return null; } String newRepo = null; String oldRepo = null; Map<DocumentRef, DocumentRef> newRefs = new HashMap<DocumentRef, DocumentRef>(); for (ExportedDocument doc : docs) { DocumentTranslationMap newMap = write(doc); if (newMap != null) { newRefs.putAll(newMap.getDocRefMap()); // assume repo will be the same for all docs if (oldRepo == null) { oldRepo = newMap.getOldServerName(); } if (newRepo == null) { newRepo = newMap.getNewServerName(); } } } return new DocumentTranslationMapImpl(oldRepo, newRepo, newRefs); }
throw new IOException("Cannot create target directory: " + file.getAbsolutePath()); OutputFormat format = AbstractDocumentWriter.createPrettyPrint(); XMLWriter writer = null; try {
@Override public DocumentTranslationMap write(ExportedDocument doc) throws IOException { OutputFormat format = AbstractDocumentWriter.createPrettyPrint(); XMLWriter writer = null; try { writer = new XMLWriter(out, format); writer.write(doc.getDocument()); } finally { if (writer != null) { writer.close(); } } // keep location unchanged DocumentLocation oldLoc = doc.getSourceLocation(); String oldServerName = oldLoc.getServerName(); DocumentRef oldDocRef = oldLoc.getDocRef(); DocumentTranslationMap map = new DocumentTranslationMapImpl(oldServerName, oldServerName); map.put(oldDocRef, oldDocRef); return map; }