Reputation: 353
I have a requirement where in i need to merge some contents(Documents) into a Single Document and send it back to the Front end ADF Application for a user to download it. I 'm trying to create a custom service which will accept the parameters in the form of an Array List -something like ["Doc,ContentID1,ContentID 2","Document,ContentID3,ContentID4"],Where DOc and Document will be the name of the merged documents and ContentID1,ContentID2 will be the contents to be merged and form a new document "Doc" and ContentID3,ContentID4 will be merged and form a new document "Document" and both these documents are sent back to the application.
If I create a custom service where can I define what type of parameters will it accept. Any help/pointers is appreciated. TIA
Upvotes: 0
Views: 1590
Reputation: 114
Parameters for services are similar to standard html GET parameters, i.e. they are just strings (so the answer is no, you can't "define what type of parameters will it accept" - they are always strings). Once a service is called all parameters are available in m_binder.
In your case call like:
http://<ucm_host>/<ucm_instance>/idcplg?IdcService=MEGE_DOCUMENTS&merge1=docName1,contentId1,contentId2&merge2=docName2,contentId1,contentId2
will run custom service MEGE_DOCUMENTS with 2 parameters - merge1 and merge2 - in m_binder. You may get them like this:
String parameter1 = m_binder.getLocal("merge1");
String parameter2 = m_binder.getLocal("merge2");
after that parameter1 will have value "docName1,contentId1,contentId2" and parameter2 - "docName2,contentId1,contentId2"
So, if this service is supposed to be run independently (e.g. from browser / as a separate service) - I'm afraid you'll have to iterate through parameters. Like this, for example (I know it is ugly, but it's all you can do in your situation):
Map<String, String> params = new HashMap<String,String>();
String prefix = "merge";
int index = 1;
boolean hasMoreParams = true;
while(hasMoreParams) {
String paramName = prefix + index;
if(m_binder.m_localData.containsKey(paramName)) {
String paramValue = m_binder.getLocal(paramName);
params.put(paramName, paramValue);
index++;
} else {
hasMoreParams = false;
}
}
In case your service will be used by other services/filters (i.e. called from java code only) you may put any java object (e.g. HashMap) in binder's local data before service call and then use it:
m_binder.m_localData.put(<Object>, <Object>);
Do not mix up m_localData with m_binder.putLocal(). m_localData is a Property variable (an extension of HashTable). putLocal() is a method which have only one String parameter.
Upvotes: 2