use of org.apache.jackrabbit.webdav.DavResourceIterator in project jackrabbit by apache.
the class DirListingExportHandler method exportContent.
/**
* @see IOHandler#exportContent(ExportContext, DavResource)
*/
public boolean exportContent(ExportContext context, DavResource resource) throws IOException {
if (!canExport(context, resource)) {
throw new IOException(getName() + ": Cannot export " + context.getExportRoot());
}
// properties (content length undefined)
context.setModificationTime(new Date().getTime());
context.setContentType("text/html", "UTF-8");
context.setETag("");
// data
if (context.hasStream()) {
PrintWriter writer = new PrintWriter(new OutputStreamWriter(context.getOutputStream(), "utf8"));
try {
Item item = context.getExportRoot();
Repository rep = item.getSession().getRepository();
String repName = rep.getDescriptor(Repository.REP_NAME_DESC);
String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);
String repVersion = rep.getDescriptor(Repository.REP_VERSION_DESC);
writer.print("<html><head><title>");
writer.print(Text.encodeIllegalHTMLCharacters(repName));
writer.print(" ");
writer.print(Text.encodeIllegalHTMLCharacters(repVersion));
writer.print(" ");
writer.print(Text.encodeIllegalHTMLCharacters(resource.getResourcePath()));
writer.print("</title></head>");
writer.print("<body><h2>");
writer.print(Text.encodeIllegalHTMLCharacters(resource.getResourcePath()));
writer.print("</h2><ul>");
writer.print("<li><a href=\"..\">..</a></li>");
DavResourceIterator iter = resource.getMembers();
while (iter.hasNext()) {
DavResource child = iter.nextResource();
String label = Text.getName(child.getResourcePath());
writer.print("<li><a href=\"");
writer.print(Text.encodeIllegalHTMLCharacters(child.getHref()));
writer.print("\">");
writer.print(Text.encodeIllegalHTMLCharacters(label));
writer.print("</a></li>");
}
writer.print("</ul><hr size=\"1\"><em>Powered by <a href=\"");
writer.print(Text.encodeIllegalHTMLCharacters(repURL));
writer.print("\">");
writer.print(Text.encodeIllegalHTMLCharacters(repName));
writer.print("</a> version ");
writer.print(Text.encodeIllegalHTMLCharacters(repVersion));
writer.print("</em></body></html>");
} catch (RepositoryException e) {
// should not occur
log.debug(e.getMessage());
}
writer.close();
}
return true;
}
use of org.apache.jackrabbit.webdav.DavResourceIterator in project jackrabbit by apache.
the class CompareBaselineReport method getVersions.
private void getVersions(DavResource collection, List<VersionResource> vList) throws DavException {
DavResourceIterator it = collection.getMembers();
while (it.hasNext()) {
DavResource member = it.nextResource();
if (member instanceof VersionControlledResource) {
String href = new HrefProperty(member.getProperty(VersionControlledResource.CHECKED_IN)).getHrefs().get(0);
DavResourceLocator locator = member.getLocator();
DavResourceLocator vLocator = locator.getFactory().createResourceLocator(locator.getPrefix(), href);
DavResource v = member.getFactory().createResource(vLocator, member.getSession());
if (v instanceof VersionResource) {
vList.add((VersionResource) v);
} else {
log.error("Internal error: DAV:checked-in property must point to a VersionResource.");
}
}
if (member.isCollection()) {
getVersions(member, vList);
}
}
}
use of org.apache.jackrabbit.webdav.DavResourceIterator in project jackrabbit by apache.
the class WorkspaceResourceImpl method spool.
/**
* @param outputContext
* @throws IOException
*/
@Override
public void spool(OutputContext outputContext) throws IOException {
outputContext.setProperty("Link", "<?" + EventJournalResourceImpl.RELURIFROMWORKSPACE + ">; title=\"Event Journal\"; rel=alternate; type=\"" + AtomFeedConstants.MEDIATYPE + "\"");
if (outputContext.hasStream()) {
Session session = getRepositorySession();
Repository rep = session.getRepository();
String repName = rep.getDescriptor(Repository.REP_NAME_DESC);
String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);
String repVersion = rep.getDescriptor(Repository.REP_VERSION_DESC);
String repostr = repName + " " + repVersion;
StringBuilder sb = new StringBuilder();
sb.append("<html><head><title>");
sb.append(repostr);
sb.append("</title>");
sb.append("<link rel=alternate type=\"" + AtomFeedConstants.MEDIATYPE + "\" title=\"Event Journal\" href=\"?" + EventJournalResourceImpl.RELURIFROMWORKSPACE + "\">");
sb.append("</head>");
sb.append("<body><h2>").append(repostr).append("</h2><ul>");
sb.append("<li><a href=\"..\">..</a></li>");
DavResourceIterator it = getMembers();
while (it.hasNext()) {
DavResource res = it.nextResource();
sb.append("<li><a href=\"");
sb.append(res.getHref());
sb.append("\">");
sb.append(res.getDisplayName());
sb.append("</a></li>");
}
sb.append("</ul><hr size=\"1\"><em>Powered by <a href=\"");
sb.append(repURL).append("\">").append(repName);
sb.append("</a> ").append(repVersion);
sb.append("</em></body></html>");
outputContext.setContentLength(sb.length());
outputContext.setModificationTime(getModificationTime());
PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputContext.getOutputStream(), "utf8"));
writer.print(sb.toString());
writer.close();
} else {
outputContext.setContentLength(0);
outputContext.setModificationTime(getModificationTime());
}
}
use of org.apache.jackrabbit.webdav.DavResourceIterator in project jackrabbit by apache.
the class RootCollection method spool.
/**
* Sets content lengths to '0' and retrieves the modification time.
*
* @param outputContext
* @throws IOException
* @see DavResource#spool(org.apache.jackrabbit.webdav.io.OutputContext)
*/
@Override
public void spool(OutputContext outputContext) throws IOException {
if (outputContext.hasStream()) {
Session session = getRepositorySession();
Repository rep = session.getRepository();
String repName = rep.getDescriptor(Repository.REP_NAME_DESC);
String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);
String repVersion = rep.getDescriptor(Repository.REP_VERSION_DESC);
String repostr = repName + " " + repVersion;
StringBuilder sb = new StringBuilder();
sb.append("<html><head><title>");
sb.append(repostr);
sb.append("</title></head>");
sb.append("<body><h2>").append(repostr).append("</h2>");
sb.append("<h3>Available Workspace Resources:</h3><ul>");
DavResourceIterator it = getMembers();
while (it.hasNext()) {
DavResource res = it.nextResource();
sb.append("<li><a href=\"");
sb.append(res.getHref());
sb.append("\">");
sb.append(res.getDisplayName());
sb.append("</a></li>");
}
sb.append("</ul><hr size=\"1\"><em>Powered by <a href=\"");
sb.append(repURL).append("\">").append(repName);
sb.append("</a> ").append(repVersion);
sb.append("</em></body></html>");
outputContext.setContentLength(sb.length());
outputContext.setModificationTime(getModificationTime());
PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputContext.getOutputStream(), "utf8"));
writer.print(sb.toString());
writer.close();
} else {
outputContext.setContentLength(0);
outputContext.setModificationTime(getModificationTime());
}
}
use of org.apache.jackrabbit.webdav.DavResourceIterator in project jackrabbit by apache.
the class ExpandPropertyReport method addResponses.
/**
* Fills the specified <code>MultiStatus</code> object by generating a
* <code>MultiStatusResponse</code> for the given resource (and
* its member according to the depth value).
*
* @param res
* @param depth
* @param ms
* @see #getResponse(DavResource, Iterator)
*/
private void addResponses(DavResource res, int depth, MultiStatus ms) {
MultiStatusResponse response = getResponse(res, propertyElements);
ms.addResponse(response);
if (depth > 0 && res.isCollection()) {
DavResourceIterator it = res.getMembers();
while (it.hasNext()) {
addResponses(it.nextResource(), depth - 1, ms);
}
}
}
Aggregations