Example usage for org.apache.commons.vfs FileContent getFile

List of usage examples for org.apache.commons.vfs FileContent getFile

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileContent getFile.

Prototype

FileObject getFile();

Source Link

Document

Returns the file which this is the content of.

Usage

From source file:com.thinkberg.webdav.GetHandler.java

void setHeader(HttpServletResponse response, FileContent content) throws FileSystemException {
    response.setHeader("Last-Modified", Util.getDateString(content.getLastModifiedTime()));
    response.setHeader("Content-Type", content.getContentInfo().getContentType());
    response.setHeader("ETag", Util.getETag(content.getFile()));
}

From source file:org.efaps.webdav4vfs.handler.GetHandler.java

void setHeader(final HttpServletResponse response, final FileContent _content) throws FileSystemException {
    response.setHeader("Last-Modified", Util.getDateString(_content.getLastModifiedTime()));
    response.setHeader("Content-Type", _content.getContentInfo().getContentType());
    response.setHeader("ETag", Util.getETag(_content.getFile()));
}

From source file:org.jahia.services.content.impl.external.vfs.VFSDataSource.java

private ExternalData getFileContent(final FileContent content) throws FileSystemException {
    Map<String, String[]> properties = new HashMap<String, String[]>();

    String s1 = content.getContentInfo().getContentType();
    if (s1 == null) {
        s1 = JCRContentUtils.getMimeType(content.getFile().getName().getBaseName());
    }/*  w w  w  . j  a va  2 s  . c  o m*/
    if (s1 == null) {
        s1 = "application/octet-stream";
    }
    properties.put(Constants.JCR_MIMETYPE, new String[] { s1 });

    Map<String, Binary[]> binaryProperties = new HashMap<String, Binary[]>();
    binaryProperties.put(Constants.JCR_DATA, new Binary[] { new VFSBinaryImpl(content) });

    String path = content.getFile().getName().getPath().substring(rootPath.length());

    ExternalData externalData = new ExternalData(path + "/" + Constants.JCR_CONTENT,
            path + "/" + Constants.JCR_CONTENT, Constants.NT_RESOURCE, properties);
    externalData.setBinaryProperties(binaryProperties);
    return externalData;
}