/** * Returns the map of parameters of this link.<p> * * @return the map of parameters */ public Map<String, String[]> getParameterMap() { if (m_parameters == null) { m_parameters = CmsRequestUtil.createParameterMap(m_query); } return m_parameters; }
/** * Returns the map of parameters of this link.<p> * * @return the map of parameters (<code>Map(String[])</code>) */ public Map getParameterMap() { if (m_parameters == null) { m_parameters = CmsRequestUtil.createParameterMap(m_query); } return m_parameters; }
/** * Parses the parameters of the given request query part and creates a parameter map out of them.<p> * * Please note: This does not parse a full request URI/URL, only the query part that * starts after the "?". For example, in the URI <code>/system/index.html?a=b&c=d</code>, * the query part is <code>a=b&c=d</code>.<p> * * If the given String is empty, an empty map is returned.<p> * * @param query the query to parse * @return the parameter map created from the query */ public static Map<String, String[]> createParameterMap(String query) { return createParameterMap(query, false, null); }
/** * Creates a new static export request wrapper.<p> * * @param req the request to wrap * @param data the data for the static export */ public CmsStaticExportRequest(HttpServletRequest req, CmsStaticExportData data) { super(req); m_parameters = CmsRequestUtil.createParameterMap(data.getParameters()); }
/** * Returns all initialized parameters of the current workplace class in the * form of a parameter map, i.e. the values are arrays.<p> * * @return all initialized parameters of the current workplace class in the * form of a parameter map */ public Map<String, String[]> paramsAsParameterMap() { return CmsRequestUtil.createParameterMap(paramValues()); }
/** * Creates a new static export request wrapper.<p> * * @param req the request to wrap * @param data the data for the static export */ public CmsStaticExportRequest(HttpServletRequest req, CmsStaticExportData data) { super(req); m_parameters = CmsRequestUtil.createParameterMap(data.getParameters()); }
/** * Returns all initialized parameters of the current workplace class in the * form of a parameter map, i.e. the values are arrays.<p> * * @return all initialized parameters of the current workplace class in the * form of a parameter map */ public Map paramsAsParameterMap() { return CmsRequestUtil.createParameterMap(paramValues()); }
/** * Returns the parameters as Map from the given url String.<p> * * @param url the url String to get the parameters from * @return the parameters as Map */ private Map<String, String[]> getParameterMap(String url) { Map<String, String[]> result = new HashMap<String, String[]>(); if (CmsStringUtil.isNotEmpty(url)) { int pos = url.indexOf(CmsRequestUtil.URL_DELIMITER); if (pos >= 0) { result = CmsRequestUtil.createParameterMap(url.substring(pos + 1)); } } return result; }
/** * Returns the parameters as Map from the given url String.<p> * * @param url the url String to get the parameters from * @return the parameters as Map */ private Map<String, String[]> getParameterMap(String url) { Map<String, String[]> result = new HashMap<String, String[]>(); if (CmsStringUtil.isNotEmpty(url)) { int pos = url.indexOf(CmsRequestUtil.URL_DELIMITER); if (pos >= 0) { result = CmsRequestUtil.createParameterMap(url.substring(pos + 1)); } } return result; }
/** * Returns the value of a parameter from a String that is formatted for a GET request.<p> * * @param url the URL to get the parameter value from * @param paramName the request parameter name * @return the value of the parameter */ public static String getRequestParam(String url, String paramName) { Map<String, String[]> params = Collections.emptyMap(); if (CmsStringUtil.isNotEmpty(url)) { int pos = url.indexOf(CmsRequestUtil.URL_DELIMITER); if (pos >= 0) { params = CmsRequestUtil.createParameterMap(url.substring(pos + 1)); } } String[] result = params.get(paramName); if (result != null) { return result[0]; } return null; }
/** * Returns the value of a parameter from a String that is formatted for a GET request.<p> * * @param url the URL to get the parameter value from * @param paramName the request parameter name * @return the value of the parameter */ public static String getRequestParam(String url, String paramName) { Map params = Collections.EMPTY_MAP; if (CmsStringUtil.isNotEmpty(url)) { int pos = url.indexOf(CmsRequestUtil.URL_DELIMITER); if (pos >= 0) { params = CmsRequestUtil.createParameterMap(url.substring(pos + 1)); } } String[] result = (String[])params.get(paramName); if (result != null) { return result[0]; } return null; }
/** * @see java.lang.Object#clone() */ @Override public CmsSolrQuery clone() { CmsSolrQuery sq = new CmsSolrQuery(null, CmsRequestUtil.createParameterMap(toString())); sq.m_ignoreExpiration = m_ignoreExpiration; return sq; }
/** * Performs a search.<p> * * @param cms the cms object * @param solrQuery the Solr query * * @return a list of documents * * @throws CmsSearchException if something goes wrong * * @see #search(CmsObject, CmsSolrQuery, boolean) */ public CmsSolrResultList search(CmsObject cms, String solrQuery) throws CmsSearchException { return search(cms, new CmsSolrQuery(null, CmsRequestUtil.createParameterMap(solrQuery)), false); }
/** * @see org.opencms.file.collectors.I_CmsResourceCollector#getResults(org.opencms.file.CmsObject, java.lang.String, java.lang.String) */ public List<CmsResource> getResults(CmsObject cms, String name, String param, int numResults) throws CmsException { name = name == null ? COLLECTORS[1] : name; Map<String, String> paramsAsMap = getParamsAsMap(param); Map<String, String[]> pm = CmsRequestUtil.createParameterMap( paramsAsMap.get(SOLR_PART), Boolean.valueOf(paramsAsMap.get(PARAM_DECODE_URL)).booleanValue(), cms.getRequestContext().getEncoding()); CmsSolrQuery q = COLLECTORS_LIST.indexOf(name) == 0 ? new CmsSolrQuery(null, pm) : new CmsSolrQuery(cms, pm); boolean excludeTimerange = Boolean.valueOf( paramsAsMap.get(CmsCollectorData.PARAM_EXCLUDETIMERANGE)).booleanValue(); if (excludeTimerange) { q.removeExpiration(); } if (numResults > 0) { q.setRows(Integer.valueOf(numResults)); } CmsSolrIndex index = CmsSearchManager.getIndexSolr(cms, pm); return new ArrayList<CmsResource>(index.search(cms, q, true)); }
/** * Helper method for executing a query.<p> * * @param cms the CMS context to use * @param index the index to use for the query * @param query the query to perform * @param start the start offset * @param rows the number of results to return * * @return the list of search results * @throws CmsSearchException if something goes wrong */ CmsSolrResultList solrSearch(CmsObject cms, CmsSolrIndex index, String query, int start, int rows) throws CmsSearchException { CmsSolrQuery q = new CmsSolrQuery(null, CmsRequestUtil.createParameterMap(query)); q.setStart(new Integer(start)); q.setRows(new Integer(rows)); CmsSolrResultList resultPage = index.search(cms, q, true); return resultPage; }
/** * @see org.opencms.file.collectors.A_CmsResourceCollector#getCreateTypeId(org.opencms.file.CmsObject, java.lang.String, java.lang.String) */ @Override public int getCreateTypeId(CmsObject cms, String collectorName, String param) throws CmsException { int result = -1; Map<String, String> paramsAsMap = getParamsAsMap(param); if (paramsAsMap.get(PARAM_CREATE_PATH) != null) { String solrParams = paramsAsMap.get(SOLR_PART); CmsSolrQuery q = new CmsSolrQuery( null, CmsRequestUtil.createParameterMap( solrParams, Boolean.valueOf(paramsAsMap.get(PARAM_DECODE_URL)).booleanValue(), cms.getRequestContext().getEncoding())); String type = CmsSolrQuery.getResourceType(q.getFilterQueries()); if (type != null) { result = OpenCms.getResourceManager().getResourceType(type).getTypeId(); } } return result; }
/** * Forwards the response to the given target, which may contain parameters appended like for example <code>?a=b&c=d</code>.<p> * * Please note: If possible, use <code>{@link #forwardRequest(String, Map, HttpServletRequest, HttpServletResponse)}</code> * where the parameters are passed as a map, since the parsing of the parameters may introduce issues with encoding * and is in general much less effective.<p> * * The parsing of parameters will likely fail for "large values" (e.g. full blown web forms with <textarea> * elements etc. Use this method only if you know that the target will just contain up to 3 parameters which * are relatively short and have no encoding or line break issues.<p> * * @param target the target to forward to (may contain parameters like <code>?a=b&c=d</code>) * @param req the request to forward * @param res the response to forward * * @throws IOException in case the forwarding fails * @throws ServletException in case the forwarding fails */ public static void forwardRequest(String target, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { // clear the current parameters CmsUriSplitter uri = new CmsUriSplitter(target); Map<String, String[]> params = createParameterMap(uri.getQuery()); forwardRequest(uri.getPrefix(), params, req, res); }
/** * Redirects to the given page with the given parameters.<p> * * @param wp the workplace object * @param pagePath the path to the page to redirect to * @param params the parameters to send * * @throws IOException in case of errors during forwarding * @throws ServletException in case of errors during forwarding */ public void jspForwardPage(CmsWorkplace wp, String pagePath, Map params) throws IOException, ServletException { Map newParams = createToolParams(wp, pagePath, params); if (pagePath.indexOf("?") > 0) { pagePath = pagePath.substring(0, pagePath.indexOf("?")); } wp.setForwarded(true); // forward to the requested page uri CmsRequestUtil.forwardRequest( wp.getJsp().link(pagePath), CmsRequestUtil.createParameterMap(newParams), wp.getJsp().getRequest(), wp.getJsp().getResponse()); }
/** * Forwards to the specified location in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @param params the map of parameters to use for the forwarded request * * @throws IOException in case the forward fails * @throws ServletException in case the forward fails */ public void sendForward(String location, Map params) throws IOException, ServletException { setForwarded(true); // params must be arrays of String, ensure this is the case params = CmsRequestUtil.createParameterMap(params); CmsRequestUtil.forwardRequest(getJsp().link(location), params, getJsp().getRequest(), getJsp().getResponse()); }
/** * Forwards to the specified location in the OpenCms VFS.<p> * * @param location the location the response is redirected to * @param params the map of parameters to use for the forwarded request * * @throws IOException in case the forward fails * @throws ServletException in case the forward fails */ public void sendForward(String location, Map<String, String[]> params) throws IOException, ServletException { setForwarded(true); // params must be arrays of String, ensure this is the case Map<String, String[]> parameters = CmsRequestUtil.createParameterMap(params); CmsRequestUtil.forwardRequest( getJsp().link(location), parameters, getJsp().getRequest(), getJsp().getResponse()); }