CmsRelationFilter.ALL.filterType(CmsRelationType.LOCALE_VARIANT)); for (CmsRelation rel : localeRelations) { if (isInSources(rel.getSourcePath()) && isInSources(rel.getTargetPath())) { CmsResource newRelationSource = m_translationsById.get(rel.getSourceId()); CmsResource newRelationTarget = m_translationsById.get(rel.getTargetId()); if ((newRelationSource != null) && (newRelationTarget != null)) { try {
List<CmsRelation> in = Lists.newArrayList(); for (CmsRelation rel : relations) { if (rel.getSourceId().equals(resource.getStructureId())) { out.add(rel); } else { CmsResource source = relation.getSource(m_cms, CmsResourceFilter.ALL); secondaryResources.add(source); CmsResource target = out.get(0).getTarget(m_cms, CmsResourceFilter.ALL); primaryResource = target; CmsRelationFilter filter = CmsRelationFilter.TARGETS.filterType( List<CmsRelation> relationsToTarget = m_cms.readRelations(filter); for (CmsRelation targetRelation : relationsToTarget) { CmsResource secondaryResource = targetRelation.getSource(m_cms, CmsResourceFilter.ALL); secondaryResources.add(secondaryResource);
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(CmsRelation r1, CmsRelation r2) { if (r1 == r2) { return 0; } String p1 = r1.getSourcePath() + r1.getTargetPath() + r1.getType().getId(); String p2 = r2.getSourcePath() + r2.getTargetPath() + r2.getType().getId(); return p1.compareTo(p2); } };
/** * Creates a relation id from the given OpenCms relation object.<p> * * @param relation the OpenCms relation object * * @return the relation id */ String createKey(CmsRelation relation) { return createKey(relation.getSourceId(), relation.getTargetId(), relation.getType().getName()); }
/** * Creates a publish resource bean from the target information of a relation object.<p> * * @param relation the relation to use * * @return the publish resource bean for the relation target * * @throws CmsException if something goes wrong */ public CmsPublishResource relationToBean(CmsRelation relation) throws CmsException { CmsPermissionInfo permissionInfo = new CmsPermissionInfo(true, false, ""); return new CmsPublishResource( relation.getTargetId(), relation.getTargetPath(), relation.getTargetPath(), CmsResourceTypePlain.getStaticTypeName(), null, CmsResourceState.STATE_UNCHANGED, permissionInfo, 0, null, null, false, null, null); }
try { if (isSource()) { resource = relation.getSource(cms, CmsResourceFilter.ALL); } else { resource = relation.getTarget(cms, CmsResourceFilter.ALL); new CmsUUID(), new CmsUUID(), relation.getTargetPath(), CmsResourceTypePlain.getStaticTypeId(), false, 0); if (!brokenLinks.contains(resource)) { brokenLinks.add(relation.getType().getLocalizedName( getWp().getJsp().getRequestContext().getLocale()) + "_" ((List)relationTypes.get(resource)).add(relation.getType()); } else { List types = new ArrayList(); types.add(relation.getType()); relationTypes.put(resource, types);
CmsResource target = relation.getTarget(getCms(), CmsResourceFilter.ALL); String structureId = target.getStructureId().toString(); String sitePath = getCms().getSitePath(target); String relationType = relation.getType().getName(); addRelationNode(relationsElement, structureId, sitePath, relationType); } catch (CmsVfsResourceNotFoundException crnfe) { LOG.warn(Messages.get().getBundle().key( Messages.LOG_IMPORTEXPORT_WARN_DELETED_RELATIONS_2, new String[] {relation.getTargetPath(), resource.getRootPath()}), crnfe);
CmsRelation relation = (CmsRelation)itRelations.next(); try { CmsResource res = relation.getTarget(cms, CmsResourceFilter.DEFAULT_FOLDERS); CmsCategory category = getCategory(cms, res); if (!repair) { relation.getTargetPath()); if (!relation.getTargetId().isNullUUID()) { filter = filter.filterStructureId(relation.getTargetId()); relation.getTargetPath(), baseFolder), resourceName); addResourceToCategory(cms, resourceName, actualCat);
HashMultimap<String, String> outgoingRelationTargets = HashMultimap.create(); for (CmsRelation outRelation : outgoingRelationsOffline) { String sourcePath = outRelation.getSourcePath(); String targetId = outRelation.getTargetId().toString(); String targetPath = outRelation.getTargetPath(); outgoingRelationTargets.put(sourcePath, targetId); outgoingRelationTargets.put(sourcePath, targetPath); String link; if (!resource.getState().isDeleted()) { link = relation.getTargetPath(); } else { link = relation.getSourcePath(); Messages.get().container( Messages.RPT_HTMLLINK_BROKEN_TARGET_2, relation.getSourcePath(), dbc.removeSiteRoot(link)), I_CmsReport.FORMAT_WARNING); Messages.RPT_HTMLLINK_BROKEN_SOURCE_2, dbc.removeSiteRoot(link), relation.getTargetPath()), I_CmsReport.FORMAT_WARNING);
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);
originalRelation = new CmsRelation(resource, target, link.getType()); } catch (Exception e) { originalRelation = new CmsRelation( resource.getStructureId(), resource.getRootPath(), while (itSiblings.hasNext()) { CmsResource sibling = (CmsResource)itSiblings.next(); CmsRelation relation = new CmsRelation( sibling.getStructureId(), sibling.getRootPath(), originalRelation.getTargetId(), originalRelation.getTargetPath(), link.getType()); m_vfsDriver.createRelation(dbc, dbc.currentProject().getUuid(), relation);
/** * 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()); } } } } }
while (itRelations.hasNext()) { CmsRelation relation = itRelations.next(); if (relation.getType() == CmsRelationType.LOCALE_VARIANT) { continue; CmsResource relTarget = relation.getTarget(cms, CmsResourceFilter.ALL); addRelationToResource(dbc, target, relTarget, relation.getType(), true); } catch (CmsVfsResourceNotFoundException e) {
for (CmsRelation relation : infoEntry.getRelations()) { try { CmsResource theResource = relation.getSource(m_cms, CmsResourceFilter.ALL); CmsPublishResourceInfo info = new CmsPublishResourceInfo( Messages.get().getBundle(m_workplaceLocale).key(Messages.GUI_BROKEN_LINK_ONLINE_0), for (CmsRelation relation : infoEntry.getRelations()) { try { CmsResource theResource = relation.getTarget(m_cms, CmsResourceFilter.ALL); CmsPublishResource pubRes = resourceToBean(theResource, null, false, null); related.add(pubRes);
type.getLocalizedName(dbc.getRequestContext().getLocale()))); CmsRelation relation = new CmsRelation(resource, target, type); getVfsDriver(dbc).createRelation(dbc, dbc.currentProject().getUuid(), relation); if (!importCase) { resource.getStructureId(), CmsLogEntryType.RESOURCE_ADD_RELATION, new String[] {relation.getSourcePath(), relation.getTargetPath()}), false);
CmsRelation relation = it.next(); try { CmsResource source = relation.getSource(cms, CmsResourceFilter.DEFAULT);
/** * 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; }
/** * Gets the resources which link to a given structure id.<p> * * @param cms the current CMS context * @param resource the relation target resource * @param deleteIds set of resources to delete * * @return the list of resources which link to the given id * * @throws CmsException if something goes wrong */ @SuppressWarnings("unused") private List<CmsResource> getLinkSources(CmsObject cms, CmsResource resource, HashSet<CmsUUID> deleteIds) throws CmsException { List<CmsRelation> relations = cms.getRelationsForResource(resource, CmsRelationFilter.SOURCES); List<CmsResource> result = new ArrayList<CmsResource>(); for (CmsRelation relation : relations) { // only add related resources that are not going to be deleted if (!deleteIds.contains(relation.getSourceId())) { CmsResource source = relation.getSource(cms, CmsResourceFilter.ALL); if (!source.getState().isDeleted()) { result.add(source); } } } return result; }
String relationName = relation.getSourcePath(); if (relationName.startsWith(infoEntry.getSiteRoot())) { html.append(relation.getType().getLocalizedName(getMessages())); html.append(")</span>"); if (itRelations.hasNext()) {