Пример #1
0
  private void generateHeader() {
    SyncmlHeader sourceHeader = syncmlDocument.getHeader();
    SyncmlHeader header = new SyncmlHeader();
    header.setMsgID(sourceHeader.getMsgID());
    header.setSessionId(sourceHeader.getSessionId());
    Target target = new Target();
    target.setLocURI(sourceHeader.getSource().getLocURI());
    header.setTarget(target);

    Source source = new Source();
    source.setLocURI(sourceHeader.getTarget().getLocURI());
    header.setSource(source);
    replySyncmlDocument.setHeader(header);
  }
Пример #2
0
  private SyncmlBody generateStatuses() {
    SyncmlBody sourceSyncmlBody = syncmlDocument.getBody();
    SyncmlHeader sourceHeader = syncmlDocument.getHeader();
    SyncmlBody syncmlBodyReply = new SyncmlBody();
    List<Status> status = new ArrayList<Status>();
    Status headerStatus =
        new Status(
            HEADER_COMMAND_REFERENCE_ID,
            sourceHeader.getMsgID(),
            HEADER_STATUS_ID,
            HEADER_COMMAND_TEXT,
            sourceHeader.getSource().getLocURI(),
            String.valueOf(Constants.SyncMLResponseCodes.AUTHENTICATION_ACCEPTED));
    status.add(headerStatus);
    if (sourceSyncmlBody.getAlert() != null) {
      Status alertStatus =
          new Status(
              sourceSyncmlBody.getAlert().getCommandId(),
              HEADER_COMMAND_REFERENCE_ID,
              sourceSyncmlBody.getAlert().getCommandId(),
              ALERT_COMMAND_TEXT,
              null,
              String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED));
      status.add(alertStatus);
    }
    if (sourceSyncmlBody.getReplace() != null) {
      Status replaceStatus =
          new Status(
              sourceSyncmlBody.getReplace().getCommandId(),
              HEADER_COMMAND_REFERENCE_ID,
              sourceSyncmlBody.getReplace().getCommandId(),
              REPLACE_COMMAND_TEXT,
              null,
              String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED));
      status.add(replaceStatus);
    }
    if (sourceSyncmlBody.getExec() != null) {
      Status replaceStatus =
          new Status(
              sourceSyncmlBody.getExec().getCommandId(),
              HEADER_COMMAND_REFERENCE_ID,
              sourceSyncmlBody.getExec().getCommandId(),
              GET_COMMAND_TEXT,
              null,
              String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED));
      status.add(replaceStatus);
    }
    if (sourceSyncmlBody.getGet() != null) {
      Status execStatus =
          new Status(
              sourceSyncmlBody.getGet().getCommandId(),
              HEADER_COMMAND_REFERENCE_ID,
              sourceSyncmlBody.getGet().getCommandId(),
              EXEC_COMMAND_TEXT,
              null,
              String.valueOf(Constants.SyncMLResponseCodes.ACCEPTED));
      status.add(execStatus);
    }

    syncmlBodyReply.setStatus(status);
    return syncmlBodyReply;
  }