Property[] props = client.getTokenProperties(token);
String user = (String) PropertyUtils.getProperty(props, AuthenticationConstants.PROPERTY_USER).getValue();
_log.info("Decrypting the token properties. We have successfully logged in as:" + user);
_log.info("Instanciate tms service client");
TempoClient tempoClient = new TempoClient("http://localhost:8080", token, client);
//RemoteTMSClient tms = new RemoteTMSClient(TMS_SERVICE, token);
_log.info("get the pipa corresponding to the absence request, by making a query on our available tasks");
Task[] ts = tempoClient.getAvailableTasks("PIPATask", "T._description like '%Examples%'");
String pipaID = ts[0].getID();
_log.info("We have found the task to instanciate the process. This task has the following ID:" + pipaID);
tempoClient.init(pipaID, tempoClient.createMessageAsDocument(pipa, "abr_initPipa.ftl"));
_log.info("wait for the task to be initiated. Hopefully 2s is enough");
Thread.sleep(SLEEP_TIME);
_log.info("get our full activity task list");
Task[] paList = tempoClient.getAvailableTasks("PATask", "ORDER BY T._creationDate DESC");
_log.info("get the id of the activity task");
String id = paList[0].getID();
_log.info("We're about to start using PATask with id:" + id);
_log.info("We cannot get input and output of a task on a get task list call (see WSDL)");
_log.info("Let's call TMS again to get the full input and output data of this PATask");
PATask task = (PATask) tempoClient.getTask(id);
_log.info("" + "\nChecking the task metadata..." + "\nThe task has been created on:" + task.getCreationDate() + "\nIt has the following description:"
+ task.getDescription() + "\nIt is attached to the process with id:" + task.getProcessID() + "\nIt is attached to the following form:"
+ task.getFormURLAsString() + "\nIt is in the following state:" + task.getState() + "\nIt has the following input:\n"
+ task.getInputAsXmlString() + "\nIt can be assigned to the following roles:" + task.getRoleOwners()
+ "\nIt can be assigned to the following users:" + task.getUserOwners());
_log.info("Let's claim the task: no one else can access this task apart from user:" + user);
tempoClient.claim(id, user);
_log.info("Let's revoke the task:every one can access this task again");
tempoClient.revoke(id);
_log.info("Call setoutput from TMS Client");
tempoClient.setOutput(id, tempoClient.createMessageAsDocument(complete, "abr_output.ftl"));
_log.info("Check the output we've just set");
String outputAsXmlString = ((PATask)tempoClient.getTask(id)).getOutputAsXmlString();
_log.info(outputAsXmlString);
_log.info("complete the PA task with some output");
tempoClient.complete(id, complete, "abr_output.ftl");
//sendSoapToTMP(complete(token, id, complete), "completeTask");
_log.info("sleep again to wait for the notification");
Thread.sleep(SLEEP_TIME);
Task[] ts2 = tempoClient.getAvailableTasks("Notification", "ORDER BY T._creationDate DESC");
String notificationId = ts2[0].getID();
_log.info("We want to retrieve some more data on the notification with id:" + notificationId);
Notification notification = (Notification) tempoClient.getTask(notificationId);
_log.info("The notification has the following:" + "\nInput:" + xmlTooling.serializeXML(notification.getInput()) + "\nCreation Date:"
+ notification.getCreationDate() + "\nAttached Form:" + notification.getFormURLAsString() + "\nDescription:"
+ notification.getDescription());
_log.info("Dismiss this notification");
tempoClient.complete(notificationId);
}