/** * Returns a localized name for the given relation type.<p> * * @param messages the message bundle to use to resolve the name * * @return a localized name */ public String getLocalizedName(CmsMessages messages) { String nameKey = "GUI_RELATION_TYPE_" + getName() + "_0"; return messages.key(nameKey); }
/** * Returns a localized name for the given relation type.<p> * * @param messages the message bundle to use to resolve the name * * @return a localized name */ public String getLocalizedName(CmsMessages messages) { String nameKey = "GUI_RELATION_TYPE_" + getName() + "_0"; return messages.key(nameKey); }
/** * Gets a relation type by name.<p> * * @param typeName the relation type name * * @return the relation type with the matching name */ protected static CmsRelationType getRelationType(String typeName) { for (CmsRelationType relType : CmsRelationType.getAll()) { if (relType.getName().equalsIgnoreCase(typeName)) { return relType; } } return null; }
break; default: result = getName();
break; default: result = getName();
/** * Creates a user-readable name from the given relation object.<p> * * @param relation the relation object * * @return the readable name */ protected String createReadableName(CmsRelation relation) { return relation.getType().getName() + "[ " + relation.getSourcePath() + " -> " + relation.getTargetPath() + " ]"; }
/** * Adds a resource identified by the given resource name to the given category.<p> * * The resource has to be locked.<p> * * @param cms the current cms context * @param resourceName the site relative path to the resource to add * @param category the category to add the resource to * * @throws CmsException if something goes wrong */ public void addResourceToCategory(CmsObject cms, String resourceName, CmsCategory category) throws CmsException { if (readResourceCategories(cms, resourceName).contains(category)) { return; } String sitePath = cms.getRequestContext().removeSiteRoot(category.getRootPath()); cms.addRelationToResource(resourceName, sitePath, CmsRelationType.CATEGORY.getName()); String parentCatPath = category.getPath(); // recursively add to higher level categories if (parentCatPath.endsWith("/")) { parentCatPath = parentCatPath.substring(0, parentCatPath.length() - 1); } if (parentCatPath.lastIndexOf('/') > 0) { addResourceToCategory(cms, resourceName, parentCatPath.substring(0, parentCatPath.lastIndexOf('/') + 1)); } }
/** * Adds a resource identified by the given resource name to the given category.<p> * * The resource has to be locked.<p> * * @param cms the current cms context * @param resourceName the site relative path to the resource to add * @param category the category to add the resource to * * @throws CmsException if something goes wrong */ public void addResourceToCategory(CmsObject cms, String resourceName, CmsCategory category) throws CmsException { if (readResourceCategories(cms, cms.readResource(resourceName, CmsResourceFilter.IGNORE_EXPIRATION)).contains( category)) { return; } String sitePath = cms.getRequestContext().removeSiteRoot(category.getRootPath()); cms.addRelationToResource(resourceName, sitePath, CmsRelationType.CATEGORY.getName()); String parentCatPath = category.getPath(); // recursively add to higher level categories if (parentCatPath.endsWith("/")) { parentCatPath = parentCatPath.substring(0, parentCatPath.length() - 1); } if (parentCatPath.lastIndexOf('/') > 0) { addResourceToCategory(cms, resourceName, parentCatPath.substring(0, parentCatPath.lastIndexOf('/') + 1)); } }
/** * 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()); }
newRelationSource, newRelationTarget, CmsRelationType.LOCALE_VARIANT.getName()); } catch (CmsException e) { LOG.error("Could not transfer locale relation: " + e.getLocalizedMessage(), e);
/** * Creates a CMIS relationship subtype for a given OpenCms relation type.<p> * * @param relType the OpenCms relation type */ private void createRelationshipType(CmsRelationType relType) { // relationship types RelationshipTypeDefinitionImpl relationshipType = new RelationshipTypeDefinitionImpl(); relationshipType.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP); relationshipType.setParentTypeId(RELATIONSHIP_TYPE_ID); relationshipType.setIsControllableAcl(Boolean.FALSE); relationshipType.setIsControllablePolicy(Boolean.FALSE); relationshipType.setIsCreatable(Boolean.valueOf(!relType.isDefinedInContent())); relationshipType.setDescription(relType.getName()); relationshipType.setDisplayName(relType.getName()); relationshipType.setIsFileable(Boolean.FALSE); relationshipType.setIsIncludedInSupertypeQuery(Boolean.TRUE); relationshipType.setLocalName(relType.getName()); relationshipType.setLocalNamespace(NAMESPACE); relationshipType.setIsQueryable(Boolean.FALSE); String id = "opencms:" + relType.getName().toUpperCase(); relationshipType.setQueryName(id); relationshipType.setId(id); List<String> typeList = new ArrayList<String>(); typeList.add("cmis:document"); typeList.add("cmis:folder"); relationshipType.setAllowedSourceTypes(typeList); relationshipType.setAllowedTargetTypes(typeList); addType(relationshipType); }
m_cms.getSitePath(relation.getSource(m_cms, CmsResourceFilter.ALL)), m_cms.getSitePath(relation.getTarget(m_cms, CmsResourceFilter.ALL)), relation.getType().getName()); } catch (CmsException e) { m_report.addWarning(e);
m_cms.getSitePath(relation.getSource(m_cms, CmsResourceFilter.ALL)), m_cms.getSitePath(relation.getTarget(m_cms, CmsResourceFilter.ALL)), relation.getType().getName()); } catch (CmsException e) { m_report.addWarning(e);
+ relation.getTargetPath() + " [" + relation.getType().getName() + "]"); relationsBySourceId.put(relation.getSourceId(), relation);
cms.addRelationToResource(resourceName, catPath, CmsRelationType.CATEGORY.getName());
/** * 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()); } } } } }
getCms().getSitePath(relation.getSource(getCms(), CmsResourceFilter.ALL)), getCms().getSitePath(relation.getTarget(getCms(), CmsResourceFilter.ALL)), relation.getType().getName()); } catch (CmsException e) { getReport().addWarning(e);
getCms().getSitePath(relation.getSource(getCms(), CmsResourceFilter.ALL)), getCms().getSitePath(relation.getTarget(getCms(), CmsResourceFilter.ALL)), relation.getType().getName()); } catch (CmsException e) { getReport().addWarning(e);
getCms().getSitePath(relation.getSource(getCms(), CmsResourceFilter.ALL)), getCms().getSitePath(relation.getTarget(getCms(), CmsResourceFilter.ALL)), relation.getType().getName()); } catch (CmsException e) { getReport().addWarning(e);
secondaryPage, targetGroup.getPrimaryResource(), CmsRelationType.LOCALE_VARIANT.getName()); } finally { if (record.getChange() == LockChange.locked) {