Splits a list of resources into groups.<p>

@param resources the list of resources

@return the list of groups
772061
public List<GROUP> getGroups(List<RESOURCE> resources) {

        List<RESOURCE> sortedResources = new ArrayList<RESOURCE>(resources);
        Collections.sort(sortedResources, new SortingComparator());
        Map<Long, Integer> daysMap = computeDaysForResources(sortedResources);
        Map<GroupAge, List<RESOURCE>> resourcesByAge = partitionPublishResourcesByAge(sortedResources, daysMap);
        List<List<RESOURCE>> youngGroups = partitionYoungResources(resourcesByAge.get(GroupAge.young));
        List<List<RESOURCE>> mediumGroups = partitionMediumResources(resourcesByAge.get(GroupAge.medium), daysMap);
        List<RESOURCE> oldGroup = resourcesByAge.get(GroupAge.old);
        List<GROUP> resultGroups = new ArrayList<GROUP>();
        for (List<RESOURCE> groupRes : youngGroups) {
            String name = getPublishGroupName(groupRes, GroupAge.young);
            resultGroups.add(createGroup(name, groupRes));
        }
        for (List<RESOURCE> groupRes : mediumGroups) {
            String name = getPublishGroupName(groupRes, GroupAge.medium);
            resultGroups.add(createGroup(name, groupRes));
        }
        if (!oldGroup.isEmpty()) {
            String oldName = getPublishGroupName(oldGroup, GroupAge.old);
            resultGroups.add(createGroup(oldName, oldGroup));
        }
        return resultGroups;
    }
192806
@SuppressWarnings("unchecked")
    public <E extends IPluginResource> List<E> getResources(Class<E> clazz) {
        List<E> list = new ArrayList<>();

        for (IPluginResource resource : resources) {
            if (clazz.isInstance(resource)) {
                list.add((E) resource);
            }
        }

        return list;
    }
797685
public List<CmsResource> getAllResources() {

        List<CmsResource> result = Lists.newArrayList();
        result.add(m_primaryResource);
        for (CmsResource res : getSecondaryResources()) {
            result.add(res);
        }
        return result;
    }
866695
public static List<Resource> getChildrenByType(final Resource resource, List<String> typeSet) {
        final ArrayList<Resource> children = new ArrayList<>();
        if (resource != null) {
            for (final Resource child : resource.getChildren()) {
                for (String type : typeSet) {
                    if (isResourceType(child, type)) {
                        children.add(child);
                        break;
                    }
                }
            }
        }
        return children;
    }
517194
public List<String> getGroups(String... groups) {
        synchronized (Hdf5Archive.LOCK_OBJECT) {
            if (groups.length == 0)
                return getObjects(this.file, H5O_TYPE_GROUP);
            Group[] groupArray = openGroups(groups);
            List<String> ls = getObjects(groupArray[groupArray.length - 1], H5O_TYPE_GROUP);
            closeGroups(groupArray);
            return ls;
        }
    }
1165522
public <T> T loadResources(Class<T> type, String... resources) {
    return loadResources(type, Arrays.asList(resources));
  }
1286713
protected List<CmsUUID> parseResources(String resources) {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(resources)) {
            return Collections.emptyList();
        } else {
            List<CmsUUID> result = new ArrayList<CmsUUID>();
            String[] resArray = resources.trim().split(";");
            for (int i = 0; i < resArray.length; i++) {
                result.add(new CmsUUID(resArray[i]));
            }
            return result;
        }
    }
768981
public static <T> List<List<T>> splitList(List<T> _list, int _elements) {
       List<List<T>> partitions = new ArrayList<>();
       for (int i = 0; i < _list.size(); i += _elements) {
           partitions.add(_list.subList(i,
                   Math.min(i + _elements, _list.size())));
       }

       return partitions;
   }
1171682
@SuppressWarnings("deprecation")
    private List<CmsResource> searchResources() {

        getReport().println(
            Messages.get().container(Messages.RPT_SOURCESEARCH_START_COLLECTING_FILES_TO_SEARCH_IN_0),
            I_CmsReport.FORMAT_HEADLINE);

        List<CmsResource> resources = new ArrayList<CmsResource>();
        if (m_settings.isSolrSearch()) {
            CmsSolrIndex index = OpenCms.getSearchManager().getIndexSolr(m_settings.getSource());
            if (index != null) {
                CmsSolrQuery query = new CmsSolrQuery(
                    null,
                    CmsRequestUtil.createParameterMap(m_settings.getQuery() + "&fl=path,type"));
                List<String> rootPaths = new ArrayList<>(m_settings.getPaths().size());
                String siteRoot = getCms().getRequestContext().getSiteRoot();
                for (String path : m_settings.getPaths()) {
                    rootPaths.add(path.startsWith(siteRoot) ? path : getCms().addSiteRoot(path));
                }
                query.setSearchRoots(rootPaths);
                if ((m_settings.getTypesArray() != null) && (m_settings.getTypesArray().length > 0)) {
                    query.setResourceTypes(m_settings.getTypesArray());
                }
                query.setRows(new Integer(MAX_PROCESSED_SOLR_RESULTS));
                query.ensureParameters();
                try {
                    resources.addAll(
                        index.search(getCms(), query, true, null, false, null, MAX_PROCESSED_SOLR_RESULTS));
                } catch (CmsSearchException e) {
                    LOG.error(e.getMessage(), e);
                }
            }
        } else {
            CmsResourceFilter filter = CmsResourceFilter.ALL.addExcludeState(
                CmsResource.STATE_DELETED).addRequireVisible();
            List<CmsResourceFilter> filterList = new ArrayList<CmsResourceFilter>();
            if ((m_settings.getTypesArray() != null) && (m_settings.getTypesArray().length > 0)) {
                for (String resTypeName : m_settings.getTypesArray()) {
                    try {
                        int typeId = OpenCms.getResourceManager().getResourceType(resTypeName).getTypeId();
                        filterList.add(((CmsResourceFilter)filter.clone()).addRequireType(typeId));
                    } catch (CmsLoaderException e) {
                        // noop
                    } catch (NullPointerException e) {
                        // noop
                    }
                }
            }
            if (filterList.size() == 1) {
                filter = filterList.get(0);
            }

            // iterate over all selected paths
            Iterator<String> iterPaths = m_settings.getPaths().iterator();

            if (!m_settings.getType().isPropertySearch()) {
                filter = filter.addRequireFile();
            }
            while (iterPaths.hasNext()) {
                String path = iterPaths.next();
                try {
                    if (m_settings.getType().isPropertySearch()) {
                        resources.addAll(
                            getCms().readResourcesWithProperty(path, m_settings.getProperty().getName(), null, filter));
                    } else {
                        // only read resources which are files and not deleted, which are in the current time range window and where the current
                        // user has the sufficient permissions to read them

                        List<CmsResource> tmpResources = getCms().readResources(path, filter);
                        List<String> subsites = null;
                        if (m_settings.ignoreSubSites()) {
                            subsites = OpenCms.getADEManager().getSubSitePaths(getCms(), path);
                            subsites.remove(
                                OpenCms.getADEManager().getSubSiteRoot(
                                    getCms(),
                                    getCms().readResource(path).getRootPath()));
                        }
                        Iterator<CmsResource> iterator = tmpResources.iterator();
                        while (iterator.hasNext()) {
                            CmsResource r = iterator.next();
                            boolean remove = true;
                            if (filterList.size() > 1) {
                                for (CmsResourceFilter f : filterList) {
                                    if (f.isValid(getCms().getRequestContext(), r)) {
                                        remove = false;
                                    }
                                }
                            } else {
                                remove = false;
                            }
                            if ((subsites != null) & !remove) {
                                if (subsites.contains(
                                    OpenCms.getADEManager().getSubSiteRoot(getCms(), r.getRootPath()))) {
                                    remove = true;
                                }
                            }
                            if (remove) {
                                iterator.remove();
                            }
                        }

                        if ((tmpResources != null) && !tmpResources.isEmpty()) {
                            resources.addAll(tmpResources);
                        }
                    }
                } catch (CmsException e) {
                    // an error occured
                    LOG.error(Messages.get().container(Messages.RPT_SOURCESEARCH_ERROR_READING_RESOURCES_1, path), e);
                    getReport().println(
                        Messages.get().container(Messages.RPT_SOURCESEARCH_ERROR_READING_RESOURCES_1, path),
                        I_CmsReport.FORMAT_ERROR);
                }
            }
        }
        return resources;
    }
1265865
public List<List<RESOURCE>> partitionMediumResources(List<RESOURCE> resources, Map<Long, Integer> days) {

        if (resources.isEmpty()) {
            return Collections.<List<RESOURCE>> emptyList();
        }
        RESOURCE firstRes = resources.get(0);
        int lastDay = days.get(new Long(getDateLastModified(firstRes))).intValue();
        List<List<RESOURCE>> result = new ArrayList<List<RESOURCE>>();
        List<RESOURCE> currentGroup = new ArrayList<RESOURCE>();
        result.add(currentGroup);
        for (RESOURCE res : resources) {
            LOG.debug("Processing medium-aged resource " + getRootPath(res));
            int day = days.get(new Long(getDateLastModified(res))).intValue();
            if (day != lastDay) {
                LOG.debug("=== new group ===");
                currentGroup = new ArrayList<RESOURCE>();
                result.add(currentGroup);
            }
            lastDay = day;
            currentGroup.add(res);
        }
        return result;
    }
1218226
public static Enumeration<URL> getResources(String resource) {
        Enumeration<URL> urls = null;
        try {
            urls = ClassUtils.getContextClassLoader().getResources(resource);
        } catch (IOException e) {
            //noop
        }
        if (urls == null) {
            try {
                urls = IOUtils.class.getClassLoader().getResources(resource);
            } catch (IOException e) {
                //noop
            }
        }

        if (urls == null) {
            URL url = IOUtils.class.getResource(resource);
            if (url != null) {
                final Iterator<URL> it = Lists.newArrayList(url).iterator();
                urls = new Enumeration<URL>() {
                    public boolean hasMoreElements() {
                        return it.hasNext();
                    }

                    public URL nextElement() {
                        return it.next();
                    }
                };
            }
        }

        if (urls == null) {
            File file = new File(resource);
            if (file.isFile()) {
                try {
                    final Iterator<URL> it = Lists.newArrayList(file.toURI().toURL()).iterator();
                    urls = new Enumeration<URL>() {
                        public boolean hasMoreElements() {
                            return it.hasNext();
                        }

                        public URL nextElement() {
                            return it.next();
                        }
                    };
                } catch (MalformedURLException e) {
                    //no op
                }
            }
        }

        return urls == null ? new Enumeration<URL>() {
            public boolean hasMoreElements() {
                return false;
            }

            public URL nextElement() {
                return null;
            }
        } : urls;
    }
867372
public List<Resource> buildResources() {
        List<Resource> resources = new ArrayList<Resource>();
        for (ResourceBuilder builder : _resourceBuilders) {
            Resource resource = builder.build();
            if (resource != null) {
                resources.add(resource);
            }
        }
        return resources;
    }
747261
@Override
  public List<? extends BoundedSource<T>> split(long desiredBundleSizeBytes,
      PipelineOptions options) throws Exception {

    List<? extends BoundedSource<T>> splits = delegate.split(desiredBundleSizeBytes, options);
    Collections.shuffle(splits);
    return splits;
  }
1106029
public void setResources(java.util.Collection<Resource> resources) {
        if (resources == null) {
            this.resources = null;
            return;
        }

        this.resources = new java.util.ArrayList<Resource>(resources);
    }
555633
public static List<? extends IResource> chain(IResource resource)
    {
        List<IResource> chain = new ArrayList<IResource>();
        while (true)
        {
           chain.add(resource);
           if (!resource.hasParent())
               break;
           resource = resource.getParent();
        }
        return chain;
    }
119494
@Override
    public List<T> getAll(final String... ids) {
        if (ids == null || ids.length == 0) {
            return Collections.<T> emptyList();
        }

        // delegate to internal method that partitions the list into smaller groups and aggregates
        // the result
        return getAll(Lists.newArrayList(ids));
    }
372634
public Optional<String[]> splitPath(URI resource) {
        int matchRes = matches(resource);
        if (matchRes < 0) {
            return Optional.empty();
        }
        return Optional.of(split(resource.getPath(), matchRes + 1));
    }