Gets the rewrite aliases matching a given filter.<p>

@param dbc the current database context
@param filter the filter used for filtering rewrite aliases

@return the rewrite aliases matching the given filter

@throws CmsException if something goes wrong
518130
public List<CmsRewriteAlias> getRewriteAliases(CmsDbContext dbc, CmsRewriteAliasFilter filter) throws CmsException {

        return getVfsDriver(dbc).readRewriteAliases(dbc, filter);
    }
470869
public List<?> getList(PMContext ctx, EntityFilter filter) throws PMException {
        return getList(ctx, filter, null, null, null);
    }
1364383
public static dbuser[] get_filtered(nitro_service service, String filter) throws Exception{
		dbuser obj = new dbuser();
		options option = new options();
		option.set_filter(filter);
		dbuser[] response = (dbuser[]) obj.getfiltered(service, option);
		return response;
	}
917071
public void addFilter(String filter) {

        if (CmsStringUtil.isNotEmpty(filter)) {
            filter = filter.trim().toLowerCase();
            if (FILTERS.contains(filter)) {
                m_filters.add(filter);
            }
        }
    }
1076140
public List<CmsAccessControlEntry> getAllAccessControlEntries(CmsRequestContext context) throws CmsException {

        CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
        List<CmsAccessControlEntry> result = null;
        try {
            result = m_driverManager.getAllAccessControlEntries(dbc);
        } catch (Exception e) {
            dbc.report(null, Messages.get().container(Messages.ERR_GET_ACL_ENTRIES_1, "<all resources>"), e);
        } finally {
            dbc.clear();
        }
        return result;

    }
287854
private CmsPair<String, List<String>> buildAliasConditions(CmsAliasFilter filter) {

        List<String> conditions = new ArrayList<String>();
        conditions.add("1 = 1");
        List<String> conditionParams = new ArrayList<String>();
        if (filter.getSiteRoot() != null) {
            conditions.add("site_root = ?");
            conditionParams.add(filter.getSiteRoot());
        }
        if (filter.getStructureId() != null) {
            conditions.add("structure_id = ?");
            conditionParams.add(filter.getStructureId().toString());
        }
        if (filter.getPath() != null) {
            conditions.add("path = ?");
            conditionParams.add(filter.getPath());
        }
        String conditionString = CmsStringUtil.listAsString(conditions, " AND ");
        return CmsPair.create(conditionString, conditionParams);
    }
545244
public void deleteRelationsFromResource(CmsResource resource, CmsRelationFilter filter) throws CmsException {

        m_securityManager.deleteRelationsForResource(m_context, resource, filter);
    }
1268608
protected CmsUserSearchParameters getSearchParams() throws CmsException {

        CmsListState state = getListState();
        CmsUserSearchParameters params = new CmsUserSearchParameters();
        String searchFilter = state.getFilter();
        params.setSearchFilter(searchFilter);
        params.setFilterCore(true);
        params.setPaging(getList().getMaxItemsPerPage(), state.getPage());
        params.setSorting(getSortKey(state.getColumn()), state.getOrder().equals(CmsListOrderEnum.ORDER_ASCENDING));
        params.setOrganizationalUnit(OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), getParamOufqn()));
        params.setRecursiveOrgUnits(false);
        return params;
    }
310679
public List<String> readUrlNamesForAllLocales(CmsDbContext dbc, CmsUUID id) throws CmsDataAccessException {

        List<String> result = new ArrayList<String>();
        List<CmsUrlNameMappingEntry> entries = getVfsDriver(dbc).readUrlNameMappingEntries(
            dbc,
            dbc.currentProject().isOnlineProject(),
            CmsUrlNameMappingFilter.ALL.filterStructureId(id));
        ArrayListMultimap<String, CmsUrlNameMappingEntry> entriesByLocale = ArrayListMultimap.create();
        for (CmsUrlNameMappingEntry entry : entries) {
            String localeKey = entry.getLocale();
            entriesByLocale.put(localeKey, entry);
        }

        for (String localeKey : entriesByLocale.keySet()) {
            List<CmsUrlNameMappingEntry> entrs = entriesByLocale.get(localeKey);
            CmsUrlNameMappingEntry maxEntryForLocale = Collections.max(entrs, new UrlNameMappingComparator());
            result.add(maxEntryForLocale.getName());
        }
        return result;
    }
844855
protected void checkWritePermissionsInFolder(CmsDbContext dbc, CmsResource folder) throws CmsDataAccessException {

        ResultSet res = null;
        PreparedStatement stmt = null;
        Connection conn = null;

        CmsUUID projectId = dbc.getRequestContext().getCurrentProject().getUuid();

        // first read all subresources with ACEs
        List<CmsResource> resources = new ArrayList<CmsResource>();
        try {
            conn = m_sqlManager.getConnection(dbc);
            stmt = m_sqlManager.getPreparedStatement(conn, projectId, "C_RESOURCES_READ_WITH_ACE_1");
            stmt.setString(1, folder.getRootPath() + "%");
            res = stmt.executeQuery();

            while (res.next()) {
                resources.add(createResource(res, projectId));
            }
        } catch (SQLException e) {
            throw new CmsDbSqlException(
                Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)),
                e);
        } finally {
            m_sqlManager.closeAll(dbc, conn, stmt, res);
        }

        // check current user write permission for each of these resources
        Iterator<CmsResource> itResources = resources.iterator();
        while (itResources.hasNext()) {
            CmsResource resource = itResources.next();
            try {
                m_driverManager.getSecurityManager().checkPermissions(
                    dbc.getRequestContext(),
                    resource,
                    CmsPermissionSet.ACCESS_WRITE,
                    false,
                    CmsResourceFilter.ALL);
            } catch (CmsException e) {
                throw new CmsDataAccessException(e.getMessageContainer(), e);
            }
        }

        // then check for possible jsp pages without permissions
        CmsResourceFilter filter = CmsResourceFilter.ALL;
        itResources = readTypesInResourceTree(
            dbc,
            projectId,
            folder.getRootPath(),
            CmsResourceTypeJsp.getJspResourceTypeIds(),
            filter.getState(),
            filter.getModifiedAfter(),
            filter.getModifiedBefore(),
            filter.getReleaseAfter(),
            filter.getReleaseBefore(),
            filter.getExpireAfter(),
            filter.getExpireBefore(),
            CmsDriverManager.READMODE_INCLUDE_TREE).iterator();
        while (itResources.hasNext()) {
            CmsResource resource = itResources.next();
            try {
                m_driverManager.getSecurityManager().checkPermissions(
                    dbc.getRequestContext(),
                    resource,
                    CmsPermissionSet.ACCESS_WRITE,
                    false,
                    CmsResourceFilter.ALL);
            } catch (CmsException e) {
                throw new CmsDataAccessException(e.getMessageContainer(), e);
            }
        }
    }
307840
public void writeResource(CmsDbContext dbc, CmsResource resource) throws CmsException {

        // access was granted - write the resource
        resource.setUserLastModified(dbc.currentUser().getId());
        CmsUUID projectId = ((dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID())
        ? dbc.currentProject().getUuid()
        : dbc.getProjectId();

        getVfsDriver(dbc).writeResource(dbc, projectId, resource, UPDATE_RESOURCE_STATE);

        // make sure the written resource has the state correctly set
        if (resource.getState().isUnchanged()) {
            resource.setState(CmsResource.STATE_CHANGED);
        }

        // delete in content relations if the new type is not parseable
        if (!(OpenCms.getResourceManager().getResourceType(resource.getTypeId()) instanceof I_CmsLinkParseable)) {
            deleteRelationsWithSiblings(dbc, resource);
        }

        // update the cache
        m_monitor.clearResourceCache();
        Map<String, Object> data = new HashMap<String, Object>(2);
        data.put(I_CmsEventListener.KEY_RESOURCE, resource);
        data.put(I_CmsEventListener.KEY_CHANGE, new Integer(CHANGED_RESOURCE));
        OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_RESOURCE_MODIFIED, data));
    }
984110
protected void addSearchFilterCondition(
        CmsSelectQuery select,
        TableAlias users,
        CmsUserSearchParameters searchParams) {

        String searchFilter = searchParams.getSearchFilter();
        if (!CmsStringUtil.isEmptyOrWhitespaceOnly(searchFilter)) {
            boolean caseInsensitive = !searchParams.isCaseSensitive();
            if (caseInsensitive) {
                searchFilter = searchFilter.toLowerCase();
            }
            CmsCompositeQueryFragment searchCondition = new CmsCompositeQueryFragment();
            searchCondition.setSeparator(" OR ");
            searchCondition.setPrefix("(");
            searchCondition.setSuffix(")");
            //use coalesce in case any of the name columns are null
            String patternExprTemplate = generateConcat(
                "COALESCE(%1$s, '')",
                "' '",
                "COALESCE(%2$s, '')",
                "' '",
                "COALESCE(%3$s, '')");
            patternExprTemplate = wrapLower(patternExprTemplate, caseInsensitive);

            String patternExpr = String.format(
                patternExprTemplate,
                users.column(colName()),
                users.column(colFirstName()),
                users.column(colLastName()));
            String like = " LIKE ? ESCAPE '!' ";
            String matchExpr = patternExpr + like;
            searchFilter = "%" + CmsEncoder.escapeSqlLikePattern(searchFilter, '!') + '%';
            searchCondition.add(new CmsSimpleQueryFragment(matchExpr, searchFilter));
            for (SearchKey key : searchParams.getSearchKeys()) {
                switch (key) {
                    case email:
                        searchCondition.add(
                            new CmsSimpleQueryFragment(
                                wrapLower(users.column(colEmail()), caseInsensitive) + like,
                                searchFilter));
                        break;
                    case orgUnit:
                        searchCondition.add(new CmsSimpleQueryFragment(
                            wrapLower(users.column(colOu()), caseInsensitive) + like,
                            searchFilter));
                        break;
                    default:
                        break;
                }
            }
            select.addCondition(searchCondition);
        }
    }
742694
public CmsLock getLock(CmsDbContext dbc, CmsResource resource) throws CmsException {

        return m_lockManager.getLock(dbc, resource);
    }
288104
protected CmsPair<String, List<I_CmsPreparedStatementParameter>> prepareLogConditions(CmsLogFilter filter) {

        List<I_CmsPreparedStatementParameter> params = new ArrayList<I_CmsPreparedStatementParameter>();
        StringBuffer conditions = new StringBuffer();

        // user id filter
        if (filter.getUserId() != null) {
            if (conditions.length() == 0) {
                conditions.append(BEGIN_CONDITION);
            } else {
                conditions.append(BEGIN_INCLUDE_CONDITION);
            }
            conditions.append(m_sqlManager.readQuery("C_LOG_FILTER_USER_ID"));
            params.add(new CmsPreparedStatementStringParameter(filter.getUserId().toString()));
            conditions.append(END_CONDITION);
        }

        // resource id filter
        if (filter.getStructureId() != null) {
            if (conditions.length() == 0) {
                conditions.append(BEGIN_CONDITION);
            } else {
                conditions.append(BEGIN_INCLUDE_CONDITION);
            }
            conditions.append(m_sqlManager.readQuery("C_LOG_FILTER_RESOURCE_ID"));
            params.add(new CmsPreparedStatementStringParameter(filter.getStructureId().toString()));
            conditions.append(END_CONDITION);
        }

        // date from filter
        if (filter.getDateFrom() != CmsResource.DATE_RELEASED_DEFAULT) {
            if (conditions.length() == 0) {
                conditions.append(BEGIN_CONDITION);
            } else {
                conditions.append(BEGIN_INCLUDE_CONDITION);
            }
            conditions.append(m_sqlManager.readQuery("C_LOG_FILTER_DATE_FROM"));
            params.add(new CmsPreparedStatementLongParameter(filter.getDateFrom()));
            conditions.append(END_CONDITION);
        }

        // date to filter
        if (filter.getDateTo() != CmsResource.DATE_RELEASED_DEFAULT) {
            if (conditions.length() == 0) {
                conditions.append(BEGIN_CONDITION);
            } else {
                conditions.append(BEGIN_INCLUDE_CONDITION);
            }
            conditions.append(m_sqlManager.readQuery("C_LOG_FILTER_DATE_TO"));
            params.add(new CmsPreparedStatementLongParameter(filter.getDateTo()));
            conditions.append(END_CONDITION);
        }

        // include type filter
        Set<CmsLogEntryType> includeTypes = filter.getIncludeTypes();
        if (!includeTypes.isEmpty()) {
            if (conditions.length() == 0) {
                conditions.append(BEGIN_CONDITION);
            } else {
                conditions.append(BEGIN_INCLUDE_CONDITION);
            }
            conditions.append(m_sqlManager.readQuery("C_LOG_FILTER_INCLUDE_TYPE"));
            conditions.append(BEGIN_CONDITION);
            Iterator<CmsLogEntryType> it = includeTypes.iterator();
            while (it.hasNext()) {
                CmsLogEntryType type = it.next();
                conditions.append("?");
                params.add(new CmsPreparedStatementIntParameter(type.getId()));
                if (it.hasNext()) {
                    conditions.append(", ");
                }
            }
            conditions.append(END_CONDITION);
            conditions.append(END_CONDITION);
        }

        // exclude type filter
        Set<CmsLogEntryType> excludeTypes = filter.getExcludeTypes();
        if (!excludeTypes.isEmpty()) {
            if (conditions.length() == 0) {
                conditions.append(BEGIN_CONDITION);
            } else {
                conditions.append(BEGIN_INCLUDE_CONDITION);
            }
            conditions.append(m_sqlManager.readQuery("C_LOG_FILTER_EXCLUDE_TYPE"));
            conditions.append(BEGIN_CONDITION);
            Iterator<CmsLogEntryType> it = excludeTypes.iterator();
            while (it.hasNext()) {
                CmsLogEntryType type = it.next();
                conditions.append("?");
                params.add(new CmsPreparedStatementIntParameter(type.getId()));
                if (it.hasNext()) {
                    conditions.append(", ");
                }
            }
            conditions.append(END_CONDITION);
            conditions.append(END_CONDITION);
        }
        return CmsPair.create(conditions.toString(), params);
    }
849989
public List<CmsResource> getLockedResources(CmsDbContext dbc, CmsResource resource, CmsLockFilter filter)
    throws CmsException {

        List<CmsResource> lockedResources = new ArrayList<CmsResource>();
        Iterator<CmsLock> itLocks = OpenCms.getMemoryMonitor().getAllCachedLocks().iterator();
        while (itLocks.hasNext()) {
            CmsLock lock = itLocks.next();
            CmsResource lockedResource;
            boolean matchesFilter = filter.match(resource.getRootPath(), lock);
            if (!matchesFilter && !filter.isSharedExclusive()) {
                // we don't need to read the resource if the filter didn't match and we don't need to look at the siblings
                continue;
            }
            try {
                lockedResource = m_driverManager.readResource(dbc, lock.getResourceName(), CmsResourceFilter.ALL);
            } catch (CmsVfsResourceNotFoundException e) {
                OpenCms.getMemoryMonitor().uncacheLock(lock.getResourceName());
                continue;
            }
            if (filter.isSharedExclusive() && (lockedResource.getSiblingCount() > 1)) {
                Iterator<CmsResource> itSiblings = internalReadSiblings(dbc, lockedResource).iterator();
                while (itSiblings.hasNext()) {
                    CmsResource sibling = itSiblings.next();
                    CmsLock siblingLock = internalSiblingLock(lock, sibling.getRootPath());
                    if (filter.match(resource.getRootPath(), siblingLock)) {
                        lockedResources.add(sibling);
                    }
                }
            }
            if (matchesFilter) {
                lockedResources.add(lockedResource);
            }
        }
        Collections.sort(lockedResources, I_CmsResource.COMPARE_ROOT_PATH);
        return lockedResources;
    }
570285
protected CmsSubscriptionFilter getSubscriptionFilter(CmsObject cms, Map<String, String> params)
    throws CmsException {

        CmsSubscriptionFilter filter = new CmsSubscriptionFilter();

        // initialize the filter
        initVisitedByFilter(filter, cms, params, false);

        // set subscription filter specific parameters

        // determine the mode to read subscribed resources
        if (params.containsKey(PARAM_KEY_MODE)) {
            String modeName = params.get(PARAM_KEY_MODE);
            filter.setMode(CmsSubscriptionReadMode.modeForName(modeName));
        }

        // determine the groups to set in the filter
        if (params.containsKey(PARAM_KEY_GROUPS)) {
            List<String> groupNames = CmsStringUtil.splitAsList(params.get(PARAM_KEY_GROUPS), ',', true);
            for (Iterator<String> i = groupNames.iterator(); i.hasNext();) {
                String groupName = i.next();
                try {
                    CmsGroup group = cms.readGroup(groupName);
                    filter.addGroup(group);
                } catch (CmsException e) {
                    // error reading a group
                    LOG.error(
                        Messages.get().getBundle().key(
                            Messages.ERR_COLLECTOR_PARAM_INVALID_1,
                            PARAM_KEY_GROUPS + "=" + params.get(PARAM_KEY_GROUPS)));
                    throw e;
                }
            }
        }
        boolean includeUserGroups = Boolean.valueOf(params.get(PARAM_KEY_INCLUDEGROUPS)).booleanValue();
        if (filter.getGroups().isEmpty() && includeUserGroups) {
            // include the given or current users groups
            String userName = null;
            if (filter.getUser() != null) {
                userName = filter.getUser().getName();
            } else {
                userName = cms.getRequestContext().getCurrentUser().getName();
            }
            filter.setGroups(cms.getGroupsOfUser(userName, false));
        }

        return filter;
    }
361782
@Override
	public SqlFilterManager addSqlFilter(final SqlFilter filter) {
		if (filter == null) {
			throw new IllegalArgumentException("filter is null.");
		}
		filters.add(filter);
		return this;
	}