Search in sources :

Example 1 with InternalHttpServletRequest

use of com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest in project convertigo by convertigo.

the class Project method executeAutoStartSequences.

public static void executeAutoStartSequences(final String projectName) {
    try {
        final Project p = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
        if (p != null) {
            for (final Sequence sequence : p.getSequencesList()) {
                if (sequence.isAutoStart()) {
                    Engine.execute(() -> {
                        try {
                            Map<String, String[]> parameters = new HashMap<String, String[]>();
                            parameters.put(Parameter.Project.getName(), new String[] { projectName });
                            parameters.put(Parameter.Sequence.getName(), new String[] { sequence.getName() });
                            InternalHttpServletRequest request = new InternalHttpServletRequest();
                            InternalRequester requester = new InternalRequester(GenericUtils.<Map<String, Object>>cast(parameters), request);
                            requester.processRequest();
                        } catch (Exception e) {
                            Engine.logEngine.error("Failed to execute the auto start sequence \"" + sequence.getQName() + "\"", e);
                        }
                    });
                }
            }
        }
    } catch (Exception e) {
        Engine.logEngine.error("Failed to execute auto start sequences for project \"" + projectName + "\"", e);
    }
}
Also used : InternalHttpServletRequest(com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest) HashMap(java.util.HashMap) InternalRequester(com.twinsoft.convertigo.engine.requesters.InternalRequester) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 2 with InternalHttpServletRequest

use of com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest in project convertigo by convertigo.

the class SequenceEditorPartWrap method runRequestable.

private void runRequestable(final String projectName, final Map<String, String[]> parameters) {
    if (!Engine.isStartFailed && Engine.isStarted) {
        parameters.put(Parameter.Project.getName(), new String[] { projectName });
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    InternalHttpServletRequest request;
                    if (session == null) {
                        request = new InternalHttpServletRequest();
                        session = request.getSession();
                    } else {
                        request = new InternalHttpServletRequest(session);
                    }
                    new InternalRequester(GenericUtils.<Map<String, Object>>cast(parameters), request).processRequest();
                } catch (Exception e) {
                // logException(e, "Failed to run the requestable of project " + projectName);
                }
            }
        }).start();
    } else {
    // logInfo("Cannot run the requestable of project " + projectName + ", the embedded tomcat is not correctly started.");
    }
}
Also used : InternalHttpServletRequest(com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest) InternalRequester(com.twinsoft.convertigo.engine.requesters.InternalRequester) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with InternalHttpServletRequest

use of com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest in project convertigo by convertigo.

the class ConnectorEditorPartWrap method runRequestable.

private void runRequestable(final String projectName, final Map<String, String[]> parameters) {
    if (!Engine.isStartFailed && Engine.isStarted) {
        parameters.put(Parameter.Project.getName(), new String[] { projectName });
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    InternalHttpServletRequest request;
                    if (session == null) {
                        request = new InternalHttpServletRequest();
                        session = request.getSession();
                    } else {
                        request = new InternalHttpServletRequest(session);
                    }
                    new InternalRequester(GenericUtils.<Map<String, Object>>cast(parameters), request).processRequest();
                } catch (Exception e) {
                // logException(e, "Failed to run the requestable of project " + projectName);
                }
            }
        }).start();
    } else {
    // logInfo("Cannot run the requestable of project " + projectName + ", the embedded tomcat is not correctly started.");
    }
}
Also used : InternalHttpServletRequest(com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest) InternalRequester(com.twinsoft.convertigo.engine.requesters.InternalRequester) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with InternalHttpServletRequest

use of com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest in project convertigo by convertigo.

the class AbstractFullSyncListener method onBulkDocs.

public void onBulkDocs(HttpServletRequest request, final JSONArray array) {
    if (isEnabled()) {
        final InternalHttpServletRequest internalRequest = new InternalHttpServletRequest(request);
        Engine.execute(new Runnable() {

            @Override
            public void run() {
                try {
                    triggerSequence(internalRequest, array);
                } catch (Exception e) {
                    Engine.logBeans.error("Unable to handle 'bulkDocs' event for \"" + getName() + "\" listener", e);
                }
            }
        });
    }
}
Also used : InternalHttpServletRequest(com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest) JSONException(org.codehaus.jettison.json.JSONException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 5 with InternalHttpServletRequest

use of com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest in project convertigo by convertigo.

the class ConvertigoPlugin method runRequestable.

public void runRequestable(final String projectName, final Map<String, String[]> parameters) {
    if (!Engine.isStartFailed && Engine.isStarted) {
        parameters.put(Parameter.Project.getName(), new String[] { projectName });
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    InternalHttpServletRequest request;
                    if (session == null || session.getMaxInactiveInterval() <= 1) {
                        request = new InternalHttpServletRequest();
                        session = request.getSession("studio");
                    } else {
                        request = new InternalHttpServletRequest(session);
                    }
                    InternalRequester requester = new InternalRequester(GenericUtils.<Map<String, Object>>cast(parameters), request);
                    HttpSessionListener.checkSession(requester.getHttpServletRequest());
                    requester.processRequest();
                } catch (Exception e) {
                    logException(e, "Failed to run the requestable of project " + projectName);
                }
            }
        }).start();
    } else {
        logInfo("Cannot run the requestable of project " + projectName + ", the embedded tomcat is not correctly started.");
    }
}
Also used : InternalHttpServletRequest(com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest) InternalRequester(com.twinsoft.convertigo.engine.requesters.InternalRequester) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) MissingResourceException(java.util.MissingResourceException) IntrospectionException(java.beans.IntrospectionException) IOException(java.io.IOException) WorkbenchException(org.eclipse.ui.WorkbenchException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

InternalHttpServletRequest (com.twinsoft.convertigo.engine.requesters.InternalHttpServletRequest)5 InternalRequester (com.twinsoft.convertigo.engine.requesters.InternalRequester)4 EngineException (com.twinsoft.convertigo.engine.EngineException)3 HashMap (java.util.HashMap)3 Map (java.util.Map)2 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)1 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)1 IntrospectionException (java.beans.IntrospectionException)1 IOException (java.io.IOException)1 MissingResourceException (java.util.MissingResourceException)1 JSONException (org.codehaus.jettison.json.JSONException)1 CoreException (org.eclipse.core.runtime.CoreException)1 PartInitException (org.eclipse.ui.PartInitException)1 WorkbenchException (org.eclipse.ui.WorkbenchException)1