com.fatwire.cs.core.uri
Class QueryAssembler

java.lang.Object
  extended by com.fatwire.cs.core.uri.AbstractAssembler
      extended by com.fatwire.cs.core.uri.QueryAssembler
All Implemented Interfaces:
Assembler
Direct Known Subclasses:
QueryAsPathInfoAssembler, SatelliteTokenAssembler

public class QueryAssembler
extends AbstractAssembler

This class is capable of assembling and disassembling a standard URL for Content Server. Content Server URLs put all parameters in the query string. These URLs look exactly the same as URLs in Content Server 6.1.0 and earlier.

This assembler identifies itself by ensuring that the entire path consists of the values corresponding to the path properties passed in. If the path does not match one of the properties, this will not disassemble the URI.

This class is meant to be extended by users desiring a custom URI appearance without needing to make significant changes to the structure of the URI. (i.e. embed an argument in the path info, rename a parameter, set default parameter values, etc.)

Since:
14-Oct-2004 5:04:52 PM

Nested Class Summary
 
Nested classes/interfaces inherited from class com.fatwire.cs.core.uri.AbstractAssembler
AbstractAssembler.AssemblyContext, AbstractAssembler.DisassemblyContext
 
Field Summary
 
Fields inherited from class com.fatwire.cs.core.uri.AbstractAssembler
PAGENAME
 
Fields inherited from interface com.fatwire.cs.core.uri.Assembler
LOG_NAME, PROP_PATH_PREFIX, PROP_URIBASE_BLOB_SERVER, PROP_URIBASE_CACHE_SERVER, PROP_URIBASE_CATALOG_MANAGER, PROP_URIBASE_CONTENT_SERVER, PROP_URIBASE_COOKIE_SERVER, PROP_URIBASE_DISPATCH_MANAGER, PROP_URIBASE_PAGE_DISPATCH_SERVER, PROP_URIBASE_SATELLITE_SERVER, PROP_URIBASE_SEED_DISPATCH_SERVER, PROP_URIBASE_SYNC_SEED_DISPATCH_SERVER, PROP_URIBASE_TREE_MANAGER
 
Constructor Summary
QueryAssembler()
           
 
Method Summary
protected  Definition.AppType getAppType(AbstractAssembler.DisassemblyContext ctx)
          Get the app type for this URI.
protected  java.lang.String getAuthority(AbstractAssembler.AssemblyContext def)
          Get the authority for this URI
protected  java.lang.String getAuthority(AbstractAssembler.DisassemblyContext ctx)
          Get the authority from the URI specified
protected  java.lang.String getFragment(AbstractAssembler.AssemblyContext def)
          Returns the fragment for this URI.
protected  java.lang.String getFragment(AbstractAssembler.DisassemblyContext ctx)
          Get the fragment from the URI specified
protected  java.lang.String getPath(AbstractAssembler.AssemblyContext def)
          This method returns the path for the URI given the definition specified.
protected  java.lang.String getPathForApp(Definition.AppType type)
          Returns the path for the definition specified given the app type.
protected  java.lang.String getPathForSatelliteServer(Definition.AppType type)
          This method returns the path for a given app type when a Satellite Server URI has been requested.
protected  java.lang.String getQuery(AbstractAssembler.AssemblyContext def)
          This method grabs all the parameters from the Definition specified and converts them into a query string.
protected  java.util.Map getQuery(AbstractAssembler.DisassemblyContext ctx)
          Return the query paramers from the URI.
protected  Definition.SatelliteContext getSatelliteContext(AbstractAssembler.DisassemblyContext ctx)
          Returns the satellite context for the URI specified.
protected  java.lang.String getScheme(AbstractAssembler.AssemblyContext def)
          Returns the scheme (protocol) for the assembly context specified.
protected  java.lang.String getScheme(AbstractAssembler.DisassemblyContext ctx)
          Get the scheme from the URI specified.
protected  boolean getSessionEncode(AbstractAssembler.DisassemblyContext ctx)
          Return whether or not session encoding should be done for the URI specified.
 
Methods inherited from class com.fatwire.cs.core.uri.AbstractAssembler
assemble, decode, disassemble, encode, getAssemblyContext, getDisassemblyContext, getLog, getProperty, parseQueryString, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryAssembler

public QueryAssembler()
Method Detail

getScheme

protected java.lang.String getScheme(AbstractAssembler.AssemblyContext def)
Description copied from class: AbstractAssembler
Returns the scheme (protocol) for the assembly context specified.

Specified by:
getScheme in class AbstractAssembler
Parameters:
def - Assembly context object
Returns:
scheme

getAuthority

protected java.lang.String getAuthority(AbstractAssembler.AssemblyContext def)
Get the authority for this URI

Specified by:
getAuthority in class AbstractAssembler
Parameters:
def -
Returns:
decoded authority

getPath

protected java.lang.String getPath(AbstractAssembler.AssemblyContext def)
This method returns the path for the URI given the definition specified. This implementation checks the satellite context then invokes one of depending on the satellite context of the definition.

Specified by:
getPath in class AbstractAssembler
Parameters:
def -
Returns:
decoded path

getPathForSatelliteServer

protected java.lang.String getPathForSatelliteServer(Definition.AppType type)
This method returns the path for a given app type when a Satellite Server URI has been requested. If the AppType passed in is not supported by Satellite Server, then an IllegalArgumentException will be thrown. Custom assemblers may override this method to alter the path of the generated URI.

Parameters:
type - The app type
Returns:
the path, based on the properties passed in
Throws:
java.lang.IllegalArgumentException - if the app type is not supported by Satellite Server.

getPathForApp

protected java.lang.String getPathForApp(Definition.AppType type)
Returns the path for the definition specified given the app type. All paths returned by this method or subclasses that override this method must begin with the value of the property corresponding to either the app type. Custom assemblers may override this method to alter the path of the generated URI.

Parameters:
type -
Returns:
path
See Also:
QueryAssembler.getPathForSatelliteServer(Definition.AppType)

getQuery

protected java.lang.String getQuery(AbstractAssembler.AssemblyContext def)
This method grabs all the parameters from the Definition specified and converts them into a query string. The params are sorted in the order in which they were returned by the getParameterNames() method of the Definition. If multiple values are specified for any parameter, the parameter will be repeated on the query string. Custom assemblers may override this to alter the query string, for example, by omitting parameters represented in other ways, or by adding new parameters. Alternately, custom assemblers may handle this by overriding the input AssemblyContext's AssemblyContext#getParameterNames method.

Specified by:
getQuery in class AbstractAssembler
Parameters:
def -
Returns:
query string in which names and values have been encoded. This prevents parsing ambiguities that could arise given the following:
NameValue
foobar&blah
+=-#*MathChars
The whole query string, however, has not been encoded in its entirety.
See Also:
Encode provides a helpful method for quoting illegal characters in the query string.

getFragment

protected java.lang.String getFragment(AbstractAssembler.AssemblyContext def)
Returns the fragment for this URI.

Specified by:
getFragment in class AbstractAssembler
Parameters:
def -
Returns:
fragment

getSessionEncode

protected boolean getSessionEncode(AbstractAssembler.DisassemblyContext ctx)
Return whether or not session encoding should be done for the URI specified.

Specified by:
getSessionEncode in class AbstractAssembler
Parameters:
ctx - DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.
Returns:
false, always, because this assembler has no knowledge of whether a URI was session-encoded or not.

getScheme

protected java.lang.String getScheme(AbstractAssembler.DisassemblyContext ctx)
Get the scheme from the URI specified.

Specified by:
getScheme in class AbstractAssembler
Parameters:
ctx - DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.
Returns:
scheme

getAuthority

protected java.lang.String getAuthority(AbstractAssembler.DisassemblyContext ctx)
Get the authority from the URI specified

Specified by:
getAuthority in class AbstractAssembler
Parameters:
ctx - DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.
Returns:
authority

getFragment

protected java.lang.String getFragment(AbstractAssembler.DisassemblyContext ctx)
Get the fragment from the URI specified

Specified by:
getFragment in class AbstractAssembler
Parameters:
ctx - DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.
Returns:
fragment

getSatelliteContext

protected Definition.SatelliteContext getSatelliteContext(AbstractAssembler.DisassemblyContext ctx)
Returns the satellite context for the URI specified. This implementation examines the URIPath. If it finds a path corresponding to the property values passed into this assembler, then it matches the SatelliteContext accordingly. This method expects that no additional information will be specified on the path. If it determines that extra information was added to the path, the ownership will be set to foreign.

Specified by:
getSatelliteContext in class AbstractAssembler
Parameters:
ctx - DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.
Returns:
SatelliteContext

getAppType

protected Definition.AppType getAppType(AbstractAssembler.DisassemblyContext ctx)
Get the app type for this URI. This method looks at the path and tries to figure out what app it refers to by matching the path with the properties passed in. If the path indicates that the URI is for Satellite Server, then the query string parameters are studied to determine which app is being served by Satellite Server. This implementation expects that no additional path information is present on the URI. If additional information is present on the URI path, ownership will be set to foreign. Consequently, classes that override the QueryAssembler.getPathForSatelliteServer(com.fatwire.cs.core.uri.Definition.AppType) and QueryAssembler.getPathForApp(com.fatwire.cs.core.uri.Definition.AppType) methods will have to override this method as well.

Specified by:
getAppType in class AbstractAssembler
Parameters:
ctx - DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.
Returns:
AppType or null if ownership is foreign.

getQuery

protected java.util.Map getQuery(AbstractAssembler.DisassemblyContext ctx)
Return the query paramers from the URI. This implementation simply parses all query parameters and sets them into the requisite map. No validation occurs in this Assembler because all parameters are legal. Any class overriding AbstractAssembler.getQuery(AssemblyContext) will need to override this method as well.

Specified by:
getQuery in class AbstractAssembler
Parameters:
ctx - DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.
Returns:
map containing the query string params.