Beispiel #1
0
  public static MESSAGE createFiletransfer(
      List<String> receivers, byte[] data, Map<String, String> parameters) {
    ObjectFactory objectFactory = new ObjectFactory();
    MESSAGE request = objectFactory.createMESSAGE();
    request.setParameters(objectFactory.createMESSAGEParameters());
    request.setReceivers(objectFactory.createMESSAGEReceivers());
    request.setType(REQUEST);
    request.setName(Request.FILETRANSFER);

    if (data != null) {
      request.setData(data);
    }

    if (receivers != null) {
      for (String receiver : receivers) {
        request.getReceivers().getReceiver().add(receiver);
      }
    }
    if (parameters != null) {

      Set<String> paramKeys = parameters.keySet();
      for (String key : paramKeys) {
        MESSAGE.Parameters.Parameter msgParamter = objectFactory.createMESSAGEParametersParameter();
        msgParamter.setName(key);
        msgParamter.setValue(parameters.get(key));
        request.getParameters().getParameter().add(msgParamter);
      }
    }
    return request;
  }
Beispiel #2
0
  public static MESSAGE createCommand(String name, Map<String, String> parameters) {
    ObjectFactory objectFactory = new ObjectFactory();
    MESSAGE request = objectFactory.createMESSAGE();
    request.setParameters(objectFactory.createMESSAGEParameters());
    request.setReceivers(objectFactory.createMESSAGEReceivers());
    request.setType(COMMAND);
    if (name != null) {
      request.setName(name);
    }
    //        if (receivers != null) {
    //            for (String receiver : receivers) {
    //                request.getReceivers().getReceiver().add(receiver);
    //            }
    //        }
    if (parameters != null) {

      Set<String> paramKeys = parameters.keySet();
      for (String key : paramKeys) {
        MESSAGE.Parameters.Parameter msgParamter = objectFactory.createMESSAGEParametersParameter();
        msgParamter.setName(key);
        msgParamter.setValue(parameters.get(key));
        request.getParameters().getParameter().add(msgParamter);
      }
    }
    return request;
  }
Beispiel #3
0
  public static void addContentAt(MESSAGE message, String name, byte[] data, int position) {
    ObjectFactory objectFactory = new ObjectFactory();

    MESSAGE.Contents.Content content = objectFactory.createMESSAGEContentsContent();
    content.setName(name);
    content.setValue(data);
    message.getContents().getContent().add(position, content);
  }
Beispiel #4
0
  public static void addParameterAt(MESSAGE message, String name, String parameter, int position) {
    ObjectFactory objectFactory = new ObjectFactory();

    MESSAGE.Parameters.Parameter msgParamter = objectFactory.createMESSAGEParametersParameter();
    msgParamter.setName(name);
    msgParamter.setValue(parameter);
    message.getParameters().getParameter().add(position, msgParamter);
  }
Beispiel #5
0
  public static MESSAGE parseXML(String xml) {
    ObjectFactory objectFactory = new ObjectFactory();
    MESSAGE toReturn = objectFactory.createMESSAGE();

    try {
      javax.xml.bind.JAXBContext jaxbCtx =
          javax.xml.bind.JAXBContext.newInstance(toReturn.getClass().getPackage().getName());
      javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
      toReturn =
          (MESSAGE) unmarshaller.unmarshal(new StreamSource(new StringReader(xml))); // NOI18N

      return toReturn;
    } catch (javax.xml.bind.JAXBException ex) {
      // XXXTODO Handle exception
      log.error(ex); // NOI18N

      return null;
    }
  }
Beispiel #6
0
  public static MESSAGE createMessage(
      String name, List<String> receivers, Map<String, String> parameters) {
    ObjectFactory objectFactory = new ObjectFactory();
    MESSAGE request = objectFactory.createMESSAGE();
    request.setParameters(objectFactory.createMESSAGEParameters());
    request.setReceivers(objectFactory.createMESSAGEReceivers());
    request.setContents(objectFactory.createMESSAGEContents());
    request.setType(MESSAGE);
    if (name != null) {
      request.setName(name);
    }
    if (receivers != null) {
      for (String receiver : receivers) {
        request.getReceivers().getReceiver().add(receiver);
      }
    }
    if (parameters != null) {

      Set<String> paramKeys = parameters.keySet();
      for (String key : paramKeys) {
        MESSAGE.Parameters.Parameter msgParamter = objectFactory.createMESSAGEParametersParameter();
        msgParamter.setName(key);
        msgParamter.setValue(parameters.get(key));
        request.getParameters().getParameter().add(msgParamter);
      }
    }
    return request;
  }