package org.gcube.portlets.admin.createusers.client;

import com.google.gwt.user.client.rpc.impl.RemoteServiceProxy;
import com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.ResponseReader;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.RpcToken;
import com.google.gwt.user.client.rpc.RpcTokenException;
import com.google.gwt.core.client.impl.Impl;
import com.google.gwt.user.client.rpc.impl.RpcStatsContext;

public class HandleUsersService_Proxy extends RemoteServiceProxy implements org.gcube.portlets.admin.createusers.client.HandleUsersServiceAsync {
  private static final String REMOTE_SERVICE_INTERFACE_NAME = "org.gcube.portlets.admin.createusers.client.HandleUsersService";
  private static final String SERIALIZATION_POLICY ="8B972F00FB49849AD6752BE168EE2733";
  private static final org.gcube.portlets.admin.createusers.client.HandleUsersService_TypeSerializer SERIALIZER = new org.gcube.portlets.admin.createusers.client.HandleUsersService_TypeSerializer();
  
  public HandleUsersService_Proxy() {
    super(GWT.getModuleBaseURL(),
      "usersservice", 
      SERIALIZATION_POLICY, 
      SERIALIZER);
  }
  
  public void getAlreadyRegisterdUsers(com.google.gwt.user.client.rpc.AsyncCallback callback) {
    com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.ServiceHelper helper = new com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.ServiceHelper("HandleUsersService_Proxy", "getAlreadyRegisterdUsers");
    try {
      SerializationStreamWriter streamWriter = helper.start(REMOTE_SERVICE_INTERFACE_NAME, 0);
      helper.finish(callback, ResponseReader.OBJECT);
    } catch (SerializationException ex) {
      callback.onFailure(ex);
    }
  }
  
  public void register(java.lang.String name, java.lang.String surname, java.lang.String company, java.lang.String email, boolean sendEmail, boolean isMale, com.google.gwt.user.client.rpc.AsyncCallback callback) {
    com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.ServiceHelper helper = new com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.ServiceHelper("HandleUsersService_Proxy", "register");
    try {
      SerializationStreamWriter streamWriter = helper.start(REMOTE_SERVICE_INTERFACE_NAME, 6);
      streamWriter.writeString("java.lang.String/2004016611");
      streamWriter.writeString("java.lang.String/2004016611");
      streamWriter.writeString("java.lang.String/2004016611");
      streamWriter.writeString("java.lang.String/2004016611");
      streamWriter.writeString("Z");
      streamWriter.writeString("Z");
      streamWriter.writeString(name);
      streamWriter.writeString(surname);
      streamWriter.writeString(company);
      streamWriter.writeString(email);
      streamWriter.writeBoolean(sendEmail);
      streamWriter.writeBoolean(isMale);
      helper.finish(callback, ResponseReader.OBJECT);
    } catch (SerializationException ex) {
      callback.onFailure(ex);
    }
  }
  @Override
  public SerializationStreamWriter createStreamWriter() {
    ClientSerializationStreamWriter toReturn =
      (ClientSerializationStreamWriter) super.createStreamWriter();
    if (getRpcToken() != null) {
      toReturn.addFlags(ClientSerializationStreamWriter.FLAG_RPC_TOKEN_INCLUDED);
    }
    return toReturn;
  }
  @Override
  protected void checkRpcTokenType(RpcToken token) {
    if (!(token instanceof com.google.gwt.user.client.rpc.XsrfToken)) {
      throw new RpcTokenException("Invalid RpcToken type: expected 'com.google.gwt.user.client.rpc.XsrfToken' but got '" + token.getClass() + "'");
    }
  }
}
