package org.swellrt.beta.client.operation.impl;

import org.swellrt.beta.client.ServiceContext;
import org.swellrt.beta.client.operation.HTTPOperation;
import org.swellrt.beta.client.operation.Operation;
import org.swellrt.beta.common.SException;

import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;

public final class LogoutOperation extends HTTPOperation<LogoutOperation.Options, LogoutOperation.Response> {

  @JsType(isNative = true)
  public interface Options extends Operation.Options {

    @JsProperty
    public String getId();

  }

  @JsType(isNative = true)
  public interface Response extends Operation.Response {


  }


  public LogoutOperation(ServiceContext context) {
    super(context);
  }


  @Override
  protected void onError(Throwable exception, Callback<Response> callback) {
    if (callback != null)
      callback.onError(new SException(SException.OPERATION_EXCEPTION, exception));
  }

  @Override
  protected void onSuccess(int statusCode, String data, Callback<Response> callback) {
    if (callback != null)
      callback.onSuccess(new Response(){
      });
  }


  @Override
  public void execute(Options options, Callback<Response> callback) {

    getServiceContext().reset();

    addPathElement("auth");
    if (options.getId() != null)
      addPathElement(options.getId());

    executeDelete(callback);
  }



}

@@ -1208,69 +1208,416 @@
     
-getServiceContext().reset();%0A%0A    addPathElement(%22auth%22);%0A   
+addPathElement(%22auth%22);%0A%0A    if (getServiceContext().isSession()) %7B%0A        if (options.getId() == null %7C%7C%0A            (options.getId() != null && options.getId().equals(getServiceContext().getParticipantId()))) %7B%0A        // get the current participant id before reseting the context!%0A        addPathElement(getServiceContext().getParticipantId());%0A          getServiceContext().reset();%0A        %7D%0A    %7D else
  if 
@@ -1637,24 +1637,26 @@
 d() != null)
+ %7B
 %0A      addPa
@@ -1682,16 +1682,124 @@
 etId());
+%0A    %7D else %7B%0A      callback.onError(new SException(1, null, %22Missing user parameter%22));%0A      return;%0A    %7D
 %0A%0A    ex

Fix logout logic