Writes the given property to the resource as structure value.<p>

@param resourceName the resource to write the value to
@param propertyName the property to write the value to
@param value the value to write

@throws CmsException if something goes wrong
969077
public void writeProperty(String resourceName, String propertyName, String value) throws CmsException {

        m_cms.lockResource(resourceName);
        m_cms.writePropertyObject(resourceName, new CmsProperty(propertyName, value, null));
    }
628835
private void lockResource(CmsObject cms, CmsLock lock, CmsResource res) throws CmsException {

        if (lock.isNullLock()) {
            cms.lockResource(res.getRootPath());
        }
    }
590283
protected void init() throws CmsException {

        m_cms = OpenCms.initCmsObject(m_cms);
        // we want to use autocorrection when writing XML contents back
        //m_cms.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE);
        m_cms.getRequestContext().setSiteRoot("");
        List<CmsPair<CmsResource, CmsResource>> allMatchingResources = Lists.newArrayList();
        for (CmsPair<String, String> pair : m_sourceTargetPairs) {
            List<CmsPair<CmsResource, CmsResource>> matchingResources = getMatchingResources(
                pair.getFirst(),
                pair.getSecond());
            allMatchingResources.addAll(matchingResources);
        }
        for (CmsPair<CmsResource, CmsResource> resPair : allMatchingResources) {
            CmsResource source = resPair.getFirst();
            CmsResource target = resPair.getSecond();
            m_translationsById.put(source.getStructureId(), target);
            m_translationsByPath.put(source.getRootPath(), target);
        }
    }
226568
protected void performSingleResourceOperation(String resourceName, int dialogAction) throws CmsException {

        // store original name to use for lock action
        String originalResourceName = resourceName;
        CmsResource res = getCms().readResource(resourceName, CmsResourceFilter.ALL);
        if (res.isFolder() && !resourceName.endsWith("/")) {
            resourceName += "/";
        }
        org.opencms.lock.CmsLock lock = getCms().getLock(res);
        // perform action depending on dialog uri
        switch (dialogAction) {
            case TYPE_LOCKCHANGE:
            case TYPE_LOCK:
                if (lock.isNullLock()) {
                    getCms().lockResource(originalResourceName);
                } else if (!lock.isDirectlyOwnedInProjectBy(getCms())) {
                    getCms().changeLock(resourceName);
                }
                break;
            case TYPE_UNLOCK:
            default:
                if (lock.isNullLock()) {
                    break;
                }
                if (lock.isOwnedBy(getCms().getRequestContext().getCurrentUser())) {
                    getCms().unlockResource(resourceName);
                }
        }
    }
232381
public void updatePropertyInMap(Map<String, CmsClientProperty> props) {

        CmsClientProperty prop = props.get(getName());
        if (prop == null) {
            prop = new CmsClientProperty(getName(), "", "");
            props.put(getName(), prop);
        }
        if (isStructureValue()) {
            prop.setStructureValue(getValue());
        } else {
            prop.setResourceValue(getValue());
        }
    }
433233
public static void setPropertyValue(BeanDefinitionBuilder builder, String propertyValue, String propertyName) {
        if (StringUtils.hasText(propertyValue)) {
            builder.addPropertyValue(propertyName, propertyValue);
        }
    }
1297783
public void setUserInfo(String username, String infoName, String value) throws CmsException {

        CmsUser user = m_cms.readUser(username);
        user.setAdditionalInfo(infoName, value);
        m_cms.writeUser(user);
    }
1079466
@Override
    public void set(String propName, Object value) {
        if (propName.equals(PROP_C)) {
            setC(((String) value));
        }
        if (propName.equals(PROP_COUNTRY_NAME)) {
            setCountryName(((String) value));
        }
        if (propName.equals(PROP_DESCRIPTION)) {
            getDescription().add(((String) value));
        }
        super.set(propName, value);
    }
92926
private void setParameterValue(CmsObject cms, String key, String value) {

        if (m_parameters == null) {
            m_parameters = getParameterMap(getStringValue(cms));
        }
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(value) && m_parameters.containsKey(key)) {
            m_parameters.remove(key);
        } else if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) {
            m_parameters.put(key, new String[] {value});
        }
        String result = CmsRequestUtil.getRequestLink(getStringValue(cms));
        result = CmsRequestUtil.appendParameters(result, m_parameters, false);
        setStringValue(cms, result);
    }
1322022
public void deleteResource(String name) throws Exception {

        m_cms.lockResource(name);
        m_cms.deleteResource(name, CmsResource.DELETE_PRESERVE_SIBLINGS);
    }
825816
protected void saveData() throws CmsException {

        CmsObject cms = m_context.getCms();
        for (CmsResource resource : m_context.getResources()) {
            CmsLockActionRecord actionRecord = null;
            try {
                actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource);

                String secureValue = (String)m_secureField.getValue();
                String exportValue = (String)m_exportField.getValue();
                String exportname = m_exportNameField.getValue();
                CmsProperty secureProp = new CmsProperty(CmsPropertyDefinition.PROPERTY_SECURE, secureValue, null);
                CmsProperty exportProp = new CmsProperty(CmsPropertyDefinition.PROPERTY_EXPORT, exportValue, null);
                CmsProperty exportNameProp = new CmsProperty(
                    CmsPropertyDefinition.PROPERTY_EXPORTNAME,
                    exportname,
                    null);
                boolean internal = m_internalField.getValue().booleanValue();

                cms.writePropertyObjects(resource, Arrays.asList(secureProp, exportProp, exportNameProp));
                resource.setInternal(internal);
                cms.writeResource(resource);
            } finally {
                if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) {
                    try {
                        cms.unlockResource(resource);
                    } catch (CmsLockException e) {
                        LOG.warn(e.getLocalizedMessage(), e);
                    }
                }
            }
        }
    }
1098738
public void setStructureId(String structureId) {

        try {
            m_resourceBuilder.setStructureId(new CmsUUID(structureId));
            m_hasStructureId = true;

        } catch (Throwable e) {
            setThrowable(e);
        }

    }
661484
protected void writeProperty(String propertyName, String propertyValue) throws CmsException {

        if (CmsStringUtil.isEmpty(propertyValue)) {
            propertyValue = CmsProperty.DELETE_VALUE;
        }

        CmsProperty newProp = new CmsProperty();
        newProp.setName(propertyName);
        CmsProperty oldProp = getCms().readPropertyObject(getParamResource(), propertyName, false);
        if (oldProp.isNullProperty()) {
            // property value was not already set
            if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
                newProp.setStructureValue(propertyValue);
            } else {
                newProp.setResourceValue(propertyValue);
            }
        } else {
            if (oldProp.getStructureValue() != null) {
                newProp.setStructureValue(propertyValue);
                newProp.setResourceValue(oldProp.getResourceValue());
            } else {
                newProp.setResourceValue(propertyValue);
            }
        }

        newProp.setAutoCreatePropertyDefinition(true);

        String oldStructureValue = oldProp.getStructureValue();
        String newStructureValue = newProp.getStructureValue();
        if (CmsStringUtil.isEmpty(oldStructureValue)) {
            oldStructureValue = CmsProperty.DELETE_VALUE;
        }
        if (CmsStringUtil.isEmpty(newStructureValue)) {
            newStructureValue = CmsProperty.DELETE_VALUE;
        }

        String oldResourceValue = oldProp.getResourceValue();
        String newResourceValue = newProp.getResourceValue();
        if (CmsStringUtil.isEmpty(oldResourceValue)) {
            oldResourceValue = CmsProperty.DELETE_VALUE;
        }
        if (CmsStringUtil.isEmpty(newResourceValue)) {
            newResourceValue = CmsProperty.DELETE_VALUE;
        }

        // change property only if it has been changed
        if (!oldResourceValue.equals(newResourceValue) || !oldStructureValue.equals(newStructureValue)) {
            getCms().writePropertyObject(getParamResource(), newProp);
        }
    }
347771
public void setResourceId(String resourceId) {

        try {
            if (!m_resourceBuilder.isFolder()) {
                m_resourceBuilder.setResourceId(new CmsUUID(resourceId));
            } else {
                m_resourceBuilder.setResourceId(new CmsUUID());
            }
        } catch (Throwable e) {
            setThrowable(e);
        }
    }
521821
public void addProperty(String propertyName, Object value)
    {
        if (propertyName != null)
        {
            propertyNames.add(propertyName);
            if (value == null)
            {
                properties.remove(propertyName);
            }
            else
            {
                properties.put(propertyName, value);
            }
        }
    }
164899
public void setIndex(String indexName) {

        resetLastResult();
        if (CmsStringUtil.isNotEmpty(indexName)) {
            try {
                I_CmsSearchIndex idx = OpenCms.getSearchManager().getIndex(indexName);
                CmsSearchIndex index = idx instanceof CmsSearchIndex ? (CmsSearchIndex)idx : null;
                if (index == null) {
                    throw new CmsException(Messages.get().container(Messages.ERR_INDEX_NOT_FOUND_1, indexName));
                }
                m_parameters.setSearchIndex(index);
            } catch (Exception exc) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(Messages.get().getBundle().key(Messages.LOG_INDEX_ACCESS_FAILED_1, indexName), exc);
                }
                m_lastException = exc;
            }
        }
    }
552512
private void writeTitleProperty(Node node, Hashtable properties) {

        String title = "";
        // the title string is stored in the first child node
        NodeList children = node.getChildNodes();
        if (children != null) {
            Node titleNode = children.item(0);
            if (titleNode != null) {
                title = titleNode.getNodeValue();
            }
        }
        // add the title property if we have one
        if ((title != null) && (title.length() > 0)) {

            properties.put(CmsPropertyDefinition.PROPERTY_TITLE, CmsStringUtil.substitute(title, "{subst}", "&#"));
            // the title will be used as navtext if no other navtext is
            // given
            if (properties.get(CmsPropertyDefinition.PROPERTY_NAVTEXT) == null) {
                properties.put(
                    CmsPropertyDefinition.PROPERTY_NAVTEXT,
                    CmsStringUtil.substitute(title, "{subst}", "&#"));
            }
        }

    }