issrg.utils.xml
Class OldPolicyFormatCompat

java.lang.Object
  extended by issrg.utils.xml.OldPolicyFormatCompat

public final class OldPolicyFormatCompat
extends java.lang.Object

This utility class provides helper methods to provide compatibility with the code that used attributes converted to elements by TAP design document v0.7. The class exactly adheres to the patterns used in the code. Hence the ability of this class to produce and consumes old data structures and comma separated lists in strings.

Author:
Dmitry Bragin

Method Summary
static java.lang.String[] getAllowedActions(org.w3c.dom.Element targetElement)
          Get the list of allowed actions on a target as an array.
static java.util.List<java.lang.String> getAllowedActions(org.w3c.dom.Element target, org.w3c.dom.Element actionPolicy)
          Computes a List of the names of the allowed actions on the specified target element.
static java.util.Enumeration<java.lang.String> getAllowedActionsEnumeration(org.w3c.dom.Element target, org.w3c.dom.Element actionPolicy)
          Gets an enumeration of the names of the allowed actions on a given target element.
static java.lang.String getAllowedActionsOldFormat(org.w3c.dom.Element targetElement)
          Get the list of allowed actions on a target in the old style format - as a comma delimited string.
static java.lang.String getAllowedActionsOldFormat(org.w3c.dom.Element targetElement, org.w3c.dom.Element actionPolicy)
          Computes a string containing the list of the names allowed actions on a target in the old style format - as a comma delimited string.
static java.lang.String getAllowedActionsOldFormat(PolicyXMLNode targetElement)
          Get the list of allowed actions on a target in the old style format - as a comma delimited string.
static java.lang.String getArgumentNamesOldFormat(org.w3c.dom.Element actionElment)
          Get the list of argument names on an action in the old style format - as a comma delimited string.
static java.lang.String getArgumentsOldFormat(PolicyXMLNode actionElement)
          Get the list of argument names on an action in the old style format - comma delimited string.
static java.lang.String getArgumentTypesOldFormat(org.w3c.dom.Element actionElment)
          Get the list of argument types on an action in the old style format - as a comma delimited string.
static java.util.List<java.lang.String> getIdFromName(org.w3c.dom.Element actionPolicy, java.util.List<java.lang.String> names)
          Computes a list of IDs corresponding to the given list of names.
static java.lang.String getIdFromName(org.w3c.dom.Element actionPolicy, java.lang.String name)
          Returns the ID corresponding to a given action name.
static java.lang.String[] getIDsOfAllowedActions(org.w3c.dom.Element targetElement)
          Get the list of the IDs of the allowed actions on a target as an array.
static java.lang.String[] getIDsOfAllowedActions(PolicyXMLNode targetNode)
          Get the list of the IDs of the allowed actions on a target as an array.
static java.lang.String getNameFromId(org.w3c.dom.Element actionPolicy, java.lang.String id)
          Computes the name of an action given its ID attribute according to a given ActionPolicy element.
static java.lang.String getTargetDomainsOldFormat(org.w3c.dom.Element actionElement)
          Get the list of target domains on an action in the old style format - as a comma delimited string.
static void setActions(org.w3c.dom.Document document, org.w3c.dom.Element targetElement, java.lang.String commaSeparatedActions)
          Create or update list of allowed actions on a target.
static void setActions(org.w3c.dom.Document document, org.w3c.dom.Element targetElement, java.lang.String[] actions)
          Create or update list of allowed actions on a target.
static void setArguments(org.w3c.dom.Document document, org.w3c.dom.Element actionElement, java.lang.String[] args)
          Create or update list of argument names on an action.
static void setArguments(org.w3c.dom.Document document, org.w3c.dom.Element parentElement, java.lang.String args, java.lang.String types)
          Create or update list of arguments on an action.
static void setTargetDomains(org.w3c.dom.Document document, org.w3c.dom.Element actionElement, java.lang.String targetDomainsCommaSeparated)
          Set the list of targetdomains on an action using a comma separated string as parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAllowedActions

public static java.lang.String[] getAllowedActions(org.w3c.dom.Element targetElement)
Get the list of allowed actions on a target as an array.

Parameters:
targetElement - the element to get the allowed actions for
Returns:
list of allowed actions on a target as an array

getIDsOfAllowedActions

public static java.lang.String[] getIDsOfAllowedActions(org.w3c.dom.Element targetElement)
Get the list of the IDs of the allowed actions on a target as an array.

Parameters:
targetElement - the element to get the allowed actions for
Returns:
list of IDs of allowed actions on a target as an array

getIDsOfAllowedActions

public static java.lang.String[] getIDsOfAllowedActions(PolicyXMLNode targetNode)
Get the list of the IDs of the allowed actions on a target as an array.

Parameters:
targetNode - the node to get the IDs of the allowed actions for
Returns:
list of IDs of allowed actions on a target as an array

getAllowedActions

public static java.util.List<java.lang.String> getAllowedActions(org.w3c.dom.Element target,
                                                                 org.w3c.dom.Element actionPolicy)
Computes a List of the names of the allowed actions on the specified target element. An element specifying the action policy is needed to convert the ID attributes on the target elements to the Name attributes of the actions.

Parameters:
target - the specified Target element
actionPolicy - the specified ActionPolicy element
Returns:
a List containing the names of the allowed actions on this target element

getIdFromName

public static java.lang.String getIdFromName(org.w3c.dom.Element actionPolicy,
                                             java.lang.String name)
Returns the ID corresponding to a given action name.

Parameters:
actionPolicy - an element representing the action policy
name - the name of the action for which the ID is to be looked up.
Returns:
the ID attribute of the corresponding element. Returns null if no Action element with the specified name attribute is present. The empty string is returned when such an element exists, but has an empty ID attribute.

getNameFromId

public static java.lang.String getNameFromId(org.w3c.dom.Element actionPolicy,
                                             java.lang.String id)
Computes the name of an action given its ID attribute according to a given ActionPolicy element.

Parameters:
actionPolicy - the ActionPolicy element
id - the ID attribute of the action for which the name is to be computed
Returns:
the name of action with the given ID attribute. Null if an action with the given ID attribute does not exist.

getIdFromName

public static java.util.List<java.lang.String> getIdFromName(org.w3c.dom.Element actionPolicy,
                                                             java.util.List<java.lang.String> names)
Computes a list of IDs corresponding to the given list of names. The returned list is of the same length as the input list. If the ID attribute is missing, the result is an empty string. If the name simply doesn't exist, the corresponding entry is null.

Parameters:
actionPolicy - an element representing the action policy
names - list of name attributes to look up. Should not be null.
Returns:
list of ID attributes corresponding to the list of name attributes.

getAllowedActionsEnumeration

public static java.util.Enumeration<java.lang.String> getAllowedActionsEnumeration(org.w3c.dom.Element target,
                                                                                   org.w3c.dom.Element actionPolicy)
Gets an enumeration of the names of the allowed actions on a given target element.

Parameters:
target - the Target element for which to get the allowed actions
actionPolicy - the ActionPolicy element to use to compute the mapping from ID attributes to the actual action names
Returns:
an enumeration of strings representing the names of the allowed actions on the given Target element
See Also:
getAllowedActions(Element, Element)

getArgumentsOldFormat

public static java.lang.String getArgumentsOldFormat(PolicyXMLNode actionElement)
Get the list of argument names on an action in the old style format - comma delimited string. Escaping of ',' is properly handled.

Parameters:
actionElement - the element to get the arguments for
Returns:
list of arguments on an action in the old style format - comma delimited string

getAllowedActionsOldFormat

public static java.lang.String getAllowedActionsOldFormat(PolicyXMLNode targetElement)
Get the list of allowed actions on a target in the old style format - as a comma delimited string. Escaping of ',' is properly handled. This is an overloaded version of the method to work with the policy parsing code.

Parameters:
targetElement - the Target element to get the allowed actions for
Returns:
list of allowed actions on a target in the old style format - comma delimited string

getAllowedActionsOldFormat

public static java.lang.String getAllowedActionsOldFormat(org.w3c.dom.Element targetElement)
Get the list of allowed actions on a target in the old style format - as a comma delimited string. Escaping of ',' is properly handled.

Parameters:
targetElement - the Target element to get the allowed actions for
Returns:
list of allowed actions on a target in the old style format - comma delimited string

getAllowedActionsOldFormat

public static java.lang.String getAllowedActionsOldFormat(org.w3c.dom.Element targetElement,
                                                          org.w3c.dom.Element actionPolicy)
Computes a string containing the list of the names allowed actions on a target in the old style format - as a comma delimited string. Escaping of ',' is properly handled.

Parameters:
targetElement - the Target element to get the allowed actions for
actionPolicy - the ActionPolicy element used to get the action names from the ID attributes
Returns:
list of allowed actions on a target in the old style format - comma delimited string

getArgumentNamesOldFormat

public static java.lang.String getArgumentNamesOldFormat(org.w3c.dom.Element actionElment)
Get the list of argument names on an action in the old style format - as a comma delimited string. Escaping of ',' is properly handled.

Parameters:
actionElment - the Action element to get the arguments for
Returns:
list of argument names on an action in the old style format - comma delimited string

getTargetDomainsOldFormat

public static java.lang.String getTargetDomainsOldFormat(org.w3c.dom.Element actionElement)
Get the list of target domains on an action in the old style format - as a comma delimited string. Escaping of ',' is properly handled.

Parameters:
actionElement - the Action element to get the targets for
Returns:
list of targets on an action in the old style format - comma delimited string

setTargetDomains

public static void setTargetDomains(org.w3c.dom.Document document,
                                    org.w3c.dom.Element actionElement,
                                    java.lang.String targetDomainsCommaSeparated)
Set the list of targetdomains on an action using a comma separated string as parameter.

Parameters:
document - parent document
actionElement - The Action Element
targetDomainsCommaSeparated - separated list of target domains

getArgumentTypesOldFormat

public static java.lang.String getArgumentTypesOldFormat(org.w3c.dom.Element actionElment)
Get the list of argument types on an action in the old style format - as a comma delimited string. Escaping of ',' is properly handled.

Parameters:
actionElment - the Action element to get the arguments for
Returns:
list of argument types on an action in the old style format - comma delimited string

setActions

public static void setActions(org.w3c.dom.Document document,
                              org.w3c.dom.Element targetElement,
                              java.lang.String commaSeparatedActions)
Create or update list of allowed actions on a target.

Parameters:
document - parent document
actionElement - the Target element
commaSeparatedActions - comma separated list of allowed actions as specified by permis

setActions

public static void setActions(org.w3c.dom.Document document,
                              org.w3c.dom.Element targetElement,
                              java.lang.String[] actions)
Create or update list of allowed actions on a target.

Parameters:
document - parent document
actionElement - the Target element
args - array of argument names

setArguments

public static void setArguments(org.w3c.dom.Document document,
                                org.w3c.dom.Element actionElement,
                                java.lang.String[] args)
Create or update list of argument names on an action.

Parameters:
document - parent document
actionElement - the Action element
args - array of argument names

setArguments

public static void setArguments(org.w3c.dom.Document document,
                                org.w3c.dom.Element parentElement,
                                java.lang.String args,
                                java.lang.String types)
Create or update list of arguments on an action.

Parameters:
document - parent document
actionElement - the Action element
args - comma separated list of argument names
types - comma separated list of type names