if (currentProperty.isNullProperty()) { currentProperty = new CmsProperty(); currentProperty.setName(propName); if (currentProperty.getStructureValue() != null) { currentProperty.setStructureValue(CmsProperty.DELETE_VALUE); currentProperty.setResourceValue(null); writeProperty = true; } else if (currentProperty.getResourceValue() != null) { currentProperty.setResourceValue(CmsProperty.DELETE_VALUE); currentProperty.setStructureValue(null); writeProperty = true; if (!propValue.equals(currentProperty.getValue())) { if ((currentProperty.getStructureValue() == null) && (currentProperty.getResourceValue() == null)) { currentProperty.setStructureValue(propValue); currentProperty.setResourceValue(null); } else { currentProperty.setResourceValue(propValue); currentProperty.setStructureValue(null); } else if (currentProperty.getStructureValue() != null) { currentProperty.setStructureValue(propValue); currentProperty.setResourceValue(null); } else {
isEqual = (property.getName() == null); } else { isEqual = m_name.equals(property.getName()); isEqual &= (property.getStructureValue() == null); } else { isEqual &= m_structureValue.equals(property.getStructureValue()); isEqual &= (property.getResourceValue() == null); } else { isEqual &= m_resourceValue.equals(property.getResourceValue());
/** * Reads a property object from a resource specified by a property name.<p> * * Returns <code>{@link CmsProperty#getNullProperty()}</code> if the property is not found.<p> * * @param dbc the current database context * @param resource the resource where the property is read from * @param key the property key name * @param search if <code>true</code>, the property is searched on all parent folders of the resource. * if it's not found attached directly to the resource. * * @return the required property, or <code>{@link CmsProperty#getNullProperty()}</code> if the property was not found * * @throws CmsException if something goes wrong */ public CmsProperty readPropertyObject(CmsDbContext dbc, CmsResource resource, String key, boolean search) throws CmsException { // NOTE: Do not call readPropertyObject(dbc, resource, key, search, null) for performance reasons // use the list reading method to obtain all properties for the resource List<CmsProperty> properties = readPropertyObjects(dbc, resource, search); int i = properties.indexOf(new CmsProperty(key, null, null)); if (i >= 0) { // property has been found in the map CmsProperty result = properties.get(i); // ensure the result value is not frozen return result.cloneAsProperty(); } return CmsProperty.getNullProperty(); }
/** * Sets the name of this property.<p> * * @param name the name of this property * * @deprecated use {@link #setName(String)} instead */ public void setKey(String name) { checkFrozen(); setName(name); }
/** * Gets the change frequency for a sitemap entry from a list of properties.<p> * * If the change frequency is not defined in the properties, this method will return null.<p> * * @param properties the properties from which the change frequency should be obtained * * @return the change frequency string */ protected static String getChangeFrequency(List<CmsProperty> properties) { CmsProperty prop = CmsProperty.get(CmsPropertyDefinition.PROPERTY_XMLSITEMAP_CHANGEFREQ, properties); if (prop.isNullProperty()) { return null; } String result = prop.getValue().trim(); return result; }
/** * Sets the value of this property as either shared or * individual value.<p> * * If the given type equals {@link CmsProperty#TYPE_SHARED} then * the value is set as a shared (resource) value, otherwise it * is set as individual (structure) value.<p> * * @param value the value to set * @param type the value type to set */ public void setValue(String value, String type) { checkFrozen(); setAutoCreatePropertyDefinition(true); if (TYPE_SHARED.equalsIgnoreCase(type)) { // set the provided value as shared (resource) value setResourceValue(value); } else { // set the provided value as individual (structure) value setStructureValue(value); } }
CmsProperty newProp = new CmsProperty(); newProp.setName(propertyName); CmsProperty oldProp = cms.readPropertyObject(resourcePath, propertyName, false); if (oldProp.isNullProperty()) { newProp.setStructureValue(propertyValue); } else { newProp.setResourceValue(propertyValue); 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; String oldResourceValue = oldProp.getResourceValue(); String newResourceValue = newProp.getResourceValue(); if (CmsStringUtil.isEmpty(oldResourceValue)) { oldResourceValue = CmsProperty.DELETE_VALUE;
/** * Writes a property for a file or folder.<p> * * @param resourcename the resource-name for which the property will be set * @param key the property-definition name * @param value the value for the property to be set * @param addDefinition flag to indicate if unknown definitions should be added * * @throws CmsException if operation was not successful * * @deprecated use <code>{@link #writePropertyObject(String, CmsProperty)}</code> instead. */ public void writeProperty(String resourcename, String key, String value, boolean addDefinition) throws CmsException { CmsProperty property = new CmsProperty(); property.setName(key); property.setStructureValue(value); property.setAutoCreatePropertyDefinition(addDefinition); writePropertyObject(resourcename, property); }
/** * Unmarshals the descriptor content. * * @throws CmsXmlException thrown if the XML structure of the descriptor is wrong. * @throws CmsException thrown if reading the descriptor file fails. */ private void unmarshalDescriptor() throws CmsXmlException, CmsException { if (null != m_desc) { // unmarshal descriptor m_descContent = CmsXmlContentFactory.unmarshal(m_cms, m_cms.readFile(m_desc)); // configure messages if wanted CmsProperty bundleProp = m_cms.readPropertyObject(m_desc, PROPERTY_BUNDLE_DESCRIPTOR_LOCALIZATION, true); if (!(bundleProp.isNullProperty() || bundleProp.getValue().trim().isEmpty())) { m_configuredBundle = bundleProp.getValue(); } } }
property = new CmsProperty(); property.setName(key); property.setStructureValue(propertyValue); } else if (mappingType == CmsProperty.RESOURCE_RECORD_MAPPING) { property.setResourceValue(propertyValue); } else { throw new CmsDbConsistencyException(Messages.get().container( return (property != null) ? property : CmsProperty.getNullProperty();
false); if (currentProperty.isNullProperty()) { currentProperty = new CmsProperty(); currentProperty.setName(CmsPropertyDefinition.PROPERTY_TITLE); if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) { currentProperty.setStructureValue(currentPropertyValue); currentProperty.setResourceValue(null); } else { currentProperty.setStructureValue(null); currentProperty.setResourceValue(currentPropertyValue); } else if (currentProperty.getStructureValue() != null) { currentProperty.setStructureValue(currentPropertyValue); currentProperty.setResourceValue(null); } else { currentProperty.setStructureValue(null); currentProperty.setResourceValue(currentPropertyValue);
/** * Converts a property object to a field value for one of the boolean selection widgets.<p> * * @param prop the property to convert * @return the field value */ private String convertPropertyToFieldValue(CmsProperty prop) { if (prop == null) { return ""; } return "" + Boolean.valueOf(prop.getValue()); }
CmsProperty property = (i.next()).clone(); if (property.getResourceValue() != null) { property.setResourceValue(resolver.resolveMacros(property.getResourceValue())); if (property.getStructureValue() != null) { property.setStructureValue(resolver.resolveMacros(property.getStructureValue()));
if (titleProp.isNullProperty()) { titleProp = new CmsProperty(CmsPropertyDefinition.PROPERTY_TITLE, title, null); cms.writePropertyObject(cms.getSitePath(res), titleProp); } else if (!titleProp.getValue().equals(title)) { titleProp.setStructureValue(title); cms.writePropertyObject(cms.getSitePath(res), titleProp);
CmsProperty titleProp = CmsProperty.getNullProperty(); if (titleProp.isNullProperty()) { options.add("[" + resource.getName() + "]"); } else { options.add(titleProp.getValue());
entry = (Map.Entry)itFilterProperties.next(); property = cms.readPropertyObject(resource, (String)entry.getKey(), true); if (property == CmsProperty.getNullProperty()) { continue; } else { if (property.getValue().equals(entry.getValue())) {
/** * Deletes a property for a file or folder.<p> * * @param resourcename the name of a resource for which the property should be deleted * @param key the name of the property * * @throws CmsException if something goes wrong * * @deprecated use <code>{@link #writePropertyObject(String, CmsProperty)}</code> instead. */ public void deleteProperty(String resourcename, String key) throws CmsException { CmsProperty property = new CmsProperty(); property.setName(key); property.setStructureValue(CmsProperty.DELETE_VALUE); writePropertyObject(resourcename, property); }
/** * Creates a single property object and sets the value individual or shared depending on the OpenCms settings.<p> * * @param name the name of the property * @param value the value to set * @return an initialized property object */ protected static CmsProperty createPropertyObject(String name, String value) { CmsProperty prop = new CmsProperty(); prop.setAutoCreatePropertyDefinition(true); prop.setName(name); if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) { prop.setValue(value, CmsProperty.TYPE_INDIVIDUAL); } else { prop.setValue(value, CmsProperty.TYPE_SHARED); } return prop; }
/** * Creates a client property bean from a server-side property.<p> * * @param prop the property from which to create the client property * @param preserveOrigin if true, the origin will be copied into the new object * * @return the new client property */ public static CmsClientProperty createClientProperty(CmsProperty prop, boolean preserveOrigin) { CmsClientProperty result = new CmsClientProperty( prop.getName(), prop.getStructureValue(), prop.getResourceValue()); if (preserveOrigin) { result.setOrigin(prop.getOrigin()); } return result; }
String propertyName = propIt.next(); CmsProperty property = cms.readPropertyObject(resource, propertyName, false); if (!property.isNullProperty()) { props.put(property.getName(), property.getValue()); } else { props.put(propertyName, null);