/** * Returns all relation types in the given list that are not defined in the content.<p> * * @param relationTypes the collection of relation types to filter * * @return a list of {@link CmsRelationType} objects */ public static List<CmsRelationType> filterNotDefinedInContent(Collection<CmsRelationType> relationTypes) { List<CmsRelationType> result = new ArrayList<CmsRelationType>(relationTypes); Iterator<CmsRelationType> it = result.iterator(); while (it.hasNext()) { CmsRelationType type = it.next(); if (type.isDefinedInContent()) { it.remove(); } } return result; }
/** * Returns all relation types in the given list that define relations in the content.<p> * * @param relationTypes the collection of relation types to filter * * @return a list of {@link CmsRelationType} objects */ public static List<CmsRelationType> filterDefinedInContent(Collection<CmsRelationType> relationTypes) { List<CmsRelationType> result = new ArrayList<CmsRelationType>(relationTypes); Iterator<CmsRelationType> it = result.iterator(); while (it.hasNext()) { CmsRelationType type = it.next(); if (!type.isDefinedInContent()) { it.remove(); } } return result; }
/** * Checks if this filter includes relations defined in the content.<p> * * @return <code>true</code> if this filter includes relations defined in the content */ public boolean includesDefinedInContent() { if ((m_types == null) || m_types.isEmpty()) { return true; } Iterator<CmsRelationType> itTypes = m_types.iterator(); while (itTypes.hasNext()) { CmsRelationType type = itTypes.next(); if (type.isDefinedInContent()) { return true; } } return false; }
/** * Checks if this filter includes relations defined in the content.<p> * * @return <code>true</code> if this filter includes relations defined in the content */ public boolean includesDefinedInContent() { if ((m_types == null) || m_types.isEmpty()) { return true; } Iterator itTypes = m_types.iterator(); while (itTypes.hasNext()) { CmsRelationType type = (CmsRelationType)itTypes.next(); if (type.isDefinedInContent()) { return true; } } return false; }
/** * Returns all relation types in the given list that define relations in the content.<p> * * @param relationTypes the collection of relation types to filter * * @return a list of {@link CmsRelationType} objects */ public static List filterDefinedInContent(Collection relationTypes) { List list = new ArrayList(relationTypes); Iterator it = list.iterator(); while (it.hasNext()) { CmsRelationType type = (CmsRelationType)it.next(); if (!type.isDefinedInContent()) { it.remove(); } } return list; }
/** * Returns all relation types in the given list that are not defined in the content.<p> * * @param relationTypes the collection of relation types to filter * * @return a list of {@link CmsRelationType} objects */ public static List filterNotDefinedInContent(Collection relationTypes) { List list = new ArrayList(relationTypes); Iterator it = list.iterator(); while (it.hasNext()) { CmsRelationType type = (CmsRelationType)it.next(); if (type.isDefinedInContent()) { it.remove(); } } return list; }
if (relation.getType().isDefinedInContent()) { hasContentLinks = true; } else {
/** * 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()); } } } } }
/** * 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); }
/** * Adds a new relation to the given resource.<p> * * @param dbc the database context * @param resource the resource to add the relation to * @param target the target of the relation * @param type the type of the relation * @param importCase if importing relations * * @throws CmsException if something goes wrong */ public void addRelationToResource( CmsDbContext dbc, CmsResource resource, CmsResource target, CmsRelationType type, boolean importCase) throws CmsException { if (type.isDefinedInContent()) { throw new CmsIllegalArgumentException(Messages.get().container( Messages.ERR_ADD_RELATION_IN_CONTENT_3, dbc.removeSiteRoot(resource.getRootPath()), dbc.removeSiteRoot(target.getRootPath()), type.getLocalizedName(dbc.getRequestContext().getLocale()))); } CmsRelation relation = new CmsRelation(resource, target, type); m_vfsDriver.createRelation(dbc, dbc.currentProject().getUuid(), relation); if (!importCase) { setDateLastModified(dbc, resource, System.currentTimeMillis()); } }
/** * Collects the allowable actions for a relation.<p> * * @param cms the current CMS context * @param file the source of the relation * @param relation the relation object * * @return the allowable actions for the given resource */ protected AllowableActions collectAllowableActions(CmsObject cms, CmsResource file, CmsRelation relation) { try { Set<Action> aas = new LinkedHashSet<Action>(); AllowableActionsImpl result = new AllowableActionsImpl(); CmsLock lock = cms.getLock(file); CmsUser user = cms.getRequestContext().getCurrentUser(); boolean canWrite = !cms.getRequestContext().getCurrentProject().isOnlineProject() && (lock.isOwnedBy(user) || lock.isLockableBy(user)) && cms.hasPermissions(file, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.DEFAULT); addAction(aas, Action.CAN_GET_PROPERTIES, true); addAction(aas, Action.CAN_DELETE_OBJECT, canWrite && !relation.getType().isDefinedInContent()); result.setAllowableActions(aas); return result; } catch (CmsException e) { handleCmsException(e); return null; } }
throws CmsException { if (type.isDefinedInContent()) { throw new CmsIllegalArgumentException( Messages.get().container(