if (!item.isCollection()) { byte[] buffer = item.getContent(); if (buffer != null) { ostream.write(buffer, 0, buffer.length); return; resourceInputStream = new ByteArrayInputStream(item.getContent()); } else { resourceInputStream = is;
/** * Get the ETag associated with a file.<p> * * @param item the WebDavItem * * @return the created ETag for the resource attributes */ protected String getETag(I_CmsRepositoryItem item) { return "\"" + item.getContentLength() + "-" + item.getLastModifiedDate() + "\""; }
/** * Checks if the items in the path or in a subpath are locked.<p> * * @param req the servlet request we are processing * @param path the path to check the items for locks * @param errorList the error list where to put the found errors */ private void checkChildLocks(HttpServletRequest req, String path, Hashtable<String, Integer> errorList) { List<I_CmsRepositoryItem> list = null; try { list = m_session.list(path); } catch (CmsException e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_LIST_ITEMS_ERROR_1, path), e); } errorList.put(path, new Integer(CmsWebdavStatus.SC_INTERNAL_SERVER_ERROR)); return; } Iterator<I_CmsRepositoryItem> iter = list.iterator(); while (iter.hasNext()) { I_CmsRepositoryItem element = iter.next(); if (isLocked(element.getName())) { errorList.put(element.getName(), new Integer(CmsWebdavStatus.SC_LOCKED)); } else { if (element.isCollection()) { checkChildLocks(req, element.getName(), errorList); } } } }
String resourceName = childItem.getName(); if (resourceName.endsWith("/")) { resourceName = resourceName.substring(0, resourceName.length() - 1); if (childItem.isCollection()) { sb.append("/"); if (childItem.isCollection()) { sb.append("/"); if (childItem.isCollection()) { sb.append(" "); } else { sb.append(renderSize(childItem.getContentLength())); sb.append(HTTP_DATE_FORMAT.format(new Date(childItem.getLastModifiedDate()))); sb.append("</tt></td>\r\n");
I_CmsRepositoryItem item = m_session.getItem(path); oldResourceStream = new ByteArrayInputStream(item.getContent()); } catch (CmsException e) { if (LOG.isErrorEnabled()) {
if (!item.isCollection()) { methodsAllowed.append(", ").append(METHOD_PUT);
String resourceName = childItem.getName(); if (resourceName.endsWith("/")) { resourceName = resourceName.substring(0, resourceName.length() - 1); if (childItem.isCollection()) { sb.append("/"); if (childItem.isCollection()) { sb.append("/"); if (childItem.isCollection()) { sb.append(" "); } else { sb.append(renderSize(childItem.getContentLength())); sb.append(HTTP_DATE_FORMAT.format(new Date(childItem.getLastModifiedDate()))); sb.append("</tt></td>\r\n");
/** * Copy the contents of the specified input stream to the specified * output stream, and ensure that both streams are closed before returning * (even in the face of an exception).<p> * * @param item the RepositoryItem * @param ostream the output stream to write to * @param range the range the client wants to retrieve * * @throws IOException if an input/output error occurs */ protected void copy(I_CmsRepositoryItem item, ServletOutputStream ostream, CmsWebdavRange range) throws IOException { IOException exception = null; InputStream resourceInputStream = new ByteArrayInputStream(item.getContent()); InputStream istream = new BufferedInputStream(resourceInputStream, m_input); exception = copyRange(istream, ostream, range.getStart(), range.getEnd()); // Clean up the input stream try { istream.close(); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_INPUT_STREAM_0), e); } } // Rethrow any exception that has occurred if (exception != null) { throw exception; } }
if (!item.isCollection()) { methodsAllowed.append(", ").append(METHOD_PUT);
if (!item.isCollection()) { if (path.endsWith("/") || (path.endsWith("\\"))) { String contentType = item.getMimeType(); if (contentType == null) { contentType = getServletContext().getMimeType(item.getName()); long contentLength = -1L; if (item.isCollection()) { response.setHeader(HEADER_LASTMODIFIED, HTTP_DATE_FORMAT.format(new Date(item.getLastModifiedDate()))); contentLength = item.getContentLength(); if ((item.isCollection()) || (((ranges == null) || (ranges.isEmpty())) && (request.getHeader(HEADER_RANGE) == null)) || (ranges == FULL_RANGE)) { if ((!item.isCollection()) && (contentLength >= 0)) { if (LOG.isDebugEnabled()) { LOG.debug( if (item.isCollection()) { renderResult = renderHtml(request.getContextPath() + request.getServletPath(), item.getName());
/** * Get the ETag associated with a file.<p> * * @param item the WebDavItem * * @return the created ETag for the resource attributes */ protected String getETag(I_CmsRepositoryItem item) { return "\"" + item.getContentLength() + "-" + item.getLastModifiedDate() + "\""; }
/** * Checks if the items in the path or in a subpath are locked.<p> * * @param req the servlet request we are processing * @param path the path to check the items for locks * @param errorList the error list where to put the found errors */ private void checkChildLocks(HttpServletRequest req, String path, Hashtable errorList) { List list = null; try { list = m_session.list(path); } catch (CmsException e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_LIST_ITEMS_ERROR_1, path), e); } errorList.put(path, new Integer(CmsWebdavStatus.SC_INTERNAL_SERVER_ERROR)); return; } Iterator iter = list.iterator(); while (iter.hasNext()) { I_CmsRepositoryItem element = (I_CmsRepositoryItem)iter.next(); if (isLocked(element.getName())) { errorList.put(element.getName(), new Integer(CmsWebdavStatus.SC_LOCKED)); } else { if (element.isCollection()) { checkChildLocks(req, element.getName(), errorList); } } } }
if (!item.isCollection()) { byte[] buffer = item.getContent(); if (buffer != null) { ostream.write(buffer, 0, buffer.length); return; resourceInputStream = new ByteArrayInputStream(item.getContent()); } else { resourceInputStream = is;
I_CmsRepositoryItem item = m_session.getItem(path); oldResourceStream = new ByteArrayInputStream(item.getContent()); } catch (CmsException e) { if (LOG.isErrorEnabled()) {
if (!item.isCollection()) { if (path.endsWith("/") || (path.endsWith("\\"))) { String contentType = item.getMimeType(); if (contentType == null) { contentType = getServletContext().getMimeType(item.getName()); long contentLength = -1L; if (item.isCollection()) { response.setHeader(HEADER_LASTMODIFIED, HTTP_DATE_FORMAT.format(new Date(item.getLastModifiedDate()))); contentLength = item.getContentLength(); if ((item.isCollection()) || (((ranges == null) || (ranges.isEmpty())) && (request.getHeader(HEADER_RANGE) == null)) || (ranges == FULL_RANGE)) { if ((!item.isCollection()) && (contentLength >= 0)) { if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key( if (item.isCollection()) { renderResult = renderHtml(request.getContextPath() + request.getServletPath(), item.getName());
long lastModified = item.getLastModifiedDate(); long fileLength = item.getContentLength();
parseProperties(req, multiStatusElem, currentItem, type, properties); if ((currentItem.isCollection()) && (depth > 0)) { List<I_CmsRepositoryItem> list = m_session.list(currentItem.getName()); Iterator<I_CmsRepositoryItem> iter = list.iterator(); while (iter.hasNext()) { Messages.get().getBundle().key(Messages.LOG_LIST_ITEMS_ERROR_1, currentItem.getName()), e);
if (!item.isCollection()) { resourceInputStream = new ByteArrayInputStream(item.getContent()); } else { resourceInputStream = is;
/** * Copy the contents of the specified input stream to the specified * output stream, and ensure that both streams are closed before returning * (even in the face of an exception).<p> * * @param item the RepositoryItem * @param writer the writer to write to * @param range the range the client wants to retrieve * * @throws IOException if an input/output error occurs */ protected void copy(I_CmsRepositoryItem item, PrintWriter writer, CmsWebdavRange range) throws IOException { IOException exception = null; InputStream resourceInputStream = new ByteArrayInputStream(item.getContent()); Reader reader = new InputStreamReader(resourceInputStream); exception = copyRange(reader, writer, range.getStart(), range.getEnd()); // Clean up the input stream try { reader.close(); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.ERR_CLOSE_READER_0), e); } } // Rethrow any exception that has occurred if (exception != null) { throw exception; } }
String path = item.getName(); Element responseElem = addElement(elem, TAG_RESPONSE); addElement(propElem, TAG_CREATIONDATE).addText(ISO8601_FORMAT.format(new Date(item.getCreationDate()))); addElement(propElem, TAG_DISPLAYNAME).addCDATA(resourceName); if (!item.isCollection()) { HTTP_DATE_FORMAT.format(new Date(item.getLastModifiedDate()))); addElement(propElem, TAG_CONTENTLENGTH).addText(String.valueOf(item.getContentLength())); String contentType = getServletContext().getMimeType(item.getName()); if (contentType != null) { addElement(propElem, TAG_CONTENTTYPE).addText(contentType); if (!item.isCollection()) { ISO8601_FORMAT.format(new Date(item.getCreationDate()))); } else if (property.equals(TAG_DISPLAYNAME)) { addElement(propElem, TAG_DISPLAYNAME).addCDATA(resourceName); } else if (property.equals(TAG_CONTENTLANGUAGE)) { if (item.isCollection()) { propertiesNotFound.add(property); } else { if (item.isCollection()) { propertiesNotFound.add(property); } else {