All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tinkerpop.rexster.protocol.msg.MessageUtil Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package com.tinkerpop.rexster.protocol.msg;

import java.util.List;
import java.util.UUID;

/**
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public class MessageUtil {
    public static ErrorResponseMessage createErrorResponse(final byte[] request, final byte[] session,
                                                           final byte flag, final String errorMessage) {
        final ErrorResponseMessage msg = new ErrorResponseMessage();
        msg.Request = request;
        msg.Session = session;
        msg.ErrorMessage = errorMessage;
        msg.Flag = flag;

        return msg;
    }

    public static SessionResponseMessage createNewSession(byte[] request, final List languages) {
        final UUID sessionKey = UUID.randomUUID();

        final SessionResponseMessage responseMessage = new SessionResponseMessage();
        responseMessage.setSessionAsUUID(sessionKey);
        responseMessage.Request = request;
        responseMessage.Flag = MessageFlag.SESSION_RESPONSE_NO_FLAG;
        responseMessage.Languages = new String[languages.size()];
        languages.toArray(responseMessage.Languages);

        return responseMessage;
    }

    public static SessionResponseMessage createEmptySession(byte[] request) {
        final SessionResponseMessage responseMessage = new SessionResponseMessage();
        responseMessage.setSessionAsUUID(RexProMessage.EMPTY_SESSION);
        responseMessage.Request = request;
        responseMessage.Languages = new String[0];
        responseMessage.Flag = MessageFlag.SESSION_RESPONSE_NO_FLAG;

        return responseMessage;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy