/** * 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; }
/** * 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()); }
for (CmsRelation relation : relations) { if (!deleteIds.contains(relation.getSourceId())) { CmsResource source1 = relation.getSource(cms, CmsResourceFilter.ALL); if (!source1.getState().isDeleted()) {
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)) {
for (CmsRelation relation : relations) { if (!deleteIds.contains(relation.getSourceId())) { CmsResource source1 = relation.getSource(cms, CmsResourceFilter.ALL); if (!source1.getState().isDeleted()) {
List<CmsRelation> relations = new ArrayList<CmsRelation>(); for (CmsRelation relation : unfilteredRelations) { if (relation.getTargetId().isNullUUID() || relation.getSourceId().isNullUUID()) { continue;
/** * @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); } }
List<CmsRelation> in = Lists.newArrayList(); for (CmsRelation rel : relations) { if (rel.getSourceId().equals(resource.getStructureId())) { out.add(rel); } else {
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(1, relation.getSourceId().toString()); stmt.setString(2, relation.getTargetId().toString()); stmt.setString(3, relation.getSourceId().toString()); stmt.setString(4, relation.getTargetId().toString()); if (LOG.isDebugEnabled()) {
+ relation.getType().getName() + "]"); relationsBySourceId.put(relation.getSourceId(), relation);
CmsRelation relation = iter.next(); if ((containerpageId != null) && containerpageId.equals(relation.getSourceId()) && relation.getType().equals(CmsRelationType.XML_STRONG)) { iter.remove();
/** * Returns the source resource when possible to read with the given filter.<p> * * @param cms the current user context * @param filter the filter to use * * @return the source resource * * @throws CmsException if something goes wrong */ public CmsResource getSource(CmsObject cms, CmsResourceFilter filter) throws CmsException { try { // first look up by id return cms.readResource(getSourceId(), filter); } catch (CmsVfsResourceNotFoundException e) { // then look up by name, but from the root site String storedSiteRoot = cms.getRequestContext().getSiteRoot(); try { cms.getRequestContext().setSiteRoot(""); return cms.readResource(getSourcePath(), filter); } finally { cms.getRequestContext().setSiteRoot(storedSiteRoot); } } }
/** * Returns the source resource when possible to read with the given filter.<p> * * @param cms the current user context * @param filter the filter to use * * @return the source resource * * @throws CmsException if something goes wrong */ public CmsResource getSource(CmsObject cms, CmsResourceFilter filter) throws CmsException { try { // first look up by id return cms.readResource(getSourceId(), filter); } catch (CmsVfsResourceNotFoundException e) { // then look up by name, but from the root site String storedSiteRoot = cms.getRequestContext().getSiteRoot(); try { cms.getRequestContext().setSiteRoot(""); return cms.readResource(getSourcePath(), filter); } finally { cms.getRequestContext().setSiteRoot(storedSiteRoot); } } }
/** * @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); } }
CmsUUID secondId = secondPage.getStructureId(); for (CmsRelation relation : relations) { CmsUUID sourceId = relation.getSourceId(); CmsUUID targetId = relation.getTargetId(); CmsResource resourceToModify = null;
List<CmsRelation> relations = cms.getRelationsForResource(resource, CmsRelationFilter.ALL); for (CmsRelation relation : relations) { if (resource.getStructureId().equals(relation.getSourceId())) { relationTargetIds.add(relation.getTargetId().toString()); relationSourceIds.add(relation.getSourceId().toString());
objectInfo.setCreatedBy(creatorName); addPropertyId(tm, result, typeId, filter, PropertyIds.SOURCE_ID, relation.getSourceId().toString()); addPropertyId(tm, result, typeId, filter, PropertyIds.TARGET_ID, relation.getTargetId().toString());