Imports a new relation to the given resource.<p>

@param resourceName the name of the source resource
@param targetPath the path of the target resource
@param relationType the type of the relation

@throws CmsException if something goes wrong
497901
public void importRelation(String resourceName, String targetPath, String relationType) throws CmsException {

        createRelation(resourceName, targetPath, relationType, true);
    }
1350801
@SuppressWarnings({ "unchecked", "rawtypes" })
	public <T, I extends Serializable, D, J extends Serializable> RelationshipRepositoryStub<T, I, D, J> getQueryParamsRepository(Class<T> sourceClass, Class<D> targetClass) {
		init();

		RegistryEntry entry = resourceRegistry.findEntry(sourceClass);

		RelationshipRepositoryAdapter repositoryAdapter = entry.getRelationshipRepositoryForClass(targetClass, null);
		return (RelationshipRepositoryStub<T, I, D, J>) repositoryAdapter.getRelationshipRepository();
	}
108129
private void onRelation(Object entity, Map<String, Object> relationsMap, final Relation relation,
            final EntityMetadata metadata, final PersistenceDelegator pd, boolean lazilyloaded,
            Map<Object, Object> relationStack)
    {
        final Object entityId = PropertyAccessorHelper.getId(entity, metadata);

        // if relation map contains value, then invoke target entity with find
        // by id.
        // else invoke target entity for find by relation, pass it's entityId as
        // a column value and relation.getJoinColumnName as column name.

        Object relationValue = relationsMap != null ? relationsMap.get(relation.getJoinColumnName(kunderaMetadata))
                : null;
        EntityMetadata targetEntityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                relation.getTargetEntity());

        List relationalEntities = fetchRelations(relation, metadata, pd, entityId, relationValue, targetEntityMetadata);

        if (relationalEntities != null)
        {

            for (Object relationEntity : relationalEntities)
            {
                if (relationEntity != null)
                {
                    addToRelationStack(relationStack, relationEntity, targetEntityMetadata);
                }
            }
            for (Object relationEntity : relationalEntities)
            {
                if (relationEntity != null)
                {
                    onParseRelation(entity, pd, targetEntityMetadata, relationEntity, relation, lazilyloaded,
                            relationStack);
                    PersistenceCacheManager.addEntityToPersistenceCache(getEntity(relationEntity), pd,
                            PropertyAccessorHelper.getId(relationEntity, targetEntityMetadata));
                }
            }
        }

    }
595023
private void addToRelationNameCollection(String relationName)
    {
        if (relationNames == null)
        {
            relationNames = new ArrayList<String>();
        }
        if (relationName != null)
        {
            relationNames.add(relationName);
        }
    }
795609
void addRelationshipAttributeType(String attributeName, AtlasRelationshipType relationshipType) {
        List<AtlasRelationshipType> relationshipTypes = relationshipAttributesType.get(attributeName);

        if (relationshipTypes == null) {
            relationshipTypes = new ArrayList<>();
            relationshipAttributesType.put(attributeName, relationshipTypes);
        }

        relationshipTypes.add(relationshipType);
    }
400830
private CmsResource findReferencingPage(CmsResource source) throws CmsException {

        List<CmsRelation> relationsToFile = m_cms.readRelations(
            CmsRelationFilter.relationsToStructureId(source.getStructureId()));
        for (CmsRelation relation : relationsToFile) {
            try {
                CmsResource referencingPage = relation.getSource(m_cms, CmsResourceFilter.DEFAULT);
                if (CmsResourceTypeXmlContainerPage.isContainerPage(referencingPage)) {
                    return referencingPage;
                }
            } catch (CmsException e) {
                LOG.info(e.getLocalizedMessage(), e);
            }
        }
        return null;
    }
1160153
public RelationshipRepository<Resource, String, Resource, String> getRepositoryForPath(String sourceResourceType,
                                                                                           String targetResourceType) {
        init();

        ResourceInformation sourceResourceInformation =
                new ResourceInformation(moduleRegistry.getTypeParser(), Resource.class, sourceResourceType, null, null,
                        PagingSpec.class);
        return (RelationshipRepository<Resource, String, Resource, String>) decorate(new RelationshipRepositoryStubImpl<>(this, Resource.class, Resource.class, sourceResourceInformation, urlBuilder));
    }
39013
private void addLockedRelatedResources(String resName, CmsLockFilter filter, Set<String> lockedResources) {

        try {
            // get and iterate over all related resources
            Iterator<CmsRelation> itRelations = getCms().getRelationsForResource(
                resName,
                CmsRelationFilter.TARGETS.filterStrong().filterIncludeChildren()).iterator();
            while (itRelations.hasNext()) {
                CmsRelation relation = itRelations.next();
                CmsResource target = null;
                try {
                    target = relation.getTarget(getCms(), CmsResourceFilter.ALL);
                } catch (CmsException e) {
                    // error reading a resource, should usually never happen
                    if (LOG.isDebugEnabled()) {
                        LOG.debug(e.getLocalizedMessage(getLocale()), e);
                    }
                    continue;
                }
                // we are interested just in unpublished resources
                if (target.getState().isUnchanged()) {
                    continue;
                }
                String targetName = getCms().getSitePath(target);
                // if already selected
                if (lockedResources.contains(targetName) || lockedResources.contains(targetName + "*")) {
                    continue;
                }
                if (m_lockedResources != null) {
                    if (m_lockedResources.contains(targetName) || m_lockedResources.contains(targetName + "*")) {
                        continue;
                    }
                }
                try {
                    org.opencms.lock.CmsLock lock = getCms().getLock(targetName);
                    if (!lock.isUnlocked() && filter.match("/", lock)) {
                        // just add resources that may come in question
                        lockedResources.add(targetName + "*");
                    }
                } catch (CmsException e) {
                    // error reading a lock, should usually never happen
                    if (LOG.isErrorEnabled()) {
                        LOG.error(e.getLocalizedMessage(getLocale()), e);
                    }
                    continue;
                }
            }
        } catch (CmsException e) {
            // error reading the relations, should usually never happen
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getLocalizedMessage(getLocale()), e);
            }
        }
    }
729645
@Override
    public Resource createRelative(String relativePath) {
        String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
        return new ClassPathResource(pathToUse, this.classLoader, this.clazz);
    }
1202608
public function createRelation($relationType, EntityRelationMeta $source, EntityRelationMeta $target, $side = NULL, $updateOtherSide = true) {
    Code::value($relationType, self::RELATION_MANY_TO_MANY, self::RELATION_MANY_TO_ONE, self::RELATION_ONE_TO_MANY, self::RELATION_ONE_TO_ONE);
    Code::value($side, self::SIDE_OWNING, self::SIDE_INVERSE, NULL);
    
    // Parameter übersetzen in constructor parameter von relation
    if ($side !== NULL) {
      $direction = EntityRelation::BIDIRECTIONAL;
      $whoIsOwningSide = $side === self::SIDE_OWNING ? EntityRelation::SOURCE : EntityRelation::TARGET;
    } else {
      $direction = EntityRelation::UNIDIRECTIONAL;
      $whoIsOwningSide = NULL;
    }
    
    $relation = new EntityRelation($source, $target, $relationType, $direction, $whoIsOwningSide);
    $this->buildRelation($relation);
    
    return $relation;
  }
550022
private void applyRelativePath(RelationQueryNode node) {
       if (tmpRelPath != null)
       {
          // try {
          QPath relPath = tmpRelPath;
          for (int i = 0; i < relPath.getEntries().length; i++)
          {
             node.addPathElement(relPath.getEntries()[i]);
          }
          tmpRelPath = null;
       }
    }
483739
@Override
  public Resource createRelative(String relativePath) {
    String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
    return new ServletContextResource(this.servletContext, pathToUse);
  }
1147649
@SuppressWarnings("deprecation")
    private CmsNewResourceInfo createResourceTypeInfo(I_CmsResourceType resType, CmsResource copyResource) {

        String name = resType.getTypeName();
        Locale locale = getWorkplaceLocale();
        String subtitle = CmsWorkplaceMessages.getResourceTypeDescription(locale, name);
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(subtitle)) {
            subtitle = CmsWorkplaceMessages.getResourceTypeName(locale, name);
        }
        if (copyResource != null) {
            CmsNewResourceInfo info = new CmsNewResourceInfo(
                copyResource.getTypeId(),
                name,
                CmsWorkplaceMessages.getResourceTypeName(locale, name),
                CmsWorkplaceMessages.getResourceTypeDescription(locale, name),
                copyResource.getStructureId(),
                false,
                subtitle);
            info.setBigIconClasses(CmsIconUtil.getIconClasses(name, null, false));
            return info;
        } else {
            CmsNewResourceInfo info = new CmsNewResourceInfo(
                resType.getTypeId(),
                name,
                CmsWorkplaceMessages.getResourceTypeName(locale, name),
                CmsWorkplaceMessages.getResourceTypeDescription(locale, name),
                null,
                false,
                subtitle);
            info.setBigIconClasses(CmsIconUtil.getIconClasses(name, null, false));
            return info;
        }
    }
87661
private synchronized void initResourceTypes() throws CmsConfigurationException {

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_STARTING_LOADER_CONFIG_0));
        }

        CmsResourceManagerConfiguration newConfiguration = new CmsResourceManagerConfiguration();

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(
                    Messages.INIT_ADD_RESTYPE_FROM_FILE_2,
                    new Integer(m_resourceTypesFromXml.size()),
                    CmsVfsConfiguration.DEFAULT_XML_FILE_NAME));
        }

        // build a new resource type list from the resource types of the XML configuration
        Iterator<I_CmsResourceType> i;
        i = m_resourceTypesFromXml.iterator();
        while (i.hasNext()) {
            I_CmsResourceType resourceType = i.next();
            initResourceType(resourceType, newConfiguration);
        }

        // add all resource types declared in the modules
        CmsModuleManager moduleManager = OpenCms.getModuleManager();
        if (moduleManager != null) {
            Iterator<String> modules = moduleManager.getModuleNames().iterator();
            while (modules.hasNext()) {
                CmsModule module = moduleManager.getModule(modules.next());
                if ((module != null) && (module.getResourceTypes().size() > 0)) {
                    // module contains resource types
                    if (CmsLog.INIT.isInfoEnabled()) {
                        CmsLog.INIT.info(
                            Messages.get().getBundle().key(
                                Messages.INIT_ADD_NUM_RESTYPES_FROM_MOD_2,
                                new Integer(module.getResourceTypes().size()),
                                module.getName()));
                    }

                    Iterator<I_CmsResourceType> j = module.getResourceTypes().iterator();
                    while (j.hasNext()) {
                        I_CmsResourceType resourceType = j.next();
                        I_CmsResourceType conflictingType = null;
                        if (resourceType.getTypeId() == CmsResourceTypeUnknownFile.RESOURCE_TYPE_ID) {
                            // default unknown file resource type
                            if (m_restypeUnknownFile != null) {
                                // error: already set
                                conflictingType = m_restypeUnknownFile;
                            } else {
                                m_restypeUnknownFile = resourceType;
                                continue;
                            }
                        } else if (resourceType.getTypeId() == CmsResourceTypeUnknownFolder.RESOURCE_TYPE_ID) {
                            // default unknown folder resource type
                            if (m_restypeUnknownFolder != null) {
                                // error: already set
                                conflictingType = m_restypeUnknownFolder;
                            } else {
                                m_restypeUnknownFile = resourceType;
                                continue;
                            }
                        } else {
                            // normal resource types
                            conflictingType = newConfiguration.getResourceTypeById(resourceType.getTypeId());
                        }
                        if (conflictingType != null) {
                            throw new CmsConfigurationException(
                                Messages.get().container(
                                    Messages.ERR_CONFLICTING_MODULE_RESOURCE_TYPES_5,
                                    new Object[] {
                                        resourceType.getTypeName(),
                                        new Integer(resourceType.getTypeId()),
                                        module.getName(),
                                        conflictingType.getTypeName(),
                                        new Integer(conflictingType.getTypeId())}));
                        }
                        initResourceType(resourceType, newConfiguration);
                    }
                }
            }
        }

        // freeze the current configuration
        newConfiguration.freeze(m_restypeUnknownFile, m_restypeUnknownFile);
        m_configuration = newConfiguration;
        m_frozen = true;

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_RESOURCE_TYPE_INITIALIZED_0));
        }
    }
656986
public Resource createRelative(String relativePath) {
        if (relativePath.startsWith("/")) {
            relativePath = relativePath.substring(1);
        }
        try {
            return new UrlResource(new URL(url, relativePath));
        } catch (MalformedURLException e) {
            return null;
        }
    }
1369101
public void loadResourceInfo(final String resourcePath) {

        CmsRpcAction<CmsResourceInfoBean> action = new CmsRpcAction<CmsResourceInfoBean>() {

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
             */
            @Override
            public void execute() {

                getService().getResourceInfo(resourcePath, getLocale(), this);
            }

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
             */
            @Override
            protected void onResponse(CmsResourceInfoBean result) {

                showData(result);
            }
        };
        action.execute();
    }
793944
protected void importRelations(CmsResource resource, Element parentElement) {

        // Get the nodes for the relations
        @SuppressWarnings("unchecked")
        List<Node> relationElements = parentElement.selectNodes(
            "./" + A_CmsImport.N_RELATIONS + "/" + A_CmsImport.N_RELATION);

        List<CmsRelation> relations = new ArrayList<CmsRelation>();
        // iterate over the nodes
        Iterator<Node> itRelations = relationElements.iterator();
        while (itRelations.hasNext()) {
            Element relationElement = (Element)itRelations.next();
            String structureID = getChildElementTextValue(relationElement, A_CmsImport.N_RELATION_ATTRIBUTE_ID);
            String targetPath = getChildElementTextValue(relationElement, A_CmsImport.N_RELATION_ATTRIBUTE_PATH);
            String relationType = getChildElementTextValue(relationElement, A_CmsImport.N_RELATION_ATTRIBUTE_TYPE);
            CmsUUID targetId = new CmsUUID(structureID);
            CmsRelationType type = CmsRelationType.valueOf(relationType);

            CmsRelation relation = new CmsRelation(
                resource.getStructureId(),
                resource.getRootPath(),
                targetId,
                targetPath,
                type);

            relations.add(relation);
        }

        if (!relations.isEmpty()) {
            m_importedRelations.put(resource.getRootPath(), relations);
        }
    }