package org.silverpeas.mobile.shared.services.rest;

import static org.fusesource.restygwt.client.AbstractJsonEncoderDecoder.*;

public class ServiceFormsOnline_Generated_RestServiceProxy_ implements org.silverpeas.mobile.shared.services.rest.ServiceFormsOnline, org.fusesource.restygwt.client.RestServiceProxy {
  private org.fusesource.restygwt.client.Resource resource = null;
  
  public void setResource(org.fusesource.restygwt.client.Resource resource) {
    this.resource = resource;
  }
  public org.fusesource.restygwt.client.Resource getResource() {
    if (this.resource == null) {
      String serviceRoot = org.fusesource.restygwt.client.Defaults.getServiceRoot();
      this.resource = new org.fusesource.restygwt.client.Resource(serviceRoot).resolve("/mobile/formsOnline");
    }
    return this.resource;
  }
  private org.fusesource.restygwt.client.Dispatcher dispatcher = null;
  
  public void setDispatcher(org.fusesource.restygwt.client.Dispatcher dispatcher) {
    this.dispatcher = dispatcher;
  }
  
  public org.fusesource.restygwt.client.Dispatcher getDispatcher() {
    return this.dispatcher;
  }
  public void getForm(java.lang.String appId, java.lang.String formName, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.FormFieldDTO>> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_formName = formName;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/form/"+(formName== null? null : com.google.gwt.http.client.URL.encodePathSegment(formName))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.FormFieldDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.FormFieldDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.FormFieldDTO_Generated_JsonEncoderDecoder_.INSTANCE);
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getFormLayer(java.lang.String appId, java.lang.String formName, java.lang.String layerType, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.formsonline.FormLayerDTO> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_formName = formName;
    final java.lang.String final_layerType = layerType;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/formlayer/"+(formName== null? null : com.google.gwt.http.client.URL.encodePathSegment(formName))+"/"+(layerType== null? null : com.google.gwt.http.client.URL.encodePathSegment(layerType))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.dto.formsonline.FormLayerDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.formsonline.FormLayerDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.formsonline.FormLayerDTO_Generated_JsonEncoderDecoder_.INSTANCE.decode(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()));
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getMyRequests(java.lang.String appId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO>> callback) {
    final java.lang.String final_appId = appId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/myrequests")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO_Generated_JsonEncoderDecoder_.INSTANCE);
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getReceivablesForms(java.lang.String appId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormDTO>> callback) {
    final java.lang.String final_appId = appId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/receivables")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.formsonline.FormDTO_Generated_JsonEncoderDecoder_.INSTANCE);
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getRequests(java.lang.String appId, java.lang.String formId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO>> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_formId = formId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/requests/"+(formId== null? null : com.google.gwt.http.client.URL.encodePathSegment(formId))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO_Generated_JsonEncoderDecoder_.INSTANCE);
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getSendablesForms(java.lang.String appId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormDTO>> callback) {
    final java.lang.String final_appId = appId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/sendables")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.formsonline.FormDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.formsonline.FormDTO_Generated_JsonEncoderDecoder_.INSTANCE);
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void getUserField(java.lang.String appId, java.lang.String formName, java.lang.String fieldName, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.BaseDTO>> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_formName = formName;
    final java.lang.String final_fieldName = fieldName;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/form/"+(formName== null? null : com.google.gwt.http.client.URL.encodePathSegment(formName))+"/"+(fieldName== null? null : com.google.gwt.http.client.URL.encodePathSegment(fieldName))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.BaseDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.BaseDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.BaseDTO_Generated_JsonEncoderDecoder_.INSTANCE);
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void loadRequest(java.lang.String appId, java.lang.String requestId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_requestId = requestId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/loadRequest/"+(requestId== null? null : com.google.gwt.http.client.URL.encodePathSegment(requestId))+"")
    .post();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.formsonline.FormRequestDTO_Generated_JsonEncoderDecoder_.INSTANCE.decode(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()));
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void processRequest(java.lang.String appId, java.lang.String requestId, org.silverpeas.mobile.shared.dto.formsonline.ValidationRequestDTO validation, org.fusesource.restygwt.client.MethodCallback<java.lang.Void> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_requestId = requestId;
    final org.silverpeas.mobile.shared.dto.formsonline.ValidationRequestDTO final_validation = validation;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/processRequest/"+(requestId== null? null : com.google.gwt.http.client.URL.encodePathSegment(requestId))+"")
    .post();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    __method.json(org.silverpeas.mobile.shared.dto.formsonline.ValidationRequestDTO_Generated_JsonEncoderDecoder_.INSTANCE.encode(validation));
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.lang.Void>(__method, callback) {
        protected java.lang.Void parseResult() throws Exception {
          return (java.lang.Void) null;
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
  public void saveForm(java.lang.String appId, java.lang.String formId, org.fusesource.restygwt.client.MethodCallback<java.lang.Boolean> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_formId = formId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/saveForm/"+(formId== null? null : com.google.gwt.http.client.URL.encodePathSegment(formId))+"")
    .post();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, org.fusesource.restygwt.client.Resource.CONTENT_TYPE_JSON);
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.lang.Boolean>(__method, callback) {
        protected java.lang.Boolean parseResult() throws Exception {
          try {
            return BOOLEAN.decode(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()));
          } catch (Throwable __e) {
            throw new org.fusesource.restygwt.client.ResponseFormatException("Response was NOT a valid JSON document", __e);
          }
        }
      });
    } catch (com.google.gwt.http.client.RequestException __e) {
      callback.onFailure(__method,__e);
    }
  }
}
