/** * 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); }
/** * 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); }
/** * 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; }
throws CmsException { CmsRelationFilter filter = CmsRelationFilter.SOURCES.filterType(CmsRelationType.JSP_STRONG); Iterator it = cms.getRelationsForResource(resource, filter).iterator(); while (it.hasNext()) {
throws CmsException { CmsRelationFilter filter = CmsRelationFilter.SOURCES.filterType(CmsRelationType.JSP_STRONG); Iterator<CmsRelation> it = cms.getRelationsForResource(resource, filter).iterator(); while (it.hasNext()) {
CmsRelationFilter filter = CmsRelationFilter.SOURCES.filterType(CmsRelationType.CATEGORY); if (recursive) { filter = filter.filterIncludeChildren();
CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType(CmsRelationType.JSP_STRONG); Iterator<CmsRelation> it; try {
CmsRelationFilter filter = CmsRelationFilter.SOURCES.filterType(CmsRelationType.CATEGORY); if (recursive) { filter = filter.filterIncludeChildren();
CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType(CmsRelationType.JSP_STRONG); Iterator it; try {
CmsRelationFilter.ALL.filterType(CmsRelationType.LOCALE_VARIANT).filterStructureId( resource.getStructureId())); List<CmsRelation> out = Lists.newArrayList(); CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType( CmsRelationType.LOCALE_VARIANT).filterStructureId(target.getStructureId()); List<CmsRelation> relationsToTarget = m_cms.readRelations(filter);
CmsRelationFilter.ALL.filterType(CmsRelationType.LOCALE_VARIANT)); for (CmsRelation rel : localeRelations) { if (isInSources(rel.getSourcePath()) && isInSources(rel.getTargetPath())) {
/** * 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); } }
/** * 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); }
CmsRelationFilter.TARGETS.filterType(CmsRelationType.XSD)); if ((relations != null) && !relations.isEmpty()) { CmsXmlEntityResolver entityResolver = new CmsXmlEntityResolver(cms);
/** * 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); }
containerPage.getStructureId()).filterType(CmsRelationType.XML_STRONG); List<CmsRelation> relations = m_guestCms.readRelations(filter); long result = containerPage.getDateLastModified();
/** * 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()); } } } } }
m_cms.deleteRelationsFromResource( secondaryPage, CmsRelationFilter.ALL.filterType(CmsRelationType.LOCALE_VARIANT)); m_cms.addRelationToResource( secondaryPage,
/** * @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); } }
CmsRelationFilter typeFilter = CmsRelationFilter.ALL.filterType(CmsRelationType.LOCALE_VARIANT); firstPage = getDefaultFileOrSelf(firstPage); secondPage = getDefaultFileOrSelf(secondPage);