Package com.tinkerpop.rexster.protocol.session

Examples of com.tinkerpop.rexster.protocol.session.AbstractRexProSession


        this.failedExecutions = metricRegistry.counter(MetricRegistry.name("rexpro", "script-engine", "fail"));
    }
    public void handleRequest(ScriptRequestMessage message, RexProRequest request) throws IOException {

        try {
            final AbstractRexProSession session;
            Graph graph = null;

            message.validateMetaData();
            if (message.metaGetInSession()) {
                if (message.Session == null) {
                    logger.error("no session key on message");
                    request.writeResponseMessage(
                        MessageUtil.createErrorResponse(
                            message.Request,
                            RexProMessage.EMPTY_SESSION_AS_BYTES,
                            ErrorResponseMessage.INVALID_SESSION_ERROR,
                            "There was no session key on the message, set the meta field 'inSession' to false if you want to execute sessionless requests"
                        )
                    );
                }

                //session script request
                session = RexProSessions.getSession(message.sessionAsUUID().toString());

                // validate session and channel
                if (sessionDoesNotExist(request, message, session)) return;

                graph = session.getGraphObj();

                // catch any graph redefinition attempts
                if (graphIsRedefined(request, message, message, graph)) return;

            } else {
                session = new EmptySession(rexsterApplication);
            }

            Bindings bindings = message.getBindings();

            // add the graph object to the bindings
            if (message.metaGetGraphName() != null) {
                graph = rexsterApplication.getGraph(message.metaGetGraphName());
                bindings.put(message.metaGetGraphObjName(), graph);
                if (graph == null) {
                    // graph config problem
                    request.writeResponseMessage(
                            MessageUtil.createErrorResponse(
                                    message.Request, RexProMessage.EMPTY_SESSION_AS_BYTES,
                                    ErrorResponseMessage.GRAPH_CONFIG_ERROR,
                                    "the graph '" + message.metaGetGraphName() + "' was not found by Rexster"
                            )
                    );
                    return;
                }
            }

            final Timer.Context timer = scriptTimer.time();
            try {

                // execute script
                session.evaluate(
                        message.Script,
                        message.LanguageName,
                        bindings,
                        message.metaGetIsolate(),
                        message.metaGetTransaction(),
View Full Code Here

TOP

Related Classes of com.tinkerpop.rexster.protocol.session.AbstractRexProSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.