Class JSyncUtil

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

public class JSyncUtil extends Object implements JSyncConstants
This class provides utility methods
Author:
Olivier Dedieu
  • Field Details

    • logger

      public static final org.apache.log4j.Logger logger
  • Constructor Details

    • JSyncUtil

      public JSyncUtil()
  • Method Details

    • sendMessage

      public static AckMessage sendMessage(String url, Message msg, String secret, int timeout)
      Send a message
      Parameters:
      url - the url the message must be sent to
      msg - the message to be sent
      secret - the sharedSecret
      timeout - request timeout
      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 - if an error occurs
      IOException - if an error occurs
      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 - if an error occurs
      IOException - if an error occurs
      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)