here it is
<java>
public static ClientResource getClientResource(String uri,String userName,String password) throws Exception {
System.out.println("in getClientResource password:"+password);
ClientResource clientResource = new ClientResource(uri);
ServiceUtil serviceUtil=new ServiceUtil();
password=serviceUtil.decrypt(password);
clientResource.setChallengeResponse(ChallengeScheme.HTTP_BASIC,userName, password);
return clientResource;
}
public static String getRequestProcessId(String processKey,String userName,String password) throws ResourceException, Exception {
String uri = REST_URI + "/process-definitions?size=100";
System.out.println("key "+processKey);
Representation response = getClientResource(uri,userName,password).get(MediaType.APPLICATION_JSON);
JSONObject object = new JSONObject(response.getText());
if (object != null) {
JSONArray arr = (JSONArray) object.get("data");
for (int i = 0; i < arr.length(); i++) {
JSONObject jsonObject = (JSONObject) arr.get(i);
if (jsonObject.get("key").equals(processKey)) {
logger.info("Returning processDefinitionId " + jsonObject.get("id"));
return (String) jsonObject.get("id");
}
}
}
return null;
}
public static String startRequestedProcess(HashMap<String,Object> param,String userName,String password)
throws Exception {
String uri = REST_URI + "/process-instance";
JSONObject object=new JSONObject();
Set s=param.keySet();
Iterator<String> itr= s.iterator();
while(itr.hasNext())
{ String key=itr.next();
object.put(key, param.get(key));
System.out.println(key +" "+param.get(key));
}
Representation rep = new JsonRepresentation(object);
rep.setMediaType(MediaType.APPLICATION_JSON);
JSONObject jsObj = new JSONObject(getClientResource(uri,userName,password).post(rep).getText());
logger.info("Returning processId " + jsObj.getString("id"));
return jsObj.getString("id");
}
</java>