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:com.att.api.immn.controller.UpdateMsgController.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final HttpSession session = request.getSession(); OAuthToken token = (OAuthToken) session.getAttribute("token"); final String readflag = request.getParameter("updateStatus"); final String msgIdStr = request.getParameter("updateMsgId"); String[] msgIds = msgIdStr.split(","); final Boolean isUnread = readflag.equals("Read") ? false : true; IMMNService srvc = new IMMNService(appConfig.getApiFQDN(), token); JSONObject jresponse = new JSONObject(); try {/* ww w .ja v a 2 s . c o m*/ if (msgIds.length > 1) { DeltaChange[] changes = new DeltaChange[msgIds.length]; for (int i = 0; i < msgIds.length; ++i) { DeltaChange dc = new DeltaChange(msgIds[i], null, isUnread); changes[i] = dc; } srvc.updateMessages(changes); } else { srvc.updateMessage(msgIds[0], isUnread, null); } jresponse.put("success", true).put("text", "Message(s) Updated"); } catch (RESTException re) { jresponse.put("success", false).put("text", re.getMessage()); } response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.print(jresponse); writer.flush(); }
From source file:wqm.web.server.controller.BaseWQMController.java
protected AtlasSensor validateSensor(HttpSession session, int sensor) { Object sensorLock = session.getAttribute(Locks.Station.getLockName()); if (sensorLock == null) { logger.error("Trying to get to a sensor without acquiring the appropriate locks."); session.setAttribute(Messages.ERROR_MESSAGE, "Deep Linking not allowed to sensor."); throw new RedirectException(".."); }/* w w w.j ava2 s .c o m*/ AtlasSensor _sensor = AtlasSensor.find(sensor); if (_sensor == null) { session.setAttribute(Messages.ERROR_MESSAGE, "Invalid sensor."); throw new RedirectException("."); } return _sensor; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration.java
public static void clearEditConfigurationInSession(HttpSession session, EditConfiguration editConfig) { if (session == null || editConfig == null) return;/*from w ww . j ava 2s .c o m*/ Map<String, EditConfiguration> configs = (Map<String, EditConfiguration>) session .getAttribute("EditConfigurations"); if (configs == null) return; if (configs.containsKey(editConfig.editKey)) configs.remove(editConfig.editKey); }
From source file:mx.com.quadrum.contratos.controller.crud.UsuarioController.java
@ResponseBody @RequestMapping(value = "agregarUsuario", method = RequestMethod.POST) public String agregarUsuario(@Valid @ModelAttribute("usuario") Usuario usuario, BindingResult bindingResult, HttpSession session) { if (session.getAttribute("usuario") == null) { return SESION_CADUCA; }//from www . j a v a 2 s. c om if (bindingResult.hasErrors()) { return ERROR_DATOS; } if (usuarioService.existeCorreo(usuario.getMail())) { return "Error...#Ya existe un usuario con el correo que quiere ingresar."; } return usuarioService.agregar(usuario); }
From source file:be.fedict.eid.applet.service.PhotoServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet"); response.setContentType("image/jpg"); response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=-1"); // http 1.1 response.setHeader("Pragma", "no-cache, no-store"); // http 1.0 response.setDateHeader("Expires", -1); ServletOutputStream out = response.getOutputStream(); HttpSession session = request.getSession(); byte[] photoData = (byte[]) session.getAttribute(IdentityDataMessageHandler.PHOTO_SESSION_ATTRIBUTE); if (null != photoData) { BufferedImage photo = ImageIO.read(new ByteArrayInputStream(photoData)); if (null == photo) { /*//from ww w . ja v a 2 s . com * In this case we render a photo containing some error message. */ photo = new BufferedImage(140, 200, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = (Graphics2D) photo.getGraphics(); RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); graphics.setRenderingHints(renderingHints); graphics.setColor(Color.WHITE); graphics.fillRect(1, 1, 140 - 1 - 1, 200 - 1 - 1); graphics.setColor(Color.RED); graphics.setFont(new Font("Dialog", Font.BOLD, 20)); graphics.drawString("Photo Error", 0, 200 / 2); graphics.dispose(); ImageIO.write(photo, "jpg", out); } else { out.write(photoData); } } out.close(); }
From source file:com.netpace.aims.controller.application.JavaApplicationHelper.java
public static String updateAction(HttpServletRequest request, String taskname, JavaApplicationUpdateForm javaForm, AimsApp aimsApp, AimsJavaApps javaApp, AimsJavaAppClob javaClobs, AimsContact aimsContact, String dateFormat) throws AimsException, AimsSecurityException { if (log.isDebugEnabled()) log.debug("JavaApplicationHelper.updateAction: Start"); String forward = "view"; HttpSession session = request.getSession(); String currUser = ((AimsUser) (session.getAttribute(AimsConstants.AIMS_USER))).getUsername(); String currUserType = ((AimsUser) (session.getAttribute(AimsConstants.AIMS_USER))).getUserType(); Long currUserId = ((AimsUser) (session.getAttribute(AimsConstants.AIMS_USER))).getUserId(); Long currentUserAllianceId = ((AimsUser) session.getAttribute(AimsConstants.AIMS_USER)).getAimsAllianc(); boolean isVerizonUser = currUserType.equals(AimsConstants.VZW_USERTYPE); boolean isAllianceUser = currUserType.equals(AimsConstants.ALLIANCE_USERTYPE); // This check access code previously was commented // BEGIN/* www . j a v a 2 s.c o m*/ // CHECK ACCESS /* * if (!(ApplicationHelper.checkPlatformAccess(request, * javaForm.getOriginalTask(), AimsConstants.JAVA_PLATFORM_ID))) throw * new AimsSecurityException(); * * if (taskname.equalsIgnoreCase("edit")) if * (!(ApplicationHelper.checkEditAccess(currUserType, * aimsApp.getAimsLifecyclePhaseId()))) throw new * AimsSecurityException(); */ // END OF CHECK ACCESS // END if ((taskname.equalsIgnoreCase("page1")) || (taskname.equalsIgnoreCase("page2")) || (taskname.equalsIgnoreCase("page3")) || (taskname.equalsIgnoreCase("page4")) || (taskname.equalsIgnoreCase("page5")) || (taskname.equalsIgnoreCase("journal")) || (taskname.equalsIgnoreCase("submitJournal")) || (taskname.equalsIgnoreCase("sendZipFile")) || (taskname.equalsIgnoreCase("submitpage4")) || (taskname.equalsIgnoreCase("page4View")) || (taskname.equalsIgnoreCase("submitpage4View"))) { if (taskname.equalsIgnoreCase("page1")) forward = "page1"; else if (taskname.equalsIgnoreCase("page2")) forward = "page2"; else if (taskname.equalsIgnoreCase("page3")) forward = "page3"; else if (taskname.equalsIgnoreCase("page4")) forward = "page4"; else if (taskname.equalsIgnoreCase("page5")) forward = "page5"; else if (taskname.equalsIgnoreCase("sendZipFile")) forward = "page3"; else if (taskname.equalsIgnoreCase("submitpage4")) forward = "page4"; else if (taskname.equalsIgnoreCase("submitpage4View")) forward = "page4View"; else if (taskname.equalsIgnoreCase("page4View")) forward = "page4View"; if (taskname.equalsIgnoreCase("sendZipFile")) javaForm.setCurrentPage("page3"); else if (taskname.equalsIgnoreCase("submitpage4")) javaForm.setCurrentPage("page4"); else if (taskname.equalsIgnoreCase("submitpage4View")) javaForm.setCurrentPage("page4"); else javaForm.setCurrentPage(taskname); javaForm.setTask(javaForm.getOriginalTask()); if (currUserType.equals(AimsConstants.VZW_USERTYPE)) { // User submitted a journal entry. if (taskname.equalsIgnoreCase("submitpage4") || taskname.equalsIgnoreCase("submitpage4View")) { try { AimsApplicationsManager.saveJournalEntry(javaForm.getAppsId(), javaForm.getJournalText(), javaForm.getJournalType(), currUser); } catch (Exception e) { log.error(e, e); AimsException aimsException = new AimsException("Error"); aimsException.addException(new GenericException("error.generic.persistance")); throw aimsException; } } // Journal Entry page. if ("page4".equals(javaForm.getCurrentPage())) { try { Collection journalEntries = AimsApplicationsManager .getJournalEntries(new Long(request.getParameter("appsId")), currentUserAllianceId); javaForm.setJournalCombinedText(getFormattedJournalEntries(journalEntries)); } catch (Exception e) { log.error(e, e); AimsException aimsException = new AimsException("Error"); aimsException.addException(new GenericException("error.generic.database")); } } } } if (taskname.equalsIgnoreCase("create") || taskname.equalsIgnoreCase("edit")) { if (taskname.equalsIgnoreCase("create")) { aimsApp.setAimsAllianceId(currentUserAllianceId); aimsApp.setAimsUserAppCreatedById(currUserId); aimsApp.setIfOnHold("N"); aimsApp.setCreatedBy(currUser); aimsApp.setCreatedDate(new Date()); } aimsApp.setTitle(javaForm.getTitle()); aimsApp.setVersion(javaForm.getVersion()); aimsApp.setShortDesc(javaForm.getShortDesc()); aimsApp.setLongDesc(javaForm.getLongDesc()); aimsApp.setRingTypeId(javaForm.getRingNumber()); javaApp.setInfoUrl(javaForm.getInfoURL()); javaApp.setEnterpriseApp(javaForm.getEnterpriseApp()); javaApp.setAppKeyword(javaForm.getAppKeyword()); // java app contract if ((javaForm.getJavaAppContractId() != null) && (javaForm.getJavaAppContractId().longValue() != 0)) javaApp.setAimsContractId(javaForm.getJavaAppContractId()); // java app content type if ((javaForm.getContentType() != null) && (javaForm.getContentType().longValue() != 0)) javaApp.setContentTypeId(javaForm.getContentType()); // java app content rating type if ((javaForm.getContentRating() != null) && (javaForm.getContentRating().longValue() != 0)) javaApp.setContentRatingTypeId(javaForm.getContentRating()); if ((javaForm.getAimsTaxCategoryCodeId() != null) && (javaForm.getAimsTaxCategoryCodeId().longValue() != 0)) javaApp.setAimsTaxCategoryCodeId(javaForm.getAimsTaxCategoryCodeId()); if ((javaForm.getAppCategory1() != null) && (javaForm.getAppCategory1().longValue() != 0)) javaApp.setAppCategory1(javaForm.getAppCategory1()); if ((javaForm.getAppSubCategory1() != null) && (javaForm.getAppSubCategory1().longValue() != 0)) javaApp.setAppSubCategory1(javaForm.getAppSubCategory1()); if ((javaForm.getAppCategory2() != null) && (javaForm.getAppCategory2().longValue() != 0)) javaApp.setAppCategory2(javaForm.getAppCategory2()); if ((javaForm.getAppSubCategory2() != null) && (javaForm.getAppSubCategory2().longValue() != 0)) javaApp.setAppSubCategory2(javaForm.getAppSubCategory2()); if (!StringFuncs.isNullOrEmpty(javaForm.getProjectedLiveDate())) javaApp.setVzwProjectedLiveDate(Utility.convertToDate(javaForm.getProjectedLiveDate(), dateFormat)); if (!StringFuncs.isNullOrEmpty(javaForm.getEnterpriseId())) javaApp.setEnterpriseId(javaForm.getEnterpriseId()); if (!StringFuncs.isNullOrEmpty(javaForm.getInitialApprovalNotes())) javaApp.setNotes(javaForm.getInitialApprovalNotes()); // aimsApp.setAimsContractId(javaForm.getJavaAppContractId()); aimsApp.setIfPrRelease(javaForm.getIfPrRelease()); aimsApp.setLastUpdatedBy(currUser); aimsApp.setLastUpdatedDate(new Date()); aimsApp.setAimsPlatformId(AimsConstants.JAVA_PLATFORM_ID); // SubCategory if ((javaForm.getAimsAppSubCategoryId() != null) && (javaForm.getAimsAppSubCategoryId().longValue() != 0)) aimsApp.setAimsAppSubCategoryId(javaForm.getAimsAppSubCategoryId()); // Contact aimsApp.setAimsContactId(javaForm.getAimsContactId()); if (javaForm.getAimsContactId().longValue() == 0) { aimsContact.setFirstName(javaForm.getContactFirstName()); aimsContact.setLastName(javaForm.getContactLastName()); aimsContact.setEmailAddress(javaForm.getContactEmail()); aimsContact.setTitle(javaForm.getContactTitle()); aimsContact.setPhone(javaForm.getContactPhone()); aimsContact.setMobile(javaForm.getContactMobile()); aimsContact.setType(AimsConstants.CONTACT_TYPE_ALLIANCE_CONTACT); aimsContact.setCreatedBy(currUser); aimsContact.setCreatedDate(new Date()); aimsContact.setLastUpdatedBy(currUser); aimsContact.setLastUpdatedDate(new Date()); } // Start User Guide if (StringUtils.isNotEmpty(javaForm.getProductDescription())) { javaApp.setProductDescription(javaForm.getProductDescription().trim()); } if (StringUtils.isNotEmpty(javaForm.getUsingApplication())) { javaClobs.setUsingApplicationStr(javaForm.getUsingApplication().trim()); } else { javaClobs.setUsingApplicationStr(""); } if (StringUtils.isNotEmpty(javaForm.getTipsAndTricks())) { javaClobs.setTipsAndTricksStr(javaForm.getTipsAndTricks().trim()); } else { javaClobs.setTipsAndTricksStr(""); } if (StringUtils.isNotEmpty(javaForm.getFaq())) { javaClobs.setFaqStr(javaForm.getFaq().trim()); } else { javaClobs.setFaqStr(""); } if (StringUtils.isNotEmpty(javaForm.getTroubleshooting())) { javaClobs.setTroubleshootingStr(javaForm.getTroubleshooting().trim()); } else { javaClobs.setTroubleshootingStr(javaForm.getTroubleshooting()); } if (StringUtils.isNotEmpty(javaForm.getDevCompanyDisclaimer())) { javaClobs.setDevelopmentCompanyDisclaimerStr(javaForm.getDevCompanyDisclaimer().trim()); } else { javaClobs.setDevelopmentCompanyDisclaimerStr(""); } if (StringUtils.isNotEmpty(javaForm.getAdditionalInformation())) { javaClobs.setAdditionalInformationStr(javaForm.getAdditionalInformation().trim()); } else { javaClobs.setAdditionalInformationStr(""); } // End User Guide if (currUserType.equals(AimsConstants.ALLIANCE_USERTYPE)) { // Start of check to see if alliance has been accepted Object[] userValues = null; String allianceStatus = null; Collection AimsAlliance = null; try { AimsAlliance = AllianceManager.getAllianceDetails(aimsApp.getAimsAllianceId(), ""); } catch (Exception ex) { AimsException aimsException = new AimsException("Error"); aimsException .addException(new RecordNotFoundException("error.application.alliance.not.accepted")); throw aimsException; } for (Iterator iter = AimsAlliance.iterator(); iter.hasNext();) { userValues = (Object[]) iter.next(); allianceStatus = (String) userValues[3]; } if (!(javaForm.getAppSubmitType().equalsIgnoreCase(AimsConstants.AIMS_SAVE_FORM))) { if (!(allianceStatus.equals(AimsConstants.ALLIANCE_STATUS_ACCEPTED))) { AimsException aimsException = new AimsException("Error"); aimsException.addException( new RecordNotFoundException("error.application.alliance.not.accepted")); throw aimsException; } } // End of check to see if alliance has been accepted // check alliance has accepted atleast one active dashboard // contract /* * if * (dashboardForm.getAppSubmitType().equalsIgnoreCase(AimsConstants * .AIMS_SUBMIT_FORM)) { try { * if(!ApplicationHelper.validateAllianceContract * (currentUserAllianceId, AimsConstants.DASHBOARD_PLATFORM_ID, * currUserType)) { AimsException aimsException = new * AimsException("Error"); aimsException.addException(new * RecordNotFoundException * ("error.dashboard.app.contract.acceptance")); throw * aimsException; } } catch (HibernateException e) { * AimsException aimsException = new AimsException("Error"); * aimsException.addException(newRecordNotFoundException( * "error.dashboard.app.contract.acceptance.exception")); throw * aimsException; } } */ } /* * //Set VZW Specific Information if (isVerizonUser) { if * (ApplicationHelper.checkAccess(request, taskname, * AimsPrivilegesConstants.DASHBOARD_INITIAL_APPROVAL)) { * dashboardApp * .setInitialApprovalNotes(dashboardForm.getInitialApprovalNotes * ());dashboardApp.setInitialApprovalAction(dashboardForm. * getInitialApprovalAction()); } * * if (ApplicationHelper.checkAccess(request, taskname, * AimsPrivilegesConstants.DASHBOARD_CONTENT_ZIP_FILE)) { if * (StringUtils.isNotEmpty(dashboardForm.getChannelId()) && * StringUtils.isNumeric(dashboardForm.getChannelId())){ * dashboardChannelId.setChannelId(new * Long(dashboardForm.getChannelId())); } else { * dashboardChannelId.setChannelId(null); } * dashboardApp.setContentZipNotes * (dashboardForm.getContentZipFileNotes()); * dashboardApp.setContentZipApprovalAction * (dashboardForm.getContentZipFileAction()); * dashboardApp.setContentZipFileLocked * (dashboardForm.getIsContentZipFileLock()); } * * if (ApplicationHelper.checkAccess(request, taskname, * AimsPrivilegesConstants.DASHBOARD_TRACKING)) { * dashboardApp.setMoveToProduction * (dashboardForm.getMoveToProduction()); * dashboardApp.setRemove(dashboardForm.getRemove()); } } */ } JavaApplicationHelper.prePopulateForm(javaForm); if (log.isDebugEnabled()) log.debug("JavaApplicationHelper.updateAction: End"); return forward; }
From source file:com.github.zhanhb.ckfinder.connector.support.XmlExceptionHandler.java
@Override public void handleException(HttpServletRequest request, HttpServletResponse response, CKFinderContext context, ConnectorException connectorException) throws IOException { HttpSession session = request.getSession(false); String userRole = session == null ? null : (String) session.getAttribute(context.getUserRoleName()); Connector.Builder connector = Connector.builder(); String currentFolder = connectorException.getCurrentFolder(); ResourceType type = connectorException.getType(); int errorNum = connectorException.getErrorCode().getCode(); if (type != null) { String typeName = type.getName(); connector.resourceType(typeName); if (StringUtils.hasLength(currentFolder)) { connector.currentFolder(/* w w w . jav a2 s . c o m*/ CurrentFolder.builder().path(currentFolder).url(type.getUrl() + currentFolder) .acl(context.getAccessControl().getAcl(typeName, currentFolder, userRole)).build()); } } connector.error(Error.builder().number(errorNum).value(connectorException.getMessage()).build()); String result = XmlCreator.INSTANCE.toString(connector.build()); response.setContentType("text/xml"); response.setCharacterEncoding("UTF-8"); response.setHeader("Cache-Control", "no-cache"); try (PrintWriter out = response.getWriter()) { out.write(result); } }
From source file:com.leapfrog.springFramework.Controller.DiscussController.java
@RequestMapping(value = "/postquestion", method = RequestMethod.POST) public String InserQuestion(@RequestParam Map<String, String> parVal, HttpServletRequest request) { HttpSession session = request.getSession(false); User user = (User) session.getAttribute("USER"); String title = parVal.get("title"); String Question = parVal.get("question"); String tag = parVal.get("tags"); Question q = new Question(); q.setTitle(title);/*w w w.j ava 2 s .c om*/ q.setQuestion(Question); q.setStatus(false); q.setTags(tag); q.setUser(user); qDao.insert(q); return "redirect:" + "/askquestion"; }
From source file:com.att.api.immn.controller.SendMsgController.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final HttpSession session = request.getSession(); OAuthToken token = (OAuthToken) session.getAttribute("token"); final String addr = request.getParameter("address"); final String[] addrs = addr.split(","); for (int i = 0; i < addrs.length; ++i) addrs[i] = addrs[i].trim();//from w ww. j a va 2 s . com final String msg = request.getParameter("sendMsgInput"); final String subject = request.getParameter("sendSubjectInput"); final boolean group = request.getParameter("groupCheckbox") != null; // TODO: handle attachments IMMNService srvc = new IMMNService(appConfig.getApiFQDN(), token); JSONObject jresponse = new JSONObject(); try { SendResponse sendResponse = null; if (!subject.isEmpty() || group) { sendResponse = srvc.sendMessage(addrs, msg, subject, group, /* TODO: finish attachments */ null); } else { sendResponse = srvc.sendMessage(addrs, msg); } final String id = sendResponse.getId(); jresponse.put("success", true).put("text", "id: " + id); } catch (RESTException re) { jresponse.put("success", false).put("text", re.getMessage()); } response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.print(jresponse); writer.flush(); }
From source file:com.naver.timetable.interceptor.LoginInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { HttpSession session = request.getSession(); //user ?? ? ? User user = (User) session.getAttribute("user"); if (session.getAttribute("user") == null) { // Login? if (request.getRequestURI().equals("/login/login")) return true; if (request.getRequestURI().equals("/login/join")) return true; session.setAttribute("targetPage", request.getRequestURI()); response.sendRedirect("/login/login"); return false; }/* w w w .j a va 2s . c om*/ //?? ? ? login ? join? . if (request.getRequestURI().equals("/login/login") || request.getRequestURI().equals("/login/join")) { response.sendRedirect("/lecture/index"); return false; } // Method method = (Method)handler; // for(Object param : method.getParameterTypes()) { // System.out.println(param.getClass().getName()); // if(param instanceof User) { // System.out.println("qwe"); // } // } return true; }