code: 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);
          }
      }
docs: Writes a property value for a resource.<p>
  
  @param propertyName the name of the property
  @param propertyValue the new value of the property
  
  @throws CmsException if something goes wrong