List of usage examples for javax.servlet.http HttpSession getServletContext
public ServletContext getServletContext();
From source file:org.intermine.web.logic.WebUtil.java
/** * Look at the current webapp page and subtab and return the help page and * tab.//from w w w .j a v a 2 s .c o m * * @param request * the request object * @return the help page and tab */ public static String[] getHelpPage(final HttpServletRequest request) { final HttpSession session = request.getSession(); final ServletContext servletContext = session.getServletContext(); final Properties webProps = SessionMethods.getWebProperties(servletContext); final WebState webState = SessionMethods.getWebState(request.getSession()); final String pageName = (String) request.getAttribute("pageName"); final String subTab = webState.getSubtab("subtab" + pageName); String prop; if (subTab == null) { prop = webProps.getProperty("help.page." + pageName); } else { prop = webProps.getProperty("help.page." + pageName + "." + subTab); } if (prop == null) { return new String[0]; } return StringUtil.split(prop, ":"); }
From source file:org.intermine.web.logic.WebUtil.java
/** * Lookup an Integer property from the SessionContext and return it. * * @param session/* ww w.j a va 2 s . com*/ * the current session * @param propertyName * the property to find * @param defaultValue * the value to return if the property isn't present * @return the int value of the property */ public static int getIntSessionProperty(final HttpSession session, final String propertyName, final int defaultValue) { final Properties webProperties = SessionMethods.getWebProperties(session.getServletContext()); final String n = webProperties.getProperty(propertyName); int intVal = defaultValue; try { intVal = Integer.parseInt(n); } catch (final NumberFormatException e) { LOG.warn("Failed to parse " + propertyName + " property: " + n); } return intVal; }
From source file:com.orchestra.portale.controller.CheckController.java
@RequestMapping("/check") public ModelAndView check(HttpServletRequest request) { HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); File f = new File(sc.getRealPath("/")); ModelAndView model = new ModelAndView("check"); model.addObject("mess", f.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg"); return model; }
From source file:com.orchestra.portale.controller.ImageBackupRestoreController.java
@RequestMapping(value = "/restoreimg") public ModelAndView restore(HttpServletRequest request) throws IOException { ModelAndView model = new ModelAndView("showResult"); HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); File root = new File(sc.getRealPath("/")); File dir = new File(sc.getRealPath("/") + "dist"); copy(root.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg" + File.separator + "poi", dir.getCanonicalPath()); copy(root.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg" + File.separator + "page", dir.getCanonicalPath()); copy(root.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg" + File.separator + "dpage", dir.getCanonicalPath()); copy(root.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg" + File.separator + "user", dir.getCanonicalPath()); model.addObject("mess", "Tutte le immagini sono state ripristinate"); return model; }
From source file:com.orchestra.portale.controller.ImageBackupRestoreController.java
@RequestMapping(value = "/backupimg") public ModelAndView backup(HttpServletRequest request) throws IOException { ModelAndView model = new ModelAndView("showResult"); HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); File root = new File(sc.getRealPath("/")); File dir = new File(sc.getRealPath("/") + "dist" + File.separator + "poi"); File dir2 = new File(sc.getRealPath("/") + "dist" + File.separator + "user"); File dir3 = new File(sc.getRealPath("/") + "dist" + File.separator + "page"); File dir4 = new File(sc.getRealPath("/") + "dist" + File.separator + "dpage"); copy(dir.getCanonicalPath(),/*w w w. ja v a2s .c o m*/ root.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg"); copy(dir2.getCanonicalPath(), root.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg"); copy(dir3.getCanonicalPath(), root.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg"); copy(dir4.getCanonicalPath(), root.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg"); model.addObject("mess", "Tutte le immagini sono state copiate"); return model; }
From source file:org.spirit.spring.BotListUserSessionListener.java
private ApplicationContext getWebApplicationContext(HttpSessionEvent httpSessionEvent) { final HttpSession session = httpSessionEvent.getSession(); final ServletContext sc = session.getServletContext(); return (ApplicationContext) sc.getAttribute(CONTEXT_BOTLIST); }
From source file:com.orchestra.portale.controller.UserInfoController.java
@RequestMapping(value = "/userInfo") @Secured("ROLE_USER") public ModelAndView getUserInfo(HttpServletRequest request) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); ModelAndView model = new ModelAndView("userInfo"); ModelAndView model2 = new ModelAndView("index"); if (auth != null) { User user = pm.findUserByUsername(auth.getName()); HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); File dir = new File(sc.getRealPath("/") + "dist" + File.separator + "user" + File.separator + "img" + File.separator + user.getId() + File.separator + "avatar.jpg"); if (dir.exists()) { model.addObject("avatar", "./dist/user/img/" + user.getId() + "/avatar.jpg"); } else {/* w ww.j a v a2 s .c o m*/ model.addObject("avatar", "./dist/img/default_avatar.png"); } model.addObject("user", user); if (request.isUserInRole("ROLE_FB")) { Object categories = fbprofiler.getFBCategories(); if (categories != null) { model.addObject("categories", categories); } } } else { return model2; } return model; }
From source file:dicky.controlleradmin.ProductAdminController.java
private File tujuanUpload(HttpSession session) { String lokasifullPath = session.getServletContext().getRealPath(folderTujuan); File hasil = new File(lokasifullPath); if (!hasil.exists()) { hasil.mkdirs();/*from w w w . j a v a2 s . c om*/ } return hasil; }
From source file:org.intermine.web.logic.session.SessionMethods.java
/** * Get the set of accepted Open-ID providers. * @param session The session to use for lookups * @return The set of open-id providers. *//*w w w . j a v a 2s .c o m*/ public static Set<String> getOpenIdProviders(HttpSession session) { ServletContext ctx = session.getServletContext(); return (Set<String>) ctx.getAttribute(Constants.OPENID_PROVIDERS); }
From source file:org.intermine.web.logic.session.SessionMethods.java
/** * Get the InterMineAPI which provides access to core features of an InterMine application. * @param session the webapp session//from ww w .j a v a 2s .co m * @return the InterMine core object */ public static InterMineAPI getInterMineAPI(HttpSession session) { return getInterMineAPI(session.getServletContext()); }