From 1d54a4abc26bf03e1c759d47282e79d6485a988a Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 27 Mar 2014 10:59:24 +0100 Subject: RemoveDomainPath now checks if the DomainPath exists, is not a context, and is an alias of the current Item. Fixes #176 --- .../instance/predefined/RemoveDomainPath.java | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined') 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", ""); } - } } -- cgit v1.2.3