List of usage examples for javax.servlet.http HttpServletRequest getParameterValues
public String[] getParameterValues(String name);
String
objects containing all of the values the given request parameter has, or null
if the parameter does not exist. From source file:fr.paris.lutece.plugins.mylutece.modules.wssodatabase.authentication.web.WssodatabaseJspBean.java
/** * Assign roles to a profil/* w ww . ja va 2s . c om*/ * @param request HttpServletRequest * @return JSP return */ public String doManageRolesProfil(HttpServletRequest request) { String mlWssoProfilCode = request.getParameter(PARAMETER_MYLUTECE_WSSO_PROFIL_CODE); if (mlWssoProfilCode == null) { return getManageProfils(request); } WssoProfil wssoProfil = WssoProfilHome.findWssoProfilByCode(mlWssoProfilCode, getPlugin()); if (wssoProfil == null) { return getManageProfils(request); } String[] roleArray = request.getParameterValues(PARAMETER_MYLUTECE_DATABASE_ROLE_IDS); IdxWSSODatabaseHome.removeRolesForProfil(wssoProfil.getCode(), getPlugin()); if (roleArray != null) { for (int i = 0; i < roleArray.length; i++) { IdxWSSODatabaseHome.addRoleForProfil(wssoProfil.getCode(), roleArray[i], getPlugin()); } } return MANAGE_ROLES_PROFIL + "?" + PARAMETER_PLUGIN_NAME + "=" + getPlugin().getName() + "&" + PARAMETER_MYLUTECE_WSSO_PROFIL_CODE + "=" + mlWssoProfilCode; }
From source file:fr.paris.lutece.plugins.calendar.web.CalendarApp.java
/** * Get the XPage for getting the search result * @param request {@link HttpServletRequest} * @param plugin {@link Plugin}// w w w . java 2s . c o m * @return the html * @throws SiteMessageException message if error */ private XPage getSearchResultPage(HttpServletRequest request, Plugin plugin) throws SiteMessageException { String strQuery = request.getParameter(Constants.PARAMETER_QUERY); String[] arrayCategory = request.getParameterValues(Constants.PARAMETER_CATEGORY); String[] arrayCalendar = request.getParameterValues(Constants.PARAMETER_CALENDAR_ID); String strDateBegin = request.getParameter(Constants.PARAMETER_DATE_START); String strDateEnd = request.getParameter(Constants.PARAMETER_DATE_END); String strPeriod = request.getParameter(Constants.PARAMETER_PERIOD); if (StringUtils.isBlank(strPeriod) || !StringUtils.isNumeric(strPeriod)) { strPeriod = Integer.toString(Constants.PROPERTY_PERIOD_NONE); } String strAgenda = null; String strBaseUrl = AppPathService.getBaseUrl(request); UrlItem url = new UrlItem(JSP_PAGE_PORTAL); url.addParameter(Constants.PARAMETER_QUERY, strQuery == null ? Constants.EMPTY_STRING : strQuery); url.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); url.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_DO_SEARCH); if (arrayCalendar != null) { for (String strAgendaId : arrayCalendar) { url.addParameter(Constants.PARAMETER_CALENDAR_ID, strAgendaId); } } else { arrayCalendar = Utils.getCalendarIds(request); } url.addParameter(Constants.PARAMETER_DATE_START, strDateBegin); url.addParameter(Constants.PARAMETER_DATE_END, strDateEnd); url.addParameter(Constants.PARAMETER_PERIOD, strPeriod); List<Event> listEvent = null; Date dateBegin = null; Date dateEnd = null; switch (Integer.parseInt(strPeriod)) { case Constants.PROPERTY_PERIOD_NONE: break; case Constants.PROPERTY_PERIOD_TODAY: dateBegin = new Date(); dateEnd = new Date(); strDateBegin = DateUtil.getDateString(new Date(), request.getLocale()); strDateEnd = DateUtil.getDateString(new Date(), request.getLocale()); break; case Constants.PROPERTY_PERIOD_WEEK: Calendar calendar = new GregorianCalendar(); Calendar calendarFirstDay = new GregorianCalendar(); Calendar calendarLastDay = new GregorianCalendar(); int nDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); if (nDayOfWeek == 1) { nDayOfWeek = 8; } calendarFirstDay = calendar; calendarFirstDay.add(Calendar.DATE, Calendar.MONDAY - nDayOfWeek); calendarLastDay = (GregorianCalendar) calendarFirstDay.clone(); calendarLastDay.add(Calendar.DATE, 6); dateBegin = calendarFirstDay.getTime(); dateEnd = calendarLastDay.getTime(); strDateBegin = DateUtil.getDateString(dateBegin, request.getLocale()); strDateEnd = DateUtil.getDateString(dateEnd, request.getLocale()); break; case Constants.PROPERTY_PERIOD_RANGE: if (StringUtils.isNotBlank(strDateBegin) && StringUtils.isNotBlank(strDateEnd)) { dateBegin = DateUtil.formatDate(strDateBegin, request.getLocale()); dateEnd = DateUtil.formatDate(strDateEnd, request.getLocale()); if (dateBegin == null || !Utils.isValidDate(dateBegin) || dateEnd == null || !Utils.isValidDate(dateEnd)) { errorDateFormat(request); } } else { errorDateFormat(request); } break; default: break; } listEvent = CalendarSearchService.getInstance().getSearchResults(arrayCalendar, arrayCategory, strQuery, dateBegin, dateEnd, plugin); _strCurrentPageIndex = Paginator.getPageIndex(request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex); _nItemsPerPage = Paginator.getItemsPerPage(request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, _nDefaultItemsPerPage); if (listEvent == null) { listEvent = new ArrayList<Event>(); } Map<String, Object> model = new HashMap<String, Object>(); Paginator<Event> paginator = new Paginator<Event>(listEvent, _nItemsPerPage, url.getUrl(), Constants.PARAMETER_PAGE_INDEX, _strCurrentPageIndex); //if one calendar is selected if ((arrayCalendar != null) && (arrayCalendar.length == 1)) { strAgenda = arrayCalendar[0]; } UrlItem urlSubscription = new UrlItem(strBaseUrl + JSP_PAGE_PORTAL); urlSubscription.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); urlSubscription.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_GET_SUBSCRIPTION_PAGE); urlSubscription.addParameter(Constants.PARAM_AGENDA, strAgenda); UrlItem urlDownload = new UrlItem(strBaseUrl + JSP_PAGE_PORTAL); urlDownload.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); urlDownload.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_GET_DOWNLOAD_PAGE); UrlItem urlRss = new UrlItem(strBaseUrl + JSP_PAGE_RSS); urlRss.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_RSS); if (arrayCalendar != null) { for (String strAgendaId : arrayCalendar) { urlRss.addParameter(Constants.PARAMETER_CALENDAR_ID, strAgendaId); } } if (arrayCategory != null) { for (String strCategoryId : arrayCategory) { urlRss.addParameter(Constants.PARAMETER_CATEGORY, strCategoryId); } } ReferenceList listAgendas = getListAgenda(request, plugin); if (arrayCalendar != null) { listAgendas.checkItems(arrayCalendar); } Collection<Category> categoryList = _categoryService.getCategories(plugin); ReferenceList listCategorys = getReferenceListCategory(categoryList); if (arrayCategory != null) { listCategorys.checkItems(arrayCategory); } // Evol List occurrences List<List<OccurrenceEvent>> listOccurrences = new ArrayList<List<OccurrenceEvent>>(); for (Event event : listEvent) { List<OccurrenceEvent> listOccurrence = _eventListService.getOccurrenceEvents(event.getIdCalendar(), event.getId(), Constants.SORT_ASC, plugin); listOccurrences.add(listOccurrence); } CalendarUserOptions options = getUserOptions(request); options.setShowSearchEngine(Boolean.TRUE); boolean bIsSelectedDay = false; String strDate; if (StringUtils.isNotBlank(strDateBegin) && !Constants.NULL.equals(strDateBegin)) { strDate = Utils.getDate(DateUtil.formatDateLongYear(strDateBegin, request.getLocale())); if (strDateBegin.equals(strDateEnd)) { bIsSelectedDay = true; } } else { strDate = Utils.getDate(new Date()); } MultiAgenda agendaWithOccurences = _calendarService.getMultiAgenda(request); model.put(Constants.MARK_QUERY, (StringUtils.isNotBlank(strQuery)) ? strQuery : StringUtils.EMPTY); model.put(Constants.MARK_SUBSCRIPTION_PAGE, urlSubscription.getUrl()); model.put(Constants.MARK_DOWNLOAD_PAGE, urlDownload.getUrl()); model.put(Constants.MARK_RSS_PAGE, urlRss.getUrl()); model.put(Constants.MARK_DATE_START, (StringUtils.isNotBlank(strDateBegin)) ? strDateBegin : StringUtils.EMPTY); model.put(Constants.MARK_DATE_END, (StringUtils.isNotBlank(strDateEnd)) ? strDateEnd : StringUtils.EMPTY); model.put(Constants.MARK_PERIOD, (StringUtils.isNotBlank(strPeriod)) ? strPeriod : StringUtils.EMPTY); model.put(Constants.MARK_EVENTS_LIST, paginator.getPageItems()); model.put(Constants.MARK_PAGINATOR, paginator); model.put(Constants.MARK_NB_ITEMS_PER_PAGE, Integer.toString(_nItemsPerPage)); model.put(Constants.MARK_CALENDARS_LIST, listAgendas); model.put(Constants.MARK_AGENDA, (StringUtils.isNotBlank(strAgenda)) ? strAgenda : StringUtils.EMPTY); model.put(Constants.MARK_LOCALE, request.getLocale()); model.put(Constants.MARK_CATEGORY_LIST, listCategorys); model.put(Constants.MARK_OCCURRENCES_LIST, listOccurrences); model.put(Constants.MARK_SMALL_MONTH_CALENDAR, SmallMonthCalendar.getSmallMonthCalendar(strDate, agendaWithOccurences, options, bIsSelectedDay)); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_DO_SEARCH_EVENTS, request.getLocale(), model); XPage page = new XPage(); page.setContent(template.getHtml()); page.setTitle( I18nService.getLocalizedString(Constants.PROPERTY_PAGE_TITLE_SEARCH_RESULT, request.getLocale())); page.setPathLabel( I18nService.getLocalizedString(Constants.PROPERTY_PAGE_TITLE_SEARCH, request.getLocale())); return page; }
From source file:pivotal.au.se.gemfirexdweb.controller.AsyncController.java
@RequestMapping(value = "/asyncevent", method = RequestMethod.POST) public String performAsyncAction(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/*from ww w . jav a 2 s. com*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } int startAtIndex = 0, endAtIndex = 0; Result result = new Result(); List<Asyncevent> asyncevents = null; String ddlString = null; logger.debug("Received request to perform an action on the async events"); AsynceventDAO asyncDAO = GemFireXDWebDAOFactory.getAsynceventDAO(); if (request.getParameter("search") != null) { asyncevents = asyncDAO.retrieveAsynceventList((String) session.getAttribute("schema"), (String) request.getParameter("search"), (String) session.getAttribute("user_key")); model.addAttribute("search", (String) request.getParameter("search")); } else { String[] tableList = request.getParameterValues("selected_async[]"); String commandStr = request.getParameter("submit_mult"); logger.debug("tableList = " + Arrays.toString(tableList)); logger.debug("command = " + commandStr); // start actions now if tableList is not null if (tableList != null) { List al = new ArrayList<Result>(); List<String> al2 = new ArrayList<String>(); for (String asyncName : tableList) { if (commandStr.equalsIgnoreCase("DDL") || commandStr.equalsIgnoreCase("DDL_FILE")) { ddlString = asyncDAO.generateDDL(asyncName, (String) session.getAttribute("user_key")); al2.add(ddlString); } else { result = null; result = asyncDAO.simpleasynceventCommand(asyncName, commandStr, (String) session.getAttribute("user_key")); al.add(result); } } if (commandStr.equalsIgnoreCase("DDL")) { request.setAttribute("arrayresultddl", al2); } else if (commandStr.equalsIgnoreCase("DDL_FILE")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, "AsyncEventListenerDDL")); ServletOutputStream out = response.getOutputStream(); for (String ddl : al2) { out.println(ddl); } out.close(); return null; } else { model.addAttribute("arrayresult", al); } } asyncevents = asyncDAO.retrieveAsynceventList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key")); } model.addAttribute("records", asyncevents.size()); model.addAttribute("estimatedrecords", asyncevents.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (asyncevents.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("asyncevents", asyncevents); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > asyncevents.size()) { endAtIndex = asyncevents.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = asyncevents.subList(startAtIndex, endAtIndex); model.addAttribute("asyncevents", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/async.jsp return "async"; }
From source file:fr.paris.lutece.portal.web.rbac.RoleManagementJspBean.java
/** * Perform the checks on the permission selection and redirects to the * description of the role if ok./*w w w . ja va 2 s . c om*/ * <ul> * <li>If selection method is global (wilcard selection - parameter "all"), * the correspondind entry is stored as a control for all resources * previously selected. The user is redirected to the role description page. * </li> * <li>If selection method is specific (id selection - parameter "choose"), * <ul> * <li>if no permission is found, the user is redirected to an error page.</li> * <li>if at least one permission is found, the correspondind entry is * stored as a control for all resources previously selected. The user is * redirected to the role description page.</li> * </ul> * </li> * <li>If no selection method is found, or if it's neither parameter "all" * nor "choose", the user is redirected to a error page.</li> * </ul> * @param request the http request * @return the url of the page to be redirected to */ public String doSelectPermissions(HttpServletRequest request) { String strRoleKey = request.getParameter(PARAMETER_ROLE_KEY); String strResourceType = request.getParameter(PARAMETER_RESOURCE_TYPE); String strResourcesSelectionMethod = request.getParameter(PARAMETER_SELECT_RESOURCES_METHOD); String strPermissionsSelectionMethod = request.getParameter(PARAMETER_SELECT_PERMISSIONS_METHOD); String[] strArrayResourceIds; String[] strArrayPermissionKeys; // get the list of resource ids selected (forward from previous screen, so no need for extensive checks) if ((strResourcesSelectionMethod != null) && strResourcesSelectionMethod.equals(PARAMETER_METHOD_SELECTION_ALL)) { strArrayResourceIds = new String[1]; strArrayResourceIds[0] = RBAC.WILDCARD_RESOURCES_ID; } else { strArrayResourceIds = request.getParameterValues(PARAMETER_RESOURCE_ID); } // check that the permission selection method is "all" or "choose" // if method is "choose", check that we have at least one id checked if (strPermissionsSelectionMethod == null) { return AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_NO_PERMISSION_SELECTION_METHOD, AdminMessage.TYPE_STOP); } else if (strPermissionsSelectionMethod.equals(PARAMETER_METHOD_SELECTION_CHOOSE)) { strArrayPermissionKeys = request.getParameterValues(PARAMETER_PERMISSION_KEY); if ((strArrayPermissionKeys == null) || (strArrayPermissionKeys.length == 0)) { return AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_PERMISSION_LIST_EMPTY, AdminMessage.TYPE_STOP); } } else if (strPermissionsSelectionMethod.equals(PARAMETER_METHOD_SELECTION_ALL)) { strArrayPermissionKeys = new String[1]; strArrayPermissionKeys[0] = RBAC.WILDCARD_PERMISSIONS_KEY; } else { return AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_NO_PERMISSION_SELECTION_METHOD, AdminMessage.TYPE_STOP); } // store the selected elements in database for (int i = 0; i < strArrayResourceIds.length; i++) { for (int j = 0; j < strArrayPermissionKeys.length; j++) { RBAC rbac = new RBAC(); rbac.setRoleKey(strRoleKey); rbac.setResourceTypeKey(strResourceType); rbac.setResourceId(strArrayResourceIds[i]); rbac.setPermissionKey(strArrayPermissionKeys[j]); RBACHome.create(rbac); } } return JSP_URL_ROLE_DESCRIPTION + "?" + PARAMETER_ROLE_KEY + "=" + strRoleKey; }
From source file:pivotal.au.se.gemfirexdweb.controller.GatewayReceiverController.java
@RequestMapping(value = "/gatewayreceivers", method = RequestMethod.POST) public String performGatewayReceiversAction(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {//from www .j a v a 2 s . com Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } int startAtIndex = 0, endAtIndex = 0; Result result = new Result(); List<GatewayReceiver> gatewayreceivers = null; String ddlString = null; logger.debug("Received request to perform an action on the gateway recievers"); GatewayReceiverDAO grDAO = GemFireXDWebDAOFactory.getGatewayRecieverDAO(); if (request.getParameter("search") != null) { gatewayreceivers = grDAO.retrieveGatewayReceiverList((String) session.getAttribute("schema"), (String) request.getParameter("search"), (String) session.getAttribute("user_key")); model.addAttribute("search", (String) request.getParameter("search")); } else { String[] tableList = request.getParameterValues("selected_gatewayreceivers[]"); String commandStr = request.getParameter("submit_mult"); logger.debug("tableList = " + Arrays.toString(tableList)); logger.debug("command = " + commandStr); // start actions now if tableList is not null if (tableList != null) { List al = new ArrayList<Result>(); List<String> al2 = new ArrayList<String>(); for (String id : tableList) { if (commandStr.equalsIgnoreCase("DDL") || commandStr.equalsIgnoreCase("DDL_FILE")) { ddlString = grDAO.generateDDL(id, (String) session.getAttribute("user_key")); al2.add(ddlString); } else { result = null; result = grDAO.simplegatewayReceiverCommand(id, commandStr, (String) session.getAttribute("user_key")); al.add(result); } } if (commandStr.equalsIgnoreCase("DDL")) { request.setAttribute("arrayresultddl", al2); } else if (commandStr.equalsIgnoreCase("DDL_FILE")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, "GatewayReceiverDDL")); ServletOutputStream out = response.getOutputStream(); for (String ddl : al2) { out.println(ddl); } out.close(); return null; } else { model.addAttribute("arrayresult", al); } } gatewayreceivers = grDAO.retrieveGatewayReceiverList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key")); } model.addAttribute("records", gatewayreceivers.size()); model.addAttribute("estimatedrecords", gatewayreceivers.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (gatewayreceivers.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("gatewayreceivers", gatewayreceivers); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > gatewayreceivers.size()) { endAtIndex = gatewayreceivers.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = gatewayreceivers.subList(startAtIndex, endAtIndex); model.addAttribute("gatewayreceivers", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/gatewayreceivers.jsp return "gatewayreceivers"; }
From source file:fr.paris.lutece.plugins.mylutece.modules.wssodatabase.authentication.web.WssodatabaseJspBean.java
/** * Assign profils to a user/* w ww.j a va 2s . com*/ * @param request HttpServletRequest * @return JSP return */ public String doManageProfilsUser(HttpServletRequest request) { String strUserId = request.getParameter(PARAMETER_MYLUTECE_WSSO_USER_ID); if (StringUtils.isBlank(strUserId)) { return getManageUsers(request); } int nWssoUserId = Integer.parseInt(strUserId); WssoUser wssoUser = WssoUserHome.findByPrimaryKey(nWssoUserId, getPlugin()); if (wssoUser == null) { return getManageUsers(request); } String[] profilArray = request.getParameterValues(PARAMETER_MYLUTECE_WSSO_PROFIL_CODE); IdxWSSODatabaseHome.removeProfilsForUser(nWssoUserId, getPlugin()); if (profilArray != null) { for (int i = 0; i < profilArray.length; i++) { IdxWSSODatabaseHome.addUserForProfil(nWssoUserId, profilArray[i], getPlugin()); } } return MANAGE_PROFILS_USER + "?" + PARAMETER_MYLUTECE_WSSO_USER_ID + "=" + nWssoUserId; }
From source file:com.zanshang.controllers.web.ProjectCreationController.java
@RequestMapping(value = "/{projectId}", method = RequestMethod.PUT) @Secured("ROLE_USER") @ResponseBody/*from w w w . j av a 2 s . c om*/ public Object edit(@RequestParam(value = "name", required = false) String name, // @RequestParam(value = "types[]", required = false) List<String> types, // @RequestParam(value = "description", required = false) String description, // @RequestParam(value = "cover", required = false) String cover, // @RequestParam(value = "aboutFirstAuthor", required = false) String aboutFirstAuthor, // @RequestParam(value = "outline", required = false) String outline, // @RequestParam(value = "draft", required = false) String draft, // @RequestParam(value = "color", required = false) int color, // @RequestParam(value = "wordCount", required = false) int wordCount, // @RequestParam(value = "imageCount", required = false) int imageCount, // @RequestParam(value = "images[]", required = false) List<String> images, // @RequestParam(value = "tags[]", required = false) List<String> tags, // HttpServletRequest request, @PathVariable("projectId") String projectId, Principal principal, Locale locale, Date requestTime) { Project project = projectTrapdoor.get(new ObjectId(projectId)); if (!project.getUid().toHexString().equals(principal.getName()) || project.getState() != ProjectState.REVIEWING) { return Ajax.failure(messageSource.getMessage("exception.expire", null, locale)); } else { project.setColorMode(color); project.setCover(cover); project.setDescription(description); project.setDraft(draft); project.setImageCount(imageCount); project.setImages(images == null ? new ArrayList<>() : images); project.setWordCount(wordCount); project.setBookName(name); project.setOutline(outline); List<BookType> typeList = new ArrayList<>(); if (CollectionUtils.isNotEmpty(types)) { for (String t : types) { BookType type = bookUtils.parse(t, locale); typeList.add(type); } } project.setTypes(typeList); project.setTags(tags); List<Project.Author> authorList = new ArrayList<>(); String[] params = request.getParameterValues("authors[]"); if (params != null && params.length != 0) { for (String s : params) { Project.Author author = Json.fromJson(s, Project.Author.class); authorList.add(author); } } project.setFirstAuthorDescription(aboutFirstAuthor); project.setAuthors(authorList); project.setUpdateTime(requestTime); projectTrapdoor.save(project); return Ajax.ok(); } }
From source file:com.redoute.datamap.servlet.datamap.FindAllDatamap.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w . java 2 s . c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS); try { String echo = policy.sanitize(request.getParameter("sEcho")); String sStart = policy.sanitize(request.getParameter("iDisplayStart")); String sAmount = policy.sanitize(request.getParameter("iDisplayLength")); String sCol = policy.sanitize(request.getParameter("iSortCol_0")); String sdir = policy.sanitize(request.getParameter("sSortDir_0")); String dir = "asc"; String[] cols = { "Id", "Stream", "Application", "Page", "LocationType", "LocationValue", "Picture", "Zone", "Implemented" }; JSONObject result = new JSONObject(); JSONArray array = new JSONArray(); int amount = 10; int start = 0; int col = 0; String id = ""; String[] stream = null; String[] page = null; String[] application = null; String locationType = ""; String locationValue = ""; String[] implemented = null; String[] picture = null; String zone = ""; String comment = ""; if (request.getParameterValues("page") != null) { page = request.getParameterValues("page"); } if (request.getParameterValues("application") != null) { application = request.getParameterValues("application"); } if (request.getParameterValues("stream") != null) { stream = request.getParameterValues("stream"); } if (request.getParameterValues("picture") != null) { picture = request.getParameterValues("picture"); } if (request.getParameterValues("impl") != null) { implemented = request.getParameterValues("impl"); } if (request.getParameterValues("comment") != null) { comment = request.getParameter("comment"); } id = policy.sanitize(request.getParameter("sSearch_0")); // FIXME are they the good sSearch numbers? locationType = policy.sanitize(request.getParameter("sSearch_3")); locationValue = policy.sanitize(request.getParameter("sSearch_4")); zone = policy.sanitize(request.getParameter("sSearch_5")); //comment = policy.sanitize(request.getParameter("sSearch_6")); List<String> sArray = new ArrayList<String>(); if (!id.equals("")) { String sId = " `Id` like '%" + id + "%'"; sArray.add(sId); } if (page != null) { String spage = " ("; for (int a = 0; a < page.length - 1; a++) { spage += " `page` like '%" + page[a] + "%' or"; } spage += " `page` like '%" + page[page.length - 1] + "%') "; sArray.add(spage); } if (application != null) { String sapplication = " ("; for (int a = 0; a < application.length - 1; a++) { sapplication += " `application` like '%" + application[a] + "%' or"; } sapplication += " `application` like '%" + application[application.length - 1] + "%') "; sArray.add(sapplication); } if (stream != null) { String sstream = " ("; for (int a = 0; a < stream.length - 1; a++) { sstream += " stream like '%" + stream[a] + "%' or"; } sstream += " stream like '%" + stream[stream.length - 1] + "%') "; sArray.add(sstream); } if (picture != null) { String spicture = " ("; for (int a = 0; a < picture.length - 1; a++) { spicture += " picture like '%" + picture[a] + "%' or"; } spicture += " picture like '%" + picture[picture.length - 1] + "%') "; sArray.add(spicture); } if (implemented != null) { String simplemented = " ("; for (int a = 0; a < implemented.length - 1; a++) { simplemented += " implemented like '%" + implemented[a] + "%' or"; } simplemented += " implemented like '%" + implemented[implemented.length - 1] + "%') "; sArray.add(simplemented); } if (!locationType.equals("")) { String sLocationType = " `locationType` like '%" + locationType + "%'"; sArray.add(sLocationType); } if (!locationValue.equals("")) { String sLocationValue = " `locationValue` like '%" + locationValue + "%'"; sArray.add(sLocationValue); } if (!zone.equals("")) { String szone = " `zone` like '%" + zone + "%'"; sArray.add(szone); } if (!comment.equals("")) { String scomment = " `comment` like '%" + comment + "%'"; sArray.add(scomment); } StringBuilder individualSearch = new StringBuilder(); if (sArray.size() == 1) { individualSearch.append(sArray.get(0)); } else if (sArray.size() > 1) { for (int i = 0; i < sArray.size() - 1; i++) { individualSearch.append(sArray.get(i)); individualSearch.append(" and "); } individualSearch.append(sArray.get(sArray.size() - 1)); } if (sStart != null) { start = Integer.parseInt(sStart); if (start < 0) { start = 0; } } if (sAmount != null) { amount = Integer.parseInt(sAmount); if (amount < 10 || amount > 100) { amount = 10; } } if (sCol != null) { col = Integer.parseInt(sCol); if (col < 0 || col > 5) { col = 0; } } if (sdir != null) { if (!sdir.equals("asc")) { dir = "desc"; } } String colName = cols[col]; String searchTerm = ""; if (!request.getParameter("sSearch").equals("")) { searchTerm = request.getParameter("sSearch"); } String inds = String.valueOf(individualSearch); JSONArray data = new JSONArray(); //data that will be shown in the table ApplicationContext appContext = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext()); IDatamapService datamapService = appContext.getBean(IDatamapService.class); List<Datamap> datamapList = datamapService.findDatamapListByCriteria(start, amount, colName, dir, searchTerm, inds); JSONObject jsonResponse = new JSONObject(); for (Datamap datamap : datamapList) { JSONArray row = new JSONArray(); row.put(datamap.getId()).put(datamap.getStream()).put(datamap.getApplication()) .put(datamap.getPage()).put(datamap.getLocationType()).put(datamap.getLocationValue()) .put(datamap.getPicture()).put(datamap.getZone()).put(datamap.getImplemented()) .put(datamap.getComment()); data.put(row); } Integer numberOfTotalRows = datamapService.getNumberOfDatamapPerCrtiteria(searchTerm, inds); jsonResponse.put("aaData", data); jsonResponse.put("sEcho", echo); jsonResponse.put("iTotalRecords", numberOfTotalRows); jsonResponse.put("iDisplayLength", data.length()); jsonResponse.put("iTotalDisplayRecords", numberOfTotalRows); response.setContentType("application/json"); response.getWriter().print(jsonResponse.toString()); } catch (JSONException ex) { Logger.log(FindAllDatamap.class.getName(), Level.FATAL, ex.toString()); } finally { out.close(); } }
From source file:edu.wisc.my.redirect.TabSelectingUrlRedirectController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { final String serverName = request.getServerName(); final PortalUrl portalUrl = this.portalUrlProvider.getPortalUrl(serverName); //If strict param matching only run if the request parameter keyset matches the mapped parameter keyset final Set<?> requestParameterKeys = request.getParameterMap().keySet(); if (this.strictParameterMatching && !requestParameterKeys.equals(this.parameterMappings.keySet())) { if (this.logger.isInfoEnabled()) { this.logger.info("Sending not found error, requested parameter key set " + requestParameterKeys + " does not match mapped parameter key set " + this.parameterMappings.keySet()); }/*from www . j a va 2 s . com*/ response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; } //Map static parameters for (final Map.Entry<String, List<String>> parameterMappingEntry : this.staticParameters.entrySet()) { final String name = parameterMappingEntry.getKey(); final List<String> values = parameterMappingEntry.getValue(); if (this.logger.isDebugEnabled()) { this.logger.debug("Adding static parameter '" + name + "' with values: " + values); } portalUrl.setParameter(name, values.toArray(new String[values.size()])); } //Map request parameters for (final Map.Entry<String, Set<String>> parameterMappingEntry : this.parameterMappings.entrySet()) { final String name = parameterMappingEntry.getKey(); final String[] values = request.getParameterValues(name); if (values != null) { for (final String mappedName : parameterMappingEntry.getValue()) { if (this.logger.isDebugEnabled()) { this.logger.debug("Mapping parameter '" + name + "' to portal parameter '" + mappedName + "' with values: " + Arrays.asList(values)); } portalUrl.setParameter(mappedName, values); } } else if (this.logger.isDebugEnabled()) { this.logger.debug( "Skipping mapped parameter '" + name + "' since it was not specified on the original URL"); } } //Set public based on if remoteUser is set final String remoteUser = request.getRemoteUser(); final boolean isAuthenticated = StringUtils.isNotBlank(remoteUser); portalUrl.setPublic(!isAuthenticated); if (isAuthenticated) { portalUrl.setTabIndex(this.privateTabIndex); } else { portalUrl.setTabIndex(this.publicTabIndex); } portalUrl.setType(RequestType.ACTION); final String redirectUrl = portalUrl.toString(); if (this.logger.isInfoEnabled()) { this.logger.info("Redirecting to: " + redirectUrl); } return new ModelAndView(new RedirectView(redirectUrl, false)); }