我希望使用他们的REST API与Documentum Repository进行交互。我想使用http-client 4.3 jars来执行此交互。
我希望有人可能有一个样本,可以帮助我指出如何与DCTM互动的正确方向。
我无法找到一个如何做到这一点的简单明了的例子。
由于
答案 0 :(得分:3)
我知道回答这个问题有点晚了。但我想回答帮助那些仍然需要代码向其他api提出请求的人。以下是向其余api发送帖子请求以启动工作流程的完整示例。
对于其他需求,您可以查看EMC提供的Documentum xCP Rest Services文档:https://support.emc.com/docu52500_Documentum-xCP-REST-Services-2.1-Development-Guide.pdf?language=en_US&request=akamai并与此示例进行比较,根据需要进行更改。
更新:
此外,如果你没有使用xcp,那么没有它的rest api的文档emc.com/collateral/TechnicalDocument/docu57895.pdf
您还可以在How can I use REST to copy an object in Documentum 7.x查看我的答案,了解来自其他api的对象数据和内容(不使用xcp)
String strResponse = "";
String process_id = "system_name of the process you want to start";
String url = "Your App Url Here/processes/" + process_id;
String json = "{"+
"\"run-stateless\" : \"false\","+
"\"data\" :"+
" { "+
" \"variables\" : "+
" { \"Variable name\" : \"Variable value\" } "+
" } "+
"}";
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
BufferedReader rd = null;
CloseableHttpResponse cls = null;
try {
HttpPost request = new HttpPost(url);
// set timeouts as you like
RequestConfig config = RequestConfig.custom()
.setSocketTimeout(60 * 1000).setConnectTimeout(20 * 1000)
.setConnectionRequestTimeout(20 * 1000).build();
request.setConfig(config);
StringEntity params = new StringEntity(json);
request.addHeader("Accept", "application/json");
request.addHeader(
"Authorization",
"Basic "
+ com.documentum.xmlconfig.util.Base64
.encode("username here" + ":"
+ "password here"));
request.addHeader("Content-Type", "application/vnd.emc.xcp+json");
request.setEntity(params);
try {
cls = httpClient.execute(request);
HttpEntity entity = cls.getEntity();
rd = new BufferedReader(new InputStreamReader(
entity.getContent()));
String line = "";
while (line != null) {
line = rd.readLine();
strResponse += line;
}
strResponse = strResponse.trim().replace("\n", "");
String statusline = cls.getStatusLine().toString();
if (!statusline.contains("200") && !statusline.contains("201")) {
Log.write("Process is not started");
// log the strResponse or do something with it
} else {
System.out.println("Process started successfully");
}
} catch (Exception e) {
e.printStackTrace();
}
} finally {
// using commons-io-2.4.jar
IOUtils.closeQuietly(httpClient);
IOUtils.closeQuietly(cls);
IOUtils.closeQuietly(rd);
}