Search in sources :

Example 1 with GraphService

use of org.jaffa.soa.dataaccess.GraphService 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();
        }
    }
}
Also used : ServiceError(org.jaffa.soa.graph.ServiceError) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) GraphDataObject(org.jaffa.soa.graph.GraphDataObject) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) UserSessionSetupException(org.jaffa.presentation.portlet.session.UserSessionSetupException) InvocationTargetException(java.lang.reflect.InvocationTargetException) GraphService(org.jaffa.soa.dataaccess.GraphService) ApplicationException(org.jaffa.exceptions.ApplicationException) UserContextWrapper(org.jaffa.modules.user.services.UserContextWrapper) GraphDataObject(org.jaffa.soa.graph.GraphDataObject) GraphUpdateResponse(org.jaffa.soa.graph.GraphUpdateResponse)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 ApplicationException (org.jaffa.exceptions.ApplicationException)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1 UserContextWrapper (org.jaffa.modules.user.services.UserContextWrapper)1 UserSessionSetupException (org.jaffa.presentation.portlet.session.UserSessionSetupException)1 GraphService (org.jaffa.soa.dataaccess.GraphService)1 GraphDataObject (org.jaffa.soa.graph.GraphDataObject)1 GraphUpdateResponse (org.jaffa.soa.graph.GraphUpdateResponse)1 ServiceError (org.jaffa.soa.graph.ServiceError)1