See: Description
Interface | Description |
---|---|
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.
|
IPhysicalVariantResource |
A physical variant resource represents a variant (content, properties and version history) that is associated with a
single logical variant resource.
|
ISerializedVariantResourceEvent | |
IVariantContextInfo |
This interface will be implemented by variant-enabled repositories to provide meta information about the available
context properties.
|
IVariantResourceEvent |
This interface is an extension of resource events generated for logical variant resources.
|
IVariantResourceEvent.EVENT_SUB_TYPE |
Class | Description |
---|---|
VariantResourceEventSubType |
Exception | Description |
---|---|
InvalidVariantContextException |
Thrown by a variant-enabled repository if the variant context (
)
is missing or invalid. |
PhysicalResourceAlreadyExistsException |
This package contains the API for Variant-Resources.
The API defined in this package enables applications to handle variant resources via specialized resource types/interfaces. A variant resource is a type of resource whose content and properties can vary depending on the resource context. The content and properties are not arbitrary but a defined set of "variants" of a resource exist. For example, a document content can be available in different languages.
Each variant is tagged with a property for each dimension for which the resources can vary. The property values are used to uniquely identify each variant. For example, each document may be available in two languages and two formats, so each variant will have two properties named "language" and "format" with two possible values each: [english, german] and [html, pdf]. The allowed dimensions - that means the property names, types and possible values - are managed by the repository.
When an application is looking up a resource the repository will select one of the available variants. This is done by matching the set of properties (names and values) provided by the application via the resource context against the properties identifying the variants. How these properties are put together is completely application-specific - but usually they are associated with a portal user (e.g. "preferred language").
Using the API in this package variants are available for plain resources, collections
and links. With collections and links only the properties may vary (not the collections' children or the links' target).
Variant resources may also be versioned: Each variant has its own version history.
Context properties are persistet at PRs. For each LR all PRs must have a unique set of context property values. A repository may allow incomplete sets of context properties to be persisted for PRs - this can make sense e.g. if the repository provides a feature to add context property definitions to an already existing repsitory instance.
null
if no PR is visible, which
means that the LR is not visible for the given VC.
IResource
methods).
The LastModified(By) property values will indicate the last change of the invariant properties of the LR
(or the last namespace operation on the children - if the PR is a collection) - it will not indicate
changes of PRs.
isA()
and as()
methods must be
used to access these interfaces.
A resource can be cast to a LR or PR using the following line of code (replace OtherType
with the
interface names):
OtherType ot = (OtherType)resource.as(OtherType.class);But not all resources in a variant-enabled repository might be variants, that means it depends on the repository whether the result of the
as()
method may be null
.
ILogicalariantResource
methods
and ResourceFactory.getResource()
/getResources()
(if the RID is a PR-RID). All other
methods will always return LR instances.
Method | LR | PR |
ICollection.getChildren | The context resolution has been applied by the repository to each child. The returned resource list will always contain only LRs. | Not supported |
IResource.getParentColletion | - | Returns null |
ICollection.createResource/createLink/createCollection | A new LR and a initial PR is created. The property map should 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 no context properties are specified the default context will be used. | Not supported |
IResource.setTargetURL/setLinkType | - | Not supported |
IResource.delete | All the PRs are also deleted. | PR will be deleted if there is at least one other PR (LR must always have one remaining PR). If the PR is a collection, no children will be deleted because a PR has no children (see also getChildren() method). |
IResource.rename/move | - | not supported |
IResource.copy | The LR and all of its PRs are copied. | The PR is copied to a new LR with an initial PR. |
IResource.search | Executes a property query for properties. It is not possible to search using invariant properties in the query expression. | not supported |
Method | LR | PR |
getProperty/getProperties | Returns the properties of the associated PR. | - |
setProperty/setProperties/deleteProperty | The properties of the associated PR are changed. Context properties can not be updated or deleted (exception is thrown). | The properties of the PR are changed. Context properties can not be updated or deleted (exception is thrown). |
updateContent: | The content of the associated PR is updated. | - |
Plain resources and links:
If a LR is locked, the lock request applies to the associated PR. The lock will be "visible" at the LR and the PR, that means
IResource.getLocks()
and getLockByToken()
will return a lock info object.
The lock will affect the namespace of the LR: The LR cannot be deleted if one of its PRs is locked.
But the lock does not affect the invariant properties of a LR - it is not possible to lock the invariant properties of plain resources.
Locking a PR directly is equivalent to locking the LR that is associated with that PR.
Collections:
If a LR of a collection is locked, the lock request applies to the LR itself because the lock affects
the namespace and the children of collections are not variant. The lock
will protect the children of the collection and the invariant properties. Of course it is possible to lock PRs of collections directly.
Method | LR | PR |
IResource.isRevision | Returns false |
Returns false |
IResource.enableVersioning IVersionController.enable/disable IResource.getVersionHistory IResource.checkOut/undoCheckOut/checkIn |
Will affect the PR resource associated with the LR. | - |
As the target RID/URL of a link resource is not variant, versioning is also not supported for link targets (only for properties).
PRs will inherit their effective ACLs from their LR.
IResource
, ICollection
or ILogicalVariantResource
interfaces. This means, that
the resource attached to the event is always the logical resource and it can be accessed by calling
IResourceEvent.getResource()
and casting it:
(ILogicalVariantResource)event.getResource().as(ILogicalVariantResource.class)
.
IVariantResourceEvent
provides additional information to variant-enabled event receivers on
the physical resource that was created, modified or deleted (directly or implicitly by a method called for the logical resource).
Because of this extension-mechanism the new event types are compatible with normal resource events to support event receivers
which are not aware of variants.
Method | Event Type | Event Sub-Type | IVariantResourceEvent.getPhysicalResource() |
ICollection.createXXX | CREATE_XXX | - | The new and first PR |
IResource.updateContent | SET | UPDATE_CONTENT | The modified PR |
IResource.setProperty/setProperties IResource.deleteProperty |
PROPERTY_SET/PROPERTY_DELETE | - | The modified PR |
IResource.delete | DELETE | - | null (All PRs are deleted when the LR is deleted) |
ILogicalVariantResource.createPhysicalResource | SET | CREATE | The new PR |
ILogicalVariantResource.set/deleteInvariantProperty | PROPERTY_SET/PROPERTY_DELETE | - | null |
Method | Event Type | Event Sub-Type | IVariantResourceEvent.getPhysicalResource() |
IResource.updateContent | SET | UPDATE_CONTENT | The modified PR |
IResource.setProperty/setProperties IResource.deleteProperty |
PROPERTY_SET/PROPERTY_DELETE | - | The modified PR |
IResource.delete | SET | DELETE | The deleted PR |
IPropertyMap variantContext = new MutablePropertyMap(); variantContext.put(new Property(propertyName, value)); IResourceContext ctxt = ResourceContext.getInstance(..., variantContext); IResource resource = ResourceFactory.getInstace().getResource(rid, ctxt);
ILogicalVariantResource lr = (ILogicalVariantResource)resource.as(ILogicalVariantResource.class) if (lr == null) ... IPhysicalVariantResource pr = lr.getPhysicalResource();In this example the LR is accessed at the PR:
IPhysicalVariantResource pr = (IPhysicalVariantResource)resource.as(IPhysicalVariantResource.class) if (pr == null) ... ILogicalVariantResource lr = pr.getLogicalResource();
IPropertyNameList cpNameList = ((IVariantContextInfo)resource.getRepositoryManager()).listNames(); IPropertyMap cpMap = resource.getProperties(cpNameList);Note: The context properties that are retrieved might be different (number of properties and values) from those in the variant context that was used to lookup the resource because the context resolution algorithm does not only do exact matches but may use all kinds of fallbacks or defaults.
findPhysicalResources()
method will return one PR or an empty list
because the complete set of context property values is used like a unique key.
IPropertyMap fullVariantContext = ... IResourceContext ctxt = ResourceContext.getInstance(..., fullVariantContext); ILogicalVariantResource lr = (ILogicalVariantResource) ResourceFactory.getInstace().getResource(rid, ctxt).as(ILogicalVariantResource.class); IResourceList list = lr.findPhysicalResources(fullVariantContext); IResource result = (list.size() > 0) ? list.get(0) : null;
Copyright 2018 SAP AG Complete Copyright Notice