// We've made sure that the object exists.
// We now parse the permissions definition list, adding each
// permission to the object's permission list.
while (permissionDefinitions.hasMoreElements()) {
Configuration permissionDefinition =
(Configuration) permissionDefinitions.nextElement();
// Create the NodePermission object matching the Castor object
String subjectUri =
permissionDefinition.getAttribute("subject");
if (accessToken.getNamespaceConfig().getUsersPath().equals(subjectUri)) {
subjectUri = SubjectNode.ALL_URI;
}
String actionUri =
permissionDefinition.getAttribute("action");
if (accessToken.getNamespaceConfig().getActionsPath().equals(actionUri)) {
actionUri = ActionNode.ALL_URI;
}
boolean inheritable = true;
try {
if (permissionDefinition.getAttribute("inheritable")
.equals("false")) {
inheritable = false;
}
} catch (ConfigurationException e) {
}
boolean negative = false;
try {
if (permissionDefinition.getAttribute("negative")
.equals("true")) {
negative = true;
}
} catch (ConfigurationException e) {
}
NodePermission permission = new NodePermission
(uri, subjectUri, actionUri, inheritable, negative);
// Adding the NodePermission to the ObjectNode
accessToken.getSecurityHelper()
.grantPermission(token, permission);
}
// Retrieve the list of revisions of the object
Enumeration revisionDefinitions =
objectDefinition.getConfigurations("revision");
boolean revisionDefinitionsFound = false;
// We parse the revision definition list
while (revisionDefinitions.hasMoreElements()) {
revisionDefinitionsFound = true;
Configuration revisionDefinition =
(Configuration) revisionDefinitions.nextElement();
loadObjectRevision(accessToken, token, uri,
revisionDefinition);
}
if (!revisionDefinitionsFound) {
loadDefaultObjectRevision(accessToken, token, uri);
}
} catch (ObjectNotFoundException e) {
// Should NEVER happen
accessToken.getLogger().log(e,LOG_CHANNEL,Logger.WARNING);
accessToken.getLogger().log
(e.toString(),LOG_CHANNEL,Logger.WARNING);
} catch (VetoException e) {
accessToken.getLogger().log(e,LOG_CHANNEL,Logger.WARNING);
accessToken.getLogger().log(e.toString(),LOG_CHANNEL,Logger.WARNING);
} catch (LinkedObjectNotFoundException e) {
// Icorrect link
accessToken.getLogger().log(e,LOG_CHANNEL,Logger.WARNING);
accessToken.getLogger().log
("Incorrect link found while creating " + uri,
LOG_CHANNEL,Logger.WARNING);
} catch (AccessDeniedException e) {
// Security exception
accessToken.getLogger().log
("Insufficient credentials to create object",
LOG_CHANNEL,Logger.INFO);
} catch (ObjectLockedException e) {
// Lock exception
accessToken.getLogger().log
("Lock-Token required",
LOG_CHANNEL,Logger.INFO);
}
Enumeration childConfigurations =
objectDefinition.getConfigurations("objectnode");
while(childConfigurations.hasMoreElements()) {
Configuration childConfiguration =
(Configuration) childConfigurations.nextElement();
loadObjectNode(accessToken, token, childConfiguration);
}
}