Add Source Code Linter Pipeline
This commit is contained in:
parent
0d0e7140c4
commit
d252f6ef50
313 changed files with 36277 additions and 0 deletions
43
screwdriver-3.5.6/box/snippets/java/GenericController.java
Normal file
43
screwdriver-3.5.6/box/snippets/java/GenericController.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package +zoccolo+.web.controller;
|
||||
|
||||
import +zoccolo+.web.controller.GenericComponent;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
public class GenericController extends GenericComponent {
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ModelAndView handleError(HttpServletRequest req, Exception exception) {
|
||||
logger.error("Request: " + req.getRequestURL() + " raised " + exception);
|
||||
|
||||
exception.printStackTrace();
|
||||
ModelAndView mav = new ModelAndView("page.error");
|
||||
|
||||
return mav;
|
||||
}
|
||||
|
||||
|
||||
protected String localizeViewName(String viewBaseName, HttpServletRequest request) {
|
||||
|
||||
String ret = viewBaseName;
|
||||
String lang = getSessionAttribute("lang", request);
|
||||
|
||||
if ("en".equals(lang))
|
||||
ret += ".en";
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T getSessionAttribute(String name, HttpServletRequest request) {
|
||||
try {
|
||||
T toReturn = (T) request.getSession().getAttribute(name);
|
||||
return toReturn == null ? null : toReturn;
|
||||
} catch (ClassCastException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue