List of usage examples for javax.servlet.http HttpServletRequest getLocalAddr
public String getLocalAddr();
From source file:net.voidfunction.rm.master.AdminServlet.java
private String pageIndex(HttpServletRequest request) throws FileNotFoundException { Template tpl = new Template(new File(templateDir + "index.tpl")); tpl.assign("HOST", node.getPublicIP()); // Status info tpl.assign("UPTIME", getDuration(ManagementFactory.getRuntimeMXBean().getUptime())); tpl.assign("WORKERCOUNT", String.valueOf(node.getWorkerDirectory().getWorkerCount())); tpl.assign("FILECOUNT", String.valueOf(node.getFileRepository().getFileCount())); // Files/* w w w . ja v a2s. c o m*/ Collection<RMFile> files = node.getFileRepository().getFileObjects(); if (files.size() == 0) { tpl.assign("FILEID", "No files."); tpl.assign("FILENAME", ""); tpl.assign("FILETYPE", ""); tpl.assign("FILESIZE", ""); tpl.assign("DOWNURL", ""); tpl.assign("DOWNTXT", ""); tpl.assign("DELETEURL", ""); tpl.assign("DELETETXT", ""); tpl.parse("main.file"); } for (RMFile file : files) { tpl.assign("FILEID", file.getId()); tpl.assign("FILENAME", file.getName()); tpl.assign("FILETYPE", file.getMimetype()); tpl.assign("FILESIZE", String.valueOf(file.getSize())); tpl.assign("DOWNURL", "http://" + request.getLocalAddr() + ":" + node.getConfig().getInt("port.http", 8080) + "/files/" + file.getId() + "/" + file.getName()); tpl.assign("DOWNTXT", "Download"); tpl.assign("DELETEURL", "?page=delete&id=" + file.getId()); tpl.assign("DELETETXT", "Delete"); tpl.parse("main.file"); } tpl.parse("main"); return tpl.out(); }
From source file:com.sammyun.plugin.alipayDirect.AlipayDirectPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SettingUtils.get(); PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn);//from ww w . ja v a 2 s . com Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "create_direct_pay_by_user"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("_input_charset", "utf-8"); parameterMap.put("sign_type", "MD5"); parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync)); parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async)); parameterMap.put("out_trade_no", sn); parameterMap.put("subject", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 60)); parameterMap.put("body", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 600)); parameterMap.put("payment_type", "1"); parameterMap.put("seller_id", pluginConfig.getAttribute("partner")); parameterMap.put("total_fee", payment.getAmount().setScale(2).toString()); parameterMap.put("show_url", setting.getSiteUrl()); parameterMap.put("paymethod", "directPay"); parameterMap.put("exter_invoke_ip", request.getLocalAddr()); parameterMap.put("extra_common_param", "preschoolEdu"); parameterMap.put("sign", generateSign(parameterMap)); return parameterMap; }
From source file:org.sipfoundry.sipxprovision.auto.Servlet.java
protected void writeDebuggingResponse(HttpServletRequest request, HttpServletResponse response) throws IOException { // Do some debugging. LOG.debug("Debugging: " + request.getPathInfo()); response.setContentType("text/plain"); PrintWriter out = response.getWriter(); logAndOut("getPathInfo(): '" + request.getPathInfo() + "'", out); logAndOut("getQueryString(): '" + request.getQueryString() + "'", out); logAndOut("getRequestURI(): '" + request.getRequestURI() + "'", out); logAndOut("getRemoteUser(): '" + request.getRemoteUser() + "'", out); logAndOut("getServletPath(): '" + request.getServletPath() + "'", out); logAndOut("getContextPath(): '" + request.getContextPath() + "'", out); logAndOut("getLocalAddr(): '" + request.getLocalAddr() + "'", out); logAndOut("getServerName(): '" + request.getServerName() + "'", out); logAndOut("getServerPort(): '" + request.getServerPort() + "'", out); logAndOut("getHeader(\"User-Agent\"): '" + request.getHeader("User-Agent") + "'", out); logAndOut("", out); logAndOut("request: " + request, out); m_config.dumpConfiguration(out);/* www .j av a 2 s . c o m*/ }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.myaccount.ApplyForWritingPermissionController.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException bindException) throws Exception { log.debug("Processing the form"); ApplyForWritingPermissionCommand afwpc = (ApplyForWritingPermissionCommand) command; log.debug("Loading Person object of actual logged user from database"); Person user = personDao.getPerson(ControllerUtils.getLoggedUserName()); log.debug("Composing e-mail message"); SimpleMailMessage mail = new SimpleMailMessage(mailMessage); mail.setFrom(user.getEmail());//w w w . ja v a 2 s. c o m log.debug("Loading list of supervisors"); List<Person> supervisors = personDao.getSupervisors(); String[] emails = new String[supervisors.size()]; int i = 0; for (Person supervisor : supervisors) { emails[i++] = supervisor.getEmail(); } mail.setTo(emails); log.debug("Setting subject to e-mail message"); mail.setSubject(mail.getSubject() + " - Write permission request from user " + user.getUsername()); String messageBody = "User " + user.getUsername() + " has requested permission for adding data into EEGbase system.\n" + "Reason is: " + afwpc.getReason() + "\n" + "Use the address below to grant the write permission.\n"; String linkAddress = "http://" + request.getLocalAddr() + ":" + request.getLocalPort() + request.getContextPath() + "/system/grant-permission.html?id=" + user.getPersonId(); log.debug("Address is: " + linkAddress); messageBody += linkAddress; mail.setText(messageBody); String mavName = ""; try { log.debug("Sending message"); mailSender.send(mail); log.debug("Mail was sent"); mavName = getSuccessView(); } catch (MailException e) { log.debug("Mail was not sent"); mavName = getFailView(); } log.debug("Returning MAV"); ModelAndView mav = new ModelAndView(mavName); return mav; }
From source file:org.bibalex.wamcp.storage.WAMCPStorage.java
public/* synchronized */void release(Document metadataXml, Element metaAlbum) throws BAGException, WAMCPException, WFSVNArtifactLoadingException, WFSVNLockedException { this.guardArtifactLoaded(); // JdbcTemplate locksDBTempl = // this.svnClient.getWfProcess().getJdbcTempl(); String releasedMetaGallUrlStr = URLPathStrUtils.appendParts(this.galleryBean.getGalleryRootUrlStr(), BAGGalleryAbstract.FILENAME_GALLERY_METADATA_XML); try {/* www .j a v a 2 s .c o m*/ XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat().setEncoding("UTF-8")); this.svnClient.getWfProcess().lockUrlStr(releasedMetaGallUrlStr, this.sessionBBean.getUserName()); try { SAXBuilder saxBuilder = new SAXBuilder(); saxBuilder.setFeature("http://xml.org/sax/features/validation", false); saxBuilder.setFeature("http://xml.org/sax/features/namespaces", true); saxBuilder.setFeature("http://xml.org/sax/features/namespace-prefixes", true); // Unsupported: // saxBuilder.setFeature("http://xml.org/sax/features/xmlns-uris", // false); Document metaGalleryXml; ByteArrayOutputStream remoteFileOS = new ByteArrayOutputStream(); ByteArrayInputStream metaGalleryIn = null; try { BAGStorage.readRemoteFile(releasedMetaGallUrlStr, remoteFileOS); metaGalleryIn = new ByteArrayInputStream(remoteFileOS.toByteArray()); metaGalleryXml = saxBuilder.build(metaGalleryIn); } finally { try { remoteFileOS.close(); metaGalleryIn.close(); } catch (IOException e) { throw new BAGException(e); } } XPath oldMetaAlbumXP = XPath .newInstance("//album[@name='" + metaAlbum.getAttributeValue("name") + "']"); Element metaGalleryRoot = metaGalleryXml.getRootElement(); for (Object oldMetaAlbum : oldMetaAlbumXP.selectNodes(metaGalleryRoot)) { ((Element) oldMetaAlbum).detach(); } metaGalleryRoot.addContent(metaAlbum); File metaGalleryTempFile = File .createTempFile(FileUtils.makeSafeFileName(this.sessionBBean.getUserName()), "metagallery"); FileOutputStream metaGalleryOut = new FileOutputStream(metaGalleryTempFile); outputter.output(metaGalleryXml, metaGalleryOut); metaGalleryOut.flush(); metaGalleryOut.close(); String releasedXMLUrlStr = URLPathStrUtils.appendParts(this.galleryBean.getGalleryRootUrlStr(), "XML", filenameForShelfMark(this.artifact.getArtifactName()) + ".tei.xml"); File msDescTempFile = File.createTempFile( FileUtils.makeSafeFileName(this.sessionBBean.getUserName()), "msDescReleased"); FileOutputStream msDescOut = new FileOutputStream(msDescTempFile); outputter.output(metadataXml, msDescOut); msDescOut.flush(); msDescOut.close(); // BAGStorage.copyFile(msDescTempFile.toURI().toString(), // releasedXMLUrlStr); // BAGStorage.copyFile(metaGalleryTempFile.toURI().toString(), // releasedMetaGallUrlStr); // TODO be DRY if (!BAGStorage.putFile(releasedXMLUrlStr, msDescTempFile, null)) { throw new WAMCPGeneralCorrectableException("Could not upload tei file to release destination"); } if (!BAGStorage.putFile(releasedMetaGallUrlStr, metaGalleryTempFile, null)) { throw new WAMCPGeneralCorrectableException( "Could not upload meta gallery file to release destination"); } generateMARCFile(msDescTempFile, this.artifact.getArtifactName(), this.galleryBean.getGalleryRootUrlStr()); // generate html file for the manuscript on release // both versions are generated (full and DIV) // also generate html for metadata print // also generate pdf for images of manuscript // Yasmine20110508 { // Yasmine20110621{ HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance() .getExternalContext().getRequest(); String uri = request.getRequestURL().toString(); String[] splited = uri.split("/"); // host = http://172.16.0.17:80/ // String host = splited[0]+"//"+splited[2]+"/"; String host = splited[0] + "//" + request.getLocalAddr() + ":" + request.getLocalPort() + "/"; int statusCode = 0; BAOAIIDBuilder oaiIdBuilder = new BAOAIIDBuilder(); String oaiId = oaiIdBuilder.buildId(this.artifact.getArtifactName()); String url = host + "BAG-API/rest/desc/" + oaiId + "/transform?type=html"; statusCode = myGetHttp(url); System.out.println(url + " ==> status code: " + statusCode); String urlDivOpt = host + "BAG-API/rest/desc/" + oaiId + "/transform?divOpt=true&type=html"; statusCode = myGetHttp(urlDivOpt); System.out.println(urlDivOpt + " ==> status code: " + statusCode); String urlMetadataHtml = host + "BAG-API/rest/desc/" + oaiId + "/transform?type=meta"; statusCode = myGetHttp(urlMetadataHtml); System.out.println(urlMetadataHtml + " ==> status code: " + statusCode); // String rootUrlStr = this.galleryBean.getGalleryRootUrlStr(); // String tempUserName = this.sessionBBean.getUserName(); // System.out.println("rootUrlStr: "+rootUrlStr); // System.out.println("tempUserName: "+tempUserName); // transformXMLtoHTML(rootUrlStr, tempUserName, // filenameForShelfMark(this.artifact.getArtifactName()), // false); // transformXMLtoHTML(rootUrlStr, tempUserName, // filenameForShelfMark(this.artifact.getArtifactName()), // true); // } Yasmine20110621 // } Yasmine20110508 } finally { this.svnClient.getWfProcess().unlockUrlStr(releasedMetaGallUrlStr, this.sessionBBean.getUserName()); } } catch (DataIntegrityViolationException e) { throw new WAMCPGeneralCorrectableException( "Another user is releasing at the moment, try again in a few seconds"); } catch (JDOMException e) { throw new WAMCPException(e); } catch (IOException e) { throw new WAMCPException(e); } }
From source file:net.shopxx.plugin.alipayDirectPayment.AlipayDirectPaymentPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SystemUtils.getSetting(); PluginConfig pluginConfig = getPluginConfig(); PaymentLog paymentLog = getPaymentLog(sn); Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "create_direct_pay_by_user"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("_input_charset", "utf-8"); parameterMap.put("sign_type", "MD5"); parameterMap.put("return_url", getNotifyUrl(PaymentPlugin.NotifyMethod.sync)); parameterMap.put("notify_url", getNotifyUrl(PaymentPlugin.NotifyMethod.async)); parameterMap.put("out_trade_no", sn); parameterMap.put("subject", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 60)); parameterMap.put("body", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 600)); parameterMap.put("payment_type", "1"); parameterMap.put("seller_id", pluginConfig.getAttribute("partner")); parameterMap.put("total_fee", paymentLog.getAmount().setScale(2).toString()); parameterMap.put("show_url", setting.getSiteUrl()); parameterMap.put("paymethod", "directPay"); parameterMap.put("extend_param", "isv^1860648a1"); parameterMap.put("exter_invoke_ip", request.getLocalAddr()); parameterMap.put("extra_common_param", "shopxx"); parameterMap.put("sign", generateSign(parameterMap)); return parameterMap; }
From source file:com.jd.survey.web.survey.PrivateSurveyController.java
/** * Updates a survey page /* ww w .j a v a 2 s . c o m*/ * @param surveyPage * @param backAction * @param proceedAction * @param bindingResult * @param uiModel * @param principal * @param httpServletRequest * @return */ @Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN", "ROLE_SURVEY_PARTICIPANT" }) @RequestMapping(method = RequestMethod.POST, produces = "text/html") public String updateSurveyPage(@Valid SurveyPage surveyPage, @RequestParam(value = "_back", required = false) String backAction, @RequestParam(value = "_proceed", required = false) String proceedAction, BindingResult bindingResult, Model uiModel, Principal principal, HttpServletRequest httpServletRequest) { try { String login = principal.getName(); Short order = surveyPage.getOrder(); if (proceedAction != null) { //next button Survey survey = surveyService.survey_findById(surveyPage.getSurvey().getId()); //Check if the user is authorized if (!survey.getLogin().equals(login)) { log.warn(UNAUTHORIZED_ATTEMPT_TO_ACCESS_SURVEY_WARNING_MESSAGE + survey.getId() + REQUEST_PATH_WARNING_MESSAGE + httpServletRequest.getPathInfo() + FROM_USER_LOGIN_WARNING_MESSAGE + principal.getName() + FROM_IP_WARNING_MESSAGE + httpServletRequest.getLocalAddr()); return "accessDenied"; } //Check that the survey was not submitted if (!(survey.getStatus().equals(SurveyStatus.I) || survey.getStatus().equals(SurveyStatus.R))) { log.warn(UNAUTHORIZED_ATTEMPT_TO_EDIT_SUBMITTED_SURVEY_WARNING_MESSAGE + survey.getId() + REQUEST_PATH_WARNING_MESSAGE + httpServletRequest.getPathInfo() + FROM_USER_LOGIN_WARNING_MESSAGE + principal.getName() + FROM_IP_WARNING_MESSAGE + httpServletRequest.getLocalAddr()); return "accessDenied"; } List<SurveyPage> surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); surveyPage.setSurvey(survey); surveyPage = surveyService.surveyPage_updateSettings(surveyPage); //populate the uploaded files MultipartHttpServletRequest multiPartRequest = (MultipartHttpServletRequest) httpServletRequest; Iterator<String> fileNames = multiPartRequest.getFileNames(); while (fileNames.hasNext()) { String fileName = fileNames.next(); Long questionId = Long.parseLong(fileName.toUpperCase().replace("FILE", "")); for (QuestionAnswer questionAnswer : surveyPage.getQuestionAnswers()) { if (questionAnswer.getQuestion().getId().equals(questionId) && multiPartRequest.getFile(fileName).getBytes().length > 0) { questionAnswer.setSurveyDocument(new SurveyDocument(survey.getId(), questionId, multiPartRequest.getFile(fileName).getName(), multiPartRequest.getFile(fileName).getContentType(), multiPartRequest.getFile(fileName).getBytes())); } } } Policy policy = Policy.getInstance(this.getClass().getResource(POLICY_FILE_LOCATION)); AntiSamy as = new AntiSamy(); for (QuestionAnswer questionAnswer : surveyPage.getQuestionAnswers()) { if (questionAnswer.getQuestion().getType().getIsTextInput()) { CleanResults cr = as.scan(questionAnswer.getStringAnswerValue(), policy); questionAnswer.setStringAnswerValue(cr.getCleanHTML()); } } GlobalSettings globalSettings = applicationSettingsService.getSettings(); SurveyPageValidator validator = new SurveyPageValidator( messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale()), globalSettings.getValidContentTypes(), globalSettings.getValidImageTypes(), globalSettings.getMaximunFileSize(), globalSettings.getInvalidContentMessage(), globalSettings.getInvalidFileSizeMessage()); validator.validate(surveyPage, bindingResult); if (bindingResult.hasErrors()) { /* for (ObjectError err :bindingResult.getAllErrors()) { log.info("getObjectName:" + err.getObjectName() + " getCode:" + err.getCode() + " getDefaultMessage:" + err.getDefaultMessage()); log.info("toString:" + err.toString()); } */ uiModel.addAttribute("survey_base_path", "private"); uiModel.addAttribute("survey", survey); uiModel.addAttribute("surveyPage", surveyPage); uiModel.addAttribute("surveyDefinition", surveySettingsService.surveyDefinition_findById(surveyPage.getSurvey().getTypeId())); uiModel.addAttribute("surveyPages", surveyPages); return "surveys/page"; } surveyService.surveyPage_update(surveyPage, messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); //get the survey pages from the database again, prvious call updates visibility when there is branching logic surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); order = getNextPageOrder(surveyPages, order); if (order.equals((short) 0)) { //Submit page uiModel.asMap().clear(); return "redirect:/private/submit/" + encodeUrlPathSegment(surveyPage.getSurvey().getId().toString(), httpServletRequest); } else { //go to the next page uiModel.asMap().clear(); return "redirect:/private/" + encodeUrlPathSegment(surveyPage.getSurvey().getId().toString(), httpServletRequest) + "/" + encodeUrlPathSegment(order.toString(), httpServletRequest); } } else {//back button Survey survey = surveyService.survey_findById(surveyPage.getSurvey().getId()); //Check if the user is authorized if (!survey.getLogin().equals(login)) { log.warn(UNAUTHORIZED_ATTEMPT_TO_ACCESS_SURVEY_WARNING_MESSAGE + survey.getId() + REQUEST_PATH_WARNING_MESSAGE + httpServletRequest.getPathInfo() + FROM_USER_LOGIN_WARNING_MESSAGE + principal.getName() + FROM_IP_WARNING_MESSAGE + httpServletRequest.getLocalAddr()); return "accessDenied"; } List<SurveyPage> surveyPages = surveyService.surveyPage_getAll(surveyPage.getSurvey().getId(), messageSource.getMessage(DATE_FORMAT, null, LocaleContextHolder.getLocale())); order = getPreviousPageOrder(surveyPages, order); if (order.equals((short) 0)) { //Go to the surveyEntries page uiModel.asMap().clear(); return "redirect:/private/" + encodeUrlPathSegment(survey.getTypeId().toString(), httpServletRequest) + "?list"; } else { //go to previous page uiModel.asMap().clear(); return "redirect:/private/" + encodeUrlPathSegment(survey.getId().toString(), httpServletRequest) + "/" + encodeUrlPathSegment(order.toString(), httpServletRequest); } } } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.jd.survey.web.settings.QuestionController.java
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) @RequestMapping(method = RequestMethod.PUT, produces = "text/html") public String update(@RequestParam(value = "_proceed", required = false) String proceed, @Valid Question question, BindingResult bindingResult, Principal principal, Model uiModel, HttpServletRequest httpServletRequest) { log.info("update(): handles PUT"); try {/* ww w. j a v a 2 s . c o m*/ //User user = userService.user_findByLogin(principal.getName()); String login = principal.getName(); User user = userService.user_findByLogin(login); //SurveyDefinitionPage surveyDefinitionPage = surveySettingsService.surveyDefinitionPage_findById(surveyDefinitionPageId); surveySettingsService.question_findById(question.getId()).getPage().getSurveyDefinition().getId() //Check if the user is authorized if (!securityService.userIsAuthorizedToManageSurvey(question.getPage().getSurveyDefinition().getId(), user) && !securityService.userBelongsToDepartment( question.getPage().getSurveyDefinition().getDepartment().getId(), user)) { log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr()); return "accessDenied"; } if (proceed != null) { if (bindingResult.hasErrors()) { populateEditForm(uiModel, question, user); log.info("-------------------------------------------" + bindingResult.getFieldErrors().toString()); return "settings/questions/update"; } if (!surveySettingsService.question_ValidateDateRange(question)) { populateEditForm(uiModel, question, user); bindingResult.rejectValue("dateMinimum", "date_format_validation_range"); return "settings/questions/update"; } if (!surveySettingsService.question_ValidateMinMaxDoubleValues(question)) { populateEditForm(uiModel, question, user); bindingResult.rejectValue("decimalMinimum", "field_min_invalid"); return "settings/questions/update"; } if (!surveySettingsService.question_ValidateMinMaxValues(question)) { populateEditForm(uiModel, question, user); bindingResult.rejectValue("integerMinimum", "field_min_invalid"); return "settings/questions/update"; } if (question.getSuportsOptions()) { //If user wants to modify and existent question without options to Rating type, then use the default values int NumberOfQuestionOptions = 0; Set<QuestionOption> qOpts = surveySettingsService .questionOption_findByQuestionId(question.getId()); for (QuestionOption q : qOpts) { NumberOfQuestionOptions++; } if ((question.getType().toString() == "SMILEY_FACES_RATING" || question.getType().toString() == "STAR_RATING") && NumberOfQuestionOptions != 5) { log.info( "Removing Question Options since the amount of Questions Options for Rating Type cannot be longer than 5 Qoptions"); surveySettingsService.questionOption_removeQuestionOptionsByQuestionId(question.getId()); SortedSet<QuestionOption> options = new TreeSet<QuestionOption>(); options.add(new QuestionOption(question, (short) 1, "1", messageSource .getMessage(EXTREMELY_UNSATISFIED_LABEL, null, LocaleContextHolder.getLocale()))); options.add(new QuestionOption(question, (short) 2, "2", messageSource .getMessage(UNSATISFIED_LABEL, null, LocaleContextHolder.getLocale()))); options.add(new QuestionOption(question, (short) 3, "3", messageSource.getMessage(NEUTRAL_LABEL, null, LocaleContextHolder.getLocale()))); options.add(new QuestionOption(question, (short) 4, "4", messageSource.getMessage(SATISFIED_LABEL, null, LocaleContextHolder.getLocale()))); options.add(new QuestionOption(question, (short) 5, "5", messageSource .getMessage(EXTREMELY_SATISFIED_LABEL, null, LocaleContextHolder.getLocale()))); //Adding default values to Rating Type Question log.info("Adding default values to Rating Type Question"); question = surveySettingsService.question_merge(question, options); uiModel.asMap().clear(); return "settings/questions/saved"; } else { Policy questionTextPolicy = Policy .getInstance(this.getClass().getResource(POLICY_FILE_LOCATION)); AntiSamy emailAs = new AntiSamy(); CleanResults crQuestionText = emailAs.scan(question.getQuestionText(), questionTextPolicy); question.setQuestionText(crQuestionText.getCleanHTML()); Policy questionTipPolicy = Policy .getInstance(this.getClass().getResource(POLICY_FILE_LOCATION)); AntiSamy completedSurveyAs = new AntiSamy(); CleanResults crQuestionTip = completedSurveyAs.scan(question.getTip(), questionTipPolicy); question.setTip(crQuestionTip.getCleanHTML()); question = surveySettingsService.question_merge(question); uiModel.asMap().clear(); return "settings/questions/saved"; } } question = surveySettingsService.question_merge(question); uiModel.asMap().clear(); return "settings/questions/saved"; } else { return "redirect:/settings/surveyDefinitions/" + encodeUrlPathSegment( question.getPage().getSurveyDefinition().getId().toString(), httpServletRequest); } } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:org.sakaiproject.portal.util.ErrorReporter.java
@SuppressWarnings("rawtypes") private String requestDisplay(HttpServletRequest request) { ResourceBundle rb = rbDefault; StringBuilder sb = new StringBuilder(); try {/* ww w . jav a2 s .c o m*/ sb.append(rb.getString("bugreport.request")).append("\n"); sb.append(rb.getString("bugreport.request.authtype")).append(request.getAuthType()).append("\n"); sb.append(rb.getString("bugreport.request.charencoding")).append(request.getCharacterEncoding()) .append("\n"); sb.append(rb.getString("bugreport.request.contentlength")).append(request.getContentLength()) .append("\n"); sb.append(rb.getString("bugreport.request.contenttype")).append(request.getContentType()).append("\n"); sb.append(rb.getString("bugreport.request.contextpath")).append(request.getContextPath()).append("\n"); sb.append(rb.getString("bugreport.request.localaddr")).append(request.getLocalAddr()).append("\n"); sb.append(rb.getString("bugreport.request.localname")).append(request.getLocalName()).append("\n"); sb.append(rb.getString("bugreport.request.localport")).append(request.getLocalPort()).append("\n"); sb.append(rb.getString("bugreport.request.method")).append(request.getMethod()).append("\n"); sb.append(rb.getString("bugreport.request.pathinfo")).append(request.getPathInfo()).append("\n"); sb.append(rb.getString("bugreport.request.protocol")).append(request.getProtocol()).append("\n"); sb.append(rb.getString("bugreport.request.querystring")).append(request.getQueryString()).append("\n"); sb.append(rb.getString("bugreport.request.remoteaddr")).append(request.getRemoteAddr()).append("\n"); sb.append(rb.getString("bugreport.request.remotehost")).append(request.getRemoteHost()).append("\n"); sb.append(rb.getString("bugreport.request.remoteport")).append(request.getRemotePort()).append("\n"); sb.append(rb.getString("bugreport.request.requesturl")).append(request.getRequestURL()).append("\n"); sb.append(rb.getString("bugreport.request.scheme")).append(request.getScheme()).append("\n"); sb.append(rb.getString("bugreport.request.servername")).append(request.getServerName()).append("\n"); sb.append(rb.getString("bugreport.request.headers")).append("\n"); for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) { String headerName = (String) e.nextElement(); boolean censor = (censoredHeaders.get(headerName) != null); for (Enumeration he = request.getHeaders(headerName); he.hasMoreElements();) { String headerValue = (String) he.nextElement(); sb.append(rb.getString("bugreport.request.header")).append(headerName).append(":") .append(censor ? "---censored---" : headerValue).append("\n"); } } sb.append(rb.getString("bugreport.request.parameters")).append("\n"); for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String parameterName = (String) e.nextElement(); boolean censor = (censoredParameters.get(parameterName) != null); String[] paramvalues = request.getParameterValues(parameterName); for (int i = 0; i < paramvalues.length; i++) { sb.append(rb.getString("bugreport.request.parameter")).append(parameterName).append(":") .append(i).append(":").append(censor ? "----censored----" : paramvalues[i]) .append("\n"); } } sb.append(rb.getString("bugreport.request.attributes")).append("\n"); for (Enumeration e = request.getAttributeNames(); e.hasMoreElements();) { String attributeName = (String) e.nextElement(); Object attribute = request.getAttribute(attributeName); boolean censor = (censoredAttributes.get(attributeName) != null); sb.append(rb.getString("bugreport.request.attribute")).append(attributeName).append(":") .append(censor ? "----censored----" : attribute).append("\n"); } HttpSession session = request.getSession(false); if (session != null) { DateFormat serverLocaleDateFormat = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault()); sb.append(rb.getString("bugreport.session")).append("\n"); sb.append(rb.getString("bugreport.session.creation")).append(session.getCreationTime()) .append("\n"); sb.append(rb.getString("bugreport.session.lastaccess")).append(session.getLastAccessedTime()) .append("\n"); sb.append(rb.getString("bugreport.session.creationdatetime")) .append(serverLocaleDateFormat.format(session.getCreationTime())).append("\n"); sb.append(rb.getString("bugreport.session.lastaccessdatetime")) .append(serverLocaleDateFormat.format(session.getLastAccessedTime())).append("\n"); sb.append(rb.getString("bugreport.session.maxinactive")).append(session.getMaxInactiveInterval()) .append("\n"); sb.append(rb.getString("bugreport.session.attributes")).append("\n"); for (Enumeration e = session.getAttributeNames(); e.hasMoreElements();) { String attributeName = (String) e.nextElement(); Object attribute = session.getAttribute(attributeName); boolean censor = (censoredAttributes.get(attributeName) != null); sb.append(rb.getString("bugreport.session.attribute")).append(attributeName).append(":") .append(censor ? "----censored----" : attribute).append("\n"); } } } catch (Exception ex) { M_log.error("Failed to generate request display", ex); sb.append("Error " + ex.getMessage()); } return sb.toString(); }
From source file:net.groupbuy.plugin.alipayBank.AlipayBankPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SettingUtils.get(); PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn);/*from ww w . j ava 2s .c om*/ Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "create_direct_pay_by_user"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("_input_charset", "utf-8"); parameterMap.put("sign_type", "MD5"); parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync)); parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async)); parameterMap.put("out_trade_no", sn); parameterMap.put("subject", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 60)); parameterMap.put("body", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 600)); parameterMap.put("payment_type", "1"); String bank = request.getParameter(BANK_PARAMETER_NAME); parameterMap.put("defaultbank", StringUtils.isNotEmpty(bank) ? bank : DEFAULT_BANK); parameterMap.put("seller_id", pluginConfig.getAttribute("partner")); parameterMap.put("total_fee", payment.getAmount().setScale(2).toString()); parameterMap.put("show_url", setting.getSiteUrl()); parameterMap.put("paymethod", "bankPay"); parameterMap.put("exter_invoke_ip", request.getLocalAddr()); parameterMap.put("extra_common_param", "shopxx"); parameterMap.put("sign", generateSign(parameterMap)); return parameterMap; }