com.arsdigita.kernel
Class GenericURLFinder
java.lang.Object
com.arsdigita.kernel.GenericURLFinder
- All Implemented Interfaces:
- URLFinder
- public class GenericURLFinder
- extends Object
- implements URLFinder
A URLFinder that can be registered for most object types. The
GenericURLFinder is constructed with a specified URL pattern such
as one-ticket?ticket_id=:id
. For a given OID, the
URL path is determined as follows:
- Try to find the package instance to which the specified
object belongs. The current process involves
examining persistence metadata to try to navigate from the
given OID to its package instance. This process will eventually
be replaced with a call to some other kernel service (to be
developed) that deals with the scoping of objects to package
instances. Until then, the process is as follows:
- Get the data object's "packageInstance" property (if it has
such a property and the property is of type PackageInstance).
- If no such property exists, use metadata to figure out
if this data object has a composite role property (a
required, visible property where
com.arsdigita.persistence.metadata.Property.isComposite()==true
).
- If a composite role exists,
fetch the composite role, and
then repeat the process with that object. See the example below.
- Once the package instance is determined, get the package
instance's primary mount point (see
PackageInstance.getDefaultMountPoint()).
- Once the primary mount point is determined, get its URL path.
- Append the URL pattern (which was specified to the constructor
of GenericURLFinder).
- Substitute terms like
:id
with values from the given
OID.
For example, suppose we have the following PDL fragment:
model examples;
object type Forum extends ACSObject {
PackageInstance[1..1] packageInstance;
}
object type Message extends ACSObject {...}
association {
Forum[1..1] forum;
composite Message[0..n] messages;
// NOTE: composite means component in PDL
}
We can register GenericURLFinder with the URLService for both of
these object types with the following code:
URLService.registerFinder("examples.Forum",
new GenericURLFinder("index?forum_id=:id"));
URLService.registerFinder("examples.Message",
new GenericURLFinder("message?message_id=:id"));
The GenericURLFinder registered for examples.Forum
will
work because examples.Forum
has a packageInstance
property of type PackageInstance
.
The finder registered for examples.Message
will work
because examples.Message
has a composite role (in this
case it is the role called forum
), and the composite
object has a packageInstance
property of type
PackageInstance
.
- Author:
- Oumi Mehrotra
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
versionId
public static final String versionId
- See Also:
- Constant Field Values
GenericURLFinder
public GenericURLFinder(String urlEndingPattern)
find
public String find(OID oid,
String context)
throws NoValidURLException
- Specified by:
find
in interface URLFinder
- Throws:
NoValidURLException
find
public String find(OID oid)
throws NoValidURLException
- Description copied from interface:
URLFinder
- Returns a URL path to a page that displays the object identified by
the given OID. The URL path is relative to the server root.
Only called from URLService.locate(OID).
- Specified by:
find
in interface URLFinder
- Throws:
NoValidURLException
- when no valid URL could be obtained
for the given OID.- See Also:
URLService.locate(OID)
Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC