org.apache.imperius.spl.datastore.impl
Class PolicyDataStoreImpl

java.lang.Object
  extended by org.apache.imperius.spl.datastore.impl.PolicyDataStoreImpl
All Implemented Interfaces:
PolicyDataStore

public class PolicyDataStoreImpl
extends java.lang.Object
implements PolicyDataStore

Implementation of PolicyDataStore that stores policies using serialization to the file PolicyStorage.DAT in the SPLLogger's home directory.


Method Summary
 boolean createPolicy(java.lang.String policyName, java.lang.String policyString)
          Store the given policy and give it the given name.
 SPLPolicy createSPLPolicyObject(java.lang.String policyName, java.lang.String policyString)
          Store the policy using the given name and create the Java object representing a parsed policy.
 void deletePolicy(java.lang.String policyName)
          Remove the named policy from the repository.
 java.util.Map getAllPolicies()
          Get a map of all policies mapped from the name of the policy to the policy string.
 java.util.List getAllPolicyNames()
           
static PolicyDataStoreImpl getInstance()
           
 SPLPolicy getInternalPolicyObject(java.lang.String policyRuleName)
          Get the java object representation of the parsed policy associated with the given name.
 java.lang.String getPolicy(java.lang.String policyRuleName)
          Get the policy with the given name.
 PolicyInfo getPolicyInfo(java.lang.String policyRuleName)
          Parse the given policy with the given name and provide the information about the policy.
 void init()
          Initialize the storage.
 void shutdown()
          Signal that the storage is no longer needed.
 void updatePolicy(java.lang.String policyRuleName, java.lang.String policyString)
          Replace the definition of the policy with the given name.
 boolean validatePolicyString(java.lang.String policyString)
          Determine if the given policy string is properly formatted and parsable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public void init()
Description copied from interface: PolicyDataStore
Initialize the storage. Calls to access/add policies before this may throw exceptions or otherwise fail.

Specified by:
init in interface PolicyDataStore

getInstance

public static PolicyDataStoreImpl getInstance()

shutdown

public void shutdown()
Description copied from interface: PolicyDataStore
Signal that the storage is no longer needed. Calls to access/add policies after this call and before a call to PolicyDataStore.init() may fail.

Specified by:
shutdown in interface PolicyDataStore

createPolicy

public boolean createPolicy(java.lang.String policyName,
                            java.lang.String policyString)
                     throws SPLException
Description copied from interface: PolicyDataStore
Store the given policy and give it the given name.

Specified by:
createPolicy in interface PolicyDataStore
Returns:
true if stored successfully.
Throws:
SPLException

deletePolicy

public void deletePolicy(java.lang.String policyName)
                  throws SPLException
Description copied from interface: PolicyDataStore
Remove the named policy from the repository.

Specified by:
deletePolicy in interface PolicyDataStore
Parameters:
policyName - name of the policy.
Throws:
SPLException - if the named policy does not exist.

getAllPolicies

public java.util.Map getAllPolicies()
                             throws SPLException
Description copied from interface: PolicyDataStore
Get a map of all policies mapped from the name of the policy to the policy string.

Specified by:
getAllPolicies in interface PolicyDataStore
Returns:
Throws:
SPLException

getAllPolicyNames

public java.util.List getAllPolicyNames()
                                 throws SPLException
Specified by:
getAllPolicyNames in interface PolicyDataStore
Throws:
SPLException

getInternalPolicyObject

public SPLPolicy getInternalPolicyObject(java.lang.String policyRuleName)
                                  throws SPLException
Description copied from interface: PolicyDataStore
Get the java object representation of the parsed policy associated with the given name.

Specified by:
getInternalPolicyObject in interface PolicyDataStore
Returns:
Throws:
SPLException

getPolicy

public java.lang.String getPolicy(java.lang.String policyRuleName)
                           throws SPLException
Description copied from interface: PolicyDataStore
Get the policy with the given name.

Specified by:
getPolicy in interface PolicyDataStore
Returns:
a policy string, never null.
Throws:
SPLException

updatePolicy

public void updatePolicy(java.lang.String policyRuleName,
                         java.lang.String policyString)
                  throws SPLException
Description copied from interface: PolicyDataStore
Replace the definition of the policy with the given name.

Specified by:
updatePolicy in interface PolicyDataStore
policyString - new policy definition.
Throws:
SPLException

getPolicyInfo

public PolicyInfo getPolicyInfo(java.lang.String policyRuleName)
                         throws SPLException
Description copied from interface: PolicyDataStore
Parse the given policy with the given name and provide the information about the policy.

Specified by:
getPolicyInfo in interface PolicyDataStore
Returns:
Throws:
SPLException

createSPLPolicyObject

public SPLPolicy createSPLPolicyObject(java.lang.String policyName,
                                       java.lang.String policyString)
                                throws SPLException
Description copied from interface: PolicyDataStore
Store the policy using the given name and create the Java object representing a parsed policy.

Specified by:
createSPLPolicyObject in interface PolicyDataStore
Returns:
Throws:
SPLException

validatePolicyString

public boolean validatePolicyString(java.lang.String policyString)
                             throws SPLException
Description copied from interface: PolicyDataStore
Determine if the given policy string is properly formatted and parsable.

Specified by:
validatePolicyString in interface PolicyDataStore
Parameters:
policyString - the SPL policy.
Returns:
true if the the string is parsable, false otherwise.
Throws:
SPLException - // TODO: why do we need to throw an exception here?