Package com.jalios.jstore.jsync
Class JSyncUtil
- java.lang.Object
-
- com.jalios.jstore.jsync.JSyncUtil
-
- All Implemented Interfaces:
JSyncConstants
,JaliosConstants
public class JSyncUtil extends java.lang.Object implements JSyncConstants
This class provides utility methods- Version:
- $Revision: 125009 $
- Author:
- Olivier Dedieu
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.log4j.Logger
logger
static java.lang.String
REVISION
-
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
-
Fields inherited from interface com.jalios.jstore.jsync.JSyncConstants
SC_BAD_ADDRESS, SC_BAD_LEADER, SC_BAD_MESSAGE, SC_DISCONNECTED, 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_DISCONNECTED, STATUS_LEADER, STATUS_LONE, STATUS_MEMBER, STATUS_SUBLEADER
-
-
Constructor Summary
Constructors Constructor Description JSyncUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkIP(javax.servlet.ServletRequest request, org.apache.oro.text.regex.Pattern ipPattern)
static int
cleanStatusCode(int status)
static java.lang.String
getStatusPhrase(int status)
Returns an english phrase associated to the given status code.static void
main(java.lang.String[] args)
static AckMessage
readAck(java.io.InputStream in)
Read and parse an AckMessagestatic AckMessage
readAck(java.lang.String responseBody)
Read and parse an AckMessagestatic Message
readMessage(java.io.InputStream in)
Read and parse a Messagestatic Message
readMessage(java.lang.String responseBody)
Read and parse a Messagestatic AckMessage
sendMessage(java.lang.String url, Message msg, java.lang.String sharedSecret)
Send a messagestatic void
writeAck(java.io.OutputStream out, java.lang.String urid, int status, StampTable progressTable)
Write an AckMessagestatic void
writeMessage(java.io.OutputStream out, Message msg)
Write a Message
-
-
-
Field Detail
-
REVISION
public static final java.lang.String REVISION
- See Also:
- Constant Field Values
-
logger
public static final org.apache.log4j.Logger logger
-
-
Method Detail
-
sendMessage
public static AckMessage sendMessage(java.lang.String url, Message msg, java.lang.String sharedSecret)
Send a message- Parameters:
url
- the url the message must be sent tomsg
- the message to be sentsharedSecret
- the sharedSecret- Returns:
- the AckMessage
- Since:
- jcms-4.1
-
writeAck
public static void writeAck(java.io.OutputStream out, java.lang.String urid, int status, StampTable progressTable)
Write an AckMessage- Parameters:
out
- the OutputStream to use for writing the messageurid
- the URID of the senderstatus
- the status codeprogressTable
- the progressTable of the sender- Since:
- jcms-4.1
-
readAck
public static AckMessage readAck(java.io.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(java.lang.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(java.io.OutputStream out, Message msg)
Write a Message- Parameters:
out
- the OutputStream to use for writing the messagemsg
- the message to write- Since:
- jcms-4.1
-
readMessage
public static Message readMessage(java.io.InputStream in) throws org.jdom.JDOMException, java.io.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
- if an error occursjava.io.IOException
- if an error occurs- Since:
- jcms-4.1
-
readMessage
public static Message readMessage(java.lang.String responseBody) throws org.jdom.JDOMException, java.io.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
- if an error occursjava.io.IOException
- if an error occurs- Since:
- jcms-5.7.5
-
cleanStatusCode
public static int cleanStatusCode(int status)
-
getStatusPhrase
public static java.lang.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(java.lang.String[] args)
-
-