/** * @see java.lang.Object#clone() */ @Override public Object clone() { CmsRelationFilter filter = new CmsRelationFilter(m_source, m_target); filter.m_structureId = m_structureId; filter.m_types = new HashSet(m_types); filter.m_path = m_path; filter.m_includeSubresources = m_includeSubresources; return filter; }
/** * Returns an extended filter with the given source relation path restriction.<p> * * @param path the source relation path to filter * * @return an extended filter with the given source relation path restriction */ public CmsRelationFilter filterPath(String path) { CmsRelationFilter filter = (CmsRelationFilter)clone(); filter.m_path = path; return filter; }
/** * Returns an extended filter with the given resource (path and id) restriction.<p> * * @param resource the resource to filter * * @return an extended filter with the given resource (path and id) restriction */ public CmsRelationFilter filterResource(CmsResource resource) { CmsRelationFilter filter = filterStructureId(resource.getStructureId()); filter = filterPath(resource.getRootPath()); return filter; }
/** * Reads the outgoing LOCALE_VARIANT relations for a given resource.<p> * * @param cms the CMS context * @param resource the resource * @return the list of relations * @throws CmsException if something goes wrong */ List<CmsRelation> readOutgoingRelations(CmsObject cms, CmsResource resource) throws CmsException { List<CmsRelation> results = cms.readRelations( CmsRelationFilter.relationsFromStructureId(resource.getStructureId()).filterType( CmsRelationType.LOCALE_VARIANT)); return results; }
Iterator itRelations = cms.getRelationsForResource( resource, CmsRelationFilter.TARGETS.filterType(CmsRelationType.CATEGORY)).iterator(); if (repair && itRelations.hasNext()) { baseFolder = getRepositoryBaseFolderName(cms); CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType(CmsRelationType.CATEGORY).filterResource( res); cms.deleteRelationsFromResource(resourceName, filter); LOG.debug(e.getLocalizedMessage(), e); CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType(CmsRelationType.CATEGORY).filterPath( relation.getTargetPath()); if (!relation.getTargetId().isNullUUID()) { filter = filter.filterStructureId(relation.getTargetId());
/** * Removes a resource identified by the given resource name from the given category.<p> * * The resource has to be previously locked.<p> * * @param cms the current cms context * @param resourceName the site relative path to the resource to remove * @param category the category to remove the resource from * * @throws CmsException if something goes wrong */ public void removeResourceFromCategory(CmsObject cms, String resourceName, CmsCategory category) throws CmsException { // remove the resource just from this category CmsRelationFilter filter = CmsRelationFilter.TARGETS; filter = filter.filterType(CmsRelationType.CATEGORY); filter = filter.filterResource( cms.readResource(cms.getRequestContext().removeSiteRoot(category.getRootPath()))); filter = filter.filterIncludeChildren(); cms.deleteRelationsFromResource(resourceName, filter); }
/** * Reads the actual resource and relation data from the OpenCms VFS.<p> * * @param cms the CMS context to use for reading the data */ public void fillRelation(CmsObject cms) { try { m_source = cms.readResource(m_sourceId); List<CmsRelation> relations = cms.getRelationsForResource( m_source, CmsRelationFilter.TARGETS.filterStructureId(m_targetId).filterType(getRelationType(m_relType))); if (relations.isEmpty()) { throw new CmisObjectNotFoundException(toString()); } m_relation = relations.get(0); } catch (CmsException e) { CmsCmisUtil.handleCmsException(e); } }
CmsRelationFilter.TARGETS.filterStrong().filterIncludeChildren()).iterator(); while (itRelations.hasNext()) { CmsRelation relation = (CmsRelation)itRelations.next();
CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterIncludeChildren().filterStructureId( CmsUUID.getNullUUID());
CmsRelationFilter filter = CmsRelationFilter.SOURCES.filterType(CmsRelationType.CATEGORY); if (recursive) { filter = filter.filterIncludeChildren();
/** * Finds relations from the target root folder or its children to the source root folder or its children.<p> * * @return the list of relations from the target to the source * * @throws CmsException if something goes wrong */ protected List<CmsRelation> findRelationsFromTargetToSource() throws CmsException { List<CmsRelation> relations = m_cms.readRelations( CmsRelationFilter.SOURCES.filterPath(m_targetPath).filterIncludeChildren()); List<CmsRelation> result = new ArrayList<CmsRelation>(); for (CmsRelation rel : relations) { if (isInTargets(rel.getSourcePath()) && isInSources(rel.getTargetPath())) { result.add(rel); } } return result; }
/** * Returns a new publish list that contains the unpublished resources related * to all resources in the given publish list, the related resources exclude * all resources in the given publish list and also locked (by other users) resources.<p> * * @param cms the cms request context * @param publishList the publish list to exclude from result * * @return a new publish list that contains the related resources * * @throws CmsException if something goes wrong */ public CmsPublishList getRelatedResourcesToPublish(CmsObject cms, CmsPublishList publishList) throws CmsException { return m_securityManager.getRelatedResourcesToPublish( cms.getRequestContext(), publishList, CmsRelationFilter.TARGETS.filterStrong()); }
/** * Removes the given resource from all categories.<p> * * @param cms the cms context * @param resourcePath the resource to reset the categories for * * @throws CmsException if something goes wrong */ public void clearCategoriesForResource(CmsObject cms, String resourcePath) throws CmsException { CmsRelationFilter filter = CmsRelationFilter.TARGETS; filter = filter.filterType(CmsRelationType.CATEGORY); cms.deleteRelationsFromResource(resourcePath, filter); }
if (OpenCms.getResourceManager().getResourceType( pubRes.getType()) instanceof CmsResourceTypeXmlContent) { CmsRelationFilter filter = CmsRelationFilter.relationsToStructureId(pubRes.getStructureId()); filter.filterStrong(); List<CmsRelation> relations = adminCms.readRelations(filter); for (CmsRelation relation : relations) { CmsRelationFilter filter = CmsRelationFilter.relationsToStructureId(pubRes.getStructureId()); filter.filterStrong(); List<CmsRelation> relations = adminCms.readRelations(filter); for (CmsRelation relation : relations) {
dbc, source, CmsRelationFilter.TARGETS.filterNotDefinedInContent()).iterator(); while (itRelations.hasNext()) { CmsRelation relation = (CmsRelation)itRelations.next();
/** * Returns the list of organizational units the given resource belongs to.<p> * * @param dbc the current database context * @param resource the resource * * @return list of {@link CmsOrganizationalUnit} objects * * @throws CmsException if something goes wrong */ public List getResourceOrgUnits(CmsDbContext dbc, CmsResource resource) throws CmsException { try { dbc.getRequestContext().setAttribute(I_CmsVfsDriver.REQ_ATTR_RESOURCE_OUS, Boolean.TRUE); return m_vfsDriver.readRelations( dbc, dbc.currentProject().getUuid(), resource, CmsRelationFilter.TARGETS.filterIncludeChildren()); } finally { dbc.getRequestContext().removeAttribute(I_CmsVfsDriver.REQ_ATTR_RESOURCE_OUS); } }
CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterPath(resource.getRootPath()); m_driverManager.getVfsDriver().deleteRelations(dbc, dbc.currentProject().getUuid(), ouResource, filter); m_driverManager.getVfsDriver().deleteRelations(dbc, CmsProject.ONLINE_PROJECT_ID, ouResource, filter);
/** * Utility method which prepares a filter for relations which point *to* a given structure id.<p> * * @param structureId the structure id * * @return the new relation filter */ public static CmsRelationFilter relationsToStructureId(CmsUUID structureId) { return TARGETS.filterStructureId(structureId); }
/** * Deletes all relations for the given resource and all its siblings.<p> * * @param dbc the current database context * @param resource the resource to delete the resource for * * @throws CmsException if something goes wrong */ protected void deleteRelationsWithSiblings(CmsDbContext dbc, CmsResource resource) throws CmsException { // get all siblings List siblings; if (resource.getSiblingCount() > 1) { siblings = readSiblings(dbc, resource, CmsResourceFilter.ALL); } else { siblings = new ArrayList(); siblings.add(resource); } // clean the relations in content for all siblings Iterator it = siblings.iterator(); while (it.hasNext()) { CmsResource sibling = (CmsResource)it.next(); // clean the relation information for this sibling m_vfsDriver.deleteRelations( dbc, dbc.currentProject().getUuid(), sibling, CmsRelationFilter.TARGETS.filterDefinedInContent()); } }
Iterator<CmsRelation> itRelations = cms.getRelationsForResource( resource, CmsRelationFilter.TARGETS.filterType(CmsRelationType.CATEGORY)).iterator(); if (repair && itRelations.hasNext()) { baseFolder = getRepositoryBaseFolderName(cms); CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType( CmsRelationType.CATEGORY).filterResource(res); cms.deleteRelationsFromResource(resourceName, filter); repaired = true; LOG.debug(e.getLocalizedMessage(), e); CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType( CmsRelationType.CATEGORY).filterPath(relation.getTargetPath()); if (!relation.getTargetId().isNullUUID()) { filter = filter.filterStructureId(relation.getTargetId());