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

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

public class ServiceDocuments_Generated_RestServiceProxy_ implements org.silverpeas.mobile.shared.services.rest.ServiceDocuments, 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/documents");
    }
    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 deleteTickets(java.lang.String appId, java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO> tickets, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO>> callback) {
    final java.lang.String final_appId = appId;
    final java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO> final_tickets = tickets;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/deletetickets")
    .post();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    __method.json(toJSON(tickets, org.silverpeas.mobile.shared.dto.tickets.TicketDTO_Generated_JsonEncoderDecoder_.INSTANCE));
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.tickets.TicketDTO_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 getAttachment(java.lang.String appId, java.lang.String attachmentId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.documents.AttachmentDTO> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_attachmentId = attachmentId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/attachment/"+(attachmentId== null? null : com.google.gwt.http.client.URL.encodePathSegment(attachmentId))+"")
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.dto.documents.AttachmentDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.documents.AttachmentDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.documents.AttachmentDTO_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 getNextPublication(java.lang.String appId, java.lang.String id, java.lang.String direction, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.documents.PublicationDTO> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_id = id;
    final java.lang.String final_direction = direction;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/nextpublication/"+(id== null? null : com.google.gwt.http.client.URL.encodePathSegment(id))+"/"+(direction== null? null : com.google.gwt.http.client.URL.encodePathSegment(direction))+"")
    .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.documents.PublicationDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.documents.PublicationDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.documents.PublicationDTO_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 getPublication(java.lang.String instanceId, java.lang.String id, java.lang.String contributionId, java.lang.String type, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.documents.PublicationDTO> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_id = id;
    final java.lang.String final_contributionId = contributionId;
    final java.lang.String final_type = type;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/publication/"+(id== null? null : com.google.gwt.http.client.URL.encodePathSegment(id))+"")
    .addQueryParam("contributionId", contributionId)
    .addQueryParam("type", type)
    .get();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<org.silverpeas.mobile.shared.dto.documents.PublicationDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.documents.PublicationDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.documents.PublicationDTO_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 getPublications(java.lang.String instanceId, java.lang.String topicId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.documents.PublicationDTO>> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_topicId = topicId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/publications/"+(topicId== null? null : com.google.gwt.http.client.URL.encodePathSegment(topicId))+"")
    .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.documents.PublicationDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.documents.PublicationDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.documents.PublicationDTO_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 getTickets(java.lang.String appId, java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO> tickets, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO>> callback) {
    final java.lang.String final_appId = appId;
    final java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO> final_tickets = tickets;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/tickets")
    .post();
    __method.setDispatcher(this.dispatcher);
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_ACCEPT, "application/json");
    __method.header(org.fusesource.restygwt.client.Resource.HEADER_CONTENT_TYPE, "application/json");
    __method.json(toJSON(tickets, org.silverpeas.mobile.shared.dto.tickets.TicketDTO_Generated_JsonEncoderDecoder_.INSTANCE));
    try {
      __method.send(new org.fusesource.restygwt.client.AbstractRequestCallback<java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.tickets.TicketDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.tickets.TicketDTO_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 getTopics(java.lang.String instanceId, java.lang.String rootTopicId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.documents.TopicDTO>> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_rootTopicId = rootTopicId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/topics/"+(rootTopicId== null? null : com.google.gwt.http.client.URL.encodePathSegment(rootTopicId))+"")
    .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.documents.TopicDTO>>(__method, callback) {
        protected java.util.List<org.silverpeas.mobile.shared.dto.documents.TopicDTO> parseResult() throws Exception {
          try {
            return toList(com.google.gwt.json.client.JSONParser.parse(__method.getResponse().getText()), org.silverpeas.mobile.shared.dto.documents.TopicDTO_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 getTopicsAndPublications(java.lang.String instanceId, java.lang.String rootTopicId, org.fusesource.restygwt.client.MethodCallback<java.util.List<org.silverpeas.mobile.shared.dto.BaseDTO>> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_rootTopicId = rootTopicId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/topicsAndPublications/"+(rootTopicId== null? null : com.google.gwt.http.client.URL.encodePathSegment(rootTopicId))+"")
    .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 publish(java.lang.String appId, java.lang.String pubId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.documents.PublicationDTO> callback) {
    final java.lang.String final_appId = appId;
    final java.lang.String final_pubId = pubId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(appId== null? null : com.google.gwt.http.client.URL.encodePathSegment(appId))+"/publish/"+(pubId== null? null : com.google.gwt.http.client.URL.encodePathSegment(pubId))+"")
    .post();
    __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.documents.PublicationDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.documents.PublicationDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.documents.PublicationDTO_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);
    }
  }
}
