List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:ilearn.orb.controller.AnalysisController.java
private static UserProfile retrieveProfile(HttpSession session, int userId) throws NumberFormatException, Exception { UserProfile p = null;/* w w w. jav a 2 s . c o m*/ User[] students = null; User selectedStudent = null; if (userId < 0) { students = HardcodedUsers.defaultStudents(); selectedStudent = selectedStudent(students, userId); //p = HardcodedUsers.defaultProfile(selectedStudent.getId()); String json = UserServices .getDefaultProfile(HardcodedUsers.defaultProfileLanguage(selectedStudent.getId())); if (json != null) p = new Gson().fromJson(json, UserProfile.class); } else { Gson gson = new GsonBuilder().registerTypeAdapter(java.util.Date.class, new UtilDateDeserializer()) .setDateFormat(DateFormat.LONG).create(); String json = UserServices.getProfiles(Integer.parseInt(session.getAttribute("id").toString()), session.getAttribute("auth").toString()); students = gson.fromJson(json, User[].class); selectedStudent = selectedStudent(students, userId); json = UserServices.getJsonProfile(userId, session.getAttribute("auth").toString()); if (json != null) p = new Gson().fromJson(json, UserProfile.class); } return p; }
From source file:de.innovationgate.wgpublisher.webtml.portlet.TMLPortlet.java
/** * Queue that stores the last 1000 fired portlet events, so portlets can * react on them with serverside code./*from w w w . j a v a 2 s. co m*/ * @param session * @return */ public static LinkedMap getFiredEventsQueue(HttpSession session) { synchronized (session) { @SuppressWarnings("unchecked") TransientObjectWrapper<LinkedMap> eventWrapper = (TransientObjectWrapper<LinkedMap>) session .getAttribute(WGACore.SESSION_FIREDPORTLETEVENTS); if (eventWrapper == null || eventWrapper.get() == null) { eventWrapper = new TransientObjectWrapper<LinkedMap>(); eventWrapper.set(new LinkedMap()); session.setAttribute(WGACore.SESSION_FIREDPORTLETEVENTS, eventWrapper); } return eventWrapper.get(); } }
From source file:sessions.ApplicationController.java
@RequestMapping(value = "/session", method = RequestMethod.GET) Object sessionDataRetrieve(HttpSession session) { return session.getAttribute("testVariable"); }
From source file:mx.com.quadrum.contratos.controller.service.user.UsuarioServiceController.java
@ResponseBody @RequestMapping(value = "agregarPermisosToUser/{id}", method = RequestMethod.POST) public String agregarPermisosUsuarios(@PathVariable("id") String id, HttpSession session) { if (session.getAttribute("usuario") == null) { return SESION_CADUCA; }//from w w w. j av a 2 s . co m return permisoUsuarioService.agregar(id); }
From source file:mx.com.quadrum.contratos.controller.service.user.UsuarioServiceController.java
@ResponseBody @RequestMapping(value = "permisosPorUsuario/{id}", method = RequestMethod.POST) public String permisosPorUsuario(@PathVariable("id") String id, HttpSession session) { if (session.getAttribute("usuario") == null) { return SESION_CADUCA; }/*from w ww .j a v a 2 s . c om*/ return permisoUsuarioService.buscarPorUsuario(Integer.parseInt(id)); }
From source file:com.digitalizat.control.TAccountingController.java
@RequestMapping(value = "clients") public String viewSignin(HttpServletRequest request) { HttpSession sesion = request.getSession(); if (sesion.getAttribute("logged") != null && ((Boolean) sesion.getAttribute("logged"))) { return "/clients/list"; } else {//from w w w . j a va 2 s .co m return "/plataforma/signin"; } }
From source file:controllers.AdminPanelController.java
@RequestMapping(method = RequestMethod.GET) public String showForm(Map map, HttpSession session) throws SQLException { if (session.getAttribute("role") == null || !session.getAttribute("role").equals("admin")) { return "redirect: index.htm"; }//from ww w.j a va2 s. co m List users = Factory.getInstance().getUserDAO().getAllUsers(); map.put("users", users); return "adminpanel"; }
From source file:com.netpace.aims.controller.application.JavaApplicationHelper.java
public static void setupAction(HttpServletRequest request, String taskname, String viewPageToView, JavaApplicationUpdateForm javaForm, AimsApp aimsApp, AimsJavaApps javaApp, AimsJavaAppClob javaClobs, AimsAppCategory aimsAppCategory, String dateFormat) throws AimsSecurityException { if (log.isDebugEnabled()) { log.debug("JavaApplicationHelper.setupAction Start:"); log.debug("taskName: " + taskname); }/*w w w . jav a2s . com*/ HttpSession session = request.getSession(); Long currentUserAllianceId = ((AimsUser) session.getAttribute(AimsConstants.AIMS_USER)).getAimsAllianc(); String currUserType = ((AimsUser) (session.getAttribute(AimsConstants.AIMS_USER))).getUserType(); boolean isVerizonUser = currUserType.equals(AimsConstants.VZW_USERTYPE); boolean isAllianceUser = currUserType.equals(AimsConstants.ALLIANCE_USERTYPE); // CHECK ACCESS /* * if (!(ApplicationHelper.checkPlatformAccess(request, * taskname,AimsConstants.JAVA_PLATFORM_ID))) throw new * AimsSecurityException(); * * if (taskname.equalsIgnoreCase("edit")) if * (!(ApplicationHelper.checkEditAccess(currUserType, * aimsApp.getAimsLifecyclePhaseId()))) throw new * AimsSecurityException(); * * if (taskname.equalsIgnoreCase("delete")) if * (!AimsSecurityManager.checkAccess * (request,AimsPrivilegesConstants.MANAGE_JAVA_APPS * ,AimsSecurityManager.DELETE)) throw new AimsSecurityException(); */ // END OF CHECK ACCESS javaForm.setCurrentPage("page1"); javaForm.setOriginalTask(javaForm.getTask()); // Set Temp File Ids to Zero javaForm.setClrPubLogoTempFileId(new Long(0)); javaForm.setAppTitleNameTempFileId(new Long(0)); javaForm.setSplashScreenEpsTempFileId(new Long(0)); javaForm.setActiveScreenEpsTempFileId(new Long(0)); javaForm.setScreenJpegTempFileId(new Long(0)); javaForm.setScreenJpeg2TempFileId(new Long(0)); javaForm.setScreenJpeg3TempFileId(new Long(0)); javaForm.setScreenJpeg4TempFileId(new Long(0)); javaForm.setScreenJpeg5TempFileId(new Long(0)); javaForm.setFaqDocTempFileId(new Long(0)); javaForm.setUserGuideTempFileId(new Long(0)); javaForm.setCompanyLogoTempFileId(new Long(0)); javaForm.setTitleImageTempFileId(new Long(0)); javaForm.setEnterpriseApp(AimsConstants.NO_CHAR); if (taskname.equalsIgnoreCase("create")) { javaForm.setTask("create"); javaForm.setAppsId(new Long(0)); javaForm.setLanguage("EN"); javaForm.setAimsLifecyclePhaseId(AimsConstants.SAVED_ID); javaForm.setAimsAllianceId(currentUserAllianceId); } else if ((taskname.equalsIgnoreCase("edit")) || (taskname.equalsIgnoreCase("clone")) || (taskname.equalsIgnoreCase("view"))) { if (taskname.equalsIgnoreCase("edit")) javaForm.setTask("edit"); else if (taskname.equalsIgnoreCase("view")) javaForm.setTask("view"); // For Cloning.... if (taskname.equalsIgnoreCase("clone")) { javaForm.setAppsId(null); javaForm.setCloneFromAppId(aimsApp.getAppsId()); javaForm.setTitle(null); javaForm.setAimsLifecyclePhaseId(AimsConstants.SAVED_ID); javaForm.setAimsAllianceId(currentUserAllianceId); javaForm.setTask("create"); javaForm.setOriginalTask("create"); if (javaForm.getRing3App()) javaForm.setAppKeyword(JavaUtils.getAppKeyword()); } else { javaForm.setTitle(javaApp.getTitle()); javaForm.setAimsLifecyclePhaseId(aimsApp.getAimsLifecyclePhaseId()); javaForm.setAimsAllianceId(aimsApp.getAimsAllianceId()); javaForm.setSubmittedDate(Utility.convertToString(aimsApp.getSubmittedDate(), dateFormat)); javaForm.setAppsId(aimsApp.getAppsId()); javaForm.setAppKeyword(javaApp.getAppKeyword()); javaForm.setVersion(aimsApp.getVersion()); } if (taskname.equalsIgnoreCase("view") && "journal".equalsIgnoreCase(viewPageToView)) { try { Collection journalEntries = AimsApplicationsManager .getJournalEntries(new Long(request.getParameter("appsId")), currentUserAllianceId); journalEntries = getJournalEntriesForUser(isAllianceUser, journalEntries); javaForm.setJournalCombinedText(getFormattedJournalEntries(journalEntries)); } catch (Exception e) { log.error(e, e); AimsException aimsException = new AimsException("Error"); aimsException.addException(new GenericException("error.generic.database")); } } javaForm.setShortDesc(javaApp.getShortDesc()); javaForm.setLongDesc(javaApp.getLongDesc()); javaForm.setInfoURL(javaApp.getInfoUrl()); javaForm.setProductDescription(javaApp.getProductDescription()); javaForm.setLanguage(aimsApp.getLanguage()); javaForm.setJavaAppContractId(javaApp.getAimsContractId()); javaForm.setContentRating(javaApp.getContentRatingTypeId()); javaForm.setAimsTaxCategoryCodeId(javaApp.getAimsTaxCategoryCodeId()); javaForm.setIfPrRelease(aimsApp.getIfPrRelease()); javaForm.setEnterpriseApp(javaApp.getEnterpriseApp()); if (aimsAppCategory != null) javaForm.setAimsAppCategoryId(aimsAppCategory.getCategoryId()); javaForm.setAimsAppSubCategoryId(aimsApp.getAimsAppSubCategoryId()); javaForm.setAppCategory1(javaApp.getAppCategory1()); javaForm.setAppSubCategory1(javaApp.getAppSubCategory1()); javaForm.setAppCategory2(javaApp.getAppCategory2()); javaForm.setAppSubCategory2(javaApp.getAppSubCategory2()); javaForm.setContentType(javaApp.getContentTypeId()); if (javaApp.getVzwProjectedLiveDate() != null) javaForm.setProjectedLiveDate( Utility.convertToString(javaApp.getVzwProjectedLiveDate(), dateFormat)); javaForm.setEnterpriseId(javaApp.getEnterpriseId()); javaForm.setInitialApprovalNotes(javaApp.getNotes()); // Set File Names javaForm.setClrPubLogoFileName(javaApp.getHrPublisherFileName()); javaForm.setAppTitleNameFileName(javaApp.getChnlTitleIconFileName()); javaForm.setSplashScreenEpsFileName(aimsApp.getSplashScreenEpsFileName()); javaForm.setActiveScreenEpsFileName(aimsApp.getActiveScreenEpsFileName()); javaForm.setScreenJpegFileName(aimsApp.getScreenJpegFileName()); javaForm.setScreenJpeg2FileName(aimsApp.getScreenJpeg2FileName()); javaForm.setScreenJpeg3FileName(aimsApp.getScreenJpeg3FileName()); javaForm.setScreenJpeg4FileName(aimsApp.getScreenJpeg4FileName()); javaForm.setScreenJpeg5FileName(aimsApp.getScreenJpeg5FileName()); javaForm.setFaqDocFileName(aimsApp.getFaqDocFileName()); javaForm.setUserGuideFileName(aimsApp.getUserGuideFileName()); javaForm.setCompanyLogoFileName(javaApp.getCompanyFileName()); javaForm.setTitleImageFileName(javaApp.getAppTitleNameFileName()); javaForm.setAimsContactId(aimsApp.getAimsContactId()); // set user guide javaForm.setProductDescription(javaApp.getProductDescription()); javaForm.setUsingApplication(javaClobs.getUsingApplicationStr()); javaForm.setTipsAndTricks(javaClobs.getTipsAndTricksStr()); javaForm.setFaq(javaClobs.getFaqStr()); javaForm.setTroubleshooting(javaClobs.getTroubleshootingStr()); javaForm.setDevCompanyDisclaimer(javaClobs.getDevelopmentCompanyDisclaimerStr()); javaForm.setAdditionalInformation(javaClobs.getAdditionalInformationStr()); } // End of taskName=edit,view check if (javaForm.getAppsId() == null || javaForm.getAppsId().longValue() == 0 || taskname.equalsIgnoreCase("clone")) { javaForm.setApplicationStatus("NEW"); } else { if (javaForm.getAimsLifecyclePhaseId() != null && javaForm.getAimsLifecyclePhaseId().longValue() > 0) { try { AimsLifecyclePhase aimsPhaseOfApplication = (AimsLifecyclePhase) DBHelper.getInstance() .load(AimsLifecyclePhase.class, javaForm.getAimsLifecyclePhaseId().toString()); javaForm.setApplicationStatus(aimsPhaseOfApplication.getPhaseName()); } catch (HibernateException e) { log.error(e, e); } } } if (javaForm.getAimsAllianceId() != null && javaForm.getAimsAllianceId().longValue() > 0) { try { AimsAllianc aimsAllianceOfApplication = (AimsAllianc) DBHelper.getInstance().load(AimsAllianc.class, javaForm.getAimsAllianceId().toString()); javaForm.setAllianceName(aimsAllianceOfApplication.getCompanyName()); javaForm.setVendorId(aimsAllianceOfApplication.getVendorId()); } catch (HibernateException e) { log.error(e, e); } } JavaApplicationHelper.prePopulateForm(javaForm); if (log.isDebugEnabled()) log.debug("javaApplicationHelper.setupAction End:"); }
From source file:springmvc.controller.PdfController.java
@ExceptionHandler(Throwable.class) public String handleTException(Throwable t, HttpSession session) { User user = (User) session.getAttribute("user"); if (!(user.isInLogged())) { return "login"; }/* www.jav a 2s. c om*/ return "error"; }
From source file:springmvc.controller.PdfController.java
@ExceptionHandler(Exception.class) public String handleException(Throwable t, HttpSession session) { User user = (User) session.getAttribute("user"); if (!(user.isInLogged())) { return "login"; }//w w w. jav a 2 s . c o m return "error"; }