summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-03-27 10:59:24 +0100
committerAndrew Branson <andrew.branson@cern.ch>2014-03-27 10:59:24 +0100
commit1d54a4abc26bf03e1c759d47282e79d6485a988a (patch)
treec7237b3895c4ba24fa2bc72671bab4ffed7a4dd7
parent9a6f9da9438308d80cda9df3d53aaa9f1b14683a (diff)
RemoveDomainPath now checks if the DomainPath exists, is not a context,
and is an alias of the current Item. Fixes #176
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java
index 642cf64..e33f722 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java
@@ -11,6 +11,8 @@ package com.c2kernel.lifecycle.instance.predefined;
import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.LDAPLookup;
@@ -34,19 +36,25 @@ public class RemoveDomainPath extends PredefinedStep
Logger.msg(1,"RemoveDomainPath::request() - Starting.");
- try
- {
- DomainPath domainPath = new DomainPath(getDataList(requestData)[0]);
- lookupManager.delete(domainPath);
- Logger.msg(8,"AddAlias::request() - context:" + domainPath.toString() + " DONE.");
- return requestData;
+ DomainPath domainPath = new DomainPath(getDataList(requestData)[0]);
+ if (!domainPath.exists())
+ throw new InvalidDataException("Domain path "+domainPath.toString()+" does not exist.", "");
+
+ if (domainPath.getType()!=DomainPath.ENTITY)
+
+ try {
+ if (domainPath.getEntity().getSysKey() != itemSysKey)
+ throw new InvalidDataException("Domain path "+domainPath.toString()+" is not an alias of the current Item "+itemSysKey, "");
+ } catch (ObjectNotFoundException ex) {
+ throw new InvalidDataException("Domain path "+domainPath.toString()+" is a context.", "");
}
- catch( Exception ex )
- {
- Logger.error("AddAlias::request() - during anyHelper.extract.");
- Logger.error(ex);
- throw new InvalidDataException(ex.toString(), "");
+ try {
+ lookupManager.delete(domainPath);
+ Logger.msg(8,"AddAlias::request() - context:" + domainPath.toString() + " DONE.");
+ return requestData;
+ } catch (ObjectCannotBeUpdated ex) {
+ Logger.error(ex);
+ throw new InvalidDataException("Problem updating directory", "");
}
-
}
}