private Set<CmsResource> getDirectlyRelatedResources(CmsResource currentResource) {

        Set<CmsResource> directlyRelatedResources = Sets.newHashSet();
        List<CmsRelation> relations = getRelationsFromResource(currentResource);
        for (CmsRelation relation : relations) {
            LOG.info("Trying to read resource for relation " + relation.getTargetPath());
            CmsResource target = getResource(relation.getTargetId());
            if (target != null) {
                if (relation.getType().isStrong() || shouldAddWeakRelationTarget(target)) {
                    directlyRelatedResources.add(target);
                }
            }
        }
        try {
            CmsResource parentFolder = m_cms.readParentFolder(currentResource.getStructureId());
            if (parentFolder != null) { // parent folder of root folder is null
                if (parentFolder.getState().isNew() || currentResource.isFile()) {
                    directlyRelatedResources.add(parentFolder);
                }
            }
        } catch (CmsException e) {
            LOG.error(
                "Error processing parent folder for " + currentResource.getRootPath() + ": " + e.getLocalizedMessage(),
                e);
        }

        try {
            directlyRelatedResources.addAll(
                m_relatedResourceProvider.getAdditionalRelatedResources(m_cms, currentResource));
        } catch (Exception e) {
            LOG.error(
                "Error processing additional related resource for "
                    + currentResource.getRootPath()
                    + ": "
                    + e.getLocalizedMessage(),
                e);
        }
        return directlyRelatedResources;
    }
private Set < CmsResource > getDirectlyRelatedResources ( CmsResource currentResource ) { Set < CmsResource > directlyRelatedResources = Sets . newHashSet ( ) ; List < CmsRelation > relations = getRelationsFromResource ( currentResource ) ; for ( CmsRelation relation : relations ) { LOG . info ( "Trying to read resource for relation " + relation . getTargetPath ( ) ) ; CmsResource target = getResource ( relation . getTargetId ( ) ) ; if ( target != null ) { if ( relation . getType ( ) . isStrong ( ) || shouldAddWeakRelationTarget ( target ) ) { directlyRelatedResources . add ( target ) ; } } } try { CmsResource parentFolder = m_cms . readParentFolder ( currentResource . getStructureId ( ) ) ; if ( parentFolder != null ) { if ( parentFolder . getState ( ) . isNew ( ) || currentResource . isFile ( ) ) { directlyRelatedResources . add ( parentFolder ) ; } } } catch ( CmsException e ) { LOG . error ( "Error processing parent folder for " + currentResource . getRootPath ( ) + ": " + e . getLocalizedMessage ( ) , e ) ; } try { directlyRelatedResources . addAll ( m_relatedResourceProvider . getAdditionalRelatedResources ( m_cms , currentResource ) ) ; } catch ( Exception e ) { LOG . error ( "Error processing additional related resource for " + currentResource . getRootPath ( ) + ": " + e . getLocalizedMessage ( ) , e ) ; } return directlyRelatedResources ; }
Fetches the directly related resources for a given resource.<p>

@param currentResource the resource for which to get the related resources
@return the directly related resources