Java Code Examples for org.apache.jackrabbit.webdav.io.OutputContext#setETag()
The following examples show how to use
org.apache.jackrabbit.webdav.io.OutputContext#setETag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexWriter.java From archiva with Apache License 2.0 | 6 votes |
public void write( OutputContext outputContext ) { outputContext.setModificationTime( new Date().getTime() ); outputContext.setContentType( "text/html" ); outputContext.setETag( "" ); // skygo ETag MRM-1127 seems to be fixed if ( outputContext.hasStream() ) { PrintWriter writer = new PrintWriter( outputContext.getOutputStream() ); writeDocumentStart( writer ); try { writeHyperlinks( writer ); } catch ( IOException e ) { log.error("Could not write hyperlinks {}", e.getMessage(), e); } writeDocumentEnd( writer ); writer.flush(); writer.close(); } }
Example 2
Source File: DavFile.java From cosmo with Apache License 2.0 | 5 votes |
public void writeTo(OutputContext outputContext) throws CosmoDavException, IOException { if (! exists()) { throw new IllegalStateException("cannot spool a nonexistent resource"); } if (LOG.isDebugEnabled()) { LOG.debug("Spooling file {}", getResourcePath()); } FileItem content = (FileItem) getItem(); String contentType = ContentTypeUtil.buildContentType(content.getContentType(), content.getContentEncoding()); outputContext.setContentType(contentType); if (content.getContentLanguage() != null) { outputContext.setContentLanguage(content.getContentLanguage()); } long len = content.getContentLength() != null ? content.getContentLength().longValue() : 0; outputContext.setContentLength(len); outputContext.setModificationTime(getModificationTime()); outputContext.setETag(getETag()); if (! outputContext.hasStream()) { return; } if (content.getContentInputStream() == null) { return; } FileCopyUtils.copy(content.getContentInputStream(), outputContext.getOutputStream()); }
Example 3
Source File: DavCalendarResource.java From cosmo with Apache License 2.0 | 5 votes |
public void writeTo(OutputContext outputContext) throws CosmoDavException, IOException { if (! exists()) { throw new IllegalStateException("cannot spool a nonexistent resource"); } if (LOG.isDebugEnabled()) { LOG.debug("Spooling file {}", getResourcePath()); } String contentType = ContentTypeUtil.buildContentType(ICALENDAR_MEDIA_TYPE, "UTF-8"); outputContext.setContentType(contentType); // Get calendar Calendar calendar = getCalendar(); // convert Calendar object to String, then to bytes (UTF-8) byte[] calendarBytes = calendar.toString().getBytes("UTF-8"); outputContext.setContentLength(calendarBytes.length); outputContext.setModificationTime(getModificationTime()); outputContext.setETag(getETag()); if (! outputContext.hasStream()) { return; } // spool calendar bytes ByteArrayInputStream bois = new ByteArrayInputStream(calendarBytes); FileCopyUtils.copy(bois, outputContext.getOutputStream()); }
Example 4
Source File: DavUserPrincipal.java From cosmo with Apache License 2.0 | 4 votes |
private void writeHtmlRepresentation(OutputContext context) throws CosmoDavException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Writing html representation for user principal {}", getDisplayName()); } context.setContentType(ContentTypeUtil.buildContentType("text/html", "UTF-8")); context.setModificationTime(getModificationTime()); context.setETag(getETag()); if (! context.hasStream()) { return; } PrintWriter writer = new PrintWriter(new OutputStreamWriter(context.getOutputStream(), "utf8")); try{ writer.write("<html>\n<head><title>"); writer.write(StringEscapeUtils.escapeHtml(getDisplayName())); writer.write("</title></head>\n"); writer.write("<body>\n"); writer.write("<h1>"); writer.write(StringEscapeUtils.escapeHtml(getDisplayName())); writer.write("</h1>\n"); writer.write("<h2>Properties</h2>\n"); writer.write("<dl>\n"); for (DavPropertyIterator i=getProperties().iterator(); i.hasNext();) { WebDavProperty prop = (WebDavProperty) i.nextProperty(); Object value = prop.getValue(); String text = null; if (value instanceof Element) { try { text = DomWriter.write((Element)value); } catch (XMLStreamException e) { LOG.warn("Error serializing value for property {}", prop.getName()); } } if (text == null) { text = prop.getValueText(); } writer.write("<dt>"); writer.write(StringEscapeUtils.escapeHtml(prop.getName().toString())); writer.write("</dt><dd>"); writer.write(StringEscapeUtils.escapeHtml(text)); writer.write("</dd>\n"); } writer.write("</dl>\n"); WebDavResource parent = getParent(); writer.write("<a href=\""); writer.write(parent.getResourceLocator().getHref(true)); writer.write("\">"); writer.write(StringEscapeUtils.escapeHtml(parent.getDisplayName())); writer.write("</a></li>\n"); User user = getSecurityManager().getSecurityContext().getUser(); if (user != null) { writer.write("<p>\n"); DavResourceLocator homeLocator = getResourceLocator().getFactory(). createHomeLocator(getResourceLocator().getContext(), user); writer.write("<a href=\""); writer.write(homeLocator.getHref(true)); writer.write("\">"); writer.write("Home collection"); writer.write("</a><br>\n"); } writer.write("</body>"); writer.write("</html>\n"); }finally{ writer.close(); } }