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 typevoiddeleteAttachment(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 idbooleanhasAccessPermission(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 idvoidsaveAttachment(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
-
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
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
-
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
-
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
-