We had a basic requirement. Content that get into UCM should also have attachments. These attachments could be added, viewed, deleted and downloaded. Sounded simple enough and with UCM admin UI it was easy peasy. But I ran into problems as soon as I started working on the RIDC part. There seems to be very little documentation on ziprendition component which is used to work with attachments. After a bit of a hassle and help from otn was able to finish it. Below is the code
Adding Attachments :
DataBinder binder3 = idcClient.createBinder();
binder3.putLocal("IdcService", "EDIT_RENDITIONS");
binder3.putLocal("dID", docID);
for (FileObject attachment : attachments) {
binder3.putLocal("renditionKeys",
binder2.getLocal("renditionKeys") + "," +
attachment.getFileName());
binder3.putLocal(attachment.getFileName() + ".name",
attachment.getFileName());
binder3.putLocal(attachment.getFileName() + ".action",
"edit");
binder3.putLocal(attachment.getFileName() + ".file:path",
attachment.getFileName());
binder3.addFile(attachment.getFileName() + ".file",
(TransferFile)attachment.getFile());
}
ServiceResponse attachmentResponse = idcClient.sendRequest(userContext, binder3);
attachmentResponse.getResponseAsBinder();
I had a number of attachments to add, hence the loop.
Viewing Attachment Details:
This was a little trickier. I was novice using RIDC and was lucky to solve this one. I saw that while using the UCM admin UI and viewing the doc info of a content, the attachment data was also visible. So it naturally follows that doc_info operation should return the attachment details as well. But I had never seen it before in the doc_info resultset. With the debugger enabled on jDev I dug through the response from UCM on doc_info operation. To my surprise doc_info was just one of the resultsets returned from the operation. My attachment details where in another resultSet called the "manifest". It was easy enough to loop through it and get the details .
DataResultSet manifest = binder.getResultSet("manifest");
if(manifest!=null){
ArrayList<FileObject> files = new ArrayList<FileObject>();
for(DataObject dataObject3 : manifest.getRows()){
FileObject file = new FileObject();
file.setFileName(dataObject3.get("extRenditionName"));
files.add(file);
}
}
Downloading Attachments:
Again the UCM admin UI gave the first clue. The attachment details that come up on the content doc info has links to download the attachments as well. On mouse over it gives a pretty good idea on how these can be downloaded. Something like
https://myip:16200/cs/idcplg?IdcService=GET_FILE&dID=<$dID $>&dDocName=<$dDocName$>&Rendition=<$extRenditionName$>&allowInterrupt=1"
You can use RIDC GET_FILE with above local parameters to get the file.
Cheers,
Adding Attachments :
DataBinder binder3 = idcClient.createBinder();
binder3.putLocal("IdcService", "EDIT_RENDITIONS");
binder3.putLocal("dID", docID);
for (FileObject attachment : attachments) {
binder3.putLocal("renditionKeys",
binder2.getLocal("renditionKeys") + "," +
attachment.getFileName());
binder3.putLocal(attachment.getFileName() + ".name",
attachment.getFileName());
binder3.putLocal(attachment.getFileName() + ".action",
"edit");
binder3.putLocal(attachment.getFileName() + ".file:path",
attachment.getFileName());
binder3.addFile(attachment.getFileName() + ".file",
(TransferFile)attachment.getFile());
}
ServiceResponse attachmentResponse = idcClient.sendRequest(userContext, binder3);
attachmentResponse.getResponseAsBinder();
I had a number of attachments to add, hence the loop.
Viewing Attachment Details:
This was a little trickier. I was novice using RIDC and was lucky to solve this one. I saw that while using the UCM admin UI and viewing the doc info of a content, the attachment data was also visible. So it naturally follows that doc_info operation should return the attachment details as well. But I had never seen it before in the doc_info resultset. With the debugger enabled on jDev I dug through the response from UCM on doc_info operation. To my surprise doc_info was just one of the resultsets returned from the operation. My attachment details where in another resultSet called the "manifest". It was easy enough to loop through it and get the details .
DataResultSet manifest = binder.getResultSet("manifest");
if(manifest!=null){
ArrayList<FileObject> files = new ArrayList<FileObject>();
for(DataObject dataObject3 : manifest.getRows()){
FileObject file = new FileObject();
file.setFileName(dataObject3.get("extRenditionName"));
files.add(file);
}
}
Downloading Attachments:
Again the UCM admin UI gave the first clue. The attachment details that come up on the content doc info has links to download the attachments as well. On mouse over it gives a pretty good idea on how these can be downloaded. Something like
https://myip:16200/cs/idcplg?IdcService=GET_FILE&dID=<$dID $>&dDocName=<$dDocName$>&Rendition=<$extRenditionName$>&allowInterrupt=1"
You can use RIDC GET_FILE with above local parameters to get the file.
Cheers,
Do you know how to delete attachments?
ReplyDelete