Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions carstore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

<groupId>com.gwtplatform</groupId>
<artifactId>carstore</artifactId>
<version>1.5</version>
<version>1.6-SNAPSHOT</version>
<packaging>war</packaging>
<name>GWTP Carstore</name>
<description>Simple application used for testing GWTP features.</description>

<properties>
<!-- Client -->
<gwt.version>2.7.0</gwt.version>
<gwtp.version>1.5</gwtp.version>
<gwtp.version>1.6-SNAPSHOT</gwtp.version>
<gin.version>2.1.2</gin.version>
<gwtquery.version>1.4.2</gwtquery.version>
<objectify-gwt.version>1.2.1</objectify-gwt.version>
Expand Down Expand Up @@ -41,8 +41,8 @@
<maven-gae-plugin.version>0.9.6</maven-gae-plugin.version>
<maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
<versions-maven-plugin.version>2.1</versions-maven-plugin.version>
<maven-failsafe-plugin.version>2.18</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>2.18</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.18.1</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<gwt-maven-plugin.version>2.7.0</gwt-maven-plugin.version>
<maven-checkstyle-plugin.version>2.14</maven-checkstyle-plugin.version>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2015 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.gwtplatform.carstore.client.dispatch;

import javax.inject.Inject;
import javax.inject.Provider;

import com.gwtplatform.carstore.client.application.ApplicationPresenter;
import com.gwtplatform.carstore.client.application.event.DisplayMessageEvent;
import com.gwtplatform.carstore.client.application.widget.message.Message;
import com.gwtplatform.carstore.client.application.widget.message.MessageStyle;
import com.gwtplatform.dispatch.client.ExceptionHandler;
import com.gwtplatform.dispatch.rest.shared.ActionResponseException;
import com.gwtplatform.dispatch.rest.shared.RestActionException;
import com.gwtplatform.dispatch.shared.ActionException;

public class DispatchExceptionHandler implements ExceptionHandler {

private final Provider<ApplicationPresenter> appPresenterProvider;

@Inject
DispatchExceptionHandler(Provider<ApplicationPresenter> appPresenterProvider) {
this.appPresenterProvider = appPresenterProvider;
}

@Override
public Status onFailure(Throwable e) {
if (e instanceof ActionException) {
return handleActionExceptions((ActionException) e);
}

return Status.CONTINUE;
}

private Status handleActionExceptions(ActionException e) {
Status status;
if (e instanceof RestActionException) {
// This is a REST action exception
status = handleRestActionExceptions((RestActionException) e);
} else {
// This is an RPC action exception
status = handleRpcActionExceptions(e);
}

return status;
}

private Status handleRestActionExceptions(RestActionException e) {
Status status = Status.CONTINUE;

if (e instanceof ActionResponseException) {
// Unauthorized access exception
if (((ActionResponseException) e).getStatusCode() == 401) {
DisplayMessageEvent.fire(appPresenterProvider.get(), new Message(
"You do not have access to this part of the system.", MessageStyle.ERROR));

status = Status.STOP;
}
}

return status;
}

private Status handleRpcActionExceptions(ActionException e) {
return Status.CONTINUE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.gwtplatform.carstore.client.gin;

import com.gwtplatform.carstore.client.dispatch.DispatchExceptionHandler;
import com.gwtplatform.carstore.client.dispatch.rest.AppRestDispatchHooks;
import com.gwtplatform.carstore.client.dispatch.rest.RestInterceptorRegistry;
import com.gwtplatform.carstore.client.dispatch.rpc.AppRpcDispatchHooks;
Expand All @@ -39,10 +40,12 @@ protected void configure() {
install(new RestDispatchAsyncModule.Builder()
.dispatchHooks(AppRestDispatchHooks.class)
.interceptorRegistry(RestInterceptorRegistry.class)
.exceptionHandler(DispatchExceptionHandler.class)
.build());
install(new RpcDispatchAsyncModule.Builder()
.dispatchHooks(AppRpcDispatchHooks.class)
.interceptorRegistry(RpcInterceptorRegistry.class)
.exceptionHandler(DispatchExceptionHandler.class)
.build());

// CarStore modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public LogInResult execute(LogInAction action, ExecutionContext context) throws
loggedInCookie = loginCookieDao.createSessionCookie(userDto);
}

logger.info("LogInHandlerexecut(): actiontype=" + getActionType());
logger.info("LogInHandlerexecut(): currentUserDto=" + currentUserDto);
logger.info("LogInHandlerexecut(): loggedInCookie=" + loggedInCookie);
logger.info("LogInHandler#execute(): actiontype=" + getActionType());
logger.info("LogInHandler#execute(): currentUserDto=" + currentUserDto);
logger.info("LogInHandler#execute(): loggedInCookie=" + loggedInCookie);

return new LogInResult(action.getActionType(), currentUserDto, loggedInCookie);
}
Expand Down