Skip to content

Commit

Permalink
feat: Enhance createAttachment method accessibility - EXO-75694 - Mee…
Browse files Browse the repository at this point in the history
  • Loading branch information
sofyenne committed Dec 9, 2024
1 parent 0bf7081 commit 22cd5f9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,27 @@ InputStream getAttachmentInputStream(String objectType,
* @param userIdentityId the ID of the user performing the operation
*/
void moveAttachments(String sourceObjectType, String sourceObjectId, String destinationObjectType, String destinationObjectId, String destinationParentObjectId, long userIdentityId);

/**
* Creates an attachment for a specified object.
*
* @param fileId the identifier of the file to be attached
* @param objectType the type of the object
* @param objectId the identifier of the object to which the attachment is being
* added.
* @param parentObjectId the parent object identifier
* @param userIdentityId user
* {@link org.exoplatform.social.core.identity.model.Identity} id
* @param properties the attachment properties
* @throws ObjectNotFoundException when the object identified by its id doesn't
* exist
* @throws ObjectAlreadyExistsException when attachment already exists for given
* object
*/
void createAttachment(String fileId,
String objectType,
String objectId,
String parentObjectId,
long userIdentityId,
Map<String, String> properties) throws ObjectNotFoundException, ObjectAlreadyExistsException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,31 @@ public void moveAttachments(String sourceObjectType,
}
}

@Override
public void createAttachment(String fileId,
String objectType,
String objectId,
String parentObjectId,
long userIdentityId,
Map<String, String> properties) throws ObjectNotFoundException, ObjectAlreadyExistsException {
MetadataKey metadataKey = null;
metadataKey = new MetadataKey(METADATA_TYPE.getName(), fileId, getAudienceId(objectType, objectId));
MetadataObject object = new MetadataObject(objectType,
objectId,
parentObjectId,
getSpaceId(objectType, objectId));
metadataService.createMetadataItem(object,
metadataKey,
properties,
userIdentityId);
broadcastAttachmentChange(ATTACHMENT_CREATED_EVENT,
fileId,
objectType,
objectId,
getUserName(userIdentityId));
}


private org.exoplatform.social.core.identity.model.Identity checkAccessPermission(String objectType,
String objectId,
String fileId,
Expand Down Expand Up @@ -503,29 +528,6 @@ private void saveAttachment(UploadedAttachmentDetail uploadedAttachmentDetail,
}
}

private void createAttachment(String fileId,
String objectType,
String objectId,
String parentObjectId,
long userIdentityId,
Map<String, String> properties) throws ObjectNotFoundException, ObjectAlreadyExistsException {
MetadataKey metadataKey = null;
metadataKey = new MetadataKey(METADATA_TYPE.getName(), fileId, getAudienceId(objectType, objectId));
MetadataObject object = new MetadataObject(objectType,
objectId,
parentObjectId,
getSpaceId(objectType, objectId));
metadataService.createMetadataItem(object,
metadataKey,
properties,
userIdentityId);
broadcastAttachmentChange(ATTACHMENT_CREATED_EVENT,
fileId,
objectType,
objectId,
getUserName(userIdentityId));
}

private void updateAttachment(String fileId,
String objectType,
String objectId,
Expand Down

0 comments on commit 22cd5f9

Please sign in to comment.