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:org.openmrs.module.sync.web.controller.SettingsController.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse reponse, Object obj, BindException errors) throws Exception { log.debug("in processFormSubmission"); ModelAndView result = new ModelAndView(new RedirectView(getSuccessView())); if (!Context.isAuthenticated()) throw new APIAuthenticationException("Not authenticated!"); HttpSession httpSession = request.getSession(); String success = ""; String error = ""; MessageSourceAccessor msa = getMessageSourceAccessor(); String action = ServletRequestUtils.getStringParameter(request, "action", ""); log.debug("action is " + action); if ("saveGeneral".equals(action)) { String serverName = ServletRequestUtils.getStringParameter(request, "serverName", ""); String adminEmail = ServletRequestUtils.getStringParameter(request, "adminEmail", ""); Context.getService(SyncService.class).saveServerName(serverName); Context.getService(SyncService.class).saveAdminEmail(adminEmail); String[] startedParams = request.getParameterValues("started"); boolean started = false; if (startedParams != null) { for (String startedParam : startedParams) { if (startedParam.equals("true")) started = true;/* www. j av a 2 s. c o m*/ } } Integer repeatInterval = ServletRequestUtils.getIntParameter(request, "repeatInterval", 0) * 60; if (started) { started = false; repeatInterval = null; error = msa.getMessage("NzeyiSynchronizationConfig.server.error.disabledSyncSchedule"); } if (started && repeatInterval < 1) error = msa.getMessage("SynchronizationConfig.server.error.invalidRepeat"); if (error.length() == 0) { RemoteServer parent = Context.getService(SyncService.class).getParentServer(); if (parent != null) { if (parent.getServerId() != null) { Integer serverId = parent.getServerId(); TaskDefinition serverSchedule = null; Collection<TaskDefinition> tasks = Context.getSchedulerService().getRegisteredTasks(); if (tasks != null) { for (TaskDefinition task : tasks) { if (task.getTaskClass().equals(SyncConstants.SCHEDULED_TASK_CLASS)) { if (serverId.toString().equals( task.getProperty(SyncConstants.SCHEDULED_TASK_PROPERTY_SERVER_ID))) { serverSchedule = task; } else { log.warn("not equal comparing " + serverId + " to " + task .getProperty(SyncConstants.SCHEDULED_TASK_PROPERTY_SERVER_ID)); } } else { log.warn("not equal comparing " + task.getTaskClass() + " to " + SyncConstants.SCHEDULED_TASK_CLASS); } } } else { log.warn("tasks is null"); } Map<String, String> props = new HashMap<String, String>(); props.put(SyncConstants.SCHEDULED_TASK_PROPERTY_SERVER_ID, serverId.toString()); if (serverSchedule != null) { if (log.isInfoEnabled()) log.info("Sync scheduled task exists, and started is " + started + " and interval is " + repeatInterval); try { Context.getSchedulerService().shutdownTask(serverSchedule); } catch (Exception e) { log.warn( "Sync task had run wild, couldn't stop it because it wasn't really running", e); } serverSchedule.setStarted(started); serverSchedule.setRepeatInterval((long) repeatInterval); serverSchedule.setStartOnStartup(started); serverSchedule.setProperties(props); if (started) { serverSchedule.setStartTime(new Date()); } Context.getSchedulerService().saveTask(serverSchedule); if (started) { Context.getSchedulerService().scheduleTask(serverSchedule); } } else { if (log.isInfoEnabled()) log.info("Sync scheduled task does not exists, and started is " + started + " and interval is " + repeatInterval); if (started) { serverSchedule = new TaskDefinition(); serverSchedule.setName(parent.getNickname() + " " + msa.getMessage("SynchronizationConfig.server.scheduler")); serverSchedule.setDescription( msa.getMessage("SynchronizationConfig.server.scheduler.description")); serverSchedule.setRepeatInterval((long) repeatInterval); serverSchedule.setStartTime(new Date()); serverSchedule.setTaskClass(SyncConstants.SCHEDULED_TASK_CLASS); serverSchedule.setStarted(started); serverSchedule.setStartOnStartup(started); serverSchedule.setProperties(props); Context.getSchedulerService().saveTask(serverSchedule); Context.getSchedulerService().scheduleTask(serverSchedule); } } } } success = msa.getMessage("SynchronizationConfig.server.saved"); } } else if ("deleteServer".equals(action)) { // check to see if the user is trying to delete a server, react // accordingly Integer serverId = ServletRequestUtils.getIntParameter(request, "serverId", 0); String serverName = "Server " + serverId.toString(); SyncService ss = Context.getService(SyncService.class); if (serverId > 0) { RemoteServer deleteServer = ss.getRemoteServer(serverId); serverName = deleteServer.getNickname(); try { ss.deleteRemoteServer(deleteServer); Object[] args = { serverName }; success = msa.getMessage("SynchronizationConfig.server.deleted", args); } catch (Exception e) { Object[] args = { serverName }; error = msa.getMessage("SynchronizationConfig.server.deleteFailed", args); } } else { error = msa.getMessage("SynchronizationConfig.server.notDeleted"); } } else if ("saveClasses".equals(action)) { String[] classIdsTo = ServletRequestUtils.getRequiredStringParameters(request, "toDefault"); String[] classIdsFrom = ServletRequestUtils.getRequiredStringParameters(request, "fromDefault"); Set<String> idsTo = new HashSet<String>(); Set<String> idsFrom = new HashSet<String>(); if (classIdsTo != null) idsTo.addAll(Arrays.asList(classIdsTo)); if (classIdsFrom != null) idsFrom.addAll(Arrays.asList(classIdsFrom)); List<SyncClass> syncClasses = Context.getService(SyncService.class).getSyncClasses(); if (syncClasses != null) { // log.warn("SYNCCLASSES IS SIZE: " + syncClasses.size()); for (SyncClass syncClass : syncClasses) { if (idsTo.contains(syncClass.getSyncClassId().toString())) syncClass.setDefaultSendTo(true); else syncClass.setDefaultSendTo(false); if (idsFrom.contains(syncClass.getSyncClassId().toString())) syncClass.setDefaultReceiveFrom(true); else syncClass.setDefaultReceiveFrom(false); Context.getService(SyncService.class).saveSyncClass(syncClass); } } success = msa.getMessage("SynchronizationConfig.classes.saved"); } if (!success.equals("")) httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success); if (!error.equals("")) httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error); return result; }
From source file:com.globalsight.everest.webapp.pagehandler.projects.workflows.JobControlExportedHandler.java
/** * Invokes this EntryPageHandler object/*w w w . j a va 2 s . c om*/ * <p> * @param p_ageDescriptor the description of the page to be produced. * @param p_request original request sent from the browser. * @param p_response original response object. * @param p_context the Servlet context. */ public void myInvokePageHandler(WebPageDescriptor p_thePageDescriptor, HttpServletRequest p_request, HttpServletResponse p_response, ServletContext p_context) throws ServletException, IOException, RemoteException, EnvoyServletException { HttpSession session = p_request.getSession(false); SessionManager sessionMgr = (SessionManager) session.getAttribute(SESSION_MANAGER); //"Job Details" >> "View Error" >> "Re-Export" (GBS-908) //After re-export,UI will turn back to "Exported" search results list. try { Company company = ServerProxy.getJobHandler() .getCompanyById(CompanyWrapper.getCurrentCompanyIdAsLong()); p_request.setAttribute("company", company); String isFromExportErrorPage = p_request.getParameter("fromExportErrorPage"); if (isFromExportErrorPage != null && "true".equals(isFromExportErrorPage)) { User user = (User) sessionMgr.getAttribute(WebAppConstants.USER); WorkflowManager wfManager = ServerProxy.getWorkflowManager(); //Get all the checked pages as an array of strings //For "View Error",only one workflow can be selected. String pages[] = p_request.getParameterValues("page"); if (pages != null && pages.length > 0) { ArrayList pageIds = new ArrayList();//target pages Workflow wf = null; Job job = null; ArrayList wfIds = new ArrayList(); // Find the workflows associated with the pages checked for (int i = 0; i < pages.length; i++) { // The value of the page param is "pageId_<pageId>_wfId_<wfId> Long curPageId = new Long( pages[i].substring(pages[i].indexOf("pageId_") + 7, pages[i].indexOf("_wfId"))); pageIds.add(curPageId); //set values for wf and job only once if (wf == null) { String wfId = pages[i].substring(pages[i].indexOf("_wfId_") + 6, pages[i].length()); wf = wfManager.getWorkflowById(new Long(wfId)); wfIds.add(new Long(wfId)); job = wf.getJob(); } } ExportParameters ep = new ExportParameters(wf); boolean isTargetPage = true; Long taskId = null; long exportBatchId = ServerProxy.getExportEventObserver().notifyBeginExportTargetBatch(job, user, pageIds, wfIds, taskId, ExportBatchEvent.INTERIM_PRIMARY); ServerProxy.getPageManager().exportPage(ep, pageIds, isTargetPage, exportBatchId); } } } catch (Exception e) { //In fact,no exception will be caught here. s_logger.error("Fail to re-export selected pages.", e); } boolean stateMarch = false; if (Job.EXPORTED.equals((String) sessionMgr.getMyjobsAttribute("lastState"))) stateMarch = true; setJobSearchFilters(sessionMgr, p_request, stateMarch); HashMap beanMap = invokeJobControlPage(p_thePageDescriptor, p_request, BASE_BEAN); p_request.setAttribute("searchType", p_request.getParameter("searchType")); // error bean. m_exportErrorBean = new NavigationBean(ERROR_BEAN, p_thePageDescriptor.getPageName()); p_request.setAttribute("action", p_request.getParameter("action")); if (p_request.getParameter("action") != null && "checkDownloadQAReport".equals(p_request.getParameter("action"))) { ServletOutputStream out = p_response.getOutputStream(); String jobIds = p_request.getParameter("jobIds"); boolean checkQA = checkQAReport(sessionMgr, jobIds); String download = ""; if (checkQA) { download = "success"; } else { download = "fail"; } Map<String, Object> returnValue = new HashMap(); returnValue.put("download", download); out.write((JsonUtil.toObjectJson(returnValue)).getBytes("UTF-8")); return; } else if (p_request.getParameter("action") != null && "downloadQAReport".equals(p_request.getParameter("action"))) { Set<Long> jobIdSet = (Set<Long>) sessionMgr.getAttribute("jobIdSet"); Set<File> exportFilesSet = (Set<File>) sessionMgr.getAttribute("exportFilesSet"); Set<String> localesSet = (Set<String>) sessionMgr.getAttribute("localesSet"); long companyId = (Long) sessionMgr.getAttribute("companyId"); WorkflowHandlerHelper.zippedFolder(p_request, p_response, companyId, jobIdSet, exportFilesSet, localesSet); sessionMgr.removeElement("jobIdSet"); sessionMgr.removeElement("exportFilesSet"); sessionMgr.removeElement("localesSet"); return; } performAppropriateOperation(p_request); Vector jobStates = new Vector(); jobStates.add(Job.EXPORTED); jobStates.add(Job.EXPORT_FAIL); p_request.setAttribute(JobManagementHandler.EXPORT_URL_PARAM, ((NavigationBean) beanMap.get(EXPORT_BEAN)).getPageURL()); p_request.setAttribute(JobManagementHandler.JOB_ID, JobManagementHandler.JOB_ID); sessionMgr.setMyjobsAttribute("lastState", Job.EXPORTED); JobVoExportSearcher searcher = new JobVoExportSearcher(); searcher.setJobVos(p_request); p_request.setAttribute(JOB_LIST_START_PARAM, p_request.getParameter(JOB_LIST_START_PARAM)); p_request.setAttribute(PAGING_SCRIPTLET, getPagingText(p_request, ((NavigationBean) beanMap.get(BASE_BEAN)).getPageURL(), jobStates)); // Set the EXPORT_INIT_PARAM in the sessionMgr so we can bring // the user back here after they Export sessionMgr.setAttribute(JobManagementHandler.EXPORT_INIT_PARAM, BASE_BEAN); sessionMgr.setAttribute("destinationPage", "exported"); //clear the session for download job from joblist page sessionMgr.setAttribute(DownloadFileHandler.DOWNLOAD_JOB_LOCALES, null); sessionMgr.setAttribute(DownloadFileHandler.DESKTOP_FOLDER, null); setJobProjectsLocales(sessionMgr, session); // turn on cache. do both. "pragma" for the older browsers. p_response.setHeader("Pragma", "yes-cache"); //HTTP 1.0 p_response.setHeader("Cache-Control", "yes-cache"); //HTTP 1.1 p_response.addHeader("Cache-Control", "yes-store"); // tell proxy not to cache // forward to the jsp page. RequestDispatcher dispatcher = p_context.getRequestDispatcher(p_thePageDescriptor.getJspURL()); dispatcher.forward(p_request, p_response); }
From source file:br.mdarte.exemplo.academico.accessControl.TrocaDeSenhaObrigatoriaProcessarFormImpl.java
/** * Override to provide population of current form with request parameters when validation fails. * * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest) *//*from ww w . j ava 2s .co m*/ public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { org.apache.struts.action.ActionErrors errors = new org.apache.struts.action.ActionErrors(); if (request.getParameter("menu") == null) { //final org.apache.struts.action.ActionErrors errors = super.validate(mapping, request); if (errors != null && !errors.isEmpty()) { Object formObj = org.andromda.presentation.bpm4struts.PageSessionObjectUtil.getPageForm(request, "${action.useCase.name}"); if (formObj != null) { try { formObj.getClass() .getMethod("resetCheckBoxes", new Class[] { org.apache.struts.action.ActionMapping.class, javax.servlet.http.HttpServletRequest.class }) .invoke(formObj, new Object[] { null, null }); } catch (Exception e2) { // ignoring } final java.util.Map parameters = new java.util.HashMap(); for (final java.util.Enumeration names = request.getParameterNames(); names .hasMoreElements();) { final String name = String.valueOf(names.nextElement()); parameters.put(name, request.getParameterValues(name)); } try { org.apache.commons.beanutils.BeanUtils.populate(formObj, parameters); } catch (java.lang.Exception populateException) { // ignore if we have an exception here (we just don't populate). } } } } else { request.getSession().setAttribute(Constantes.MENU, "true"); } return errors; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.onlineTests.TestsManagementAction.java
public ActionForward insertTestQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException { final String[] metadataCodes = request.getParameterValues("metadataCode"); final Integer questionOrder = getCodeFromRequest(request, "questionOrder"); final String testCode = getStringFromRequest(request, "testCode"); Double questionValue = null;//from ww w . j a va 2 s. co m if (request.getParameter("questionValue") != null) { questionValue = new Double(request.getParameter("questionValue")); } final Integer formula = getCodeFromRequest(request, "formula"); CorrectionFormula correctionFormulas = new CorrectionFormula(CorrectionFormula.FENIX); if (formula != null) { correctionFormulas = new CorrectionFormula(formula); } try { InsertTestQuestion.runInsertTestQuestion(getExecutionCourse(request).getExternalId(), testCode, metadataCodes, questionOrder, questionValue, correctionFormulas); } catch (FenixServiceException e) { throw new FenixActionException(e); } request.setAttribute("order", request.getParameter("order")); request.setAttribute("asc", request.getParameter("asc")); request.setAttribute("testCode", testCode); return showAvailableQuestions(mapping, form, request, response); }
From source file:fr.paris.lutece.plugins.mylutece.modules.wssodatabase.authentication.web.WssodatabaseJspBean.java
/** * Process assignation roles for a specified user * //from www . ja va2 s . com * @param request The Http request * @return Html form */ public String doAssignRoleUser(HttpServletRequest request) { int nUserId = Integer.parseInt(request.getParameter(PARAMETER_MYLUTECE_WSSO_USER_ID)); WssoUser user = WssoUserHome.findByPrimaryKey(nUserId, getPlugin()); String[] roleArray = request.getParameterValues(PARAMETER_MYLUTECE_WSSO_ROLE_ID); WssoUserRoleHome.deleteRolesForUser(user.getMyluteceWssoUserId(), getPlugin()); if (roleArray != null) { for (int i = 0; i < roleArray.length; i++) { WssoUserRoleHome.createRoleForUser(nUserId, roleArray[i], getPlugin()); } } return MANAGE_USERS + "?" + PARAMETER_PLUGIN_NAME + "=" + getPlugin().getName(); }
From source file:org.esgf.legacydatacart.LegacyOldFileTemplateController.java
/** * //from w w w. j a v a 2s. com * @param request * @return */ private String getDataCart(HttpServletRequest request) { // System.out.println("in getDataCart"); //org.esgf.commonui.Utils.queryStringInfo(request); String queryString = preassembleQueryString(request); //get the ids from the servlet querystring here //note: these represent the 'keys' in the localStorage['dataCart'] map String[] names = request.getParameterValues("id[]"); String showAll = request.getParameter("showAll"); Document document = null; String jsonContent = null; document = new Document(new Element("response")); if (names != null) { List<LegacyDocElement> docElements = new ArrayList<LegacyDocElement>(); for (int i = 0; i < names.length; i++) { String dataset_id = names[i]; //get files for each data set in a jsonarray JSONArray jsonArrayResponseDocs = getJSONArrayForDatasetidUsingSearchAPI(queryString, dataset_id); try { //create doc element LegacyDocElement docElement = new LegacyDocElement(); //add the dataset id docElement.setDatasetId(dataset_id); //System.out.println("dataset_id: " + dataset_id); List<LegacyFileElement> fileElements = new ArrayList<LegacyFileElement>(); //insert initial file here LegacyFileElement initialFileElement = createInitialFileElement1(); //add all other file elements for (int j = 0; j < jsonArrayResponseDocs.length(); j++) { JSONObject docJSON = new JSONObject(jsonArrayResponseDocs.get(j).toString()); LegacyFileElement fileElement = createFileElementUsingSearchAPI(docJSON); fileElements.add(fileElement); } docElement.setCount(jsonArrayResponseDocs.length()); docElement.setFileElements(fileElements); docElements.add(docElement); } catch (Exception e) { System.out.println("JSON ERROR"); //e.printStackTrace(); } } String xmlStr = ""; for (int i = 0; i < docElements.size(); i++) { xmlStr += docElements.get(i).toXML(); } JSONObject returnJSON = null; try { returnJSON = XML.toJSONObject(xmlStr); } catch (JSONException e) { e.printStackTrace(); } jsonContent = returnJSON.toString(); } return jsonContent; }
From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.web.PDFProducerJspBean.java
/** * Create a new configuration// w w w . j a v a2 s .c om * @param request request * @return message to confirm the creation or not */ public String doCreateConfigProducer(HttpServletRequest request) { String strIdDirectory = request.getParameter(PARAMETER_ID_DIRECTORY); if (!isAuthorized(strIdDirectory)) { return AdminMessageService.getMessageUrl(request, Messages.USER_ACCESS_DENIED, AdminMessage.TYPE_STOP); } String strNameConfig = request.getParameter(PARAMETER_CREATECONFIG_NAME); String strIdEntryFileName = request.getParameter(PARAMETER_ID_ENTRY_FILE_NAME); String strTypeConfigFileName = request.getParameter(PARAMETER_TYPE_CONFIG_FILE_NAME); String strTextFileName = request.getParameter(PARAMETER_TEXT_FILE_NAME); String strExtractNotEmpty = request.getParameter(PARAMETER_EXTRACT_NOT_EMPTY); String[] listStrIdEntry = request.getParameterValues(PARAMETER_CONFIG_ENTRY); List<Integer> listIdEntry = new ArrayList<Integer>(); if (listStrIdEntry != null) { for (int i = 0; i < listStrIdEntry.length; i++) { if (StringUtils.isNotBlank(listStrIdEntry[i]) && StringUtils.isNumeric(listStrIdEntry[i])) { listIdEntry.add(Integer.valueOf(listStrIdEntry[i])); } } } checkEntryGroup(listIdEntry); UrlItem url = new UrlItem(JSP_CREATE_CONFIG_PRODUCER); if (request.getParameterMap().containsKey(PARAMETER_CREATECONFIG_SAVE)) { url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory); url.addParameter(PARAMETER_TYPE_CONFIG_FILE_NAME, strTypeConfigFileName); url.addParameter(PARAMETER_TEXT_FILE_NAME, strTextFileName); url.addParameter(PARAMETER_EXTRACT_NOT_EMPTY, StringUtils.defaultString(strExtractNotEmpty)); if (!listIdEntry.isEmpty()) { for (Integer idEntry : listIdEntry) { url.addParameter(PARAMETER_CONFIG_ENTRY, String.valueOf(idEntry)); } } if (StringUtils.isBlank(strNameConfig)) { url.addParameter(PARAMETER_ID_ENTRY_FILE_NAME, strIdEntryFileName); return AdminMessageService.getMessageUrl(request, MESSAGE_NAME_CONFIG_MISSED, url.getUrl(), AdminMessage.TYPE_ERROR); } else if (StringUtils.isBlank(strIdEntryFileName) && (StringUtils.isEmpty(strTypeConfigFileName) || strTypeConfigFileName.equals(CONSTANT_DIRECTORY_ENTRY))) { url.addParameter(PARAMETER_CREATECONFIG_NAME, strIdEntryFileName); return AdminMessageService.getMessageUrl(request, MESSAGE_ENTRY_FILE_NAME_MISSED, url.getUrl(), AdminMessage.TYPE_ERROR); } else { url = new UrlItem(JSP_MANAGE_CONFIG_PRODUCER); url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory); ConfigProducer configProducer = new ConfigProducer(); configProducer.setName(strNameConfig); configProducer.setIdEntryFileName(DirectoryUtils.convertStringToInt(strIdEntryFileName)); configProducer.setIdDirectory(DirectoryUtils.convertStringToInt(strIdDirectory)); configProducer.setType(TYPE_CONFIG_PDF); configProducer.setTextFileName(strTextFileName); configProducer.setTypeConfigFileName(strTypeConfigFileName); if (StringUtils.isNotBlank(strExtractNotEmpty)) { configProducer.setExtractNotFilled(false); } else { configProducer.setExtractNotFilled(true); } _manageConfigProducerService.addNewConfig(getPlugin(), configProducer, listIdEntry); return AdminMessageService.getMessageUrl(request, MESSAGE_ADD_NEW_CONFIG, url.getUrl(), AdminMessage.TYPE_INFO); } } else if (request.getParameterMap().containsKey(PARAMETER_CREATECONFIG_CANCEL)) { url = new UrlItem(JSP_MANAGE_CONFIG_PRODUCER); url.addParameter(PARAMETER_ID_DIRECTORY, strIdDirectory); return AdminMessageService.getMessageUrl(request, MESSAGE_CANCEL_CREATE, url.getUrl(), AdminMessage.TYPE_INFO); } else { url = new UrlItem(JSP_CREATE_CONFIG_PRODUCER_BIS); return doCheckAll(url, strIdDirectory, listIdEntry, strNameConfig, strIdEntryFileName, strTextFileName, strTypeConfigFileName); } }
From source file:org.ldaptive.servlets.AbstractServletSearchTemplatesExecutor.java
@Override public void search(final HttpServletRequest request, final HttpServletResponse response) throws LdapException, IOException { Integer fromResult = null;/*from ww w .j a va 2 s .c o m*/ if (request.getParameter("from-result") != null) { try { fromResult = Integer.valueOf(request.getParameter("from-result")); } catch (NumberFormatException e) { logger.warn("Received invalid fromResult parameter: {}", request.getParameter("from-result")); } } Integer toResult = null; if (request.getParameter("to-result") != null) { try { toResult = Integer.valueOf(request.getParameter("to-result")); } catch (NumberFormatException e) { logger.warn("Received invalid toResult parameter: {}", request.getParameter("to-result")); } } boolean doSearch = true; final String queryString = request.getParameter("query"); if (queryString == null || queryString.length() == 0) { logger.info("Ignoring empty query"); doSearch = false; } if (doSearch && ignorePattern != null) { final Matcher matcher = ignorePattern.matcher(queryString); if (matcher.matches()) { logger.info("Ignoring query {}", queryString); doSearch = false; } } if (doSearch) { final Query query = new Query(queryString); query.setReturnAttributes(request.getParameterValues("attrs")); query.setSearchRestrictions(request.getParameter("search-restrictions")); query.setFromResult(fromResult); query.setToResult(toResult); logger.info("Performing query {}", query); final SearchResult result = search(query); writeResponse(result, response); } }
From source file:net.duckling.ddl.web.controller.task.TaskBaseController.java
/** ??? */ @RequestMapping(params = "func=modifySubmit") public ModelAndView modifySubmitTask(HttpServletRequest request, @PathVariable("teamCode") String teamCode) { VWBContext context = VWBContext.createContext(request, UrlPatterns.T_TASK_PATTERNS); Site site = context.getSite();//from w ww. j ava 2s . c om TaskService service = taskService; String taskId = StringUtils.trimToEmpty(request.getParameter("taskId")); String taskType = StringUtils.trimToEmpty(request.getParameter("taskType")); String taskTitle = StringUtils.trimToEmpty(request.getParameter("taskTitle")); String takerListStr = convert2TaskNameType(StringUtils.trimToEmpty(request.getParameter("takerList")), site); String takerFromPop = convert2TaskNameType(StringUtils.trimToEmpty(request.getParameter("takerList_pop")), site); takerListStr = deleteSame(takerListStr, takerFromPop); // if (!isNull(taskId)) { String needDeleteItemsId = request.getParameter("needDeleteItemsId"); String needUpdateItemsId = request.getParameter("needUpdateItemsId"); String[] needAddItemsContents = request.getParameterValues("newTaskContent"); String[] modifyContents = request.getParameterValues("modifyTaskContent"); Task task = service.getShareTask(taskId); task.setTitle(taskTitle); service.updateTask(task); service.updateTakers(task, takerListStr, TaskService.TYPE_SHARE, DEntity.DTASK_SHARE); service.addShareItems(needAddItemsContents, task.getTaskId() + ""); service.updateShareItems(needUpdateItemsId.split(","), modifyContents); service.deleteShareItems(needDeleteItemsId.split(",")); // noticeS? service.sendNotice(site.getId(), service.getTakers(taskId), task, DEntity.DTASK_SHARE, DAction.UPDATE_TASK, task.getCreator()); } // else { String items[] = request.getParameterValues("newTaskContent"); String title = request.getParameter("taskTitle"); String[] takerArray = takerListStr.split(","); Task task = new Task(); task.setTeamId(teamCode); task.setCreateTime(DateUtil.getCurrentTime()); task.setCreator(context.getCurrentUID()); task.setTaskType(taskType); task.setTitle(title); int id = service.addTask(task); task.setTaskId(id); service.addShareItems(items, id + ""); service.addTakers(takerListStr.split(","), id + ""); // noticeS ??? service.sendNotice(site.getId(), getListFromArray(takerArray, id), task, DEntity.DTASK_SHARE, DAction.CREATE, task.getCreator()); } return getRedirect(teamCode); }
From source file:edu.lafayette.metadb.web.dataman.ViewMetadata.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) *///from ww w.j av a 2 s . c om protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "UTF8"), true); String projname = (String) request.getSession(false).getAttribute(Global.SESSION_PROJECT); String username = (String) request.getSession(false).getAttribute(Global.SESSION_USERNAME); JSONObject output = new JSONObject(); JSONArray headers = new JSONArray(); JSONArray items = new JSONArray(); if (projname == null || projname.equals("")) return; int itemCount = ItemsDAO.nextItemNumber(projname) - 1; try { JSONObject itemNumberHeader = new JSONObject(); itemNumberHeader.put("name", "Filename"); itemNumberHeader.put("editable", false); headers.put(itemNumberHeader); for (int i = 0; i < itemCount; i++) { items.put(new JSONArray()); int itemNumber = i + 1; String[] filePath = ItemsDAO.getMasterPath(projname, itemNumber).split("/"); //String[] itemFilename = filePath[filePath.length - 1].split("-"); String itemName = filePath[filePath.length - 1]; items.getJSONArray(i).put(itemName); } String[] techList = request.getParameterValues(Global.MD_TYPE_TECH); if (techList != null) for (String attr : techList) { String element = attr.split("-")[0]; String[] labelArray = attr.split("-"); String label = labelArray.length > 1 ? labelArray[1] : ""; JSONObject techHeader = new JSONObject(); techHeader.put("name", element + (label.equals("") ? "" : "." + label)); techHeader.put("editable", false); headers.put(techHeader); List<String> techData = TechnicalDataDAO.getMultipleTechnicalData(projname, element, label); for (int i = 0; i < itemCount; i++) { String data = ""; if (i < techData.size()) data = techData.get(i); items.getJSONArray(i).put(data); } } Permission metadataPermission = PermissionManDAO.getUserPermission(username, projname); boolean editAdmin = metadataPermission.getAdmin_md().equals("read_write"); boolean editDesc = metadataPermission.getDesc_md().equals("read_write"); String[] adminList = request.getParameterValues(Global.MD_TYPE_ADMIN); if (adminList != null) for (String attr : adminList) { String[] labelArray = attr.split("-"); String element = labelArray[0]; String label = labelArray.length > 1 ? labelArray[1] : ""; List<String> adminDescData = AdminDescDataDAO.getMultipleAdminDescData(projname, element, label, Global.MD_TYPE_ADMIN); //MetaDbHelper.note("Select size "+adminDescData.size()); JSONObject adminHeader = new JSONObject(); adminHeader.put("name", element + (label.equals("") ? "" : "." + label)); adminHeader.put("editable", editAdmin); headers.put(adminHeader); for (int i = 0; i < itemCount; i++) { String data = ""; if (i < adminDescData.size()) data = StringEscapeUtils.escapeHtml(adminDescData.get(i)); items.getJSONArray(i).put(data); } } String[] descList = request.getParameterValues(Global.MD_TYPE_DESC); if (descList != null) for (String attr : descList) { String[] labelArray = attr.split("-"); String element = labelArray[0]; String label = labelArray.length > 1 ? labelArray[1] : ""; List<String> adminDescData = AdminDescDataDAO.getMultipleAdminDescData(projname, element, label, Global.MD_TYPE_DESC); //MetaDbHelper.note("Select size "+adminDescData.size()); JSONObject descHeader = new JSONObject(); descHeader.put("name", element + (label.equals("") ? "" : "." + label)); descHeader.put("editable", editDesc); headers.put(descHeader); for (int i = 0; i < itemCount; i++) { String data = ""; if (i < adminDescData.size()) if (AdminDescAttributesDAO.getAttributeByName(projname, element, label).isSorted()) data = StringEscapeUtils.escapeHtml(MetaDbHelper.sortVocab(adminDescData.get(i))); else data = StringEscapeUtils.escapeHtml(adminDescData.get(i)); items.getJSONArray(i).put(data); } } output.put("headers", headers); output.put("items", items); } catch (Exception e) { MetaDbHelper.logEvent(e); } out.print(output); out.flush(); }