use of org.jaffa.soa.graph.ServiceError in project jaffa-framework by jaffa-projects.
the class GraphCreateThread method run.
@Override
public void run() {
UserContextWrapper ucw = null;
ApplicationExceptions appExps = new ApplicationExceptions();
try {
synchronized (this) {
ucw = UserContextWrapperFactory.instance(userId);
}
List<GraphDataObject> graphs = new ArrayList<GraphDataObject>();
graphs.add(this.graph);
GraphService service = (GraphService) serviceClazz.newInstance();
Object graphArray = Array.newInstance(graph.getClass(), 1);
Array.set(graphArray, 0, graph);
Method m = serviceClazz.getDeclaredMethod("update", graphArray.getClass());
GraphUpdateResponse[] responses = (GraphUpdateResponse[]) m.invoke(serviceClazz.newInstance(), graphArray);
if (responses != null && responses.length > 0) {
for (GraphUpdateResponse response : responses) {
ServiceError[] faults = response.getErrors();
if (faults != null && faults.length > 0) {
for (ServiceError fault : faults) {
appExps.add(new ApplicationException("error", new String[] { fault.getLocalizedMessage() }));
}
}
synchronized (this) {
test.getUpdateResponses().add(response);
}
}
}
if (appExps.size() > 0)
throw appExps;
} catch (ApplicationExceptions | UserSessionSetupException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
log.error(e);
} finally {
synchronized (this) {
if (ucw != null)
ucw.unsetContext();
}
}
}
Aggregations