/** * 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); }
/** * Utility method which prepares a filter for relations which point *from* a given structure id.<p> * * @param structureId the structure id * * @return the new relation filter */ public static CmsRelationFilter relationsFromStructureId(CmsUUID structureId) { return SOURCES.filterStructureId(structureId); }
/** * 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; }
/** * 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; }
CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterIncludeChildren().filterStructureId( CmsUUID.getNullUUID());
CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterIncludeChildren().filterStructureId( CmsUUID.getNullUUID());
CmsRelationFilter.ALL.filterType(CmsRelationType.LOCALE_VARIANT).filterStructureId( resource.getStructureId())); List<CmsRelation> out = Lists.newArrayList(); primaryResource = target; CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType( CmsRelationType.LOCALE_VARIANT).filterStructureId(target.getStructureId()); List<CmsRelation> relationsToTarget = m_cms.readRelations(filter); for (CmsRelation targetRelation : relationsToTarget) {
/** * 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); } }
relation.getTargetPath()); if (!relation.getTargetId().isNullUUID()) { filter = filter.filterStructureId(relation.getTargetId());
/** * Rewrites relations which are not derived from links in the content itself.<p> * * @param res the resource for which to rewrite the relations * @param relations the original relations * * @throws CmsException if something goes wrong */ protected void rewriteOtherRelations(CmsResource res, Collection<CmsRelation> relations) throws CmsException { LOG.info("Rewriting non-content links for " + res.getRootPath()); for (CmsRelation rel : relations) { CmsUUID targetId = rel.getTargetId(); CmsResource newTargetResource = m_translationsById.get(targetId); CmsRelationType relType = rel.getType(); if (!relType.isDefinedInContent()) { if (newTargetResource != null) { m_cms.deleteRelationsFromResource( rel.getSourcePath(), CmsRelationFilter.TARGETS.filterStructureId(rel.getTargetId()).filterType(relType)); m_cms.addRelationToResource( rel.getSourcePath(), newTargetResource.getRootPath(), relType.getName()); } } } } }
CmsRelationType.CATEGORY).filterPath(relation.getTargetPath()); if (!relation.getTargetId().isNullUUID()) { filter = filter.filterStructureId(relation.getTargetId());
/** * @see org.opencms.cmis.I_CmsCmisObjectHelper#deleteObject(org.opencms.cmis.CmsCmisCallContext, java.lang.String, boolean) */ public void deleteObject(CmsCmisCallContext context, String objectId, boolean allVersions) { try { RelationKey rk = parseRelationKey(objectId); CmsUUID sourceId = rk.getSourceId(); CmsObject cms = m_repository.getCmsObject(context); CmsResource sourceResource = cms.readResource(sourceId); boolean wasLocked = CmsCmisUtil.ensureLock(cms, sourceResource); try { CmsRelationFilter relFilter = CmsRelationFilter.ALL.filterType( getRelationType(rk.getRelType())).filterStructureId(rk.getTargetId()); cms.deleteRelationsFromResource(sourceResource.getRootPath(), relFilter); } finally { if (wasLocked) { cms.unlockResource(sourceResource); } } } catch (CmsException e) { CmsCmisUtil.handleCmsException(e); } }
List<CmsRelation> relations = m_cms.readRelations(typeFilter.filterStructureId(secondPage.getStructureId())); CmsUUID firstId = firstPage.getStructureId(); CmsUUID secondId = secondPage.getStructureId();