com.jalios.jstore.jsync
Class JSyncUtil

java.lang.Object
  extended by com.jalios.jstore.jsync.JSyncUtil
All Implemented Interfaces:
JSyncConstants, JaliosConstants

public class JSyncUtil
extends Object
implements JSyncConstants

This class provides utility methods

Version:
$Revision: 27753 $
Author:
Olivier Dedieu

Field Summary
static org.apache.log4j.Logger logger
           
static String REVISION
           
 
Fields inherited from interface com.jalios.jstore.jsync.JSyncConstants
SC_BAD_ADDRESS, SC_BAD_LEADER, SC_BAD_MESSAGE, SC_INTERNAL_SERVER_ERROR, SC_JOIN_REJECTED, SC_LEADER_CANNOT_JOIN, SC_NO_ACK, SC_NO_SEND, SC_OK, SC_UNKNOWN, SC_UNKNOWN_URID, SC_URID_ALREADY_ADDED, STATUS_LEADER, STATUS_LONE, STATUS_MEMBER, STATUS_SUBLEADER
 
Fields inherited from interface com.jalios.util.JaliosConstants
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
 
Constructor Summary
JSyncUtil()
           
 
Method Summary
static boolean checkIP(javax.servlet.ServletRequest request, org.apache.oro.text.regex.Pattern ipPattern)
           
static int cleanStatusCode(int status)
           
static String getStatusPhrase(int status)
          Returns an english phrase associated to the given status code.
static void main(String[] args)
           
static AckMessage readAck(InputStream in)
          Read and parse an AckMessage
static AckMessage readAck(String responseBody)
          Read and parse an AckMessage
static Message readMessage(InputStream in)
          Read and parse a Message
static Message readMessage(String responseBody)
          Read and parse a Message
static AckMessage sendMessage(String url, Message msg)
          Send a message
static void writeAck(OutputStream out, String urid, int status, StampTable progressTable)
          Write an AckMessage
static void writeMessage(OutputStream out, Message msg)
          Write a Message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

logger

public static final org.apache.log4j.Logger logger
Constructor Detail

JSyncUtil

public JSyncUtil()
Method Detail

sendMessage

public static AckMessage sendMessage(String url,
                                     Message msg)
Send a message

Parameters:
url - the url the message must be sent to
msg - the message to be sent
Returns:
the AckMessage
Since:
jcms-4.1

writeAck

public static void writeAck(OutputStream out,
                            String urid,
                            int status,
                            StampTable progressTable)
Write an AckMessage

Parameters:
out - the OutputStream to use for writing the message
urid - the URID of the sender
status - the status code
progressTable - the progressTable of the sender
Since:
jcms-4.1

readAck

public static AckMessage readAck(InputStream in)
Read and parse an AckMessage

Parameters:
in - the InputStream that contains the message to be read
Returns:
an AckMessage or null if the message have not been correctly parsed
Since:
jcms-4.1

readAck

public static AckMessage readAck(String responseBody)
Read and parse an AckMessage

Parameters:
responseBody - a string containing the message to be read, usually the response body of JSync http request.
Returns:
an AckMessage or null if the message could not be parsed
Since:
jcms-5.7.5

writeMessage

public static void writeMessage(OutputStream out,
                                Message msg)
Write a Message

Parameters:
out - the OutputStream to use for writing the message
msg - the message to write
Since:
jcms-4.1

readMessage

public static Message readMessage(InputStream in)
                           throws org.jdom.JDOMException,
                                  IOException
Read and parse a Message

Parameters:
in - the InputStream that contains the message to be read
Returns:
an instance of a sub class of Message class, or null if the message have not been correctly parsed
Throws:
org.jdom.JDOMException
IOException
Since:
jcms-4.1

readMessage

public static Message readMessage(String responseBody)
                           throws org.jdom.JDOMException,
                                  IOException
Read and parse a Message

Parameters:
responseBody - a string containing the message to be read, usually the response body of JSync http request.
Returns:
an instance of a sub class of Message class, or null if the message could not be parsed
Throws:
org.jdom.JDOMException
IOException
Since:
jcms-5.7.5

cleanStatusCode

public static int cleanStatusCode(int status)

getStatusPhrase

public static String getStatusPhrase(int status)
Returns an english phrase associated to the given status code.

Parameters:
status - the status code
Returns:
an english phrase associated to the given status code.
Since:
jcms-4.1

checkIP

public static boolean checkIP(javax.servlet.ServletRequest request,
                              org.apache.oro.text.regex.Pattern ipPattern)

main

public static void main(String[] args)


Copyright © 2001-2010 Jalios SA. All Rights Reserved.