public abstract class AbstractAssembler extends Object implements Assembler
QueryAssembler
class is the primary implementation and is most likely the first place to start in developing a custom assembler.Assembler
, QueryAssembler
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractAssembler.AssemblyContext
This class is a wrapper over the
Definition object. |
protected static class |
AbstractAssembler.DisassemblyContext
This class is a wrapper over the incoming URI that contains an accessor to arbitrary context parameters that extending classes can specify.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
PAGENAME
This string corresponds to the required variable for the Content Server app type, pagename.
|
BASE_NAME, 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
Modifier | Constructor and Description |
---|---|
protected |
AbstractAssembler()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
URI |
assemble(Definition def)
Constructs a URI from the Definition provided.
|
protected String |
decode(String string)
URLDecodes a string using the encoding specified by this class.
|
protected String |
decode(String string, String encoding)
URLDecodes a string using the encoding specified.
|
Definition |
disassemble(URI uri, Definition.ContainerType ct)
Constructs a Definition from the URI provided, using the container type specified.
|
protected String |
encode(String string)
URLEncodes a string using the encoding specified by this class.
|
protected abstract Definition.AppType |
getAppType(AbstractAssembler.DisassemblyContext ctx)
Return the AppType for the URI specified.
|
protected AbstractAssembler.AssemblyContext |
getAssemblyContext(Definition def)
Returns an assembly context object given the input definition.
|
protected abstract String |
getAuthority(AbstractAssembler.AssemblyContext ctx)
Returns the authority (host and port) for the assembly context specified.
|
protected abstract String |
getAuthority(AbstractAssembler.DisassemblyContext ctx)
Returns the authority (host:port etc) for the URI specified
|
protected AbstractAssembler.DisassemblyContext |
getDisassemblyContext(URI uri) |
protected abstract String |
getFragment(AbstractAssembler.AssemblyContext ctx)
Get the fragment corresponding to this assembly context.
|
protected abstract String |
getFragment(AbstractAssembler.DisassemblyContext ctx)
Returns the fragment for the uri specified
|
protected org.apache.commons.logging.Log |
getLog()
Return a Log object that is appropriate for use with this component.
|
protected abstract String |
getPath(AbstractAssembler.AssemblyContext ctx)
Returns the path for the assembly context specified.
|
protected String |
getProperty(String name, String dephault)
Get the property value of a specified property.
|
protected abstract String |
getQuery(AbstractAssembler.AssemblyContext ctx)
This method returns the query string for the URI given the assembly context specified.
|
protected abstract Map |
getQuery(AbstractAssembler.DisassemblyContext ctx)
Returns a map of query name/value pairs for the URI specified.
|
protected abstract Definition.SatelliteContext |
getSatelliteContext(AbstractAssembler.DisassemblyContext ctx)
Return the Satellite Context for this Definition
|
protected abstract String |
getScheme(AbstractAssembler.AssemblyContext ctx)
Returns the scheme (protocol) for the assembly context specified.
|
protected abstract String |
getScheme(AbstractAssembler.DisassemblyContext ctx)
Return the scheme (http, https, etc.) for the URI specified
|
protected abstract boolean |
getSessionEncode(AbstractAssembler.DisassemblyContext ctx)
Get the session encode flag for this Definition.
|
protected Map<String,String[]> |
parseQueryString(String qry)
Parse a query string and put the parameters into a map.
|
void |
setProperties(Properties props)
Sets the properties into the assembler.
|
protected static final String PAGENAME
protected AbstractAssembler()
protected final org.apache.commons.logging.Log getLog()
public final void setProperties(Properties props)
Assembler
, and they contain information about the url path for each app type. Some containers may not permit the use of a url base, in which case the property value supplied will be null. Property values do not need to be unique. This method must be called by all Assemblers before any other Assembler methods are called.setProperties
in interface Assembler
props
- The propertiesprotected final String getProperty(String name, String dephault)
name
- property namedephault
- default property value or nullpublic URI assemble(Definition def) throws URISyntaxException
assemble
in interface Assembler
def
- definitionURISyntaxException
- throws URISyntaxExceptionAbstractAssembler.encode(String)
, AbstractAssembler.decode(String)
protected abstract String getScheme(AbstractAssembler.AssemblyContext ctx)
ctx
- Assembly context objectprotected abstract String getAuthority(AbstractAssembler.AssemblyContext ctx)
ctx
- Assembly context objectprotected abstract String getPath(AbstractAssembler.AssemblyContext ctx)
AbstractAssembler.assemble(com.fatwire.cs.core.uri.Definition)
.ctx
- Assembly context objectprotected abstract String getQuery(AbstractAssembler.AssemblyContext ctx)
ctx
- Assembly context objectEncode provides a helpful method for quoting illegal characters in the query string.
protected abstract String getFragment(AbstractAssembler.AssemblyContext ctx)
AbstractAssembler.assemble(com.fatwire.cs.core.uri.Definition)
.ctx
- Assembly context objectprotected AbstractAssembler.AssemblyContext getAssemblyContext(Definition def)
def
- input definitionAbstractAssembler.AssemblyContext
public Definition disassemble(URI uri, Definition.ContainerType ct) throws URISyntaxException
AbstractAssembler.DisassemblyContext
object as the argument. If through the decoding process, a method determines that the URI provided does not correspond to the current assembler, the assembler should set the ownership to foreign. This will prevent any further processing (and it is more efficient than throwing an exception). Methods are called in the following order:
AbstractAssembler.getDisassemblyContext(URI)
AbstractAssembler.getQuery(DisassemblyContext)
AbstractAssembler.getAppType(DisassemblyContext)
AbstractAssembler.getSatelliteContext(DisassemblyContext)
AbstractAssembler.getSessionEncode(DisassemblyContext)
AbstractAssembler.getScheme(DisassemblyContext)
AbstractAssembler.getAuthority(DisassemblyContext)
AbstractAssembler.getFragment(DisassemblyContext)
disassemble
in interface Assembler
uri
- a URIct
- the container type to be set in the returned DefinitionURISyntaxException
- throws URISyntaxExceptionDefinition
, Definition.ContainerType
protected abstract boolean getSessionEncode(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract Definition.SatelliteContext getSatelliteContext(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract String getScheme(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract String getAuthority(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract String getFragment(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract Definition.AppType getAppType(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected AbstractAssembler.DisassemblyContext getDisassemblyContext(URI uri)
protected abstract Map getQuery(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected final String encode(String string)
string
- a StringIllegalStateException
- if UTF-8 encoding is not supported and the platform's default encoding is not supported.protected final String decode(String string)
string
- encoded stringIllegalStateException
- if UTF-8 encoding is not supported and the platform's default encoding is not supported.IllegalArgumentException
- if the string is not well-formed for decoding.protected final String decode(String string, String encoding)
string
- encoded stringencoding
- the encoding to use to decode the string. If null is specified, the decoding specified by this class shall be used.IllegalStateException
- if the encoding specified is not supported, or if UTF-8 encoding is not supported and the platform's default encoding is not supported.IllegalArgumentException
- if the string is not well-formed for decoding.protected final Map<String,String[]> parseQueryString(String qry)
qry
- query stringIllegalArgumentException
- if there are mistakes in the string that make it impossible to parse.