Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
prevent lost connection notification when exiting workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Dec 5, 2012
1 parent 0a58c0f commit c708730
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 42 deletions.
Expand Up @@ -25,7 +25,6 @@
import org.zanata.webtrans.shared.rpc.ActivateWorkspaceResult;
import org.zanata.webtrans.shared.rpc.EventServiceConnectedAction;
import org.zanata.webtrans.shared.rpc.ExitWorkspaceAction;
import org.zanata.webtrans.shared.rpc.ExitWorkspaceResult;
import org.zanata.webtrans.shared.rpc.GetDocumentList;
import org.zanata.webtrans.shared.rpc.GetDocumentListResult;
import org.zanata.webtrans.shared.rpc.NoOpResult;
Expand Down Expand Up @@ -107,7 +106,7 @@ public void onSuccess(final ActivateWorkspaceResult result)

public static void exitWorkspace()
{
injector.getDispatcher().execute(new ExitWorkspaceAction(identity.getPerson()), new NoOpAsyncCallback<ExitWorkspaceResult>());
injector.getDispatcher().execute(new ExitWorkspaceAction(identity.getPerson()), new NoOpAsyncCallback<NoOpResult>());
}

private void startApp()
Expand Down
Expand Up @@ -15,6 +15,7 @@
import org.zanata.webtrans.shared.auth.InvalidTokenError;
import org.zanata.webtrans.shared.model.UserWorkspaceContext;
import org.zanata.webtrans.shared.rpc.AbstractWorkspaceAction;
import org.zanata.webtrans.shared.rpc.ExitWorkspaceAction;
import org.zanata.webtrans.shared.rpc.WrappedAction;

import com.allen_sauer.gwt.log.client.Log;
Expand Down Expand Up @@ -75,7 +76,10 @@ public void onFailure(final Throwable caught)
{
if (caught instanceof com.google.gwt.user.client.rpc.StatusCodeException && ((StatusCodeException) caught).getStatusCode() == 0)
{
eventBus.fireEvent(new NotificationEvent(NotificationEvent.Severity.Error, messages.noResponseFromServer()));
if (!(action instanceof ExitWorkspaceAction))
{
eventBus.fireEvent(new NotificationEvent(NotificationEvent.Severity.Error, messages.noResponseFromServer()));
}
}
if (caught instanceof AuthenticationError || caught instanceof InvalidTokenError)
{
Expand Down
Expand Up @@ -12,12 +12,12 @@
import org.zanata.webtrans.server.TranslationWorkspace;
import org.zanata.webtrans.server.TranslationWorkspaceManager;
import org.zanata.webtrans.shared.rpc.ExitWorkspaceAction;
import org.zanata.webtrans.shared.rpc.ExitWorkspaceResult;
import org.zanata.webtrans.shared.rpc.NoOpResult;

@Name("webtrans.gwt.ExitWorkspaceHandler")
@Scope(ScopeType.STATELESS)
@ActionHandlerFor(ExitWorkspaceAction.class)
public class ExitWorkspaceHandler extends AbstractActionHandler<ExitWorkspaceAction, ExitWorkspaceResult>
public class ExitWorkspaceHandler extends AbstractActionHandler<ExitWorkspaceAction, NoOpResult>
{
@In
private ZanataIdentity identity;
Expand All @@ -26,7 +26,7 @@ public class ExitWorkspaceHandler extends AbstractActionHandler<ExitWorkspaceAct
private TranslationWorkspaceManager translationWorkspaceManager;

@Override
public ExitWorkspaceResult execute(ExitWorkspaceAction action, ExecutionContext context) throws ActionException
public NoOpResult execute(ExitWorkspaceAction action, ExecutionContext context) throws ActionException
{

identity.checkLoggedIn();
Expand All @@ -35,11 +35,11 @@ public ExitWorkspaceResult execute(ExitWorkspaceAction action, ExecutionContext

// Send ExitWorkspace event to client
workspace.removeEditorClient(action.getEditorClientId());
return new ExitWorkspaceResult(action.getPerson().getId().toString());
return new NoOpResult();
}

@Override
public void rollback(ExitWorkspaceAction action, ExitWorkspaceResult result, ExecutionContext context) throws ActionException
public void rollback(ExitWorkspaceAction action, NoOpResult result, ExecutionContext context) throws ActionException
{
}
}
Expand Up @@ -2,7 +2,7 @@

import org.zanata.webtrans.shared.model.Person;

public class ExitWorkspaceAction extends AbstractWorkspaceAction<ExitWorkspaceResult>
public class ExitWorkspaceAction extends AbstractWorkspaceAction<NoOpResult>
{

private static final long serialVersionUID = 1L;
Expand Down

This file was deleted.

@@ -1,24 +1,19 @@
package org.zanata.webtrans.server.rpc;

import org.hamcrest.Matchers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.zanata.common.LocaleId;
import org.zanata.model.TestFixture;
import org.zanata.seam.SeamAutowire;
import org.zanata.security.ZanataIdentity;
import org.zanata.webtrans.server.TranslationWorkspace;
import org.zanata.webtrans.server.TranslationWorkspaceManager;
import org.zanata.webtrans.shared.auth.EditorClientId;
import org.zanata.webtrans.shared.model.Person;
import org.zanata.webtrans.shared.model.PersonId;
import org.zanata.webtrans.shared.model.WorkspaceId;
import org.zanata.webtrans.shared.rpc.ExitWorkspaceAction;
import org.zanata.webtrans.shared.rpc.ExitWorkspaceResult;

import static org.hamcrest.MatcherAssert.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -60,11 +55,10 @@ public void testExecute() throws Exception
action.setEditorClientId(editorClientId);
action.setWorkspaceId(workspaceId);

ExitWorkspaceResult result = handler.execute(action, null);
handler.execute(action, null);

verify(identity).checkLoggedIn();
verify(translationWorkspace).removeEditorClient(action.getEditorClientId());
assertThat(result.getuserName(), Matchers.equalTo(person.getId().toString()));
}

@Test
Expand Down

0 comments on commit c708730

Please sign in to comment.