Interface AttachmentService


public interface AttachmentService
  • Field Details

  • Method Details

    • saveAttachments

      ObjectAttachmentOperationReport saveAttachments(FileAttachmentResourceList attachment, org.exoplatform.services.security.Identity userAclIdentity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Makes an update of attached files to an object (activity, comment, task...) by adding newly uploaded files and deletes attachments not listed in attached fileIds
      Parameters:
      attachment - FileAttachmentResourceList to store
      userAclIdentity - user ACL making the update
      Returns:
      ObjectAttachmentOperationReport
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the object identified by its id in FileAttachmentResourceList doesn't exists
      IllegalAccessException - when user doesn't have "write" permission on selected object
    • saveAttachments

      Makes an update of attached files to an object (activity, comment, task...) by adding newly uploaded files and deletes attachments not listed in attached fileIds
      Parameters:
      attachment - FileAttachmentResourceList to store
      Returns:
      ObjectAttachmentOperationReport
    • saveAttachment

      void saveAttachment(UploadedAttachmentDetail uploadedAttachmentDetail, String objectType, String objectId, String parentObjectId, long userIdentityId) throws IOException, ObjectAlreadyExistsException, org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      uploadedAttachmentDetail - UploadedAttachmentDetail object to attach
      objectType - Object type
      objectId - Object identifier
      parentObjectId - Parent object identifier
      userIdentityId - User Identity id
      Throws:
      IOException - when an error occurred while accessing uploaded resource
      ObjectAlreadyExistsException - when attachment already exists for given object
      org.exoplatform.commons.exception.ObjectNotFoundException - when attachment not found
    • deleteAttachments

      void deleteAttachments(String objectType, String objectId)
      Delete attachments of a given object identified by its type and id
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
    • deleteAttachment

      void deleteAttachment(String objectType, String objectId, String fileId)
      Delete attachment of a given object identified by its type and id
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      fileId - attachment file identifier
    • getAttachments

      ObjectAttachmentList getAttachments(String objectType, String objectId, org.exoplatform.services.security.Identity userAclIdentity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Retrieves the list of attachments of a given object identified by its id
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      userAclIdentity - user ACL identity retrieved used IdentityRegistry
      Returns:
      ObjectAttachmentList with the list of attached files. If no attached files, it will return an object containing empty list
      Throws:
      IllegalAccessException - when user identified by its Identity id doesn't have "read" permission of selected object
      org.exoplatform.commons.exception.ObjectNotFoundException - when the object identified by its id in FileAttachmentResourceList doesn't exists
    • getAttachments

      ObjectAttachmentList getAttachments(String objectType, String objectId)
      Retrieves the list of attachments of a given object identified by its id
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      Returns:
      ObjectAttachmentList with the list of attached files. If no attached files, it will return an object containing empty list
    • getAttachmentFileIds

      List<String> getAttachmentFileIds(String objectType, String objectId, org.exoplatform.services.security.Identity userAclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      userAclIdentity - user ACL identity retrieved used IdentityRegistry
      Returns:
      List of attached FileInfo id
      Throws:
      IllegalAccessException - when user identified by its Identity id doesn't have "read" permission of selected object
      org.exoplatform.commons.exception.ObjectNotFoundException - when the object identified by its id doesn't exists
    • getAttachmentFileIds

      List<String> getAttachmentFileIds(String objectType, String objectId)
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      Returns:
      List of attached FileInfo id
    • getAttachment

      ObjectAttachmentDetail getAttachment(String objectType, String objectId, String fileId, org.exoplatform.services.security.Identity userAclIdentity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Retrieve an attached file to a dedicated object identified by its type and id
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      fileId - attachment file identifier
      userAclIdentity - user ACL identity retrieved used IdentityRegistry
      Returns:
      ObjectAttachmentDetail corresponding to a given object, else null
      Throws:
      IllegalAccessException - when user identified by its Identity id doesn't have "read" permission of selected object
      org.exoplatform.commons.exception.ObjectNotFoundException - when the object identified by its id in FileAttachmentResourceList doesn't exists
    • getAttachment

      ObjectAttachmentDetail getAttachment(String objectType, String objectId, String fileId)
      Retrieve an attached file to a dedicated object identified by its type and id
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      fileId - attachment file identifier
      Returns:
      ObjectAttachmentDetail corresponding to a given object, else null
    • getAttachmentInputStream

      InputStream getAttachmentInputStream(String objectType, String objectId, String fileId, String imageDimensions, org.exoplatform.services.security.Identity userAclIdentity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException, IOException
      Retrieves the input stream of an attached file to a dedicated object identified by its type and id
      Parameters:
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      fileId - attachment file identifier
      imageDimensions - applied only when mime type is of type image/*
      userAclIdentity - user ACL identity retrieved used IdentityRegistry
      Returns:
      InputStream of an attached file
      Throws:
      IllegalAccessException - when user identified by its Identity id doesn't have "read" permission of selected object
      org.exoplatform.commons.exception.ObjectNotFoundException - when the object identified by its id in FileAttachmentResourceList doesn't exists
      IOException - when an error occurs while reading attached file content
    • hasAccessPermission

      boolean hasAccessPermission(org.exoplatform.services.security.Identity userAclIdentity, String objectType, String objectId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Checks whether the user have access permission to a given object identified by its id
      Parameters:
      userAclIdentity - user ACL identity retrieved used IdentityRegistry
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      Returns:
      true if the user can have access to an entity.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the object identified by its id doesn't exists
    • hasEditPermission

      boolean hasEditPermission(org.exoplatform.services.security.Identity userAclIdentity, String objectType, String objectId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Checks whether the user have edit permission to a given object identified by its id
      Parameters:
      userAclIdentity - user ACL identity retrieved used IdentityRegistry
      objectType - object type, can be of any type: activity, comment, notes...
      objectId - object technical unique identifier
      Returns:
      true if the user can have access to an entity.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the object identified by its id doesn't exists
    • addPlugin

      void addPlugin(AttachmentPlugin attachmentPermissionPlugin)
      Add an Attachment Permission Plugin that will serve to make an ACL for a given object type
      Parameters:
      attachmentPermissionPlugin - AttachmentPlugin
    • getSupportedObjectTypes

      Set<String> getSupportedObjectTypes()
      Returns:
      the List of supported object types
    • getAttachmentPlugins

      Map<String,AttachmentPlugin> getAttachmentPlugins()
      Returns:
      the Map of supported Attachment plugin