Builds a list of resources for a given path.<p>

@param path the requested path
@param filter a filter object (only "includeDeleted" information is used!)

@return list of <code>{@link CmsResource}</code>s

@throws CmsException if something goes wrong
337788
public List<CmsResource> readPath(String path, CmsResourceFilter filter) throws CmsException {

        return m_securityManager.readPath(m_context, addSiteRoot(path), filter);
    }
543943
private void repairXmlContents() throws CmsException {

        // set the resource filter to filter XML contents of the selected type
        CmsResourceFilter filter = CmsResourceFilter.IGNORE_EXPIRATION.addRequireType(m_settings.getResourceTypeId());
        String path = CmsResource.getFolderPath(m_settings.getVfsFolder());
        // get the list of resources to check
        List<CmsResource> resources = getCms().readResources(path, filter, m_settings.isIncludeSubFolders());

        // set the report counters
        int count = 0;
        int resSize = resources.size();

        // create an entity resolver to use
        CmsXmlEntityResolver resolver = new CmsXmlEntityResolver(getCms());

        // iterate the resources
        Iterator<CmsResource> i = resources.iterator();
        while (i.hasNext()) {

            count++;
            CmsResource res = i.next();

            // generate report output
            getReport().print(
                org.opencms.report.Messages.get().container(
                    org.opencms.report.Messages.RPT_SUCCESSION_2,
                    String.valueOf(count),
                    String.valueOf(resSize)),
                I_CmsReport.FORMAT_NOTE);
            getReport().print(Messages.get().container(Messages.RPT_PROCESSING_XMLCONTENT_0), I_CmsReport.FORMAT_NOTE);
            getReport().print(
                org.opencms.report.Messages.get().container(
                    org.opencms.report.Messages.RPT_ARGUMENT_1,
                    getCms().getSitePath(res)));
            getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_DOTS_0));

            try {

                // get the file contents
                CmsFile file = getCms().readFile(res);
                // get the XML content
                CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), file);

                // check the XML structure
                boolean fixFile = m_settings.isForce();
                if (!fixFile) {
                    try {
                        xmlContent.validateXmlStructure(resolver);
                    } catch (CmsXmlException e) {
                        // XML structure is not valid, this file has to be fixed
                        fixFile = true;
                    }
                }
                if (fixFile) {

                    // check the lock state of the file to repair
                    CmsLock lock = getCms().getLock(res);
                    boolean isLocked = false;
                    boolean canWrite = false;
                    if (lock.isNullLock()) {
                        // file is not locked, lock it
                        getCms().lockResource(getCms().getSitePath(res));
                        isLocked = true;
                        canWrite = true;
                    } else if (lock.isOwnedBy(getCms().getRequestContext().getCurrentUser())) {
                        // file is locked by current user
                        canWrite = true;
                    }

                    if (canWrite) {
                        // enable "auto correction mode" - this is required or the XML structure will not be fully corrected
                        xmlContent.setAutoCorrectionEnabled(true);
                        // now correct the XML
                        xmlContent.correctXmlStructure(getCms());
                        file.setContents(xmlContent.marshal());
                        // write the corrected file
                        getCms().writeFile(file);
                    } else {
                        // no write operation possible
                        getReport().println(
                            Messages.get().container(Messages.RPT_XMLCONTENTREPAIR_NOTLOCKED_0),
                            I_CmsReport.FORMAT_NOTE);
                    }

                    if (isLocked) {
                        // unlock previously locked resource
                        getCms().unlockResource(getCms().getSitePath(res));
                    }

                    if (canWrite) {
                        // successfully repaired XML content, report it
                        getReport().println(
                            Messages.get().container(Messages.RPT_XMLCONTENTREPAIR_REPAIRED_0),
                            I_CmsReport.FORMAT_OK);
                    }

                } else {
                    // nothing to fix, skip this file
                    getReport().println(
                        Messages.get().container(Messages.RPT_XMLCONTENTREPAIR_SKIPFILE_0),
                        I_CmsReport.FORMAT_NOTE);
                }

            } catch (CmsException e) {
                // an error occurred, show exception on report output
                getReport().println(e);
            }
        }
    }
381316
private boolean existsResource(String path, boolean rootPath) {

        CmsObject cms = getCmsObject();
        if (rootPath) {
            String origSiteRoot = cms.getRequestContext().getSiteRoot();
            try {
                cms.getRequestContext().setSiteRoot("");
                if (cms.existsResource(path, CmsResourceFilter.ALL)) {
                    return true;
                }
            } finally {
                cms.getRequestContext().setSiteRoot(origSiteRoot);
            }
        } else {
            if (cms.existsResource(path, CmsResourceFilter.ALL)) {
                return true;
            }
        }
        return false;
    }
1061662
public List<CmsCategory> readResourceCategories(CmsObject cms, CmsResource resource) throws CmsException {

        return internalReadResourceCategories(cms, resource, false);
    }
618624
public void getSubEntries(
        final String rootPath,
        final boolean isRoot,
        final String filter,
        final I_CmsSimpleCallback<List<CmsSitemapEntryBean>> callback) {

        CmsRpcAction<List<CmsSitemapEntryBean>> action = new CmsRpcAction<List<CmsSitemapEntryBean>>() {

            @Override
            public void execute() {

                start(0, false);
                getGalleryService().getSubEntries(rootPath, isRoot, filter, this);
            }

            @Override
            protected void onResponse(List<CmsSitemapEntryBean> result) {

                stop(false);
                callback.execute(result);
            }

        };
        action.execute();
    }
1155133
private Set<Resource<T>> filterResources(Path path, Predicate<Resource> test) {
        validatePath(path);
        if (!hasDirectory(path)) {
            throw StorageException.listException(path, "not a directory path: " + path);
        }
        File file = filepathMapper.directoryForPath(path);
        HashSet<Resource<T>> files = new HashSet<Resource<T>>();
        try {
            for (File file1 : file.listFiles()) {
                Resource<T> res = loadResource(filepathMapper.pathForContentFile(file1), false);
                if (null == test || test.apply(res)) {
                    files.add(res);
                }
            }
        } catch (IOException e) {
            throw StorageException.listException(path, "Failed to list directory: " + path + ": " + e.getMessage(), e);
        }
        return files;
    }
646720
public static Resource[] listResources(Resource[] resources, ResourceFilter filter) {
	int count = 0;
	Resource[] children;
	ArrayList<Resource[]> list = new ArrayList<Resource[]>();
	for (int i = 0; i < resources.length; i++) {
	    children = filter == null ? resources[i].listResources() : resources[i].listResources(filter);
	    if (children != null) {
		count += children.length;
		list.add(children);
	    }
	    else list.add(new Resource[0]);
	}
	Resource[] rtn = new Resource[count];
	int index = 0;
	for (int i = 0; i < resources.length; i++) {
	    children = list.get(i);
	    for (int y = 0; y < children.length; y++) {
		rtn[index++] = children[y];
	    }
	}
	// print.out(rtn);
	return rtn;
    }
852803
protected void addResource(String path) {

        CmsPathSelectField field = new CmsPathSelectField();
        field.setCmsObject(m_cms);
        field.setUseRootPaths(true);
        field.setValue(path);
        field.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 8646438704383992571L;

            public void valueChange(ValueChangeEvent event) {

                setOkButtonEnabled(true);

            }
        });
        m_componentsToValidate.add(field);
        CmsRemovableFormRow<CmsPathSelectField> row = new CmsRemovableFormRow<CmsPathSelectField>(
            field,
            CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNC_REMOVE_RESOURCE_0));
        row.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNC_RESOURCE_0));
        row.setRemoveRunnable(new Runnable() {

            public void run() {

                setOkButtonEnabled(true);
            }
        });
        m_resources.addComponent(row);
    }
871268
protected CmsVisitedByFilter getVisitedByFilter(CmsObject cms, String param) throws CmsException {

        CmsVisitedByFilter filter = new CmsVisitedByFilter();
        Map<String, String> params = getParameters(param);

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

        return filter;
    }
378524
public CmsGallerySearchResult searchByPath(String path, Locale locale) throws CmsException {

        I_CmsSearchDocument sDoc = m_index.getDocument(CmsSearchField.FIELD_PATH, path);
        CmsGallerySearchResult result = null;
        if ((sDoc != null) && (sDoc.getDocument() != null)) {
            result = new CmsGallerySearchResult(sDoc, m_cms, 100, locale);
        } else {
            CmsResource res = m_cms.readResource(path, CmsResourceFilter.IGNORE_EXPIRATION);
            result = new CmsGallerySearchResult(m_cms, res);
        }
        return result;
    }
1265909
private List<String> getResourcePaths() {

        List<String> res = new ArrayList<String>();
        for (Component c : m_resources) {
            if (c instanceof CmsRemovableFormRow<?>) {
                AbstractField<?> field = (AbstractField<?>)(((CmsRemovableFormRow)c).getInput());
                res.add((String)(field.getValue()));
            }
        }
        return res;
    }
1229402
private List<CmsResource> getContents(String folderPath, String type) throws CmsException {

        CmsPathMap<CmsResource> pathMap = getPathMapForType(type);
        return pathMap.getChildValues(folderPath);
    }
852989
protected List<CmsResource> getResources() {

        List<CmsResource> result = Collections.emptyList();
        // get all image resources of the folder
        CmsResourceFilter filter = CmsResourceFilter.DEFAULT;
        try {
            CmsObject cms = getCms();
            result = cms.readResources(getParamResource(), filter, false);

        } catch (CmsException e) {
            // log, should never happen
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getLocalizedMessage(getLocale()));
            }
        }
        return result;
    }
591587
public static List<Path> getSubDirectoryPathList(Path startDirectoryPath,
			Predicate<Path> filter) {
		return getSubPathList(startDirectoryPath, Integer.MAX_VALUE,
				DirectoryAndNotSymbolicLinkFilter.and(filter));
	}
612912
protected CmsResourceTreeTable createTree(CmsObject cms, CmsResource root) {

        return new CmsResourceTreeTable(cms, root, m_filter);
    }
1113595
public static CmsFlexBucketConfiguration loadFromVfsFile(CmsObject cms, String path) throws CmsException {

        if (!cms.existsResource(path)) {
            return null;
        }
        CmsResource configRes = cms.readResource(path);
        if (configRes.isFolder()) {
            return null;
        }
        CmsFile configFile = cms.readFile(configRes);
        String encoding = CmsFileUtil.getEncoding(cms, configRes);
        Properties props = new Properties();
        try {
            props.load(new InputStreamReader(new ByteArrayInputStream(configFile.getContents()), encoding));
            return loadFromProperties(props);
        } catch (IOException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        return null;
    }
483617
public List<CmsResource> getLockedResources(CmsResource resource, CmsLockFilter filter) throws CmsException {

        return m_securityManager.getLockedResourcesObjects(m_context, resource, filter);
    }