-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
198 additions
and
130 deletions.
There are no files selected for viewing
16 changes: 11 additions & 5 deletions
16
BcnxWebService/src/com/bcnx/web/app/exception/ApplicationExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
package com.bcnx.web.app.exception; | ||
|
||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
import org.jboss.resteasy.spi.ApplicationException; | ||
import org.apache.log4j.Logger; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.bcnx.web.app.service.entity.ErrMsg; | ||
|
||
@Provider | ||
public class ApplicationExceptionHandler implements | ||
ExceptionMapper<ApplicationException> { | ||
@Component | ||
public class ApplicationExceptionHandler implements ExceptionMapper<Exception> { | ||
private static final Logger logger = Logger.getLogger(ApplicationExceptionHandler.class); | ||
@Produces("application/json") | ||
@Override | ||
public Response toResponse(ApplicationException ex) { | ||
public Response toResponse(Exception ex) { | ||
logger.debug("Exception occured while process request",ex); | ||
logger.debug("Exception message :"+ex.getMessage()); | ||
ErrMsg errMsg = new ErrMsg(); | ||
errMsg.setCode("510"); | ||
errMsg.setMessage("Internal Message Error"); | ||
return Response.status(500).entity(errMsg).build(); | ||
return Response.serverError().entity(errMsg).build(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
BcnxWebService/src/com/bcnx/web/app/exception/SessionTimeOutHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.bcnx.web.app.exception; | ||
|
||
import javax.servlet.http.HttpSession; | ||
import javax.servlet.http.HttpSessionEvent; | ||
import javax.servlet.http.HttpSessionListener; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import com.bcnx.web.app.service.UserService; | ||
import com.bcnx.web.app.service.entity.User; | ||
|
||
public class SessionTimeOutHandler implements HttpSessionListener { | ||
private static Logger logger = Logger.getLogger(SessionTimeOutHandler.class); | ||
private UserService userService; | ||
public void setUserService(UserService userService){ | ||
this.userService = userService; | ||
} | ||
@Override | ||
public void sessionCreated(HttpSessionEvent event) { | ||
logger.debug("session is created"); | ||
return; | ||
} | ||
|
||
@Override | ||
public void sessionDestroyed(HttpSessionEvent event) { | ||
logger.debug("session is destroyed"); | ||
HttpSession session = event.getSession(); | ||
User user = (User) session.getAttribute("user"); | ||
user = userService.getUser(user); | ||
user.setState(0); | ||
userService.update(user); | ||
return; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.