public class JcrAttachmentsProvider extends PageFlowScopeAdapter implements IWebDavAwareAttachmentsProvider, Serializable
Modifier and Type | Class and Description |
---|---|
protected static class |
JcrAttachmentsProvider.ErrorReportingMode
Used to affect how errors are reported
|
protected class |
JcrAttachmentsProvider.JcrAttachmentItem
Implementation of IAttachmentItem to wrap a JCR file node.
|
static class |
JcrAttachmentsProvider.JcrFileItem
Implementation of FileItem to wrap a JCR file node.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoSave
True if the attachment changes are automatically saved.
|
protected String |
iconBaseUrl
Holds the base Url for attachment icons.
|
protected String |
jcrFileServletPath
Holds the path of the JCR File download servlet
|
protected javax.jcr.Session |
jcrSession
Reference to the current JCR session
|
protected String |
parentId
Holds the parent node id
|
protected javax.jcr.Node |
parentNode
Reference to the parent Node where the attachments are stored
|
protected String |
parentPath
Holds the parent node path
|
protected boolean |
useWebDav
true to use WebDAV urls, false otherwise
|
fExpireWithPageFlow
Constructor and Description |
---|
JcrAttachmentsProvider() |
Modifier and Type | Method and Description |
---|---|
void |
addAttachment(org.apache.commons.fileupload.FileItem fileItem,
String fileEncoding)
Add Attachment
|
boolean |
getHasAttachments()
Returns whether the attachment provider has any attachments
|
String |
getIconBaseUrl()
Returns the icon base URL which is prepended to all the icon URLs
|
String |
getJcrFileServletPath()
Returns the servlet path to the JCR file streaming servlet
|
javax.jcr.Session |
getJcrSession()
Returns the active JCR session
|
String |
getParentId()
Returns the id of the parent JCR node
|
javax.jcr.Node |
getParentNode()
Returns a reference to the JCR Node that is the parent of the attachments.
|
String |
getParentPath()
Returns the path of the parent Node
|
protected String |
getSafeFileName(String filePath)
Gets a normalized file name from the supplied file path.
|
boolean |
isAddAttachmentsAvailable()
Returns whether attachments can be added
|
boolean |
isAutoSave()
Returns whether auto-save is enabled.
|
boolean |
isUseWebDav()
Returns whether to use WebDAV urls
|
List<IAttachmentItem> |
listAttachments()
Returns a list of the current attachments
|
void |
refresh()
Does nothing
|
void |
removeAttachment(String attachmentID)
Remove Attachment
|
protected void |
reportError(JcrAttachmentsProvider.ErrorReportingMode mode,
String msg)
Report an error
|
protected void |
safeNodeSave(javax.jcr.Node node)
Saves changes to the supplied nodes
|
protected boolean |
sanityCheck(JcrAttachmentsProvider.ErrorReportingMode mode)
Validates that the JCR session is alive and that the
parent node has been configured correctly
|
void |
setAutoSave(boolean autoSave)
Sets whether autoSave is enabled
|
void |
setIconBaseUrl(String iconBaseUrl)
Sets the base URL to prepend to all the icon URLs
|
void |
setJcrFileServletPath(String jcrFileServletPath)
Sets the servlet path to the JCR file streaming servlet
|
void |
setJcrSession(javax.jcr.Session jcrSession)
Sets the active JCR session
|
void |
setParentId(String id)
Sets the id of the parent JCR node to use
|
void |
setParentPath(String path)
Sets the path of the parent JCR Node to use.
|
void |
setUseWebDav(boolean useWebDav)
Sets whether to use WebDAV urls
|
void |
updateAttachment(String attachmentID,
org.apache.commons.fileupload.FileItem fileItem,
String fileEncoding)
Update an Attachment
|
getExpireWithPageFlow, setExpireWithPageFlow
protected transient javax.jcr.Session jcrSession
protected transient javax.jcr.Node parentNode
protected boolean autoSave
protected String jcrFileServletPath
protected String iconBaseUrl
protected String parentId
protected String parentPath
protected boolean useWebDav
public String getIconBaseUrl()
public void setIconBaseUrl(String iconBaseUrl)
iconBaseUrl
- the baseURL to usepublic String getParentId()
public void setParentId(String id)
id
- the uuid of the JCR node to use as the attachments parentpublic void setParentPath(String path)
path
- the path of the JCR node to use as the attachments parentpublic String getParentPath()
public javax.jcr.Session getJcrSession()
public void setJcrSession(javax.jcr.Session jcrSession)
jcrSession
- the JCR session to usepublic boolean isAutoSave()
public void setAutoSave(boolean autoSave)
autoSave
- the autoSave to setpublic String getJcrFileServletPath()
public void setJcrFileServletPath(String jcrFileServletPath)
jcrFileServletPath
- the jcrFileServletPath to setpublic javax.jcr.Node getParentNode()
protected void reportError(JcrAttachmentsProvider.ErrorReportingMode mode, String msg)
mode
- the error reporting mode to usemsg
- the error messageprotected boolean sanityCheck(JcrAttachmentsProvider.ErrorReportingMode mode)
mode
- the error reporting modepublic void addAttachment(org.apache.commons.fileupload.FileItem fileItem, String fileEncoding)
IAttachmentsProvider
addAttachment
in interface IAttachmentsProvider
fileItem
- the attachment contentfileEncoding
- the encoding of the attachment file (if known)protected void safeNodeSave(javax.jcr.Node node) throws javax.jcr.RepositoryException
node
- the node to savejavax.jcr.RepositoryException
public boolean isAddAttachmentsAvailable()
IAttachmentsProvider
isAddAttachmentsAvailable
in interface IAttachmentsProvider
public List<IAttachmentItem> listAttachments()
IAttachmentsProvider
listAttachments
in interface IAttachmentsProvider
public boolean getHasAttachments()
IAttachmentsProvider
getHasAttachments
in interface IAttachmentsProvider
public void removeAttachment(String attachmentID)
IAttachmentsProvider
removeAttachment
in interface IAttachmentsProvider
attachmentID
- the id of the attachment to removepublic void updateAttachment(String attachmentID, org.apache.commons.fileupload.FileItem fileItem, String fileEncoding)
IAttachmentsProvider
updateAttachment
in interface IAttachmentsProvider
attachmentID
- the id of the attachment to updatefileItem
- the new attachment contentfileEncoding
- the encoding of the attachment file (if known)protected String getSafeFileName(String filePath)
filePath
- the file path to processpublic boolean isUseWebDav()
isUseWebDav
in interface IWebDavAwareAttachmentsProvider
public void setUseWebDav(boolean useWebDav)
setUseWebDav
in interface IWebDavAwareAttachmentsProvider
public void refresh()
refresh
in interface IWebDavAwareAttachmentsProvider