Commit 2e7f7695 authored by Kyriakos Kritikos's avatar Kyriakos Kritikos

Small change to RestClient

parent d2ceb92e
......@@ -264,7 +264,8 @@ class RestClient{
logger.debug("... Addition of objects to session: " + sessionName + " finished");
}
private String getObjects(String sessionName){
private KBContent getObjects(String sessionName){
KBContent content = null;
logger.debug("Obtaining objects from StatefulKnowledgeSession with name: " + sessionName + " ...");
Client c = Client.create();
c.setFollowRedirects(true);
......@@ -282,12 +283,11 @@ class RestClient{
response = r.queryParams(params).post(ClientResponse.class);
//System.out.println("Response: " + response.getEntity(String.class));
int code = response.getStatus();
String s = null;
if (code < 300){
s = response.getEntity(String.class);
content = response.getEntity(KBContent.class);
}
logger.debug("... Retrieval of objects from StatefulKnowledgeSession: " + sessionName + " finished");
return s;
return content;
}
private void fireRules(String sessionName){
......@@ -447,48 +447,41 @@ class RestClient{
ec.addRules(kbName,"queries.drl");
//Get all objects of derived from the session
try{
String s = ec.getObjects("mySession");
if (s != null){
s = s.trim();
logger.debug("Unmarshalled KBContent: " + s);
//String s = ec.getObjects("mySession");
KBContent mc = ec.getObjects("mySession");
//if (s != null){
//s = s.trim();
if (mc != null){
logger.debug("Unmarshalled KBContent: " + mc);
Unmarshaller um = context.createUnmarshaller();
um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
//um.setAdapter(new CDOIDAdapter());
KBContent mc = (KBContent)um.unmarshal(new InputSource(new StringReader(s)));
if (mc == null) logger.debug("No objects were returned");
else {
//Do something with the content
logger.debug("Marshalled KBContent:");
for (Object o: mc.getElements()){
Node node = (Node)o;
Object o2 = um.unmarshal(node);
if (o2 instanceof BestApplicationDeployment){
BestApplicationDeployment bad = (BestApplicationDeployment)o2;
logger.debug("Got BestApplicationDeployment with: " + bad.getId() + " " + bad.getApplication() + " " + bad.getDeploymentModel() + " " + bad.getMetrics());
}
else if (o2 instanceof BestComponentDeployment){
BestComponentDeployment bad = (BestComponentDeployment)o2;
logger.debug("Got BestComponentDeployment with: " + bad.getId() + " " + bad.getComponent() + " " + bad.getHostingComponent() + " " + bad.getMetrics());
}
else if (o2 instanceof ApplicationMatch){
ApplicationMatch match = (ApplicationMatch)o2;
logger.debug("Got ApplicationMatch with: " + match.getFirstApplicationID() + " " + match.getSecondApplicationID() + " " + match.getApplicationMatching());
}
else if (o2 instanceof ComponentMatch){
ComponentMatch match = (ComponentMatch)o2;
logger.debug("Got ComponentMatch with: " + match.getFirstInternalComponentID() + " " + match.getSecondInternalComponentID());
}
else if (o2 instanceof SuccessfulApplicationDeployment){
SuccessfulApplicationDeployment sad = (SuccessfulApplicationDeployment)o2;
logger.debug("Got SuccessfulApplicationDeployment with: " + sad.getApplication() + " " + sad.getDeploymentModel() + " " + sad.getExecutionContexts() + " " + sad.getSlos());
}
else if (o2 instanceof SuccessfulComponentDeployment){
SuccessfulComponentDeployment scd = (SuccessfulComponentDeployment)o2;
logger.debug("Got SuccessfulComponentDeployment with: " + scd.getComponent() + " " + scd.getHostingComponent() + " " + scd.getExecutionContextID() + " " + scd.getSlos());
}
//System.out.println("Returned object: " + o2.toString());
for (Object o: mc.getElements()){
Node node = (Node)o;
Object o2 = um.unmarshal(node);
if (o2 instanceof BestApplicationDeployment){
BestApplicationDeployment bad = (BestApplicationDeployment)o2;
logger.debug("Got BestApplicationDeployment with: " + bad.getId() + " " + bad.getApplication() + " " + bad.getDeploymentModel() + " " + bad.getMetrics());
}
else if (o2 instanceof BestComponentDeployment){
BestComponentDeployment bad = (BestComponentDeployment)o2;
logger.debug("Got BestComponentDeployment with: " + bad.getId() + " " + bad.getComponent() + " " + bad.getHostingComponent() + " " + bad.getMetrics());
}
else if (o2 instanceof ApplicationMatch){
ApplicationMatch match = (ApplicationMatch)o2;
logger.debug("Got ApplicationMatch with: " + match.getFirstApplicationID() + " " + match.getSecondApplicationID() + " " + match.getApplicationMatching());
}
else if (o2 instanceof ComponentMatch){
ComponentMatch match = (ComponentMatch)o2;
logger.debug("Got ComponentMatch with: " + match.getFirstInternalComponentID() + " " + match.getSecondInternalComponentID());
}
else if (o2 instanceof SuccessfulApplicationDeployment){
SuccessfulApplicationDeployment sad = (SuccessfulApplicationDeployment)o2;
logger.debug("Got SuccessfulApplicationDeployment with: " + sad.getApplication() + " " + sad.getDeploymentModel() + " " + sad.getExecutionContexts() + " " + sad.getSlos());
}
else if (o2 instanceof SuccessfulComponentDeployment){
SuccessfulComponentDeployment scd = (SuccessfulComponentDeployment)o2;
logger.debug("Got SuccessfulComponentDeployment with: " + scd.getComponent() + " " + scd.getHostingComponent() + " " + scd.getExecutionContextID() + " " + scd.getSlos());
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment