@Override public void beginWiki(String name, FilterEventParameters parameters) throws FilterException { this.wikiWriter = new XARWikiWriter( this.properties.getPackageName() != null ? this.properties.getPackageName() : name, this.properties); }
private void addSpacePath(StringBuilder path, EntityReference spaceReference) { EntityReference parent = spaceReference.getParent(); if (parent != null && parent.getType() == EntityType.SPACE) { addSpacePath(path, parent); } path.append(escapeXARPath(spaceReference.getName())).append('/'); }
@Override public void endWiki(String name, FilterEventParameters parameters) throws FilterException { try { this.wikiWriter.close(); } catch (IOException e) { throw new FilterException("Failed to close XAR writer", e); } this.wikiWriter = null; }
} else { if (this.wikiWriter == null) { this.wikiWriter = new XARWikiWriter( this.properties.getPackageName() != null ? this.properties.getPackageName() : "package", this.properties); this.wikiWriter.newEntry(new LocalDocumentReference(this.currentDocumentReference, locale)), this.properties.getEncoding(), this.properties.isFormat(), true);
@Override public void close() throws IOException { // Add package.xml descriptor try { writePackage(); } catch (FilterException e) { throw new IOException("Failed to write package", e); } // Close zip stream this.zipStream.close(); } }
@Override public void endWikiDocumentLocale(Locale locale, FilterEventParameters parameters) throws FilterException { this.writer.writeEndElement(); this.writer.writeEndDocument(); this.writer.close(); if (this.wikiWriter != null) { this.wikiWriter.closeEntry(); } this.writer = null; }
public OutputStream newEntry(LocalDocumentReference reference) throws FilterException { StringBuilder path = new StringBuilder(); // Add space path addSpacePath(path, reference.getParent()); // Add document name path.append(escapeXARPath(reference.getName())); // Add language if (reference.getLocale() != null && !reference.getLocale().equals(Locale.ROOT)) { path.append('.'); path.append(reference.getLocale()); } // Add extension path.append(".xml"); String entryName = path.toString(); ZipArchiveEntry zipentry = new ZipArchiveEntry(entryName); try { this.zipStream.putArchiveEntry(zipentry); } catch (IOException e) { throw new FilterException("Failed to add a new zip entry for [" + path + "]", e); } this.xarPackage.addEntry(reference, entryName); return this.zipStream; }
@Override public void close() throws IOException { if (this.writer != null) { try { this.writer.close(); this.writer = null; } catch (FilterException e) { throw new IOException("Failed to close XML writer", e); } } if (this.wikiWriter != null) { this.wikiWriter.close(); this.wikiWriter = null; } this.properties.getTarget().close(); }