[Yanel-commits] rev 50461 -
public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi
michi at wyona.com
michi at wyona.com
Wed Jun 16 22:54:32 CEST 2010
Author: michi
Date: 2010-06-16 22:54:32 +0200 (Wed, 16 Jun 2010)
New Revision: 50461
Modified:
public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi/UserManagerResource.java
Log:
remove policies recursively, whereas made a note re violation of API
Modified: public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi/UserManagerResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi/UserManagerResource.java 2010-06-16 19:49:51 UTC (rev 50460)
+++ public/yanel/trunk/src/contributions/resources/security-api/src/java/org/wyona/yanel/impl/resources/securityapi/UserManagerResource.java 2010-06-16 20:54:32 UTC (rev 50461)
@@ -95,6 +95,7 @@
String recursivelyText = getParameterAsString("deep");
boolean recursively = "1".equals(recursivelyText);
deletePolicy(path, recursively);
+ sb.append("<policy-deleted path=\"" + path + "\" recursively=\"" + recursively + "\"/>");
} else {
log.warn("No such usecase implemented: " + usecase);
sb.append("<no-such-yanel-usecase-implemented>" + usecase + "</no-such-yanel-usecase-implemented>");
@@ -303,13 +304,39 @@
/**
* Deletes a specific policy.
* @param id the policy ID
+ * @param recursively Flag whether to delete sub-policies recursively
*/
private void deletePolicy(String path, boolean recursively) throws Exception {
PolicyManager pm = getRealm().getPolicyManager();
+
if (recursively) {
- log.warn("Recursively deletion of policies not yet implemented, only policy "+path+" will be deleted.");
+ org.wyona.yarep.core.Repository apRepo = getRealm().getPolicyManager().getPoliciesRepository();
+ if (apRepo.existsNode(path)) {
+ org.wyona.yarep.core.Node node = apRepo.getNode(path);
+ if (node.getType() == org.wyona.yarep.core.NodeType.COLLECTION) {
+ org.wyona.yarep.core.Node[] children = node.getNodes();
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
+ log.debug("Child: " + children[i].getName());
+ deletePolicy(children[i].getPath(), true);
+ }
+ }
+ }
+ }
+ } else {
+ log.info("Only delete this particular policy: " + path);
}
- pm.removePolicy(path);
+
+ if (pm.getPolicy(path, false) != null) {
+ pm.removePolicy(path);
+ log.info("Policy '" + path + "' has been deleted.");
+ } else if (path.endsWith(".policy")) { // WARNING/TODO: This check violates the API!
+ String withoutImplSuffix = path.substring(0, path.indexOf(".policy"));
+ log.warn("This seems to be a policy: " + path + " (" + withoutImplSuffix + "), but this check violates the API!");
+ pm.removePolicy(withoutImplSuffix);
+ } else {
+ log.warn("No such policy: " + path);
+ }
}
/**
More information about the Yanel-commits
mailing list