简体   繁体   English

Oracle UCM -Custom Service创建

[英]Oracle UCM -Custom Service creation

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. 我有一个要求,我需要将一些内容(文档)合并到单个文档中,然后将其发送回前端ADF应用程序以供用户下载。 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. 我正在尝试创建一个自定义服务,它将接受数组列表形式的参数 - 像[“Doc,ContentID1,ContentID 2”,“Document,ContentID3,ContentID4”],其中DOc和Document将是合并文档的名称和ContentID1,ContentID2将是要合并的内容并形成新文档“Doc”和ContentID3,ContentID4将被合并并形成新文档“Document”,并且这两个文档都被发送回应用程序。

If I create a custom service where can I define what type of parameters will it accept. 如果我创建自定义服务,我可以在其中定义它接受的参数类型。 Any help/pointers is appreciated. 任何帮助/指针表示赞赏。 TIA TIA

Parameters for services are similar to standard html GET parameters, ie they are just strings (so the answer is no, you can't "define what type of parameters will it accept" - they are always strings). 服务的参数类似于标准的html GET参数,即它们只是字符串(所以答案是否定的,你不能“定义它接受的参数类型” - 它们总是字符串)。 Once a service is called all parameters are available in m_binder. 调用服务后,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. 将在m_binder中运行带有2个参数的自定义服务MEGE_DOCUMENTS - merge1和merge2。 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 " 之后,parameter1将具有值“ docName1,contentId1,contentId2 ”和parameter2 - “ docName2,contentId1,contentId2


So, if this service is supposed to be run independently (eg 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 (ie called from java code only ) you may put any java object (eg HashMap) in binder's local data before service call and then use it: 如果您的服务将被其他服务中使用/过滤器(即从Java代码中调用 ),你可以将任何Java对象(例如,HashMap中)在粘结剂的本地数据服务电话前,然后使用它:

m_binder.m_localData.put(<Object>, <Object>);

Do not mix up m_localData with m_binder.putLocal(). 不要将m_localData与m_binder.putLocal()混淆。 m_localData is a Property variable (an extension of HashTable). m_localData是一个Property变量(HashTable的扩展)。 putLocal() is a method which have only one String parameter. putLocal()是一个只有一个String参数的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM