Class JcrAttachmentsProvider
java.lang.Object
com.webmethods.caf.faces.bean.PageFlowScopeAdapter
com.webmethods.caf.jcr.faces.data.JcrAttachmentsProvider
- All Implemented Interfaces:
IPageFlowScopeAdapter
,IAttachmentsProvider
,IWebDavAwareAttachmentsProvider
,Serializable
- Direct Known Subclasses:
SubFolderJcrAttachmentsProvider
,TaskJcrAttachmentsProvider
public class JcrAttachmentsProvider
extends PageFlowScopeAdapter
implements IWebDavAwareAttachmentsProvider, Serializable
Content provider for exposing the children of a JCR node for use with the
CAF AttachmentsPanel control.
- Since:
- 8.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enum
Used to affect how errors are reportedprotected class
Implementation of IAttachmentItem to wrap a JCR file node.static class
Implementation of FileItem to wrap a JCR file node. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
True if the attachment changes are automatically saved.protected String
Holds the base Url for attachment icons.protected String
Holds the path of the JCR File download servletprotected javax.jcr.Session
Reference to the current JCR sessionprotected String
Holds the parent node idprotected javax.jcr.Node
Reference to the parent Node where the attachments are storedprotected String
Holds the parent node pathprotected boolean
true to use WebDAV urls, false otherwiseFields inherited from class com.webmethods.caf.faces.bean.PageFlowScopeAdapter
fExpireWithPageFlow
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttachment
(org.apache.commons.fileupload.FileItem fileItem, String fileEncoding) Add Attachmentboolean
Returns whether the attachment provider has any attachmentsReturns the icon base URL which is prepended to all the icon URLsReturns the servlet path to the JCR file streaming servletjavax.jcr.Session
Returns the active JCR sessionReturns the id of the parent JCR nodejavax.jcr.Node
Returns a reference to the JCR Node that is the parent of the attachments.Returns the path of the parent Nodeprotected String
getSafeFileName
(String filePath) Gets a normalized file name from the supplied file path.boolean
Returns whether attachments can be addedboolean
Returns whether auto-save is enabled.boolean
Returns whether to use WebDAV urlsReturns a list of the current attachmentsvoid
refresh()
Does nothingvoid
removeAttachment
(String attachmentID) Remove Attachmentprotected void
Report an errorprotected void
safeNodeSave
(javax.jcr.Node node) Saves changes to the supplied nodesprotected boolean
Validates that the JCR session is alive and that the parent node has been configured correctlyvoid
setAutoSave
(boolean autoSave) Sets whether autoSave is enabledvoid
setIconBaseUrl
(String iconBaseUrl) Sets the base URL to prepend to all the icon URLsvoid
setJcrFileServletPath
(String jcrFileServletPath) Sets the servlet path to the JCR file streaming servletvoid
setJcrSession
(javax.jcr.Session jcrSession) Sets the active JCR sessionvoid
setParentId
(String id) Sets the id of the parent JCR node to usevoid
setParentPath
(String path) Sets the path of the parent JCR Node to use.void
setUseWebDav
(boolean useWebDav) Sets whether to use WebDAV urlsvoid
updateAttachment
(String attachmentID, org.apache.commons.fileupload.FileItem fileItem, String fileEncoding) Update an AttachmentMethods inherited from class com.webmethods.caf.faces.bean.PageFlowScopeAdapter
getExpireWithPageFlow, setExpireWithPageFlow
-
Field Details
-
jcrSession
protected transient javax.jcr.Session jcrSessionReference to the current JCR session -
parentNode
protected transient javax.jcr.Node parentNodeReference to the parent Node where the attachments are stored -
autoSave
protected boolean autoSaveTrue if the attachment changes are automatically saved. Defaults to true. -
jcrFileServletPath
Holds the path of the JCR File download servlet -
iconBaseUrl
Holds the base Url for attachment icons. Defaults to the MWS front end url. -
parentId
Holds the parent node id -
parentPath
Holds the parent node path -
useWebDav
protected boolean useWebDavtrue to use WebDAV urls, false otherwise
-
-
Constructor Details
-
JcrAttachmentsProvider
public JcrAttachmentsProvider()
-
-
Method Details
-
getIconBaseUrl
Returns the icon base URL which is prepended to all the icon URLs- Returns:
- the base URL to prepend to all the icon URLs
-
setIconBaseUrl
Sets the base URL to prepend to all the icon URLs- Parameters:
iconBaseUrl
- the baseURL to use
-
getParentId
Returns the id of the parent JCR node- Returns:
- the uuid of the parent JCR node
-
setParentId
Sets the id of the parent JCR node to use- Parameters:
id
- the uuid of the JCR node to use as the attachments parent
-
setParentPath
Sets the path of the parent JCR Node to use. NOTE: if a parentId is supplied, the path is not used.- Parameters:
path
- the path of the JCR node to use as the attachments parent
-
getParentPath
Returns the path of the parent Node- Returns:
- the path of the JCR node being used as the attachments parent
-
getJcrSession
public javax.jcr.Session getJcrSession()Returns the active JCR session- Returns:
- the JCR Session
-
setJcrSession
public void setJcrSession(javax.jcr.Session jcrSession) Sets the active JCR session- Parameters:
jcrSession
- the JCR session to use
-
isAutoSave
public boolean isAutoSave()Returns whether auto-save is enabled. If autoSave is true, then whenever an attachment is added/updated/deleted the JCR session is automatically saved. Otherwise the changes will only get persisted when someone else invokes the jcrSession.save() API.- Returns:
- the autoSave value
-
setAutoSave
public void setAutoSave(boolean autoSave) Sets whether autoSave is enabled- Parameters:
autoSave
- the autoSave to set
-
getJcrFileServletPath
Returns the servlet path to the JCR file streaming servlet- Returns:
- the jcrFileServletPath
-
setJcrFileServletPath
Sets the servlet path to the JCR file streaming servlet- Parameters:
jcrFileServletPath
- the jcrFileServletPath to set
-
getParentNode
public javax.jcr.Node getParentNode()Returns a reference to the JCR Node that is the parent of the attachments.- Returns:
- the parentNode
-
reportError
Report an error- Parameters:
mode
- the error reporting mode to usemsg
- the error message
-
sanityCheck
Validates that the JCR session is alive and that the parent node has been configured correctly- Parameters:
mode
- the error reporting mode- Returns:
- true if everything is ok, false otherwise
-
addAttachment
Description copied from interface:IAttachmentsProvider
Add Attachment- Specified by:
addAttachment
in interfaceIAttachmentsProvider
- Parameters:
fileItem
- the attachment contentfileEncoding
- the encoding of the attachment file (if known)
-
safeNodeSave
protected void safeNodeSave(javax.jcr.Node node) throws javax.jcr.RepositoryException Saves changes to the supplied nodes- Parameters:
node
- the node to save- Throws:
javax.jcr.RepositoryException
-
isAddAttachmentsAvailable
public boolean isAddAttachmentsAvailable()Description copied from interface:IAttachmentsProvider
Returns whether attachments can be added- Specified by:
isAddAttachmentsAvailable
in interfaceIAttachmentsProvider
- Returns:
- true or false
-
listAttachments
Description copied from interface:IAttachmentsProvider
Returns a list of the current attachments- Specified by:
listAttachments
in interfaceIAttachmentsProvider
- Returns:
- collection of AttachmentItems
-
getHasAttachments
public boolean getHasAttachments()Description copied from interface:IAttachmentsProvider
Returns whether the attachment provider has any attachments- Specified by:
getHasAttachments
in interfaceIAttachmentsProvider
- Returns:
- true or false
-
removeAttachment
Description copied from interface:IAttachmentsProvider
Remove Attachment- Specified by:
removeAttachment
in interfaceIAttachmentsProvider
- Parameters:
attachmentID
- the id of the attachment to remove
-
updateAttachment
public void updateAttachment(String attachmentID, org.apache.commons.fileupload.FileItem fileItem, String fileEncoding) Description copied from interface:IAttachmentsProvider
Update an Attachment- Specified by:
updateAttachment
in interfaceIAttachmentsProvider
- Parameters:
attachmentID
- the id of the attachment to updatefileItem
- the new attachment contentfileEncoding
- the encoding of the attachment file (if known)
-
getSafeFileName
Gets a normalized file name from the supplied file path. Illegal charactgers are escaped- Parameters:
filePath
- the file path to process- Returns:
- safe file name
-
isUseWebDav
public boolean isUseWebDav()Returns whether to use WebDAV urls- Specified by:
isUseWebDav
in interfaceIWebDavAwareAttachmentsProvider
- Returns:
- true or false
-
setUseWebDav
public void setUseWebDav(boolean useWebDav) Sets whether to use WebDAV urls- Specified by:
setUseWebDav
in interfaceIWebDavAwareAttachmentsProvider
-
refresh
public void refresh()Does nothing- Specified by:
refresh
in interfaceIWebDavAwareAttachmentsProvider
-