/** * @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); } };
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { if ((o1 == o2) || !(o1 instanceof CmsRelation) || !(o2 instanceof CmsRelation)) { return 0; } CmsRelation r1 = (CmsRelation)o1; String p1 = r1.getSourcePath() + r1.getTargetPath() + r1.getType().getId(); CmsRelation r2 = (CmsRelation)o2; String p2 = r2.getSourcePath() + r2.getTargetPath() + r2.getType().getId(); return p1.compareTo(p2); } };
/** * 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() + " ]"; }
/** * 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()); }
html.append(relation.getType().getLocalizedName(getMessages())); html.append(")</span>"); if (itRelations.hasNext()) {
html.append(relation.getType().getLocalizedName(getMessages())); html.append(")</span>"); if (itRelations.hasNext()) {
try { CmsResource relTarget = relation.getTarget(cms, CmsResourceFilter.ALL); addRelationToResource(dbc, target, relTarget, relation.getType(), true); } catch (CmsVfsResourceNotFoundException e) {
/** * @see org.opencms.db.I_CmsVfsDriver#createRelation(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.relations.CmsRelation) */ public void createRelation(CmsDbContext dbc, CmsUUID projectId, CmsRelation relation) throws CmsDataAccessException { Connection conn = null; PreparedStatement stmt = null; try { conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, projectId, "C_CREATE_RELATION"); stmt.setString(1, relation.getSourceId().toString()); stmt.setString(2, relation.getSourcePath()); stmt.setString(3, relation.getTargetId().toString()); stmt.setString(4, relation.getTargetPath()); stmt.setInt(5, relation.getType().getId()); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key( Messages.LOG_CREATE_RELATION_2, String.valueOf(projectId), relation)); } stmt.executeUpdate(); } catch (SQLException e) { throw new CmsDbSqlException(Messages.get().container( Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, null); } }
html.append(relation.getType().getLocalizedName(getMessages())); html.append(")</span>"); if (itRelations.hasNext()) {
CmsResource target = getResource(relation.getTargetId()); if (target != null) { if (relation.getType().isStrong() || shouldAddWeakRelationTarget(target)) { directlyRelatedResources.add(target);
if (relation.getType().isDefinedInContent()) { hasContentLinks = true; } else {
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);
if ((containerpageId != null) && containerpageId.equals(relation.getSourceId()) && relation.getType().equals(CmsRelationType.XML_STRONG)) { iter.remove();
+ relation.getTargetPath() + " [" + relation.getType().getName() + "]"); relationsBySourceId.put(relation.getSourceId(), 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()); } } } } }
/** * @see org.opencms.db.I_CmsVfsDriver#createRelation(org.opencms.db.CmsDbContext, CmsUUID, org.opencms.relations.CmsRelation) */ public void createRelation(CmsDbContext dbc, CmsUUID projectId, CmsRelation relation) throws CmsDataAccessException { try { I_CmsDAOResourceRelations rr = CmsProject.isOnlineProject(projectId) ? new CmsDAOOnlineResourceRelations() : new CmsDAOOfflineResourceRelations(); rr.setRelationSourceId(relation.getSourceId().toString()); rr.setRelationSourcePath(relation.getSourcePath()); rr.setRelationTargetId(relation.getTargetId().toString()); rr.setRelationTargetPath(relation.getTargetPath()); rr.setRelationType(relation.getType().getId()); m_sqlManager.persist(dbc, rr); if (LOG.isDebugEnabled()) { LOG.debug( Messages.get().getBundle().key( Messages.LOG_CREATE_RELATION_2, String.valueOf(projectId), relation)); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } }
/** * 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; } }
if (relation.getType() == CmsRelationType.XSD) { continue;