Esempio n. 1
0
  @WebMethod
  public ReadResponse Save(
      @XmlElement(required = true, nillable = false) @WebParam(name = "request")
          SaveRequest request)
      throws Exception {

    ReadResponse response = new ReadResponse();
    response.setError(new GatewayError("0", "SUCCESS", "SAVE"));

    for (GatewayRecord parentRecord : request.getParentRecord()) {
      String operationName = "Create";
      String entityIdFieldName = parentRecord.getEntity() + "Id";
      for (GatewayField field : parentRecord.getField()) {
        if (field.getName().equalsIgnoreCase(entityIdFieldName) && !field.getValue().equals("0")) {
          log.fine("Found update operation for entityId: [" + field.getValue() + "]");
          operationName = "Update";
          break;
        }
      }

      CreateRequest transactionRequest = new CreateRequest();
      transactionRequest.setParentRecord(parentRecord);

      Cruddable entityProxy = getCruddable(parentRecord.getEntity());
      ReadResponse transactionResponse = null;
      if (operationName.equals("Create")) {
        log.info("Executing create operation with record: [" + transactionRequest + "]");
        transactionResponse = entityProxy.Create(transactionRequest);
      } else {
        log.info("Executing update operation with record: [" + transactionRequest + "]");
        transactionResponse = entityProxy.Update(transactionRequest);
      }

      if (!transactionResponse.getError().getExceptionId().equals("0")) {
        log.severe("An exception has occured during transaction processing.");
        response.setError(transactionResponse.getError());
        return response;
      } else {
        log.fine("Transaction succesfully executed, building response.");
        for (GatewayRecord responseRecord : transactionResponse.getParentRecord()) {
          log.finer("Adding response record: " + responseRecord);
          response.addParentRecord(responseRecord);
        }
      }
    }

    return response;
  }
Esempio n. 2
0
  @WebMethod
  public ReadResponse Update(
      @XmlElement(required = true, nillable = false) @WebParam(name = "request")
          CreateRequest request) {
    log.entering(this.getClass().getCanonicalName(), "Update");
    log.info("Update gateway invoked with the following content: [" + request + "]");

    Cruddable entityProxy = getCruddable(request.getParentRecord().getEntity());
    log.exiting(this.getClass().getCanonicalName(), "Update");

    ReadResponse response = entityProxy.Update(request);
    log.info(
        "Update gateway completed by " + getLoggedUser() + " as: [" + response.getError() + "]");

    return response;
  }