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

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

public class ServiceMedia_Generated_RestServiceProxy_ implements org.silverpeas.mobile.shared.services.rest.ServiceMedia, 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/medialib");
    }
    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 getAlbumsAndPictures(java.lang.String instanceId, java.lang.String rootAlbumId, int callNumber, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.StreamingList<org.silverpeas.mobile.shared.dto.BaseDTO>> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_rootAlbumId = rootAlbumId;
    final int final_callNumber = callNumber;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/albumsandpics/"+(rootAlbumId== null? null : com.google.gwt.http.client.URL.encodePathSegment(rootAlbumId))+"/"+(""+callNumber== null? null : com.google.gwt.http.client.URL.encodePathSegment(""+callNumber))+"")
    .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.StreamingList<org.silverpeas.mobile.shared.dto.BaseDTO>>(__method, callback) {
        protected org.silverpeas.mobile.shared.StreamingList<org.silverpeas.mobile.shared.dto.BaseDTO> parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.StreamingList__org_silverpeas_mobile_shared_dto_BaseDTO_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 getMedia(java.lang.String instanceId, java.lang.String id, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.media.MediaDTO> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_id = id;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/media/"+(id== null? null : com.google.gwt.http.client.URL.encodePathSegment(id))+"")
    .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.media.MediaDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.media.MediaDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.media.MediaDTO_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 getPreviewPicture(java.lang.String instanceId, java.lang.String pictureId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.media.PhotoDTO> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_pictureId = pictureId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/photo/"+(pictureId== null? null : com.google.gwt.http.client.URL.encodePathSegment(pictureId))+"")
    .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.media.PhotoDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.media.PhotoDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.media.PhotoDTO_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 getSound(java.lang.String instanceId, java.lang.String soundId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.media.SoundDTO> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_soundId = soundId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/sound/"+(soundId== null? null : com.google.gwt.http.client.URL.encodePathSegment(soundId))+"")
    .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.media.SoundDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.media.SoundDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.media.SoundDTO_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 getVideo(java.lang.String instanceId, java.lang.String videoId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.media.VideoDTO> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_videoId = videoId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/video/"+(videoId== null? null : com.google.gwt.http.client.URL.encodePathSegment(videoId))+"")
    .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.media.VideoDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.media.VideoDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.media.VideoDTO_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 getVideoStreaming(java.lang.String instanceId, java.lang.String videoId, org.fusesource.restygwt.client.MethodCallback<org.silverpeas.mobile.shared.dto.media.VideoStreamingDTO> callback) {
    final java.lang.String final_instanceId = instanceId;
    final java.lang.String final_videoId = videoId;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve(""+(instanceId== null? null : com.google.gwt.http.client.URL.encodePathSegment(instanceId))+"/videostream/"+(videoId== null? null : com.google.gwt.http.client.URL.encodePathSegment(videoId))+"")
    .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.media.VideoStreamingDTO>(__method, callback) {
        protected org.silverpeas.mobile.shared.dto.media.VideoStreamingDTO parseResult() throws Exception {
          try {
            return org.silverpeas.mobile.shared.dto.media.VideoStreamingDTO_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 uploadPicture(java.lang.String name, java.lang.String data, java.lang.String idGallery, java.lang.String idAlbum, org.fusesource.restygwt.client.MethodCallback<java.lang.Void> callback) {
    final java.lang.String final_name = name;
    final java.lang.String final_data = data;
    final java.lang.String final_idGallery = idGallery;
    final java.lang.String final_idAlbum = idAlbum;
    final org.fusesource.restygwt.client.Method __method =
    getResource()
    .resolve("add/"+(name== null? null : com.google.gwt.http.client.URL.encodePathSegment(name))+"/"+(data== null? null : com.google.gwt.http.client.URL.encodePathSegment(data))+"/"+(idGallery== null? null : com.google.gwt.http.client.URL.encodePathSegment(idGallery))+"/"+(idAlbum== null? null : com.google.gwt.http.client.URL.encodePathSegment(idAlbum))+"")
    .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.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);
    }
  }
}
