package org.gcube.portlets.user.gcubewidgets.client.rpc;

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 ScopeService_Proxy extends RemoteServiceProxy implements org.gcube.portlets.user.gcubewidgets.client.rpc.ScopeServiceAsync {
  private static final String REMOTE_SERVICE_INTERFACE_NAME = "org.gcube.portlets.user.gcubewidgets.client.rpc.ScopeService";
  private static final String SERIALIZATION_POLICY ="61CF2EB1942C991A9518A75D35EC17FD";
  private static final org.gcube.portlets.user.gcubewidgets.client.rpc.ScopeService_TypeSerializer SERIALIZER = new org.gcube.portlets.user.gcubewidgets.client.rpc.ScopeService_TypeSerializer();
  
  public ScopeService_Proxy() {
    super(GWT.getModuleBaseURL(),
      "scopeService", 
      SERIALIZATION_POLICY, 
      SERIALIZER);
  }
  
  public void setScope(java.lang.String portalURL, 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("ScopeService_Proxy", "setScope");
    try {
      SerializationStreamWriter streamWriter = helper.start(REMOTE_SERVICE_INTERFACE_NAME, 1);
      streamWriter.writeString("java.lang.String/2004016611");
      streamWriter.writeString(portalURL);
      helper.finish(callback, ResponseReader.BOOLEAN);
    } 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() + "'");
    }
  }
}
