org.modeshape.web.jcr.webdav
Class DefaultContentMapper
java.lang.Object
org.modeshape.web.jcr.webdav.DefaultContentMapper
- All Implemented Interfaces:
- ContentMapper
public class DefaultContentMapper
- extends Object
- implements ContentMapper
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INIT_CONTENT_PRIMARY_TYPE_NAMES
public static final String INIT_CONTENT_PRIMARY_TYPE_NAMES
- See Also:
- Constant Field Values
INIT_RESOURCE_PRIMARY_TYPES_NAMES
public static final String INIT_RESOURCE_PRIMARY_TYPES_NAMES
- See Also:
- Constant Field Values
INIT_NEW_FOLDER_PRIMARY_TYPE_NAME
public static final String INIT_NEW_FOLDER_PRIMARY_TYPE_NAME
- See Also:
- Constant Field Values
INIT_NEW_RESOURCE_PRIMARY_TYPE_NAME
public static final String INIT_NEW_RESOURCE_PRIMARY_TYPE_NAME
- See Also:
- Constant Field Values
INIT_NEW_CONTENT_PRIMARY_TYPE_NAME
public static final String INIT_NEW_CONTENT_PRIMARY_TYPE_NAME
- See Also:
- Constant Field Values
DefaultContentMapper
public DefaultContentMapper()
initialize
public void initialize(javax.servlet.ServletContext servletContext)
- Description copied from interface:
ContentMapper
- Initialize the content mapper based on the provided context
- Specified by:
initialize
in interface ContentMapper
- Parameters:
servletContext
- the servlet context for this servlet
getParam
protected String getParam(javax.servlet.ServletContext servletContext,
String name)
getResourceContent
public InputStream getResourceContent(Node node)
throws RepositoryException
- Specified by:
getResourceContent
in interface ContentMapper
- Parameters:
node
- the node to check; may not be null
- Returns:
- the contents for the node; null if the node maps to a WebDAV folder
- Throws:
RepositoryException
- if the node cannot be accessed
getResourceLength
public long getResourceLength(Node node)
throws RepositoryException,
IOException
- Specified by:
getResourceLength
in interface ContentMapper
- Parameters:
node
- the node to check; may not be null
- Returns:
- the length of the file content for the node; -1 if the node maps to a WebDAV folder
- Throws:
RepositoryException
- if the node cannot be accessed
IOException
- if the content of the node cannot be accessed
getLastModified
public Date getLastModified(Node node)
throws RepositoryException
- Specified by:
getLastModified
in interface ContentMapper
- Parameters:
node
- the node to check; may not be null
- Returns:
- the date at which the file was last modified; null if node is a folder
- Throws:
RepositoryException
- if the node cannot be accessed
isFolder
public boolean isFolder(Node node)
throws RepositoryException
- Specified by:
isFolder
in interface ContentMapper
- Parameters:
node
- the node to check; may not be null
- Returns:
- true if
node
should be treated as a WebDAV folder
- Throws:
RepositoryException
- if the node cannot be accessed
isFile
public boolean isFile(Node node)
throws RepositoryException
- Specified by:
isFile
in interface ContentMapper
- Parameters:
node
- the node to check
- Returns:
- true if
node
's primary type is one of the types in filePrimaryTypes
; may not be null
- Throws:
RepositoryException
- if an error occurs checking the node's primary type
createFile
public void createFile(Node parentNode,
String fileName)
throws RepositoryException
- Specified by:
createFile
in interface ContentMapper
- Parameters:
parentNode
- the parent node of the new file; may not be nullfileName
- the name of the file that is to be created; may not be null
- Throws:
RepositoryException
- if the node cannot be created
createFolder
public void createFolder(Node parentNode,
String folderName)
throws RepositoryException
- Specified by:
createFolder
in interface ContentMapper
- Parameters:
parentNode
- the parent node of the new folder; may not be nullfolderName
- the name of the folder that is to be created; may not be null
- Throws:
RepositoryException
- if the node cannot be created
setContent
public long setContent(Node parentNode,
String resourceName,
InputStream newContent,
String contentType,
String characterEncoding)
throws RepositoryException,
IOException
- Description copied from interface:
ContentMapper
- Creates or modifies the content of a WebDAV file. Implementations may choose whether to store this content directly on the
file node or in some other location (e.g., the jcr:content child of the nt:file node that corresponds to the WebDAV file).
- Specified by:
setContent
in interface ContentMapper
- Parameters:
parentNode
- node corresponding to the parent folder of the file; may not be nullresourceName
- the name of the file to which this content belongs; may not be nullnewContent
- the content to store; may not be nullcontentType
- the MIME type of the content; may not be nullcharacterEncoding
- the character encoding of the content; may not be null
- Returns:
- the length of the newly-created content
- Throws:
RepositoryException
- if the node cannot be created or updated
IOException
- if the content of the node cannot be modified or created
Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.