Interface AttachmentService
public interface AttachmentService
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final MetadataType -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPlugin(AttachmentPlugin attachmentPermissionPlugin) Add an Attachment Permission Plugin that will serve to make an ACL for a given object typevoidcreateAttachment(String fileId, String objectType, String objectId, String parentObjectId, long userIdentityId, Map<String, String> properties) Creates an attachment for a specified object.createAttachment(String objectType, String objectId, FileAttachmentObject attachmentObject, org.exoplatform.services.security.Identity userAclIdentity) Creates an attachment associated with a specific object.voiddeleteAttachment(String objectType, String objectId, String fileId) Delete attachment of a given object identified by its type and idvoiddeleteAttachments(String objectType, String objectId) Delete attachments of a given object identified by its type and idgetAttachment(String objectType, String objectId, String fileId) Retrieve an attached file to a dedicated object identified by its type and idgetAttachment(String objectType, String objectId, String fileId, org.exoplatform.services.security.Identity userAclIdentity) Retrieve an attached file to a dedicated object identified by its type and idgetAttachmentFileIds(String objectType, String objectId) getAttachmentFileIds(String objectType, String objectId, org.exoplatform.services.security.Identity userAclIdentity) getAttachmentInputStream(String objectType, String objectId, String fileId, String imageDimensions, org.exoplatform.services.security.Identity userAclIdentity) Retrieves the input stream of an attached file to a dedicated object identified by its type and idgetAttachments(String objectType, String objectId) Retrieves the list of attachments of a given object identified by its idgetAttachments(String objectType, String objectId, org.exoplatform.services.security.Identity userAclIdentity) Retrieves the list of attachments of a given object identified by its idgetAttachments(String objectType, String objectId, org.exoplatform.services.security.Identity userAclIdentity, int offset, int limit) Retrieves a list ofObjectAttachmentDetailobjects 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.booleanhasAccessPermission(org.exoplatform.services.security.Identity userAclIdentity, String objectType, String objectId) Checks whether the user have access permission to a given object identified by its idbooleanhasEditPermission(org.exoplatform.services.security.Identity userAclIdentity, String objectType, String objectId) Checks whether the user have edit permission to a given object identified by its idvoidmoveAttachments(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.voidsaveAttachment(UploadedAttachmentDetail uploadedAttachmentDetail, String objectType, String objectId, String parentObjectId, long userIdentityId) saveAttachments(FileAttachmentResourceList attachment) Makes an update of attached files to an object (activity, comment, task...) by adding newly uploaded files and deletes attachments not listed in attached fileIdssaveAttachments(FileAttachmentResourceList attachment, org.exoplatform.services.security.Identity userAclIdentity) 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
-
Field Details
-
METADATA_TYPE
-
ATTACHMENT_CREATED_EVENT
- See Also:
-
ATTACHMENT_DELETED_EVENT
- See Also:
-
ATTACHMENTS_UPDATED_EVENT
- See Also:
-
ATTACHMENTS_DELETED_EVENT
- See Also:
-
-
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-FileAttachmentResourceListto storeuserAclIdentity- user ACL making the update- Returns:
ObjectAttachmentOperationReport- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the object identified by its id inFileAttachmentResourceListdoesn't existsIllegalAccessException- 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-FileAttachmentResourceListto 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-UploadedAttachmentDetailobject to attachobjectType- Object typeobjectId- Object identifierparentObjectId- Parent object identifieruserIdentityId- UserIdentityid- Throws:
IOException- when an error occurred while accessing uploaded resourceObjectAlreadyExistsException- when attachment already exists for given objectorg.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.ObjectNotFoundExceptionIllegalAccessException
-
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 identifieruserAclIdentity- user ACL identity retrieved usedIdentityRegistry- Returns:
ObjectAttachmentListwith the list of attached files. If no attached files, it will return an object containing empty list- Throws:
IllegalAccessException- when user identified by itsIdentityid doesn't have "read" permission of selected objectorg.exoplatform.commons.exception.ObjectNotFoundException- when the object identified by its id inFileAttachmentResourceListdoesn't exists
-
deleteAttachments
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
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 identifierfileId- attachment file identifier
-
getAttachments
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:
ObjectAttachmentListwith 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 ofObjectAttachmentDetailobjects 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
ObjectAttachmentListis returned. If the user does not have the necessary access permissions, anIllegalAccessExceptionwill 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:
ObjectAttachmentListA 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 identifieruserAclIdentity- user ACL identity retrieved usedIdentityRegistry- Returns:
Listof attachedFileInfoid- Throws:
IllegalAccessException- when user identified by itsIdentityid doesn't have "read" permission of selected objectorg.exoplatform.commons.exception.ObjectNotFoundException- when the object identified by its id doesn't exists
-
getAttachmentFileIds
- Parameters:
objectType- object type, can be of any type: activity, comment, notes...objectId- object technical unique identifier- Returns:
Listof attachedFileInfoid
-
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 identifierfileId- attachment file identifieruserAclIdentity- user ACL identity retrieved usedIdentityRegistry- Returns:
ObjectAttachmentDetailcorresponding to a given object, else null- Throws:
IllegalAccessException- when user identified by itsIdentityid doesn't have "read" permission of selected objectorg.exoplatform.commons.exception.ObjectNotFoundException- when the object identified by its id inFileAttachmentResourceListdoesn't exists
-
getAttachment
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 identifierfileId- attachment file identifier- Returns:
ObjectAttachmentDetailcorresponding 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 identifierfileId- attachment file identifierimageDimensions- applied only when mime type is of type image/*userAclIdentity- user ACL identity retrieved usedIdentityRegistry- Returns:
InputStreamof an attached file- Throws:
IllegalAccessException- when user identified by itsIdentityid doesn't have "read" permission of selected objectorg.exoplatform.commons.exception.ObjectNotFoundException- when the object identified by its id inFileAttachmentResourceListdoesn't existsIOException- 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 usedIdentityRegistryobjectType- 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 usedIdentityRegistryobjectType- 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
Add an Attachment Permission Plugin that will serve to make an ACL for a given object type- Parameters:
attachmentPermissionPlugin-AttachmentPlugin
-
getSupportedObjectTypes
- Returns:
- the
Listof supported object types
-
getAttachmentPlugins
Map<String,AttachmentPlugin> getAttachmentPlugins()- Returns:
- the
Mapof 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 objectsourceObjectId- the ID of the source objectdestinationObjectType- the type of the destination objectdestinationObjectId- the ID of the destination objectdestinationParentObjectId- the ID of the destination's parent objectuserIdentityId- 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, ObjectAlreadyExistsExceptionCreates an attachment for a specified object.- Parameters:
fileId- the identifier of the file to be attachedobjectType- the type of the objectobjectId- the identifier of the object to which the attachment is being added.parentObjectId- the parent object identifieruserIdentityId- userIdentityidproperties- the attachment properties- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the object identified by its id doesn't existObjectAlreadyExistsException- when attachment already exists for given object
-