/** * Removes the expiration flag. */ public void removeExpiration() { if (getFilterQueries() != null) { for (String fq : getFilterQueries()) { if (fq.startsWith(CmsSearchField.FIELD_DATE_EXPIRED + ":") || fq.startsWith(CmsSearchField.FIELD_DATE_RELEASED + ":")) { removeFilterQuery(fq); } } } m_ignoreExpiration = true; }
/** * Removes those filter queries that restrict the fields used in the given filter query Strings.<p> * * Searches in the given Strings for a ":", then takes the field name part * and removes the already set filter queries queries that are matching the same field name.<p> * * @param fqs the filter query Strings in the format <code>fq=fieldname:value</code> that should be removed */ private void removeFilterQueries(String[] fqs) { // iterate over the given filter queries to remove for (String fq : fqs) { int idx = fq.indexOf(':'); if (idx != -1) { // get the field name of the fq to remove String fieldName = fq.substring(0, idx); // iterate over the fqs of the already existing fqs from the solr query if (getFilterQueries() != null) { for (String sfq : getFilterQueries()) { if (sfq.startsWith(fieldName + ":")) { // there exists a filter query for exact the same field, remove it removeFilterQuery(sfq); } } } } } }
/** * Ensures that expired and not yet released resources are not returned by default.<p> */ private void ensureExpiration() { boolean expirationDateSet = false; boolean releaseDateSet = false; if (getFilterQueries() != null) { for (String fq : getFilterQueries()) { if (fq.startsWith(CmsSearchField.FIELD_DATE_EXPIRED + ":")) { expirationDateSet = true; } if (fq.startsWith(CmsSearchField.FIELD_DATE_RELEASED + ":")) { releaseDateSet = true; } } } if (!expirationDateSet) { addFilterQuery(CmsSearchField.FIELD_DATE_EXPIRED + ":[NOW TO *]"); } if (!releaseDateSet) { addFilterQuery(CmsSearchField.FIELD_DATE_RELEASED + ":[* TO NOW]"); } }
/** * Creates and adds a filter query.<p> * * @param fieldName the field name to create a filter query on * @param vals the values that should match for the given field * @param all <code>true</code> to combine the given values with 'AND', <code>false</code> for 'OR' * @param useQuotes <code>true</code> to surround the given values with double quotes, <code>false</code> otherwise */ public void addFilterQuery(String fieldName, List<String> vals, boolean all, boolean useQuotes) { if (getFilterQueries() != null) { for (String fq : getFilterQueries()) { if (fq.startsWith(fieldName + ":")) { removeFilterQuery(fq); } } } addFilterQuery(createFilterQuery(fieldName, vals, all, useQuotes)); }
if ((locales == null) || locales.isEmpty()) { m_textSearchFields.add(CmsSearchField.FIELD_TEXT); if (getFilterQueries() != null) { for (String fq : getFilterQueries()) { if (fq.startsWith(CmsSearchField.FIELD_CONTENT_LOCALES + ":")) { removeFilterQuery(fq);
/** * @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; }
/** * @see org.opencms.file.collectors.I_CmsResourceCollector#getCreateParam(org.opencms.file.CmsObject, java.lang.String, java.lang.String) */ public String getCreateParam(CmsObject cms, String collectorName, String param) throws CmsDataAccessException { collectorName = collectorName == null ? COLLECTORS[1] : collectorName; switch (COLLECTORS_LIST.indexOf(collectorName)) { case 0: // byQuery case 1: // byContext // check if the param supports resource creation Map<String, String> paramsAsMap = getParamsAsMap(param); CmsSolrQuery q = new CmsSolrQuery( null, CmsRequestUtil.createParameterMap( paramsAsMap.get(SOLR_PART), Boolean.valueOf(paramsAsMap.get(PARAM_DECODE_URL)).booleanValue(), cms.getRequestContext().getEncoding())); String type = CmsSolrQuery.getResourceType(q.getFilterQueries()); String path = paramsAsMap.get(PARAM_CREATE_PATH); if ((type != null) && (path != null)) { return param; } return null; default: throw new CmsDataAccessException( Messages.get().container(Messages.ERR_COLLECTOR_NAME_INVALID_1, collectorName)); } }
/** * @see org.opencms.file.collectors.I_CmsResourceCollector#getCreateLink(org.opencms.file.CmsObject, java.lang.String, java.lang.String) */ public String getCreateLink(CmsObject cms, String collectorName, String param) throws CmsException { collectorName = collectorName == null ? COLLECTORS[1] : collectorName; switch (COLLECTORS_LIST.indexOf(collectorName)) { case 0: // byQuery case 1: // byContext Map<String, String> paramsAsMap = getParamsAsMap(param); CmsSolrQuery q = new CmsSolrQuery( null, CmsRequestUtil.createParameterMap( paramsAsMap.get(SOLR_PART), Boolean.valueOf(paramsAsMap.get(PARAM_DECODE_URL)).booleanValue(), cms.getRequestContext().getEncoding())); String type = CmsSolrQuery.getResourceType(q.getFilterQueries()); String path = paramsAsMap.get(PARAM_CREATE_PATH); if ((type != null) && (path != null)) { return OpenCms.getResourceManager().getNameGenerator().getNewFileName(cms, path, 4); } return null; default: throw new CmsDataAccessException( Messages.get().container(Messages.ERR_COLLECTOR_NAME_INVALID_1, collectorName)); } }