com.sapportals.wcm.repository.variants

Interface ILogicalVariantResource


public interface ILogicalVariantResource

A logical variant resource is a type of resource whose content, properties and versions depend on the resource context which contains a variant-context. An application can detect if a resource has variants by calling resource.as(ILogicalVariantResource.class). Variants are supported for "plain" resources, collections or links. Variants are not suppored for all other types of resources (e.g. Versions). For collections and links only the properties may vary (but not the collections children or the links target).
A logical resource can have a set of properties which are called "invariant" properties. These properties are persisted at the logical resource and can only be modified or retrieved with the methods in this interface (but not the IResource methods).
In the following code example a variant-context is constructed which will be used by the repository to select one of the available content and property variants. If an application is not aware of variants and no variant-context is attached a repository-specific default handling will select one of the available variants.

 IPropertyMap variantContext = new MutablePropertyMap();
 variantContext.put(new Property(propertyName, "value");
 IResourceContext ctxt = ResourceContext.getInstance(rid, variantContext);
   
 IResource resource = ResourceFactory.getInstace().getResource(rid, ctxt);
 ILogicalVariantResource lr = (ILogicalVariantResource)resource.as(ILogicalVariantResource.class);
 if (lr != null) { ... }
 

See Also:
IPhysicalVariantResource

Method Summary
 IResource createPhysicalResource(IContent content, IPropertyMap properties, boolean ignorePropertyFailures)
          Creates a new physical resource for this logical resource.
 void deleteInvariantProperty(IPropertyName propertyName)
          Deletes the invariant property with the specified name if it exists.
 IResourceList findPhysicalResources(IPropertyMap properties)
          Returns a list of resource instances of type IPhysicalVariantResource which match the given map of context properties.
 IPropertyMap getInvariantProperties(IPropertyNameList list)
          Returns a map of invariant properties with the specified names or all properties if the list is null.
 IProperty getInvariantProperty(IPropertyName name)
          Returns an invariant property with the given name or null if it does not exist.
 IResource getPhysicalResource()
          Returns the physical resource that was the result of the context resultion for this resource (at the time when this resource was created).
 void setInvariantProperty(IProperty property)
          Sets the specified property as a invariant property of this logical resource.
 void updateInvariantProperties(List updates)
          Updates the invariant properties of this resource.
 

Method Detail

getPhysicalResource

IResource getPhysicalResource()
                              throws ResourceException
Returns the physical resource that was the result of the context resultion for this resource (at the time when this resource was created).

Returns:
the physical resource that was the result of the context resultion for this resource.
Throws:
ResourceException

createPhysicalResource

IResource createPhysicalResource(IContent content,
                                 IPropertyMap properties,
                                 boolean ignorePropertyFailures)
                                 throws ResourceException,
                                        InvalidVariantContextException
Creates a new physical resource for this logical resource. The logical resource might be a plain resource, collection or link. For collectins and links the content parameter must be null. The property map must contain all context properties required by the repository. Whether it is required to specify all context properties or not depends on the repository implementation. If these properties are not unique for this logical resource (a physical resource with these context property values already exists) an exception is thrown.

Parameters:
content - The resource content. Must be null for collections and links.
properties - A map of properties for the new resource. The map must contain the required context properties.
ignorePropertyFailures - true: Ignore errors while setting the given properties
Returns:
the instance of the new physical resource.
Throws:
PhysicalResourceAlreadyExistsException - If a physical resource with the specified subset of context properties and values already exists.
ResourceException - If the type or value of a property is invalid, particularly if the value of a context property is not contained in the list of allowed values. If the property map does not contain all context properties.
InvalidVariantContextException
OperationNotSupportedException

findPhysicalResources

IResourceList findPhysicalResources(IPropertyMap properties)
                                    throws ResourceException
Returns a list of resource instances of type IPhysicalVariantResource which match the given map of context properties. A physical resource matches if the values of all properties in the map are equal to the values of the resource properties. Properties that exist at the resource but are not contained in the map are used as "wildcard" properties, that means they match any value. If the property map is empty or null the list will contain all existing physical resources (at least one). If one of the properties in the map is not a context property a ResourceException is thrown.

Parameters:
properties - A map of context properties to be used as a search condition.
Returns:
a list of resource instances of type IPhysicalVariantResource.
Throws:
ResourceException - If one of the properties in the map is not a known context property.

getInvariantProperties

IPropertyMap getInvariantProperties(IPropertyNameList list)
                                    throws ResourceException
Returns a map of invariant properties with the specified names or all properties if the list is null.

Parameters:
list - A list of property names - may be null.
Returns:
a map of invariant properties at this resource. The map may be empty but not null.
Throws:
ResourceException

getInvariantProperty

IProperty getInvariantProperty(IPropertyName name)
                               throws ResourceException
Returns an invariant property with the given name or null if it does not exist.

Parameters:
name - A property name
Returns:
Throws:
ResourceException

setInvariantProperty

void setInvariantProperty(IProperty property)
                          throws ResourceException
Sets the specified property as a invariant property of this logical resource. If a invariant property with the same name already exists it is overwritten.

Parameters:
property - The property to set
Throws:
ResourceException

updateInvariantProperties

void updateInvariantProperties(List updates)
                               throws ResourceException
Updates the invariant properties of this resource.

Parameters:
updates - list of updates: contains IProperty entries for properties to be set and IPropertyName entries for properties to be removed.
Throws:
ResourceException

deleteInvariantProperty

void deleteInvariantProperty(IPropertyName propertyName)
                             throws ResourceException
Deletes the invariant property with the specified name if it exists.

Parameters:
propertyName - The name of the property to delete.
Throws:
ResourceException
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] KMC-WPC [sap.com] tc/kmc/wpc/wpcfacade api EP-PIN-WPC-WCM
[sap.com] KMC-CM [sap.com] tc/km/frwk api EP-KM-CM


Copyright 2012 SAP AG Complete Copyright Notice