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, org.exoplatform.commons.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
      org.exoplatform.commons.ObjectAlreadyExistsException - when attachment already exists for given object
      org.exoplatform.commons.exception.ObjectNotFoundException - when attachment not found
    • createAttachment

      ObjectAttachmentDetail createAttachment(String objectType, String objectId, FileAttachmentObject attachmentObject, org.exoplatform.services.security.Identity userAclIdentity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Creates an attachment associated with a specific object.
      Parameters:
      objectType - The type of the object to which the attachment belongs.
      objectId - The unique identifier of the object.
      attachmentObject - The attachment details, including metadata and file information.
      userAclIdentity - The identity acl of the user creating the attachment.
      Returns:
      ObjectAttachmentDetail
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • 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
    • 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)
      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
    • getAttachments

      ObjectAttachmentList getAttachments(String objectType, String objectId, org.exoplatform.services.security.Identity userAclIdentity, int offset, int limit) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Retrieves a list of ObjectAttachmentDetail objects associated with a specific object type and object ID, with metadata enrichment based on the given user's access identity.The result is paginated based on the provided offset and limit.

      If no attachments are found, an empty ObjectAttachmentList is returned. If the user does not have the necessary access permissions, an IllegalAccessException will be thrown.

      Parameters:
      objectType - The type of the object associated with the attachments.
      objectId - The unique ID of the object associated with the attachments.
      userAclIdentity - The identity of the user requesting the attachments, used for access control checks.
      offset - The offset to be used for pagination (zero-based index).
      limit - The maximum number of items to return (for pagination).
      Returns:
      ObjectAttachmentList A list of attachments associated with the specified object type and object ID, enriched with metadata (e.g., alt text and format) where applicable.
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - If the object associated with the provided object ID does not exist.
      IllegalAccessException - If the user does not have the necessary permissions to access the requested attachments.
    • 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
    • moveAttachments

      void moveAttachments(String sourceObjectType, String sourceObjectId, String destinationObjectType, String destinationObjectId, String destinationParentObjectId, long userIdentityId)
      Moves attachments from a specified source object type to a specified destination object type.
      Parameters:
      sourceObjectType - the type of the source object
      sourceObjectId - the ID of the source object
      destinationObjectType - the type of the destination object
      destinationObjectId - the ID of the destination object
      destinationParentObjectId - the ID of the destination's parent object
      userIdentityId - the ID of the user performing the operation
    • createAttachment

      void createAttachment(String fileId, String objectType, String objectId, String parentObjectId, long userIdentityId, Map<String,String> properties) throws org.exoplatform.commons.exception.ObjectNotFoundException, org.exoplatform.commons.ObjectAlreadyExistsException
      Creates an attachment for a specified object.
      Parameters:
      fileId - the identifier of the file to be attached
      objectType - the type of the object
      objectId - the identifier of the object to which the attachment is being added.
      parentObjectId - the parent object identifier
      userIdentityId - user Identity id
      properties - the attachment properties
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the object identified by its id doesn't exist
      org.exoplatform.commons.ObjectAlreadyExistsException - when attachment already exists for given object