pnever 2003/10/28 02:10:02
Modified: src/share/org/apache/slide/common NamespaceConfig.java
Log:
Fixed bug - thanks to Oliver Zeigermann and Ingo Brunberg
Revision Changes Path
1.31 +218 -214
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.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- NamespaceConfig.java 20 Oct 2003 12:38:17 -0000 1.30
+++ NamespaceConfig.java 28 Oct 2003 10:10:02 -0000 1.31
@@ -84,11 +84,11 @@
* @version $Revision$
*/
public final class NamespaceConfig {
-
-
+
+
// -------------------------------------------------------------- Constants
-
-
+
+
/**
* Base role names.
*/
@@ -97,8 +97,8 @@
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();
-
-
+
+
/** generic action nodes */
public static final ActionNode DEFAULT_ACTION = new ActionNode("default");
public static final ActionNode ALL_ACTION = new ActionNode("all");
@@ -109,209 +109,209 @@
public static final SubjectNode ALL_SUBJECT = new SubjectNode("all");
public static final SubjectNode OWNER_SUBJECT = new SubjectNode("owner");
public static final SubjectNode GUEST_SUBJECT = new SubjectNode("guest");
-
-
+
+
// ----------------------------------------------------- Instance Variables
-
-
+
+
/**
* Namespace name.
*/
protected String name;
-
-
+
+
/**
* 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;
-
-
+
+
/**
* Bind/unbind actions
*/
protected ActionNode bindMemberAction;
protected ActionNode unbindMemberAction;
-
+
/**
* Users path.
*/
protected String usersPath = null;
-
+
protected String resolvedUsersPath = null;
protected String resolvedGroupsPath = null;
protected String resolvedRolesPath = null;
-
+
/**
* Guest user path.
*/
protected String guestPath;
-
-
+
+
/**
* File path.
*/
protected String filesPath = null;
-
-
+
+
/**
* File path.
*/
protected String actionsPath = null;
-
-
+
+
/**
* 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
= 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.
*
@@ -320,8 +320,8 @@
public ActionNode getDefaultAction() {
return DEFAULT_ACTION;
}
-
-
+
+
/**
* Read object action accessor.
*
@@ -330,8 +330,8 @@
public ActionNode getReadObjectAction() {
return readObjectAction;
}
-
-
+
+
/**
* Create object action accessor.
*
@@ -340,8 +340,8 @@
public ActionNode getCreateObjectAction() {
return createObjectAction;
}
-
-
+
+
/**
* Remove object accessor.
*
@@ -350,8 +350,8 @@
public ActionNode getRemoveObjectAction() {
return removeObjectAction;
}
-
-
+
+
/**
* Grant permission accessor.
*
@@ -360,8 +360,8 @@
public ActionNode getGrantPermissionAction() {
return grantPermissionAction;
}
-
-
+
+
/**
* Revoke permission accessor.
*
@@ -370,8 +370,8 @@
public ActionNode getRevokePermissionAction() {
return revokePermissionAction;
}
-
-
+
+
/**
* Read permissions accessor.
*
@@ -380,8 +380,8 @@
public ActionNode getReadPermissionsAction() {
return readPermissionsAction;
}
-
-
+
+
/**
* Lock object accessor.
*
@@ -390,8 +390,8 @@
public ActionNode getLockObjectAction() {
return lockObjectAction;
}
-
-
+
+
/**
* Kill lock accessor.
*
@@ -400,8 +400,8 @@
public ActionNode getKillLockAction() {
return killLockAction;
}
-
-
+
+
/**
* Read locks accessor.
*
@@ -410,8 +410,8 @@
public ActionNode getReadLocksAction() {
return readLocksAction;
}
-
-
+
+
/**
* Create revision metadata accessor.
*
@@ -420,8 +420,8 @@
public ActionNode getCreateRevisionMetadataAction() {
return createRevisionMetadataAction;
}
-
-
+
+
/**
* Read revision metadata accessor.
*
@@ -430,8 +430,8 @@
public ActionNode getReadRevisionMetadataAction() {
return readRevisionMetadataAction;
}
-
-
+
+
/**
* Modify revision metadata accessor.
*
@@ -440,8 +440,8 @@
public ActionNode getModifyRevisionMetadataAction() {
return modifyRevisionMetadataAction;
}
-
-
+
+
/**
* Remove revision metadata accessor.
*
@@ -450,8 +450,8 @@
public ActionNode getRemoveRevisionMetadataAction() {
return removeRevisionMetadataAction;
}
-
-
+
+
/**
* Read revision content accessor.
*
@@ -460,8 +460,8 @@
public ActionNode getReadRevisionContentAction() {
return readRevisionContentAction;
}
-
-
+
+
/**
* Create revision content accessor.
*
@@ -470,8 +470,8 @@
public ActionNode getCreateRevisionContentAction() {
return createRevisionContentAction;
}
-
-
+
+
/**
* Modify revision content accessor.
*
@@ -480,8 +480,8 @@
public ActionNode getModifyRevisionContentAction() {
return modifyRevisionContentAction;
}
-
-
+
+
/**
* Remove revision content accessor.
*
@@ -490,8 +490,8 @@
public ActionNode getRemoveRevisionContentAction() {
return removeRevisionContentAction;
}
-
-
+
+
/**
* Method getBindAction
*
@@ -500,12 +500,12 @@
public ActionNode getBindMemberAction() {
return bindMemberAction;
}
-
+
public ActionNode getUnbindMemberAction() {
return unbindMemberAction;
}
-
+
/**
* Users path accessor.
*
@@ -518,16 +518,18 @@
resolvedUsersPath = "";
}
else {
+ resolvedUsersPath = usersPath;
String ucoll = getParameter("user_collection");
if (ucoll != null && ucoll.length() > 0) {
if (!ucoll.startsWith("/")) {
ucoll = "/"+ucoll;
}
- resolvedUsersPath = usersPath+ucoll;
+ resolvedUsersPath += ucoll;
}
}
}
return resolvedUsersPath;
+
}
/**
@@ -541,12 +543,13 @@
resolvedGroupsPath = "";
}
else {
+ resolvedGroupsPath = usersPath;
String gcoll = getParameter("group_collection");
if (gcoll != null && gcoll.length() > 0) {
if (!gcoll.startsWith("/")) {
gcoll = "/"+gcoll;
}
- resolvedGroupsPath = usersPath+gcoll;
+ resolvedGroupsPath += gcoll;
}
}
}
@@ -564,19 +567,20 @@
resolvedRolesPath = "";
}
else {
+ resolvedRolesPath = usersPath;
String rcoll = getParameter("role_collection");
if (rcoll != null && rcoll.length() > 0) {
if (!rcoll.startsWith("/")) {
rcoll = "/"+rcoll;
}
- resolvedRolesPath = usersPath+rcoll;
+ resolvedRolesPath += rcoll;
}
}
}
return resolvedRolesPath;
}
-
-
+
+
/**
* Guest path accessor.
*
@@ -585,8 +589,8 @@
public String getGuestPath() {
return guestPath;
}
-
-
+
+
/**
* Files path accessor.
*
@@ -595,8 +599,8 @@
public String getFilesPath() {
return filesPath;
}
-
-
+
+
/**
* Actions path accessor.
*
@@ -605,8 +609,8 @@
public String getActionsPath() {
return actionsPath;
}
-
-
+
+
/**
* Get default properties for a given role.
*
@@ -619,19 +623,19 @@
else
return result.elements();
}
-
-
+
+
/**
* Get content interceptors.
*/
ContentInterceptor[] getContentInterceptors() {
return contentInterceptors;
}
-
-
+
+
// --------------------------------------------------------- Public Methods
-
-
+
+
/**
* Get parameter value.
*
@@ -646,8 +650,8 @@
return (String) result;
}
}
-
-
+
+
/**
* 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.
@@ -663,16 +667,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.
@@ -680,11 +684,11 @@
public String getAutoCreateUsersRole() {
return autoCreateUsersRole;
}
-
-
+
+
// -------------------------------------------------------- Package Methods
-
-
+
+
/**
* Initialize the Namespace configuration using the given Configuration
* object.
@@ -697,9 +701,9 @@
*/
void initializeNamespaceConfig(Namespace namespace, Configuration config)
throws InvalidNamespaceConfigurationException, SlideException {
-
+
name = namespace.getName();
-
+
readObjectAction = getConfiguredNode(namespace, config, "read-object");
createObjectAction = getConfiguredNode(namespace, config, "create-object");
removeObjectAction = getConfiguredNode(namespace, config, "remove-object");
@@ -717,19 +721,19 @@
createRevisionContentAction = getConfiguredNode(namespace, config,
"create-revision-content");
modifyRevisionContentAction = getConfiguredNode(namespace, config,
"modify-revision-content");
removeRevisionContentAction = getConfiguredNode(namespace, config,
"remove-revision-content");
-
+
bindMemberAction = getConfiguredNode(namespace, config, "bind-member");
unbindMemberAction = getConfiguredNode(namespace, config, "unbind-member");
-
-
+
+
setPathsAndConfigValues(config);
-
+
setParameters(config, namespace);
-
+
setRoles(config, namespace);
-
+
setDefaultProperties(config, namespace);
-
+
Enumeration contentInteceptorsDef =
config.getConfigurations("content-interceptor");
try {
@@ -737,7 +741,7 @@
Configuration contentInterceptorDef =
(Configuration) contentInteceptorsDef.nextElement();
String classname = contentInterceptorDef.getAttribute("class");
-
+
// Load contentInterceptor parameters
Enumeration contentInterceptorParametersDef =
contentInterceptorDef.getConfigurations("parameter");
@@ -746,12 +750,12 @@
Configuration parameterDefinition = (Configuration)
contentInterceptorParametersDef.nextElement();
String parameterName =
- parameterDefinition.getAttribute("name");
+ parameterDefinition.getAttribute("name");
String parameterValue = parameterDefinition.getValue();
contentInterceptorParameters.put(parameterName,
parameterValue);
}
-
+
try {
Class contentInterceptorClass =
Class.forName(classname);
@@ -769,11 +773,11 @@
} catch (Exception e) {
namespace.getLogger().log
(Messages.format
- ("org.apache.slide.common.InvalidContentInterceptor",
- classname, e.getMessage()), Logger.WARNING);
+ ("org.apache.slide.common.InvalidContentInterceptor",
+ classname, e.getMessage()), Logger.WARNING);
}
}
-
+
// Initialize the content interceptors with the
// NamespaceAccessToken
NamespaceAccessToken nat = new NamespaceAccessTokenImpl(namespace);
@@ -786,9 +790,9 @@
throw new InvalidNamespaceConfigurationException
(namespace, e.getMessage());
}
-
+
}
-
+
private void setDefaultProperties(Configuration config, Namespace namespace)
throws InvalidNamespaceConfigurationException {
defaultProperties = new Hashtable();
Enumeration defaultPropertiesDef =
@@ -809,7 +813,7 @@
(namespace, e.getMessage());
}
}
-
+
private void setParameters(Configuration config, Namespace namespace) throws
InvalidNamespaceConfigurationException {
parameters = new Hashtable();
Enumeration parametersDef = config.getConfigurations("parameter");
@@ -825,7 +829,7 @@
(namespace, e.getMessage());
}
}
-
+
private ActionNode getConfiguredNode(Namespace namespace, Configuration config,
String nodeName) throws SlideException {
ActionNode result = null;
try {
@@ -835,32 +839,32 @@
}
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 {
actionsPath = config.getConfiguration("actionspath").getValue();
} catch (ConfigurationException e) {
actionsPath = "";
}
-
+
try {
autoCreateUsers = Boolean.valueOf
(config.getConfiguration("auto-create-users").getValue())
@@ -868,15 +872,15 @@
} 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.
@@ -890,18 +894,18 @@
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);
@@ -922,8 +926,8 @@
(namespace, e.getMessage());
}
}
-
-
+
+
/**
* Create a dummy config, used to create the base namespace data.
*
@@ -933,9 +937,9 @@
*/
void initializeAsDummyConfig(Namespace namespace)
throws InvalidNamespaceConfigurationException {
-
+
name = namespace.getName();
-
+
try {
readObjectAction = getDefaultAction();
createObjectAction = getDefaultAction();
@@ -956,32 +960,32 @@
removeRevisionContentAction = getDefaultAction();
bindMemberAction = getDefaultAction();
unbindMemberAction = getDefaultAction();
-
- usersPath = "";
- filesPath = "";
-
+
+// usersPath = "";
+// filesPath = "";
+
// remove this parameter, as it is used in contructing the
// principal url. In case of a dummy init this parameter should
// be ignore, similar to the usersPath setting.
parameters.remove("user_collection");
-
-
+
+
} catch (Exception e) {
throw new InvalidNamespaceConfigurationException
(namespace, e.getMessage());
}
-
+
}
-
-
+
+
/**
* TEST PURPOSES ONLY.
*/
public void initializeForTestPurposesOnly()
throws InvalidNamespaceConfigurationException {
-
+
name = "slide";
-
+
try {
readObjectAction = getDefaultAction();
createObjectAction = getDefaultAction();
@@ -1002,21 +1006,21 @@
removeRevisionContentAction = getDefaultAction();
bindMemberAction = getDefaultAction();
unbindMemberAction = getDefaultAction();
-
+
usersPath = "";
filesPath = "";
-
+
} catch (Exception e) {
throw new InvalidNamespaceConfigurationException
(null, e.getMessage());
}
-
+
}
-
-
+
+
// ------------------------------------------------------ Protected Methods
-
-
+
+
/**
* Add a new parameter.
*
@@ -1028,8 +1032,8 @@
parameters.put(name, value);
}
}
-
-
+
+
/**
* Add a new default property.
*
@@ -1051,8 +1055,8 @@
(new NodeProperty(name, value, namespace));
}
}
-
-
+
+
/**
* Add a new role mapping.
*
@@ -1065,8 +1069,8 @@
roleClassMappings.put(value, name);
}
}
-
-
+
+
/**
* Retrieve an action node.
*
@@ -1075,32 +1079,32 @@
*/
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()
.retrieveObject(actionUri);
- }
+ }
else {
result = getDefaultAction();
}
-
+
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]