juergen 2003/07/16 00:36:25
Modified: src/share/org/apache/slide/common NamespaceConfig.java
Log:
1) userpath et. al. are now available during the init phase too
2) minor refactoring
Revision Changes Path
1.25 +355 -493
jakarta-slide/src/share/org/apache/slide/common/NamespaceConfig.java
Index: NamespaceConfig.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/NamespaceConfig.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- NamespaceConfig.java 17 May 2002 15:49:51 -0000 1.24
+++ NamespaceConfig.java 16 Jul 2003 07:36:25 -0000 1.25
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Slide", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
@@ -59,7 +59,7 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.slide.common;
@@ -79,16 +79,16 @@
/**
* Configuration of the Namespace.
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
* @version $Revision$
*/
public final class NamespaceConfig {
-
-
+
+
// -------------------------------------------------------------- Constants
-
-
+
+
/**
* Base role names.
*/
@@ -97,411 +97,411 @@
public static final String BASE_ROLE = SubjectNode.class.getName();
public static final String ACTION_ROLE = ActionNode.class.getName();
public static final String LINK_ROLE = LinkNode.class.getName();
-
-
+
+
// ----------------------------------------------------- Instance Variables
-
-
+
+
/**
* Namespace name.
*/
protected String name;
-
-
+
+
/**
* Default action.
*/
protected ActionNode defaultAction;
-
-
+
+
/**
* Read object action.
*/
protected ActionNode readObjectAction;
-
-
+
+
/**
* Create object action. Equivalent to createChildAction.
*/
protected ActionNode createObjectAction;
-
-
+
+
/**
* Remove object action.
*/
protected ActionNode removeObjectAction;
-
-
+
+
/**
* Grant permission action.
*/
protected ActionNode grantPermissionAction;
-
-
+
+
/**
* Revoke permission action.
*/
protected ActionNode revokePermissionAction;
-
-
+
+
/**
* Read permissions action.
*/
protected ActionNode readPermissionsAction;
-
-
+
+
/**
* Lock object action.
*/
protected ActionNode lockObjectAction;
-
-
+
+
/**
* Kill lock action.
*/
protected ActionNode killLockAction;
-
-
+
+
/**
* Read locks action.
*/
protected ActionNode readLocksAction;
-
-
+
+
/**
* Create revision metadata action.
*/
protected ActionNode createRevisionMetadataAction;
-
-
+
+
/**
* Modify revision metadata action.
*/
protected ActionNode modifyRevisionMetadataAction;
-
-
+
+
/**
* Remove revision metadata action.
*/
protected ActionNode removeRevisionMetadataAction;
-
-
+
+
/**
* Read revision metadata action.
*/
protected ActionNode readRevisionMetadataAction;
-
-
+
+
/**
* Read revision content action.
*/
protected ActionNode readRevisionContentAction;
-
-
+
+
/**
* Create revision content action.
*/
protected ActionNode createRevisionContentAction;
-
-
+
+
/**
* Modify revision content action.
*/
protected ActionNode modifyRevisionContentAction;
-
-
+
+
/**
* Remove revision content action.
*/
protected ActionNode removeRevisionContentAction;
-
-
+
+
/**
* Users path.
*/
protected String usersPath;
-
-
+
+
/**
* Guest user path.
*/
protected String guestPath;
-
-
+
+
/**
* File path.
*/
protected String filesPath;
-
-
+
+
/**
* Additional parameters.
*/
protected Hashtable parameters;
-
-
+
+
/**
* Role name -> role interface mappings.
* Note : One name is associated to only one interface.
*/
protected Hashtable roleMappings = new Hashtable();
-
-
+
+
/**
* Role interface -> role name mappings.
* Note : One interface can be associated to multiple names, in which case
* only one is stored here.
*/
protected Hashtable roleClassMappings = new Hashtable();
-
-
+
+
/**
* List of default properties.
* Role name -> Vector[NodeProperty].
*/
protected Hashtable defaultProperties;
-
-
+
+
/**
* Empty vector. Don't add stuff there.
*/
protected static Vector emptyVector = new Vector();
-
-
+
+
/**
* Content interceptors.
*/
- protected ContentInterceptor[] contentInterceptors
+ protected ContentInterceptor[] contentInterceptors
= new ContentInterceptor[0];
-
+
/**
* Automatically create users.
*/
protected boolean autoCreateUsers = false;
-
-
+
+
/**
* Roles implementation to be used for automatically created users.
*/
protected String autoCreateUsersRole = "slideroles.basic.UserRoleImpl";
-
-
+
+
// ------------------------------------------------------------- Properties
-
-
+
+
/**
* Default action accessor.
- *
+ *
* @return ActionNode Default action
*/
public ActionNode getDefaultAction() {
return defaultAction;
}
-
-
+
+
/**
* Read object action accessor.
- *
+ *
* @return ActionNode Read object action
*/
public ActionNode getReadObjectAction() {
return readObjectAction;
}
-
-
+
+
/**
* Create object action accessor.
- *
+ *
* @return ActionNode Create object action
*/
public ActionNode getCreateObjectAction() {
return createObjectAction;
}
-
-
+
+
/**
* Remove object accessor.
- *
+ *
* @return ActionNode Remove object action
*/
public ActionNode getRemoveObjectAction() {
return removeObjectAction;
}
-
-
+
+
/**
* Grant permission accessor.
- *
+ *
* @return ActionNode Grant permission action
*/
public ActionNode getGrantPermissionAction() {
return grantPermissionAction;
}
-
-
+
+
/**
* Revoke permission accessor.
- *
+ *
* @return ActionNode Revoke permission action
*/
public ActionNode getRevokePermissionAction() {
return revokePermissionAction;
}
-
-
+
+
/**
* Read permissions accessor.
- *
+ *
* @return ActionNode Read permissions action
*/
public ActionNode getReadPermissionsAction() {
return readPermissionsAction;
}
-
-
+
+
/**
* Lock object accessor.
- *
+ *
* @return ActionNode Lock object action
*/
public ActionNode getLockObjectAction() {
return lockObjectAction;
}
-
-
+
+
/**
* Kill lock accessor.
- *
+ *
* @return ActionNode Kill lock action
*/
public ActionNode getKillLockAction() {
return killLockAction;
}
-
-
+
+
/**
* Read locks accessor.
- *
+ *
* @return ActionNode Read locks action
*/
public ActionNode getReadLocksAction() {
return readLocksAction;
}
-
-
+
+
/**
* Create revision metadata accessor.
- *
+ *
* @return ActionNode Create revision metadata action
*/
public ActionNode getCreateRevisionMetadataAction() {
return createRevisionMetadataAction;
}
-
-
+
+
/**
* Read revision metadata accessor.
- *
+ *
* @return ActionNode Read revision metadata action
*/
public ActionNode getReadRevisionMetadataAction() {
return readRevisionMetadataAction;
}
-
-
+
+
/**
* Modify revision metadata accessor.
- *
+ *
* @return ActionNode Modify revision metadata action
*/
public ActionNode getModifyRevisionMetadataAction() {
return modifyRevisionMetadataAction;
}
-
-
+
+
/**
* Remove revision metadata accessor.
- *
+ *
* @return ActionNode Remove revision metadata action
*/
public ActionNode getRemoveRevisionMetadataAction() {
return removeRevisionMetadataAction;
}
-
-
+
+
/**
* Read revision content accessor.
- *
+ *
* @return ActionNode Read revision content action
*/
public ActionNode getReadRevisionContentAction() {
return readRevisionContentAction;
}
-
-
+
+
/**
* Create revision content accessor.
- *
+ *
* @return ActionNode Create revision content action
*/
public ActionNode getCreateRevisionContentAction() {
return createRevisionContentAction;
}
-
-
+
+
/**
* Modify revision content accessor.
- *
+ *
* @return ActionNode Modify revision content action
*/
public ActionNode getModifyRevisionContentAction() {
return modifyRevisionContentAction;
}
-
-
+
+
/**
* Remove revision content accessor.
- *
+ *
* @return ActionNode Remove revision content action
*/
public ActionNode getRemoveRevisionContentAction() {
return removeRevisionContentAction;
}
-
-
+
+
/**
* Users path accessor.
- *
+ *
* @return String Users path
*/
public String getUsersPath() {
return usersPath;
}
-
-
+
+
/**
* Guest path accessor.
- *
+ *
* @return String Guest path
*/
public String getGuestPath() {
return guestPath;
}
-
-
+
+
/**
* Files path accessor.
- *
+ *
* @return String Files path
*/
public String getFilesPath() {
return filesPath;
}
-
-
+
+
/**
* Get default properties for a given role.
- *
+ *
* @return Enumeration of properties
*/
public Enumeration getDefaultProperties(String role) {
@@ -511,22 +511,22 @@
else
return result.elements();
}
-
-
+
+
/**
* Get content interceptors.
*/
ContentInterceptor[] getContentInterceptors() {
return contentInterceptors;
}
-
-
+
+
// --------------------------------------------------------- Public Methods
-
-
+
+
/**
* Get parameter value.
- *
+ *
* @param name Parameter name
* @return String Parameter value
*/
@@ -538,12 +538,12 @@
return (String) result;
}
}
-
-
+
+
/**
- * Get role mapping. If the interface name is given, one of the names is
+ * Get role mapping. If the interface name is given, one of the names is
* returned. If the name is given, the interface name is returned.
- *
+ *
* @param name Role name (or interface name)
* @return String Role interface name (or name)
*/
@@ -555,16 +555,16 @@
return (String) result;
}
}
-
-
+
+
/**
* Is automcatic user creation active ?
*/
public boolean isAutoCreateUsers() {
return autoCreateUsers;
}
-
-
+
+
/**
* Get the class name of the role which will be used to create nodes which
* are automatically created when isAutoCreateUsers() returns true.
@@ -572,263 +572,66 @@
public String getAutoCreateUsersRole() {
return autoCreateUsersRole;
}
-
-
+
+
// -------------------------------------------------------- Package Methods
-
-
+
+
/**
- * Initialize the Namespace configuration using the given Configuration
+ * Initialize the Namespace configuration using the given Configuration
* object.
- *
+ *
* @param namespace Namespace on which we are trying to load the config
* @param config Castor Config object
- * @exception InvalidNamespaceConfigurationException Namespace
+ * @exception InvalidNamespaceConfigurationException Namespace
* configuration is invalid
* @exception SlideException One of the action nodes doesn't exist
*/
void initializeNamespaceConfig(Namespace namespace, Configuration config)
throws InvalidNamespaceConfigurationException, SlideException {
-
+
name = namespace.getName();
-
- try {
- defaultAction =
- getActionNode(namespace, config.getConfiguration
- ("default-action").getValue());
- } catch (ConfigurationException e) {
- throw new InvalidNamespaceConfigurationException
- (namespace, e.getMessage());
- }
-
- try {
- readObjectAction =
- getActionNode(namespace, config.getConfiguration
- ("read-object").getValue());
- } catch (ConfigurationException e) {
- readObjectAction = defaultAction;
- }
-
- try {
- createObjectAction =
- getActionNode(namespace, config.getConfiguration
- ("create-object").getValue());
- } catch (ConfigurationException e) {
- createObjectAction = defaultAction;
- }
-
- try {
- removeObjectAction =
- getActionNode(namespace, config.getConfiguration
- ("remove-object").getValue());
- } catch (ConfigurationException e) {
- removeObjectAction = defaultAction;
- }
-
- try {
- grantPermissionAction =
- getActionNode(namespace, config.getConfiguration
- ("grant-permission").getValue());
- } catch (ConfigurationException e) {
- grantPermissionAction = defaultAction;
- }
-
- try {
- revokePermissionAction =
- getActionNode(namespace, config.getConfiguration
- ("revoke-permission").getValue());
- } catch (ConfigurationException e) {
- revokePermissionAction = defaultAction;
- }
-
- try {
- readPermissionsAction =
- getActionNode(namespace, config.getConfiguration
- ("read-permissions").getValue());
- } catch (ConfigurationException e) {
- readPermissionsAction = defaultAction;
- }
-
- try {
- lockObjectAction =
- getActionNode(namespace, config.getConfiguration
- ("lock-object").getValue());
- } catch (ConfigurationException e) {
- lockObjectAction = defaultAction;
- }
-
- try {
- killLockAction =
- getActionNode(namespace, config.getConfiguration
- ("kill-lock").getValue());
- } catch (ConfigurationException e) {
- killLockAction = defaultAction;
- }
-
- try {
- readLocksAction =
- getActionNode(namespace, config.getConfiguration
- ("read-locks").getValue());
- } catch (ConfigurationException e) {
- readLocksAction = defaultAction;
- }
-
- try {
- readRevisionMetadataAction =
- getActionNode(namespace, config.getConfiguration
- ("read-revision-metadata").getValue());
- } catch (ConfigurationException e) {
- readRevisionMetadataAction = defaultAction;
- }
-
- try {
- createRevisionMetadataAction =
- getActionNode(namespace, config.getConfiguration
- ("create-revision-metadata").getValue());
- } catch (ConfigurationException e) {
- createRevisionMetadataAction = defaultAction;
- }
-
- try {
- modifyRevisionMetadataAction =
- getActionNode(namespace, config.getConfiguration
- ("modify-revision-metadata").getValue());
- } catch (ConfigurationException e) {
- modifyRevisionMetadataAction = defaultAction;
- }
-
- try {
- removeRevisionMetadataAction =
- getActionNode(namespace, config.getConfiguration
- ("remove-revision-metadata").getValue());
- } catch (ConfigurationException e) {
- removeRevisionMetadataAction = defaultAction;
- }
-
- try {
- readRevisionContentAction =
- getActionNode(namespace, config.getConfiguration
- ("read-revision-content").getValue());
- } catch (ConfigurationException e) {
- readRevisionContentAction = defaultAction;
- }
-
- try {
- createRevisionContentAction =
- getActionNode(namespace, config.getConfiguration
- ("create-revision-content").getValue());
- } catch (ConfigurationException e) {
- createRevisionContentAction = defaultAction;
- }
-
- try {
- modifyRevisionContentAction =
- getActionNode(namespace, config.getConfiguration
- ("modify-revision-content").getValue());
- } catch (ConfigurationException e) {
- modifyRevisionContentAction = defaultAction;
- }
-
- try {
- removeRevisionContentAction =
- getActionNode(namespace, config.getConfiguration
- ("remove-revision-content").getValue());
- } catch (ConfigurationException e) {
- removeRevisionContentAction = defaultAction;
- }
-
- try {
- usersPath = config.getConfiguration("userspath").getValue();
- } catch (ConfigurationException e) {
- usersPath = "";
- }
-
- try {
- guestPath = config.getConfiguration("guestpath").getValue();
- } catch (ConfigurationException e) {
- guestPath = "";
- }
-
- try {
- filesPath = config.getConfiguration("filespath").getValue();
- } catch (ConfigurationException e) {
- filesPath = "";
- }
-
- try {
- autoCreateUsers = Boolean.valueOf
- (config.getConfiguration("auto-create-users").getValue())
- .booleanValue();
- } catch (ConfigurationException e) {
- autoCreateUsers = false;
- }
-
- try {
- autoCreateUsersRole =
- config.getConfiguration("auto-create-users-role").getValue();
- } catch (ConfigurationException e) {
- }
-
- parameters = new Hashtable();
- Enumeration parametersDef = config.getConfigurations("parameter");
- try {
- while (parametersDef.hasMoreElements()) {
- Configuration parameter =
- (Configuration) parametersDef.nextElement();
- addParameter(parameter.getAttribute("name"),
- parameter.getValue());
- }
- } catch (ConfigurationException e) {
- throw new InvalidNamespaceConfigurationException
- (namespace, e.getMessage());
- }
-
- // Add basic role mappings
- addRoleMapping(NOBODY, NOBODY_ROLE);
- addRoleMapping(NOBODY, LINK_ROLE);
- addRoleMapping(NOBODY, ACTION_ROLE);
- // Note : the base role should be the last one.
- addRoleMapping(NOBODY, BASE_ROLE);
- Enumeration roleMappingsDef = config.getConfigurations("role");
- try {
- while (roleMappingsDef.hasMoreElements()) {
- Configuration roleMappingDef =
- (Configuration) roleMappingsDef.nextElement();
- addRoleMapping(roleMappingDef.getAttribute("name"),
- roleMappingDef.getValue());
- }
- } catch (ConfigurationException e) {
- throw new InvalidNamespaceConfigurationException
- (namespace, e.getMessage());
- }
-
- defaultProperties = new Hashtable();
- Enumeration defaultPropertiesDef =
- config.getConfigurations("default-property");
- try {
- while (defaultPropertiesDef.hasMoreElements()) {
- Configuration defaultProperty =
- (Configuration) defaultPropertiesDef.nextElement();
- String name = defaultProperty.getAttribute("name");
- String value = defaultProperty.getAttribute("value", "");
- String propertyNamespace = defaultProperty.getAttribute
- ("namespace", NodeProperty.DEFAULT_NAMESPACE);
- String role = defaultProperty.getAttribute("role");
- addDefaultProperty(role, name, value, propertyNamespace);
- }
- } catch (ConfigurationException e) {
- throw new InvalidNamespaceConfigurationException
- (namespace, e.getMessage());
- }
-
- Enumeration contentInteceptorsDef =
+
+ defaultAction = null;
+ defaultAction = getConfiguredNode(namespace, config, "default-action");
+ if (defaultAction == null)
+ throw new InvalidNamespaceConfigurationException(namespace, "Default
action could not be set");
+
+ readObjectAction = getConfiguredNode(namespace, config, "read-object");
+ createObjectAction = getConfiguredNode(namespace, config, "create-object");
+ removeObjectAction = getConfiguredNode(namespace, config, "remove-object");
+ grantPermissionAction = getConfiguredNode(namespace, config,
"grant-permission");
+ revokePermissionAction = getConfiguredNode(namespace, config,
"revoke-permission");
+ readPermissionsAction = getConfiguredNode(namespace, config,
"read-permissions");
+ lockObjectAction = getConfiguredNode(namespace, config, "lock-object");
+ killLockAction = getConfiguredNode(namespace, config, "kill-lock");
+ readLocksAction = getConfiguredNode(namespace, config, "read-locks");
+ readRevisionMetadataAction = getConfiguredNode(namespace, config,
"read-revision-metadata");
+ createRevisionMetadataAction = getConfiguredNode(namespace, config,
"create-revision-metadata");
+ modifyRevisionMetadataAction = getConfiguredNode(namespace, config,
"modify-revision-metadata");
+ removeRevisionMetadataAction = getConfiguredNode(namespace, config,
"remove-revision-metadata");
+ readRevisionContentAction = getConfiguredNode(namespace, config,
"read-revision-content");
+ createRevisionContentAction = getConfiguredNode(namespace, config,
"create-revision-content");
+ modifyRevisionContentAction = getConfiguredNode(namespace, config,
"modify-revision-content");
+ removeRevisionContentAction = getConfiguredNode(namespace, config,
"remove-revision-content");
+
+
+ setPathsAndConfigValues(config);
+
+ setParameters(config, namespace);
+
+ setRoles(config, namespace);
+
+ setDefaultProperties(config, namespace);
+
+ Enumeration contentInteceptorsDef =
config.getConfigurations("content-interceptor");
try {
while (contentInteceptorsDef.hasMoreElements()) {
Configuration contentInterceptorDef =
(Configuration) contentInteceptorsDef.nextElement();
String classname = contentInterceptorDef.getAttribute("class");
-
+
// Load contentInterceptor parameters
Enumeration contentInterceptorParametersDef =
contentInterceptorDef.getConfigurations("parameter");
@@ -836,21 +639,21 @@
while (contentInterceptorParametersDef.hasMoreElements()) {
Configuration parameterDefinition = (Configuration)
contentInterceptorParametersDef.nextElement();
- String parameterName =
+ String parameterName =
parameterDefinition.getAttribute("name");
String parameterValue = parameterDefinition.getValue();
contentInterceptorParameters.put(parameterName,
parameterValue);
}
-
+
try {
Class contentInterceptorClass =
Class.forName(classname);
- ContentInterceptor contentInterceptor =
- (ContentInterceptor)
+ ContentInterceptor contentInterceptor =
+ (ContentInterceptor)
contentInterceptorClass.newInstance();
contentInterceptor.setParameters(contentInterceptorParameters);
- ContentInterceptor[] tempArray =
+ ContentInterceptor[] tempArray =
new ContentInterceptor[contentInterceptors.length + 1];
for (int i = 0; i < contentInterceptors.length; i++) {
tempArray[i] = contentInterceptors[i];
@@ -864,8 +667,8 @@
classname, e.getMessage()), Logger.WARNING);
}
}
-
- // Initialize the content interceptors with the
+
+ // Initialize the content interceptors with the
// NamespaceAccessToken
NamespaceAccessToken nat = new NamespaceAccessTokenImpl(namespace);
ContentInterceptor[] contentInterceptors =
@@ -877,38 +680,117 @@
throw new InvalidNamespaceConfigurationException
(namespace, e.getMessage());
}
-
+
}
-
-
- /**
- * Initialize the Namespace configuration using the given Configuration
- * object.
- *
- * @param namespace Namespace on which we are trying to load the config
- * @param config Castor Config object
- * @exception InvalidNamespaceConfigurationException Namespace
- * configuration is invalid
- * @exception SlideException One of the action nodes doesn't exist
- */
- void initializeNamespaceParameters
- (Namespace namespace, Configuration config)
- throws InvalidNamespaceConfigurationException, SlideException {
-
+
+ private void setDefaultProperties(Configuration config, Namespace namespace)
throws InvalidNamespaceConfigurationException {
+ defaultProperties = new Hashtable();
+ Enumeration defaultPropertiesDef =
+ config.getConfigurations("default-property");
+ try {
+ while (defaultPropertiesDef.hasMoreElements()) {
+ Configuration defaultProperty =
+ (Configuration) defaultPropertiesDef.nextElement();
+ String name = defaultProperty.getAttribute("name");
+ String value = defaultProperty.getAttribute("value", "");
+ String propertyNamespace = defaultProperty.getAttribute
+ ("namespace", NodeProperty.DEFAULT_NAMESPACE);
+ String role = defaultProperty.getAttribute("role");
+ addDefaultProperty(role, name, value, propertyNamespace);
+ }
+ } catch (ConfigurationException e) {
+ throw new InvalidNamespaceConfigurationException
+ (namespace, e.getMessage());
+ }
+ }
+
+ private void setParameters(Configuration config, Namespace namespace) throws
InvalidNamespaceConfigurationException {
parameters = new Hashtable();
Enumeration parametersDef = config.getConfigurations("parameter");
try {
while (parametersDef.hasMoreElements()) {
- Configuration parameter =
+ Configuration parameter =
(Configuration) parametersDef.nextElement();
- addParameter(parameter.getAttribute("name"),
+ addParameter(parameter.getAttribute("name"),
parameter.getValue());
}
} catch (ConfigurationException e) {
throw new InvalidNamespaceConfigurationException
(namespace, e.getMessage());
}
-
+ }
+
+ private ActionNode getConfiguredNode(Namespace namespace, Configuration config,
String nodeName) throws SlideException {
+ ActionNode result = null;
+ try {
+ result = getActionNode(namespace, config.getConfiguration(
nodeName).getValue());
+ } catch (ConfigurationException e) {
+ result = defaultAction;
+ }
+ return result;
+ }
+
+ private void setPathsAndConfigValues(Configuration config) {
+ try {
+ usersPath = config.getConfiguration("userspath").getValue();
+ } catch (ConfigurationException e) {
+ usersPath = "";
+ }
+
+ try {
+ guestPath = config.getConfiguration("guestpath").getValue();
+ } catch (ConfigurationException e) {
+ guestPath = "";
+ }
+
+ try {
+ filesPath = config.getConfiguration("filespath").getValue();
+ } catch (ConfigurationException e) {
+ filesPath = "";
+ }
+
+ try {
+ autoCreateUsers = Boolean.valueOf
+ (config.getConfiguration("auto-create-users").getValue())
+ .booleanValue();
+ } catch (ConfigurationException e) {
+ autoCreateUsers = false;
+ }
+
+ try {
+ autoCreateUsersRole =
+ config.getConfiguration("auto-create-users-role").getValue();
+ } catch (ConfigurationException e) {
+ }
+ }
+
+
+ /**
+ * Initialize the Namespace configuration using the given Configuration
+ * object.
+ *
+ * @param namespace Namespace on which we are trying to load the config
+ * @param config Castor Config object
+ * @exception InvalidNamespaceConfigurationException Namespace
+ * configuration is invalid
+ * @exception SlideException One of the action nodes doesn't exist
+ */
+ void initializeNamespaceParameters
+ (Namespace namespace, Configuration config)
+ throws InvalidNamespaceConfigurationException, SlideException {
+
+
+ setParameters(config, namespace);
+
+ setPathsAndConfigValues(config);
+
+ setRoles(config, namespace);
+
+ setDefaultProperties(config, namespace);
+
+ }
+
+ private void setRoles(Configuration config, Namespace namespace) throws
InvalidNamespaceConfigurationException {
// Add basic role mappings
addRoleMapping(NOBODY, NOBODY_ROLE);
addRoleMapping(NOBODY, LINK_ROLE);
@@ -918,52 +800,32 @@
Enumeration roleMappingsDef = config.getConfigurations("role");
try {
while (roleMappingsDef.hasMoreElements()) {
- Configuration roleMappingDef =
+ Configuration roleMappingDef =
(Configuration) roleMappingsDef.nextElement();
- addRoleMapping(roleMappingDef.getAttribute("name"),
+ addRoleMapping(roleMappingDef.getAttribute("name"),
roleMappingDef.getValue());
}
} catch (ConfigurationException e) {
throw new InvalidNamespaceConfigurationException
(namespace, e.getMessage());
}
-
- defaultProperties = new Hashtable();
- Enumeration defaultPropertiesDef =
- config.getConfigurations("default-property");
- try {
- while (defaultPropertiesDef.hasMoreElements()) {
- Configuration defaultProperty =
- (Configuration) defaultPropertiesDef.nextElement();
- String name = defaultProperty.getAttribute("name");
- String value = defaultProperty.getAttribute("value", "");
- String propertyNamespace = defaultProperty.getAttribute
- ("namespace", NodeProperty.DEFAULT_NAMESPACE);
- String role = defaultProperty.getAttribute("role");
- addDefaultProperty(role, name, value, propertyNamespace);
- }
- } catch (ConfigurationException e) {
- throw new InvalidNamespaceConfigurationException
- (namespace, e.getMessage());
- }
-
}
-
-
+
+
/**
* Create a dummy config, used to create the base namespace data.
- *
+ *
* @param namespace Namespace
- * @exception InvalidNamespaceConfigurationException Namespace
+ * @exception InvalidNamespaceConfigurationException Namespace
* configuration is invalid
*/
- void initializeAsDummyConfig(Namespace namespace)
+ void initializeAsDummyConfig(Namespace namespace)
throws InvalidNamespaceConfigurationException {
-
+
name = namespace.getName();
-
+
try {
-
+
Uri tempActionUri = namespace.getUri("/tempaction");
defaultAction = (ActionNode) tempActionUri.getStore()
.retrieveObject(tempActionUri);
@@ -984,26 +846,26 @@
createRevisionContentAction = defaultAction;
modifyRevisionContentAction = defaultAction;
removeRevisionContentAction = defaultAction;
-
+
usersPath = "";
filesPath = "";
-
+
} catch (Exception e) {
throw new InvalidNamespaceConfigurationException
(namespace, e.getMessage());
}
-
+
}
-
-
+
+
/**
* TEST PURPOSES ONLY.
*/
public void initializeForTestPurposesOnly()
throws InvalidNamespaceConfigurationException {
-
+
name = "slide";
-
+
try {
// Uri tempActionUri = namespace.getUri("/tempaction");
// defaultAction = (ActionNode) tempActionUri.getStore()
@@ -1025,24 +887,24 @@
createRevisionContentAction = defaultAction;
modifyRevisionContentAction = defaultAction;
removeRevisionContentAction = defaultAction;
-
+
usersPath = "";
filesPath = "";
-
+
} catch (Exception e) {
throw new InvalidNamespaceConfigurationException
(null, e.getMessage());
}
-
+
}
-
-
+
+
// ------------------------------------------------------ Protected Methods
-
-
+
+
/**
* Add a new parameter.
- *
+ *
* @param name Parameter name
* @param value Parameter value
*/
@@ -1051,20 +913,20 @@
parameters.put(name, value);
}
}
-
-
+
+
/**
* Add a new default property.
- *
+ *
* @param role Role
* @param name Property name
* @param value Property value
* @param namespace Property namespace
*/
- protected void addDefaultProperty(String role, String name, String value,
+ protected void addDefaultProperty(String role, String name, String value,
String namespace) {
if ((role!=null) && (name!=null) && (value!=null)) {
- Vector currentDefaultProperties =
+ Vector currentDefaultProperties =
(Vector) defaultProperties.get(role);
if (currentDefaultProperties == null) {
currentDefaultProperties = new Vector();
@@ -1074,11 +936,11 @@
(new NodeProperty(name, value, namespace));
}
}
-
-
+
+
/**
* Add a new role mapping.
- *
+ *
* @param name Role mapping name
* @param value Role mapping value
*/
@@ -1088,19 +950,19 @@
roleClassMappings.put(value, name);
}
}
-
-
+
+
/**
* Retrieve an action node.
- *
+ *
* @param actionPath Path of the action
* @param ActionNode Action object
*/
protected ActionNode getActionNode(Namespace namespace, String actionPath)
throws InvalidNamespaceConfigurationException, SlideException {
-
+
ActionNode result = null;
-
+
if (actionPath != null) {
Uri actionUri = namespace.getUri(actionPath);
result = (ActionNode) actionUri.getStore()
@@ -1113,21 +975,21 @@
(namespace, "Needed default action is not defined");
}
}
-
+
return result;
-
+
}
-
-
+
+
// --------------------------------------------------------- Object Methods
-
-
+
+
/**
* Get a String representation of this domain.
*/
public String toString() {
return name;
}
-
-
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]