Instances of the UriRewriter
class provide the capability to parse a URI string
from recognized javascript pseudo-protocol links. Such psuedo-protocol links are the result of
client-side URL rewriting done by the DISC framework to support AJAX enabled portlets and desktops.
Using a UriRewriter
to instantiate a Uri
, a user does not need foreknowledge
about whether or not the URI has been rewritten by DISC. In this way, the same code can be used to
transparently manipulate a URI whether or not it has been rewritten by DISC.
UriRewriter
classes provide a mechanism for manipulating target URIs for recognized
proxy URIs, such as proxy URIs for remote portlets. This generic base class UriRewriter
returns false
for isProxyUri()
and has a null proxy URI property but it
does have a getTargetUri()
method that provides access to the URI. This same method
is used by subclasses, including those that really are proxy URIs. Therefore, the
UriRewriterFactory
can be used to select the proper UriRewriter
for
transparently rewriting a target URI.
The underlying proxy and target URIs for UriRewriter
instances are instances
of Uri
Note: URIs with entity-encoded ampersands (&) should not be passed to this API. It should
rarely be necessary to handle URIs with entity-encoded ampersands in client code. A URI, such as
one that comes from the value of the href attribute of an anchor tag, will contain no evidence of
HTML entity-encoding after it is in memory in the client.
This base class is intended to be used as an abstract base class for implementing subclasses
that understand how to get/set a target URI from a particular kind of proxy URI. Instead of instantiating
this class to work with generic, non-proxy URIs you should use GenericUriRewriter
.
The class GenericUriRewriter
extends this class.
Field Summary | |
public static object[]
|
JS_PSEUDO_PROTOCOL_REGEXES
An array of objects containing regular expressions used to parse URIs out of links for all known JavaScript pseudoprotocol links. |
public static object
|
SERVICE_UPDATE_REGEX
An object containing a RegExp property named regex and three
integer properties named preBackRef , uriBackRef , and
endBackRef .
|
public static object
|
UPDATE_CONTENTS_REGEX
An object similar to the UriRewriter.SERVICE_UPDATE_REGEX object.
|
Initializer Summary | |
UriRewriter(uriStr, [tmpltMap])
Initializes this instance. |
Method Summary | ||
public string
|
getFullUriString()
Gets the string for the URI associated with this instance, including the prefix and suffix. |
|
public bea.wlp.disc.uri.Uri
|
getProxyUri()
A Uri instance that represents the proxy URI.
|
|
public bea.wlp.disc.uri.Uri
|
getTargetUri()
Gets the target Uri associated with this instance.
|
|
public string
|
getUriPrefix()
Gets the prefix for the URI associated with this instance. |
|
public string
|
getUriSuffix()
Gets the suffix for the URI associated with this instance. |
|
public static boolean
|
groksUri(uriStr, [tmpltMap])
Determines if this class understands the given URI string well enough to work with it. |
|
public boolean
|
isProxyUri()
Determines if the URI for this instance is a proxy URI that contains a target URI. |
|
public object
|
parseUriStrParts(uriStr)
Parses the prefix, URI string, and suffix from recognized javascript pseudo-protocol links. |
|
public void
|
refreshTargetOnProxyUri()
Sets the instance target URI as a parameter (or path or whatever) of the instance proxy URI. |
|
public void
|
setProxyUri(proxyUri)
Sets the proxy URI for this instance. |
|
public void
|
setTargetUri(targetUri)
Sets the target Uri associated with this instance.
|
|
public void
|
setUriPrefix(prefix)
Sets the prefix for the URI associated with this instance. |
|
public void
|
setUriSuffix(suffix)
Sets the suffix for the URI associated with this instance. |
|
public static object
|
staticParseUriStrParts(uriStr)
Parses the prefix, URI string, and suffix from recognized javascript pseudo-protocol links. |
Field Detail |
public static object[] JS_PSEUDO_PROTOCOL_REGEXES
bea.wlp.disc.uri.UriRewriter.SERVICE_UPDATE_REGEX
objectpublic static object SERVICE_UPDATE_REGEX
RegExp
property named regex
and three
integer properties named preBackRef
, uriBackRef
, and
endBackRef
. The regex
property is a regular expression for
parsing javascript psuedo-protocol links that use the bea.wlp.disc.xie._Service.update()
method. The three integer properties correspond to the indices of back references
(parenthised subexpressions) in regex
that contain the URI prefix, the
URI string, and the URI suffix, respectively.
Here is an example of how this field could be used to parse a link:
var match = myUriStr.match(UriRewriter.SERVICE_UPDATE_REGEX.regex); var uriPreStr, uriStr, uriEndStr; if ( match ) { uriPreStr = match[UriRewriter.SERVICE_UPDATE_REGEX.preBackRef]; uriStr = match[UriRewriter.SERVICE_UPDATE_REGEX.uriBackRef]; uriEndStr = match[UriRewriter.SERVICE_UPDATE_REGEX.endBackRef]; }For example, the string
javascript:bea.wlp.disc.xie._Service.update('http://www.oracle.com');would have a prefix of
javascript:bea.wlp.disc.xie._Service.update('a URI string of
http://www.oracle.comand a suffix of
');
public static object UPDATE_CONTENTS_REGEX
UriRewriter.SERVICE_UPDATE_REGEX
object. This one is
for parsing javascript psuedo-protocol links that use the bea.netuix.ajaxportlet.updateContents()
method, e.g. the string
javascript:bea.netuix.ajaxportlet.updateContents(%22my_portlet_label%22, %22http://www.oracle.com%22)would have a prefix of
javascript:bea.netuix.ajaxportlet.updateContents(%22my_portlet_label%22, %22a URI string of
http://www.oracle.comand a suffix of
%22)
Initializer Detail |
public UriRewriter(uriStr, [tmpltMap])
uriStr
then
the target URI will be set to an empty Uri
instance.
The optional tmpltMap
argument must be provided if the uriStr
argument is a
templatized URI string. This constructor will perform template replacement prior to attempting to
parse the URI string. This allows it to more reliably parse the string into a URI.
Template keys are enclosed in curly braces, i.e., {myKey}
. A templatized URI string
such as:
{protocol}://www.oracle.com/products?id={productId}could have its template keys replaced by using a
tmpltMap
argument such as
{protocol:'http', productId:'1001'}This would result in
http://www.oracle.com/products?id=1001This base class is intended to be used as an abstract base class for implementing subclasses that understand how to get/set a target URI from a particular kind of proxy URI. Instead of instantiating this class to work with generic, non-proxy URIs you should use
GenericUriRewriter
.
The class GenericUriRewriter
extends this class.uriStr
- The string form of the URI[tmpltMap]
- An optional map of template key/values, e.g., {protocol:'http', productId:'1001'}
.
This argument is required if the uriStr
argument is templatized.Method Detail |
public string getFullUriString()
javascript:bea.wlp.disc.xie._Service.update('http://www.oracle.com');would have a prefix of
javascript:bea.wlp.disc.xie._Service.update('a URI string of
http://www.oracle.comand a suffix of
');
string
-
The string for the URI associated with this instance, including the prefix and suffixpublic bea.wlp.disc.uri.Uri getProxyUri()
Uri
instance that represents the proxy URI. The proxy URI contains a target URI,
perhaps as a query parameter.bea.wlp.disc.uri.Uri
-
A Uri
instance that represents the proxy URI. The proxy URI contains a target URI,
perhaps as a query parameter. Returns null if this instance is not a proxy URI.public bea.wlp.disc.uri.Uri getTargetUri()
Uri
associated with this instance. If this instance represents
a proxy URI then the target URI is contained somewhere in the proxy URI, perhaps as a
query parameter.
The target URI is extracted from the proxy URI in a manner that is specific to each
subclass of the base UriRewriter
class.bea.wlp.disc.uri.Uri
-
The target Uri
associated with this instancepublic string getUriPrefix()
javascript:bea.wlp.disc.xie._Service.update('http://www.oracle.com');would have a prefix of
javascript:bea.wlp.disc.xie._Service.update('
string
-
The prefix for the URI associated with this instance. Returns the empty string, '', if there
is no prefix.public string getUriSuffix()
javascript:bea.wlp.disc.xie._Service.update('http://www.oracle.com');would have a suffix of
');
string
-
The suffix for the URI associated with this instance. Returns the empty string, '', if there
is no suffix.public static boolean groksUri(uriStr, [tmpltMap])
groksUri
method for use by
the UriRewriterFactory
in selecting a UriRewriter
.string uriStr
- The URI stringobject [tmpltMap]
- An optional map of template key/values, e.g., {protocol:'http', productId:'1001'}
.
This argument is required if the uriStr
argument is templatized.boolean
-
true if this class understands the given URI string well enough to work with it, else falsepublic boolean isProxyUri()
getProxyUri()
returns null.boolean
-
true if the URI for this instance is a proxy URI that contains a target URI, else false and
the URI is considered to be a target URI.public object parseUriStrParts(uriStr) throws Error
javascript:
, e.g, the string
javascript:bea.wlp.disc.xie._Service.update('http://www.oracle.com');would have a prefix of
javascript:bea.wlp.disc.xie._Service.update('a URI string of
http://www.oracle.comand a suffix of
');Recognized javascript psuedo-protocol links are strings that can be parsed using the regular expressions in
UriRewriter.JS_PSEUDO_PROTOCOL_REGEXES
If the input argument is a string that is not a javascript pseudo-protocol link then the
prefix and suffix will be the empty string, '', and the uriStr
property is
the same as the input argument.
This method can be overriden in subclasses in order to change the parsing of javascript psuedo-protocol
links in the constructor. Typically, a user will not use this method. They would use the static
staticParseUriStrParts
method. This method is intended to behave as a protected method
to allow subclasses to override it for use in the constructor.string uriStr
- The string to be parsed for its prefix, URI string, and suffixobject
-
An object with properties uriPreStr
, uriStr
, and uriEndStr
that
correspond to the prefix, URI string, and suffix, respectively. If the input argument is a URI
string that is not a javascript pseudo-protocol link then the prefix and suffix will be the empty
string, '', and the uriStr
property is the same as the input argument.Error
-
Thrown when the uriStr
is a javascript pseudo-protocol link
that is not recognized. In this case, the URI string cannot be parsed from the given string
and the user should parse the URI string out of the javascript themselves.public void refreshTargetOnProxyUri()
getProxyUri
and setTargetUri
so
users of those methods do not need to use this method themselves.
This method is used by getProxyUri
and setTargetUri
so
users of those methods do not need to use this method themselves. This method is
intended to serve as a protected method to allow subclasses to override it for use
in getProxyUri
and setTargetUri
.
This method should be overridden by subclasses that are used to manipulate proxy URIs.public void setProxyUri(proxyUri)
UriRewriter
class.bea.wlp.disc.uri.Uri proxyUri
- A Uri
instance that represents the proxy URI. The proxy URI contains a target URI,
perhaps as a query parameter.public void setTargetUri(targetUri)
Uri
associated with this instance. This method will
refresh the proxy Uri
by setting the target URI in a manner that is
specific to each subclass of the base UriRewriter
class.bea.wlp.disc.uri.Uri targetUri
- The target Uri
associated with this instancepublic void setUriPrefix(prefix)
javascript:bea.wlp.disc.xie._Service.update('http://www.oracle.com');would have a prefix of
javascript:bea.wlp.disc.xie._Service.update('
string prefix
- The prefix for the URI associated with this instance.public void setUriSuffix(suffix)
javascript:bea.wlp.disc.xie._Service.update('http://www.oracle.com');would have a suffix of
');
string suffix
- The suffix for the URI associated with this instance.public static object staticParseUriStrParts(uriStr) throws Error
parseUriStrParts
method.string uriStr
- The string to be parsed for its prefix, URI string, and suffixobject
-
An object with properties uriPreStr
, uriStr
, and uriEndStr
that
correspond to the prefix, URI string, and suffix, respectively. If the input argument is a URI
string that is not a javascript pseudo-protocol link then the prefix and suffix will be the empty
string, '', and the uriStr
property is the same as the input argument.Error
-
Thrown when the uriStr
is a javascript pseudo-protocol link
that is not recognized. In this case, the URI string cannot be parsed from the given string
and the user should parse the URI string out of the javascript themselves.
Oracle Fusion Middleware Disc API Reference for Oracle WebLogic Portal
10g Release 3 (10.3.4)
E14257-04
Copyright © 2011, Oracle. All rights reserved.