com.webmethods.portal.bizPolicy.biz.alias
Interface IAliasPolicy


public interface IAliasPolicy

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 IAliasPolicy.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 IAliasPolicy.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 com.webmethods.portal.mech.alias.IAliasMechanics which implements the com.webmethods.portal.system.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 IAliasPolicy.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.


Method Summary
 void createAlias(IContext context, Object source, Object target, String params, boolean isSystem)
          This will create a new alias.
 AliasValue 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.
 

Method Detail

createAlias

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 IAliasPolicy.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.

Parameters:
context - Command context (user state information).
source - either a String, IURI or IThingID
target - either a String, IURI or IThingID
params - optional paramater list
isSystem - whether this is a protected system alias
Throws:
BizException
See Also:
com.webmethods.portal.service.cache.caches.IAliasCache, AliasValue

lookupAlias

AliasValue lookupAlias(IContext context,
                       Object key)
                       throws BizException
Retrieve the appropriate AliasValue based on a simple key. The key is 'object' passed in from a previous call to IAliasPolicy.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.

Parameters:
context - Command context (user state information).
key - an arbitary key that may be a IURI or a String
Returns:
the AliasValue if found, NULL otherwise
Throws:
BizException

removeAlias

void removeAlias(IContext context,
                 Object key)
                 throws BizException
Removes an alias previously created. The key is 'object' passed in from a previous call to IAliasPolicy.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 com.webmethods.portal.bizPolicy.ITraits on the IContext.

Parameters:
context - Command context (user state information).
key - an arbitary key that may be a IURI or a String
Throws:
BizException