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:
  • Field Details

    • jcrSession

      protected transient javax.jcr.Session jcrSession
      Reference to the current JCR session
    • parentNode

      protected transient javax.jcr.Node parentNode
      Reference to the parent Node where the attachments are stored
    • autoSave

      protected boolean autoSave
      True if the attachment changes are automatically saved. Defaults to true.
    • jcrFileServletPath

      protected String jcrFileServletPath
      Holds the path of the JCR File download servlet
    • iconBaseUrl

      protected String iconBaseUrl
      Holds the base Url for attachment icons. Defaults to the MWS front end url.
    • parentId

      protected String parentId
      Holds the parent node id
    • parentPath

      protected String parentPath
      Holds the parent node path
    • useWebDav

      protected boolean useWebDav
      true to use WebDAV urls, false otherwise
  • Constructor Details

    • JcrAttachmentsProvider

      public JcrAttachmentsProvider()
  • Method Details

    • getIconBaseUrl

      public String 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

      public void setIconBaseUrl(String iconBaseUrl)
      Sets the base URL to prepend to all the icon URLs
      Parameters:
      iconBaseUrl - the baseURL to use
    • getParentId

      public String getParentId()
      Returns the id of the parent JCR node
      Returns:
      the uuid of the parent JCR node
    • setParentId

      public void setParentId(String id)
      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

      public void setParentPath(String path)
      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

      public String 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

      public String getJcrFileServletPath()
      Returns the servlet path to the JCR file streaming servlet
      Returns:
      the jcrFileServletPath
    • setJcrFileServletPath

      public void setJcrFileServletPath(String jcrFileServletPath)
      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

      protected void reportError(JcrAttachmentsProvider.ErrorReportingMode mode, String msg)
      Report an error
      Parameters:
      mode - the error reporting mode to use
      msg - the error message
    • sanityCheck

      protected boolean sanityCheck(JcrAttachmentsProvider.ErrorReportingMode mode)
      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

      public void addAttachment(org.apache.commons.fileupload.FileItem fileItem, String fileEncoding)
      Description copied from interface: IAttachmentsProvider
      Add Attachment
      Specified by:
      addAttachment in interface IAttachmentsProvider
      Parameters:
      fileItem - the attachment content
      fileEncoding - 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 interface IAttachmentsProvider
      Returns:
      true or false
    • listAttachments

      public List<IAttachmentItem> listAttachments()
      Description copied from interface: IAttachmentsProvider
      Returns a list of the current attachments
      Specified by:
      listAttachments in interface IAttachmentsProvider
      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 interface IAttachmentsProvider
      Returns:
      true or false
    • removeAttachment

      public void removeAttachment(String attachmentID)
      Description copied from interface: IAttachmentsProvider
      Remove Attachment
      Specified by:
      removeAttachment in interface IAttachmentsProvider
      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 interface IAttachmentsProvider
      Parameters:
      attachmentID - the id of the attachment to update
      fileItem - the new attachment content
      fileEncoding - the encoding of the attachment file (if known)
    • getSafeFileName

      protected String getSafeFileName(String filePath)
      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 interface IWebDavAwareAttachmentsProvider
      Returns:
      true or false
    • setUseWebDav

      public void setUseWebDav(boolean useWebDav)
      Sets whether to use WebDAV urls
      Specified by:
      setUseWebDav in interface IWebDavAwareAttachmentsProvider
    • refresh

      public void refresh()
      Does nothing
      Specified by:
      refresh in interface IWebDavAwareAttachmentsProvider