org.jasig.portal
Class UPFileSpec

java.lang.Object
  extended by org.jasig.portal.UPFileSpec

public class UPFileSpec
extends Object

This helper class allows for easy access to the information contained in the ever-changing uP file URL spec. The uP file syntax is likely to change often, therefore we encourage developers to use this class instead of trying to parse the uP file on your own.

Note: in case you're wondering what in the world "uP file" is, take a look at the portal URLs. The context path ends with a file-like specification that always has ".uP" at the end ... that's what we call a "uP" file. It is used to provide information on how different requests should be processed.

Current uP file syntax looks like this: "[tag.tagId.]{method}.methodId.[target.targetId.][*.]uP", where "[]" denote optional expressions and "{}" choice-defined expressions. The "{method}" field, at the moment has two choices: "render" and "worker".

uPortal will assume that the .uP file spec is always well-formed, so don't try to construct it on your own, use baseActionURL or one of the workerActionURLs.

Version:
$Revision: 19776 $
Author:
Peter Kharchenko pkharchenko@interactivebusiness.com"

Field Summary
static String DETACH_URL_ELEMENT
           
static String FILE_DOWNLOAD_WORKER
           
static String PORTAL_URL_SEPARATOR
           
static String PORTAL_URL_SUFFIX
           
static int RENDER_METHOD
           
static String RENDER_URL_ELEMENT
           
static String TARGET_URL_ELEMENT
           
static String USER_LAYOUT_ROOT_NODE
          Used to designate user layout root node in .uP files
static int WORKER_METHOD
           
static String WORKER_URL_ELEMENT
           
 
Constructor Summary
UPFileSpec()
          Creates a new UPFileSpec instance with all values being null.
UPFileSpec(HttpServletRequest req)
          Construct a .uP file spec object for a .uP file contained in a given request.
UPFileSpec(int method, String methodNodeId, String targetNodeId, String extraElements)
          A building constructor.
UPFileSpec(String uPFile)
          Construct a .uP file spec object by providing the actual .uP file string
UPFileSpec(UPFileSpec up)
          Copy constructor.
 
Method Summary
protected  void analyze(String uPFile)
           
static String buildUPFile(int method, String methodNodeId, String targetNodeId, String extraElements)
          Constructs a .uP file
static String buildUPFileBase(int method, String methodNodeId, String targetNodeId, String extraElements)
          Constructs a .uP file, without the suffix (actual ".uP") so it can be extended further.
protected static String buildUPFileBase(String method, String methodNodeId, String targetNodeId, String extraElements)
           
 String getMethod()
          Determine method name
 String getMethodNodeId()
          Determine Id specified by the method element.
 String getTargetNodeId()
          Determine Id specified by the "target" element.
 String getUPFile()
          Get the full .uP file String.
 String getUPFileExtras()
          Returns a "cleaned-up" version of the uP file with all known fields such as tag, method, and target, removed.
 void setMethod(int method)
          Set a method.
 void setMethodNodeId(String nodeId)
          Set method node id.
 void setTargetNodeId(String nodeId)
          Set target node id
 void setUPFileExtras(String extras)
          Set extras to be appended to the spec before the suffix element (".uP")
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_LAYOUT_ROOT_NODE

public static final String USER_LAYOUT_ROOT_NODE
Used to designate user layout root node in .uP files

See Also:
Constant Field Values

TARGET_URL_ELEMENT

public static final String TARGET_URL_ELEMENT
See Also:
Constant Field Values

WORKER_URL_ELEMENT

public static final String WORKER_URL_ELEMENT
See Also:
Constant Field Values

DETACH_URL_ELEMENT

public static final String DETACH_URL_ELEMENT
See Also:
Constant Field Values

RENDER_URL_ELEMENT

public static final String RENDER_URL_ELEMENT
See Also:
Constant Field Values

PORTAL_URL_SEPARATOR

public static final String PORTAL_URL_SEPARATOR
See Also:
Constant Field Values

PORTAL_URL_SUFFIX

public static final String PORTAL_URL_SUFFIX
See Also:
Constant Field Values

FILE_DOWNLOAD_WORKER

public static final String FILE_DOWNLOAD_WORKER
See Also:
Constant Field Values

RENDER_METHOD

public static final int RENDER_METHOD
See Also:
Constant Field Values

WORKER_METHOD

public static final int WORKER_METHOD
See Also:
Constant Field Values
Constructor Detail

UPFileSpec

public UPFileSpec()
Creates a new UPFileSpec instance with all values being null.


UPFileSpec

public UPFileSpec(HttpServletRequest req)
Construct a .uP file spec object for a .uP file contained in a given request.

Parameters:
req - a HttpServletRequest value

UPFileSpec

public UPFileSpec(String uPFile)
Construct a .uP file spec object by providing the actual .uP file string

Parameters:
uPFile - a String value

UPFileSpec

public UPFileSpec(UPFileSpec up)
Copy constructor.

Parameters:
up - an UPFileSpec value to copy the values from

UPFileSpec

public UPFileSpec(int method,
                  String methodNodeId,
                  String targetNodeId,
                  String extraElements)
           throws PortalException
A building constructor.

Parameters:
method - a method String value (required, must be one of the UPFileSpec.*_METHOD constants, i.e. RENDER_METHOD or WORKER_METHOD)
methodNodeId - a method node id String value (required value, can not be null)
targetNodeId - a target id String value (can be null)
extraElements - a String to be incorporated into the file name before the suffix (".uP"). These values will be available from the getUPFileExtras() result when .uP file is parsed. (can be null)
Throws:
PortalException - if an invalid method code is passed or no methodNodeId is present.
Method Detail

setMethod

public void setMethod(int method)
               throws PortalException
Set a method.

Parameters:
method - a method String value (required, must be one of the UPFileSpec.*_METHOD constants, i.e. RENDER_METHOD or WORKER_METHOD)
Throws:
PortalException - if an invalid method id is passed.

setMethodNodeId

public void setMethodNodeId(String nodeId)
Set method node id.

Parameters:
nodeId - a String value

setTargetNodeId

public void setTargetNodeId(String nodeId)
Set target node id

Parameters:
nodeId - a String value

setUPFileExtras

public void setUPFileExtras(String extras)
Set extras to be appended to the spec before the suffix element (".uP")

Parameters:
extras - a String value

getMethod

public String getMethod()
Determine method name

Returns:
a String method name, null if no method was specified.

getMethodNodeId

public String getMethodNodeId()
Determine Id specified by the method element.

Returns:
a String method node Id value, null if no method was specified.

getTargetNodeId

public String getTargetNodeId()
Determine Id specified by the "target" element.

Returns:
a String target Id value, null if no target was specified.

getUPFile

public String getUPFile()
                 throws PortalException
Get the full .uP file String.

Returns:
a String value
Throws:
PortalException

getUPFileExtras

public String getUPFileExtras()
Returns a "cleaned-up" version of the uP file with all known fields such as tag, method, and target, removed. This can be used by...

Returns:
a String value, null if none were encountered.

buildUPFile

public static String buildUPFile(int method,
                                 String methodNodeId,
                                 String targetNodeId,
                                 String extraElements)
                          throws PortalException
Constructs a .uP file

Parameters:
method - a method String value (required, must be one of the UPFileSpec.*_METHOD constants, i.e. RENDER_METHOD or WORKER_METHOD)
methodNodeId - a method node id String value (required value, can not be null)
targetNodeId - a target id String value (can be null)
extraElements - a String to be incorporated into the file name before the suffix (".uP"). These values will be available from the getUPFileExtras() result when .uP file is parsed. (can be null)
Returns:
a String value
Throws:
PortalException - if an invalid method code is passed or no methodNodeId is present.

buildUPFileBase

public static String buildUPFileBase(int method,
                                     String methodNodeId,
                                     String targetNodeId,
                                     String extraElements)
                              throws PortalException
Constructs a .uP file, without the suffix (actual ".uP") so it can be extended further.

Parameters:
method - a method String value (required, must be one of the UPFileSpec.*_METHOD constants, i.e. RENDER_METHOD or WORKER_METHOD)
methodNodeId - a method node id String value (required value, can not be null)
targetNodeId - a target id String value (can be null)
extraElements - a String to be incorporated into the file name before the suffix (".uP"). These values will be available from the getUPFileExtras() result when .uP file is parsed. (can be null)
Returns:
a String value
Throws:
PortalException - if an invalid method code is passed or no methodNodeId is present.

buildUPFileBase

protected static String buildUPFileBase(String method,
                                        String methodNodeId,
                                        String targetNodeId,
                                        String extraElements)
                                 throws PortalException
Throws:
PortalException

analyze

protected void analyze(String uPFile)


Copyright © 2010 Jasig. All Rights Reserved.