public interface IAliasPolicy extends IBizPolicy
Policy for querying, creating and removing aliases.
Aliases are a persistent pseudonym for various things, including portal resources, uri's or arbitrary strings.
Once you have created an alias using createAlias(com.webmethods.portal.bizPolicy.IContext, java.lang.Object, java.lang.Object, java.lang.String, boolean)
, then you can lookup the target of that alias using
lookupAlias(com.webmethods.portal.bizPolicy.IContext, java.lang.Object)
.
This becomes especially useful for creating friendly names for portal resources. For example, if you want to
browse to the help topic, instead of typing in /server/nis/meta/default/topic/000000043
(assuming
you had that memorized), you could instead type: /server/nis/topic.help
and you would get automatically
redirected to the help topic.
Alias resolution like the example above works, because calls to PortalSystem.acquireURI(java.lang.String)
automatically ties into the the IAliasMechanics
which implements the IURIResolver
.
Therefore, any call to find the IURI
for 'topic.help' results in the appropriate
IThingID
for the help topic. This is done transparently to the client of
the IAliasPolicy, and is a useful by product of using this api.
Finally, aliases are persistent and clustered. This means that once you set an alias, by calling createAlias(com.webmethods.portal.bizPolicy.IContext, java.lang.Object, java.lang.Object, java.lang.String, boolean)
,
the alias will be stored in the database, and (relatively) immediately available throughout the cluster. As a result, they are optimized
for lookups, not creation calls.
Note: When setting portal resource uri's as keys, you should use ITopicSpacePolicy
instead.
Modifier and Type | Method and Description |
---|---|
void |
createAlias(IContext context,
Object source,
Object target,
String params,
boolean isSystem)
This will create a new alias.
|
IAliasValue |
lookupAlias(IContext context,
Object key)
Retrieve the appropriate
AliasValue based on a simple key. |
void |
removeAlias(IContext context,
Object key)
Removes an alias previously created.
|
getComponentData, getComponentName, getComponentProvider, getURI, isInitialized, setComponentData, setComponentProvider
init, shutdown
void createAlias(IContext context, Object source, Object target, String params, boolean isSystem) throws BizException
This will create a new alias. The source can be thought of as the 'key', and it is what will be passed in
to subsequent calls to lookupAlias(com.webmethods.portal.bizPolicy.IContext, java.lang.Object)
to retrieve the AliasValue
which will represent the target.
Paramaters are rarely used. They are important when in the context of the web application, you want to redirect
to a resource and append some extra paramaters to the url. They should be in the form of name=value&name2=value2
IsSystem specifies extra restrictions placed upon this alias. If this is set to true, then this alias can not be removed through the alias administration portlet, and will require an administrator invoking apis directly to remove this alias.
context
- Command context (user state information).source
- either a String, IURI
or IThingID
target
- either a String, IURI
or IThingID
params
- optional paramater listisSystem
- whether this is a protected system aliasBizException
IAliasCache
,
AliasValue
IAliasValue lookupAlias(IContext context, Object key) throws BizException
AliasValue
based on a simple key. The key is 'object' passed in from a previous call
to createAlias(com.webmethods.portal.bizPolicy.IContext, java.lang.Object, java.lang.Object, java.lang.String, boolean)
. If an alias is found, you can get the 'target' by calling AliasValue#getValue
.
Other information is also available on the AliasValue
.context
- Command context (user state information).key
- an arbitary key that may be a IURI
or a StringAliasValue
if found, NULL otherwiseBizException
void removeAlias(IContext context, Object key) throws BizException
createAlias(com.webmethods.portal.bizPolicy.IContext, java.lang.Object, java.lang.Object, java.lang.String, boolean)
.
Note, if this alias was created as a 'system' alias, then you will not have access rights to remove it, unless
you first disable the ITraits
on the IContext
.context
- Command context (user state information).key
- an arbitary key that may be a IURI
or a StringBizException