private void saveProperties(String resourcePath, Map<String, String> properties) throws CmsException {

        CmsResource resource;
        CmsObject cms = getCmsObject();
        int pos = resourcePath.indexOf("?");
        String resName = resourcePath;
        if (pos > -1) {
            resName = resourcePath.substring(0, pos);
        }
        resource = cms.readResource(resName);

        if (properties != null) {
            for (Entry<String, String> entry : properties.entrySet()) {
                String propertyName = entry.getKey();
                String propertyValue = entry.getValue();
                if (CmsStringUtil.isEmptyOrWhitespaceOnly(propertyValue)) {
                    propertyValue = "";
                }
                try {
                    CmsProperty currentProperty = cms.readPropertyObject(resource, propertyName, false);
                    // detect if property is a null property or not
                    if (currentProperty.isNullProperty()) {
                        // create new property object and set key and value
                        currentProperty = new CmsProperty();
                        currentProperty.setName(propertyName);
                        if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
                            // set structure value
                            currentProperty.setStructureValue(propertyValue);
                            currentProperty.setResourceValue(null);
                        } else {
                            // set resource value
                            currentProperty.setStructureValue(null);
                            currentProperty.setResourceValue(propertyValue);
                        }
                    } else if (currentProperty.getStructureValue() != null) {
                        // structure value has to be updated
                        currentProperty.setStructureValue(propertyValue);
                        currentProperty.setResourceValue(null);
                    } else {
                        // resource value has to be updated
                        currentProperty.setStructureValue(null);
                        currentProperty.setResourceValue(propertyValue);
                    }
                    CmsLock lock = cms.getLock(resource);
                    if (lock.isUnlocked()) {
                        // lock resource before operation
                        cms.lockResource(resName);
                    }
                    // write the property to the resource
                    cms.writePropertyObject(resName, currentProperty);
                    // unlock the resource
                    cms.unlockResource(resName);
                } catch (CmsException e) {
                    // writing the property failed, log error
                    log(e.getLocalizedMessage());
                }
            }
        }
    }
private void saveProperties ( String resourcePath , Map < String , String > properties ) throws CmsException { CmsResource resource ; CmsObject cms = getCmsObject ( ) ; int pos = resourcePath . indexOf ( "?" ) ; String resName = resourcePath ; if ( pos > - 1 ) { resName = resourcePath . substring ( 0 , pos ) ; } resource = cms . readResource ( resName ) ; if ( properties != null ) { for ( Entry < String , String > entry : properties . entrySet ( ) ) { String propertyName = entry . getKey ( ) ; String propertyValue = entry . getValue ( ) ; if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( propertyValue ) ) { propertyValue = "" ; } try { CmsProperty currentProperty = cms . readPropertyObject ( resource , propertyName , false ) ; if ( currentProperty . isNullProperty ( ) ) { currentProperty = new CmsProperty ( ) ; currentProperty . setName ( propertyName ) ; if ( OpenCms . getWorkplaceManager ( ) . isDefaultPropertiesOnStructure ( ) ) { currentProperty . setStructureValue ( propertyValue ) ; currentProperty . setResourceValue ( null ) ; } else { currentProperty . setStructureValue ( null ) ; currentProperty . setResourceValue ( propertyValue ) ; } } else if ( currentProperty . getStructureValue ( ) != null ) { currentProperty . setStructureValue ( propertyValue ) ; currentProperty . setResourceValue ( null ) ; } else { currentProperty . setStructureValue ( null ) ; currentProperty . setResourceValue ( propertyValue ) ; } CmsLock lock = cms . getLock ( resource ) ; if ( lock . isUnlocked ( ) ) { cms . lockResource ( resName ) ; } cms . writePropertyObject ( resName , currentProperty ) ; cms . unlockResource ( resName ) ; } catch ( CmsException e ) { log ( e . getLocalizedMessage ( ) ) ; } } } }
Saves the given properties to the resource.<p>

@param resourcePath the resource path
@param properties the properties

@throws CmsException if something goes wrong