-
Notifications
You must be signed in to change notification settings - Fork 9
Copy Attachments to copy Links and type column value #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cdcf6ef
Changes
rashmiangadi11 63c3c12
Update SDMCustomServiceHandler.java
rashmiangadi11 fa6f645
Changes
rashmiangadi11 32f157b
UT's
rashmiangadi11 038938d
unnecessary files
rashmiangadi11 0119960
Changes
rashmiangadi11 4b4dcb2
Create attachments-demo-app.capnb
rashmiangadi11 2fcb96e
Review comments
rashmiangadi11 bbcde81
Update DBQuery.java
rashmiangadi11 0b1dc40
Review comments
rashmiangadi11 f6a1ccf
Update README.md
rashmiangadi11 f84919c
Update README.md
rashmiangadi11 a035b9c
Merge branch 'develop' into copybug
rashmiangadi11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,14 @@ | |
| import com.sap.cds.sdm.handler.TokenHandler; | ||
| import com.sap.cds.sdm.model.CmisDocument; | ||
| import com.sap.cds.sdm.model.SDMCredentials; | ||
| import com.sap.cds.sdm.persistence.DBQuery; | ||
| import com.sap.cds.sdm.service.RegisterService; | ||
| import com.sap.cds.sdm.service.SDMService; | ||
| import com.sap.cds.services.ServiceException; | ||
| import com.sap.cds.services.draft.DraftService; | ||
| import com.sap.cds.services.handler.annotations.On; | ||
| import com.sap.cds.services.handler.annotations.ServiceName; | ||
| import com.sap.cds.services.persistence.PersistenceService; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
|
|
@@ -26,14 +28,22 @@ | |
| @ServiceName(value = "*", type = RegisterService.class) | ||
| public class SDMCustomServiceHandler { | ||
| private final SDMService sdmService; | ||
| private final DBQuery dbQuery; | ||
| private final List<DraftService> draftService; | ||
| private final TokenHandler tokenHandler; | ||
| private final PersistenceService persistenceService; | ||
|
|
||
| public SDMCustomServiceHandler( | ||
| SDMService sdmService, List<DraftService> draftService, TokenHandler tokenHandler) { | ||
| SDMService sdmService, | ||
| List<DraftService> draftService, | ||
| TokenHandler tokenHandler, | ||
| DBQuery dbQuery, | ||
| PersistenceService persistenceService) { | ||
| this.sdmService = sdmService; | ||
| this.draftService = draftService; | ||
| this.tokenHandler = tokenHandler; | ||
| this.dbQuery = dbQuery; | ||
| this.persistenceService = persistenceService; | ||
| } | ||
|
|
||
| @On(event = RegisterService.EVENT_COPY_ATTACHMENT) | ||
|
|
@@ -62,12 +72,15 @@ public void copyAttachments(AttachmentCopyEventContext context) throws IOExcepti | |
| folderId = succinctProperties.getString("cmis:objectId"); | ||
| } | ||
| CmisDocument cmisDocument = new CmisDocument(); | ||
| cmisDocument.setRepositoryId(repositoryId); | ||
| cmisDocument.setFolderId(folderId); | ||
|
|
||
| List<String> objectIds = context.getObjectIds(); | ||
| List<List<String>> attachmentsMetadata = new ArrayList<>(); | ||
| for (String objectId : objectIds) { | ||
| // get Link Url from objectId and set to cmisDocument | ||
| cmisDocument = dbQuery.getAttachmentForObjectID(persistenceService, objectId, context); | ||
| cmisDocument.setObjectId(objectId); | ||
| cmisDocument.setRepositoryId(repositoryId); | ||
| cmisDocument.setFolderId(folderId); | ||
| try { | ||
| attachmentsMetadata.add( | ||
| sdmService.copyAttachment(cmisDocument, sdmCredentials, isSystemUser)); | ||
|
|
@@ -101,15 +114,21 @@ public void copyAttachments(AttachmentCopyEventContext context) throws IOExcepti | |
| for (List<String> attachmentMetadata : attachmentsMetadata) { | ||
| String fileName = attachmentMetadata.get(0); | ||
| String mimeType = attachmentMetadata.get(1); | ||
| if (mimeType.equalsIgnoreCase("application/internet-shortcut")) { | ||
| int dotIndex = fileName.lastIndexOf('.'); | ||
| fileName = fileName.substring(0, dotIndex); | ||
| } | ||
|
Comment on lines
+117
to
+120
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this for?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If link is created sdm creates link as name with suffix .url |
||
| String newObjectId = attachmentMetadata.get(2); | ||
| updatedFields.put("objectId", newObjectId); | ||
| updatedFields.put("repositoryId", repositoryId); | ||
| updatedFields.put("folderId", folderId); | ||
| updatedFields.put("status", "Clean"); | ||
| updatedFields.put("mimeType", mimeType); | ||
| updatedFields.put("type", cmisDocument.getType()); | ||
| updatedFields.put("fileName", fileName); | ||
| updatedFields.put("HasDraftEntity", false); | ||
| updatedFields.put("HasActiveEntity", false); | ||
| updatedFields.put("linkUrl", cmisDocument.getUrl()); | ||
| updatedFields.put( | ||
| "contentId", newObjectId + ":" + folderId + ":" + context.getFacet() + ":" + mimeType); | ||
| updatedFields.put(upIdKey, upID); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed adding the mta.yaml hook here. Please add it .