From 0ed2c1124cf1b9e49a2ec1fa0126a8df09f9e758 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 7 Oct 2014 09:18:11 +0200 Subject: Repackage to org.cristalise --- .../instance/predefined/AddC2KObject.java | 66 ------- .../instance/predefined/AddDomainPath.java | 61 ------- .../instance/predefined/AddMemberToCollection.java | 104 ----------- .../predefined/AddNewCollectionDescription.java | 109 ------------ .../lifecycle/instance/predefined/AddNewSlot.java | 127 -------------- .../instance/predefined/AssignItemToSlot.java | 120 ------------- .../lifecycle/instance/predefined/ClearSlot.java | 113 ------------ .../predefined/CreateNewCollectionVersion.java | 102 ----------- .../lifecycle/instance/predefined/Import.java | 105 ----------- .../instance/predefined/PredefinedStep.java | 191 -------------------- .../predefined/PredefinedStepContainer.java | 79 --------- .../instance/predefined/RemoveC2KObject.java | 69 -------- .../instance/predefined/RemoveDomainPath.java | 72 -------- .../predefined/RemoveSlotFromCollection.java | 130 -------------- .../instance/predefined/ReplaceDomainWorkflow.java | 76 -------- .../instance/predefined/WriteProperty.java | 79 --------- .../instance/predefined/WriteViewpoint.java | 87 --------- .../agent/AgentPredefinedStepContainer.java | 47 ----- .../agent/CreateAgentFromDescription.java | 136 --------------- .../instance/predefined/agent/RemoveAgent.java | 89 ---------- .../predefined/agent/SetAgentPassword.java | 69 -------- .../instance/predefined/agent/SetAgentRoles.java | 93 ---------- .../predefined/item/CreateItemFromDescription.java | 194 --------------------- .../lifecycle/instance/predefined/item/Erase.java | 79 --------- .../item/ItemPredefinedStepContainer.java | 45 ----- .../predefined/server/AddDomainContext.java | 66 ------- .../instance/predefined/server/CreateNewAgent.java | 67 ------- .../instance/predefined/server/CreateNewItem.java | 62 ------- .../instance/predefined/server/CreateNewRole.java | 59 ------- .../predefined/server/RemoveDomainContext.java | 64 ------- .../instance/predefined/server/RemoveRole.java | 67 ------- .../server/ServerPredefinedStepContainer.java | 62 ------- 32 files changed, 2889 deletions(-) delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateNewCollectionVersion.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/AgentPredefinedStepContainer.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/item/ItemPredefinedStepContainer.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java delete mode 100644 src/main/java/com/c2kernel/lifecycle/instance/predefined/server/ServerPredefinedStepContainer.java (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java deleted file mode 100644 index a39e815..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - -import java.util.Arrays; - -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.entity.C2KLocalObject; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.31 $ - **************************************************************************/ -public class AddC2KObject extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castror - **************************************************************************/ - public AddC2KObject() - { - super(); - getProperties().put("Agent Role", "Admin"); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, PersistencyException { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) throw new InvalidDataException("AddC2KObject: Invalid parameters "+Arrays.toString(params)); - C2KLocalObject obj; - try { - obj = (C2KLocalObject)Gateway.getMarshaller().unmarshall(params[0]); - } catch (Exception e) { - throw new InvalidDataException("AddC2KObject: Could not unmarshall new object: "+params[0]); - } - Gateway.getStorage().put(item, obj, null ); - return requestData; - } -} \ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java deleted file mode 100644 index 8723d3b..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - - - -import java.util.Arrays; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.lookup.LookupManager; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class AddDomainPath extends PredefinedStep -{ - public AddDomainPath() - { - super(); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AddDomainPath: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) throw new InvalidDataException("AddDomainPath: Invalid parameters "+Arrays.toString(params)); - - LookupManager lookupManager = Gateway.getLookupManager(); - - DomainPath domainPath = new DomainPath(params[0], item); - lookupManager.add(domainPath); - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java deleted file mode 100644 index 90db8e1..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - -import java.util.Arrays; - -import com.c2kernel.collection.Dependency; -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.entity.C2KLocalObject; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.CastorHashMap; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.8 $ - **************************************************************************/ -public class AddMemberToCollection extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castor - **************************************************************************/ - public AddMemberToCollection() - { - super(); - } - - - /** - * Generates a new slot in a Dependency for the given item - * - * Params: - * 0 - collection name - * 1 - target entity key - * @throws ObjectAlreadyExistsException - * @throws PersistencyException - * @throws ObjectNotFoundException - * @throws InvalidCollectionModification - */ - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException, InvalidCollectionModification { - - String collName; - ItemPath newChild; - Dependency dep; - CastorHashMap props = null; - - // extract parameters - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AddMemberToCollection: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - try { - collName = params[0]; - newChild = new ItemPath(params[1]); - if (params.length > 2) - props = (CastorHashMap)Gateway.getMarshaller().unmarshall(params[2]); - - } catch (Exception e) { - throw new InvalidDataException("AddMemberToCollection: Invalid parameters "+Arrays.toString(params)); - } - - // load collection - C2KLocalObject collObj; - collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - if (!(collObj instanceof Dependency)) throw new InvalidDataException("AddMemberToCollection: AddMemberToCollection operates on Dependency collections only."); - dep = (Dependency)collObj; - - // find member and assign entity - if (props == null) - dep.addMember(newChild); - else - dep.addMember(newChild, props, null); - - Gateway.getStorage().put(newChild, dep, null); - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java deleted file mode 100644 index 99fd666..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewCollectionDescription.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - -import java.util.Arrays; - -import com.c2kernel.collection.AggregationDescription; -import com.c2kernel.collection.CollectionDescription; -import com.c2kernel.collection.DependencyDescription; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.8 $ - **************************************************************************/ -public class AddNewCollectionDescription extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castor - **************************************************************************/ - public AddNewCollectionDescription() - { - super(); - } - - - /** - * Generates a new empty collection description. Collection instances should - * be added by an Admin, who can do so using AddC2KObject. - * - * Params: - * 0 - collection name - * 1 - collection type (Aggregation, Dependency) - * @throws PersistencyException - */ - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException { - - String collName; - String collType; - - // extract parameters - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AddNewCollectionDescription: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 2) - throw new InvalidDataException("AddNewCollectionDescription: Invalid parameters "+Arrays.toString(params)); - - collName = params[0]; - collType = params[1]; - - // check if collection already exists - try { - Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - throw new ObjectAlreadyExistsException("Collection '"+collName+"' already exists"); - } catch (ObjectNotFoundException ex) { - // collection doesn't exist - } catch (PersistencyException ex) { - Logger.error(ex); - throw new PersistencyException("AddNewCollectionDescription: Error checking for collection '"+collName+"': "+ex.getMessage()); - } - - - CollectionDescription newCollDesc; - - if (collType.equals("Aggregation")) - newCollDesc = new AggregationDescription(collName); - if (collType.equals("Dependency")) - newCollDesc = new DependencyDescription(collName); - else - throw new InvalidDataException("AddNewCollectionDescription: Invalid collection type specified: '"+collType+"'. Must be Aggregation or Dependency."); - - // store it - try { - Gateway.getStorage().put(item, newCollDesc, null); - } catch (PersistencyException e) { - throw new PersistencyException("AddNewCollectionDescription: Error saving new collection '"+collName+"': "+e.getMessage()); - } - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java deleted file mode 100644 index 3d9e5d3..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - -import java.util.Arrays; - -import com.c2kernel.collection.Aggregation; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.entity.C2KLocalObject; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.property.PropertyDescription; -import com.c2kernel.property.PropertyDescriptionList; -import com.c2kernel.property.PropertyUtility; -import com.c2kernel.utils.CastorHashMap; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.8 $ - **************************************************************************/ -public class AddNewSlot extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castor - **************************************************************************/ - public AddNewSlot() - { - super(); - } - - - /** - * Creates a new slot in the given aggregation, that holds instances of the given item description - * - * Params: - *
  1. Collection name
  2. - *
  3. Item Description key (optional)
  4. - *
  5. Item Description version (optional)
  6. - *
- * - * @throws InvalidDataException Then the parameters were incorrect - * @throws PersistencyException There was a problem loading or saving the collection from persistency - * @throws ObjectNotFoundException A required object, such as the collection or a PropertyDescription outcome, wasn't found - */ - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, PersistencyException, ObjectNotFoundException { - - String collName; - ItemPath descKey = null; - String descVer = "last"; - Aggregation agg; - - // extract parameters - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AddNewSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - - // resolve desc item path and version - try { - collName = params[0]; - if (params.length > 1 && params[1].length() > 0) descKey = new ItemPath(params[1]); - if (params.length > 2 && params[2].length() > 0) descVer = params[2]; - } catch (Exception e) { - throw new InvalidDataException("AddNewSlot: Invalid parameters "+Arrays.toString(params)); - } - - // load collection - C2KLocalObject collObj; - try { - collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (PersistencyException ex) { - Logger.error(ex); - throw new PersistencyException("AddNewSlot: Error loading collection '\"+collName+\"': "+ex.getMessage()); - } - if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AddNewSlot: AddNewSlot operates on Aggregation collections only."); - agg = (Aggregation)collObj; - - // get props - CastorHashMap props = new CastorHashMap(); - StringBuffer classProps = new StringBuffer(); - if (descKey != null) { - PropertyDescriptionList propList; - propList = PropertyUtility.getPropertyDescriptionOutcome(descKey, descVer); - for (PropertyDescription pd : propList.list) { - props.put(pd.getName(), pd.getDefaultValue()); - if (pd.getIsClassIdentifier()) - classProps.append((classProps.length()>0?",":"")).append(pd.getName()); - } - } - - agg.addSlot(props, classProps.toString()); - - try { - Gateway.getStorage().put(item, agg, null); - } catch (PersistencyException e) { - Logger.error(e); - throw new PersistencyException("AddNewSlot: Error saving collection '"+collName+"': "+e.getMessage()); - } - - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java deleted file mode 100644 index 04d6770..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - -import java.util.Arrays; - -import com.c2kernel.collection.Aggregation; -import com.c2kernel.collection.AggregationMember; -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.entity.C2KLocalObject; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.8 $ - **************************************************************************/ -public class AssignItemToSlot extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castor - **************************************************************************/ - public AssignItemToSlot() - { - super(); - } - - - /** - * Params: - * 0 - collection name - * 1 - slot number - * 2 - target entity key - * @throws ObjectNotFoundException - * @throws PersistencyException - * @throws ObjectCannotBeUpdated - * @throws InvalidCollectionModification - */ - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, PersistencyException, ObjectCannotBeUpdated, InvalidCollectionModification { - - String collName; - int slotNo; - ItemPath childItem; - Aggregation agg; - - // extract parameters - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AssignItemToSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - - try { - collName = params[0]; - slotNo = Integer.parseInt(params[1]); - childItem = new ItemPath(params[2]); - } catch (Exception e) { - throw new InvalidDataException("AssignItemToSlot: Invalid parameters "+Arrays.toString(params)); - } - - // load collection - C2KLocalObject collObj; - try { - collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (PersistencyException ex) { - Logger.error(ex); - throw new PersistencyException("AssignItemToSlot: Error loading collection '\"+collName+\"': "+ex.getMessage()); - } - if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AssignItemToSlot: AssignItemToSlot operates on Aggregation collections only."); - agg = (Aggregation)collObj; - - // find member and assign entity - boolean stored = false; - for (AggregationMember member : agg.getMembers().list) { - if (member.getID() == slotNo) { - if (member.getItemPath() != null) - throw new ObjectCannotBeUpdated("AssignItemToSlot: Member slot "+slotNo+" not empty"); - member.assignItem(childItem); - stored = true; - break; - } - } - if (!stored) { - throw new ObjectNotFoundException("AssignItemToSlot: Member slot "+slotNo+" not found."); - } - - try { - Gateway.getStorage().put(item, agg, null); - } catch (PersistencyException e) { - throw new PersistencyException("AssignItemToSlot: Error saving collection '"+collName+"': "+e.getMessage()); - } - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java deleted file mode 100644 index 1bfb8d0..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - -import java.util.Arrays; - -import com.c2kernel.collection.Aggregation; -import com.c2kernel.collection.AggregationMember; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.8 $ - **************************************************************************/ -public class ClearSlot extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castor - **************************************************************************/ - public ClearSlot() - { - super(); - } - - - /** - * Params: - * 0 - collection name - * 1 - slot number - * @throws ObjectNotFoundException - * @throws PersistencyException - * @throws ObjectCannotBeUpdated - */ - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, PersistencyException, ObjectCannotBeUpdated { - - String collName; - int slotNo; - Aggregation agg; - - // extract parameters - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "ClearSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - - try { - collName = params[0]; - slotNo = Integer.parseInt(params[1]); - } catch (Exception e) { - throw new InvalidDataException("ClearSlot: Invalid parameters "+Arrays.toString(params)); - } - - // load collection - try { - agg = (Aggregation)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (PersistencyException ex) { - Logger.error(ex); - throw new PersistencyException("ClearSlot: Error loading collection '"+collName+"': "+ex.getMessage()); - } - - // find member and clear - boolean stored = false; - for (AggregationMember member : agg.getMembers().list) { - if (member.getID() == slotNo) { - if (member.getItemPath() != null) - throw new ObjectCannotBeUpdated("ClearSlot: Member slot "+slotNo+" already empty"); - member.clearItem(); - stored = true; - break; - } - } - if (!stored) { - throw new ObjectNotFoundException("ClearSlot: Member slot "+slotNo+" not found."); - } - - - try { - Gateway.getStorage().put(item, agg, null); - } catch (PersistencyException e) { - Logger.error(e); - throw new PersistencyException("ClearSlot: Error storing collection"); - } - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateNewCollectionVersion.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateNewCollectionVersion.java deleted file mode 100644 index 8e68ae3..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateNewCollectionVersion.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - -import java.util.Arrays; - -import com.c2kernel.collection.Collection; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.8 $ - **************************************************************************/ -public class CreateNewCollectionVersion extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castor - **************************************************************************/ - public CreateNewCollectionVersion() - { - super(); - } - - - /** - * Generates a new snapshot of a collection from its current state. The - * new version is given the next available number, starting at 0. - * - * Params: - * 0 - Collection name - * @throws InvalidDataException - * @throws PersistencyException - * - * @throws ObjectNotFoundException when there is no collection present with - * that name - */ - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, PersistencyException, ObjectNotFoundException - { - String collName; - - // extract parameters - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "CreateNewCollectionVersion: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) - throw new InvalidDataException("CreateNewCollectionVersion: Invalid parameters "+Arrays.toString(params)); - - collName = params[0]; - Collection coll = (Collection)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - - // find last numbered version - int lastVer = -1; - String[] versions = Gateway.getStorage().getClusterContents(item, ClusterStorage.COLLECTION+"/"+collName); - for (String thisVerStr : versions) { - try { - int thisVer = Integer.parseInt(thisVerStr); - if (thisVer > lastVer) lastVer = thisVer; - } catch (NumberFormatException ex) { } // ignore non-integer versions - } - - // Remove it from the cache before we change it - Gateway.getStorage().clearCache(item, ClusterStorage.COLLECTION+"/"+collName+"/last"); - // Set the version - coll.setVersion(lastVer+1); - - // store it - try { - Gateway.getStorage().put(item, coll, null); - } catch (PersistencyException e) { - throw new PersistencyException("CreateNewCollectionVersion: Error saving new collection '"+collName+"': "+e.getMessage()); - } - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java deleted file mode 100644 index 12cb488..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - -import java.util.Arrays; - -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.events.Event; -import com.c2kernel.events.History; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.TransactionManager; -import com.c2kernel.persistency.outcome.Outcome; -import com.c2kernel.persistency.outcome.Viewpoint; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * $Revision: 1.21 $ - * $Date: 2005/06/02 12:17:22 $ - * - * Params: Schemaname_version:Viewpoint (optional), Outcome, Timestamp (optional - * - * Copyright (C) 2003 CERN - European Organization for Nuclear Research - * All rights reserved. - **************************************************************************/ -public class Import extends PredefinedStep -{ - public Import() - { - super(); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, PersistencyException { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "Import: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - - int split1 = params[0].indexOf('_'); - int split2 = params[0].indexOf(':'); - - if (split1 == -1) - throw new InvalidDataException("Import: Invalid parameters "+Arrays.toString(params)); - - requestData = params[1]; - - String schemaName = params[0].substring(0, split1); - String viewpoint = null; - int schemaVersion; - if (split2 > -1) { - schemaVersion = Integer.parseInt(params[0].substring(split1+1, split2)); - viewpoint = params[0].substring(split2+1); - } - else - schemaVersion = Integer.parseInt(params[0].substring(split1+1)); - - String timestamp; - if (params.length == 3) - timestamp = params[2]; - else - timestamp = Event.timeToString(Event.getGMT()); - - // write event, outcome and viewpoints to storage - - TransactionManager storage = Gateway.getStorage(); - Object locker = getWf(); - History hist = getWf().getHistory(); - Event event = hist.addEvent(agent, getCurrentAgentRole(), getName(), getPath(), getType(), schemaName, schemaVersion, getStateMachine().getName(), getStateMachine().getVersion(), getStateMachine().getTransition(transitionID), viewpoint, timestamp); - - try { - storage.put(item, new Outcome(event.getID(), requestData, schemaName, schemaVersion), locker); - storage.put(item, new Viewpoint(item, schemaName, viewpoint, schemaVersion, event.getID()), locker); - if (!"last".equals(viewpoint)) - storage.put(item, new Viewpoint(item, schemaName, "last", schemaVersion, event.getID()), locker); - } catch (PersistencyException e) { - storage.abort(locker); - throw e; - } - storage.commit(locker); - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java deleted file mode 100644 index 9b6d6c4..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java +++ /dev/null @@ -1,191 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; -import java.io.StringReader; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.CDATASection; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; -import org.xml.sax.InputSource; - -import com.c2kernel.lifecycle.instance.Activity; -import com.c2kernel.lifecycle.instance.predefined.agent.AgentPredefinedStepContainer; -import com.c2kernel.lifecycle.instance.predefined.item.ItemPredefinedStepContainer; -import com.c2kernel.lifecycle.instance.predefined.server.ServerPredefinedStepContainer; -import com.c2kernel.persistency.outcome.Outcome; -import com.c2kernel.utils.Logger; -/*********************************************************************************************************************************************************************************************************************************************************************************************************** - * @author $Author: sgaspard $ $Date: 2004/09/21 10:32:17 $ - * @version $Revision: 1.14 $ - **********************************************************************************************************************************************************************************************************************************************************************************************************/ -public abstract class PredefinedStep extends Activity -{ - /******************************************************************************************************************************************************************************************************************************************************************************************************* - * predefined Steps are always Active, and have only one transition subclasses could override this method (if necessary) - ******************************************************************************************************************************************************************************************************************************************************************************************************/ - - private boolean isPredefined = false; - public static final int DONE = 0; - public static final int AVAILABLE = 0; - - public PredefinedStep() { - super(); - getProperties().put("SchemaType", "PredefinedStepOutcome"); - getProperties().put("SchemaVersion", "0"); - } - - @Override - public boolean getActive() - { - if (isPredefined) - return true; - else - return super.getActive(); - } - - - - @Override - protected String getDefaultSMName() { - return "PredefinedStep"; - } - - @Override - public String getErrors() - { - if (isPredefined) - return getName(); - else - return super.getErrors(); - } - @Override - public boolean verify() - { - if (isPredefined) - return true; - else - return super.verify(); - } - /** - * Returns the isPredefined. - * - * @return boolean - */ - public boolean getIsPredefined() - { - return isPredefined; - } - /** - * Sets the isPredefined. - * - * @param isPredefined - * The isPredefined to set - */ - public void setIsPredefined(boolean isPredefined) - { - this.isPredefined = isPredefined; - } - @Override - public String getType() - { - return getName(); - } - - static public String getPredefStepSchemaName(String stepName) { - PredefinedStepContainer[] allSteps = { new ItemPredefinedStepContainer(), new AgentPredefinedStepContainer(), new ServerPredefinedStepContainer() }; - for (PredefinedStepContainer thisContainer : allSteps) { - String stepPath = thisContainer.getName()+"/"+stepName; - Activity step = (Activity)thisContainer.search(stepPath); - if (step != null) { - return (String)step.getProperties().get("SchemaType"); - } - } - return "PredefinedStepOutcome"; // default to standard if not found - server may be a newer version - } - - // generic bundling of parameters - static public String bundleData(String[] data) - { - try - { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document dom = builder.newDocument(); - Element root = dom.createElement("PredefinedStepOutcome"); - dom.appendChild(root); - for (String element : data) { - Element param = dom.createElement("param"); - Text t = dom.createTextNode(element); - param.appendChild(t); - root.appendChild(param); - } - - return Outcome.serialize(dom, false); - - } - catch (Exception e) - { - Logger.error(e); - StringBuffer xmlData = new StringBuffer().append(""); - for (String element : data) - xmlData.append(""); - xmlData.append(""); - return xmlData.toString(); - } - } - - // generic bundling of single parameter - static public String bundleData(String data) - { - return bundleData(new String[]{ data }); - } - - public static String[] getDataList(String xmlData) - { - try - { - Document scriptDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xmlData))); - NodeList nodeList = scriptDoc.getElementsByTagName("param"); - String[] result = new String[nodeList.getLength()]; - for (int i = 0; i < nodeList.getLength(); i++) - { - Node n = nodeList.item(i).getFirstChild(); - if (n instanceof CDATASection) - result[i] = ((CDATASection) n).getData(); - else if (n instanceof Text) - result[i] = ((Text) n).getData(); - } - return result; - } - catch (Exception ex) - { - Logger.error("Exception::PredefinedStep::getDataList()"); - Logger.error(ex); - } - return null; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java deleted file mode 100644 index e1f9ffc..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; -import com.c2kernel.graph.model.GraphPoint; -import com.c2kernel.lifecycle.instance.CompositeActivity; -public abstract class PredefinedStepContainer extends CompositeActivity -{ - protected int num = 0; - - public PredefinedStepContainer() - { - super(); - setName("predefined"); - getProperties().put("Description", "Contains all predefined Steps"); - createChildren(); - } - public void createChildren() - { - predInit("AddDomainPath", "Adds a new path to this entity in the LDAP domain tree", new AddDomainPath()); - predInit("RemoveDomainPath", "Removes an existing path to this Entity from the LDAP domain tree", new RemoveDomainPath()); - predInit("ReplaceDomainWorkflow", "Replaces the domain CA with the supplied one. Used by the GUI to save new Wf layout", new ReplaceDomainWorkflow()); - predInit("AddC2KObject", "Adds or overwrites a C2Kernel object for this Item", new AddC2KObject()); - predInit("RemoveC2KObject", "Removes the named C2Kernel object from this Item.", new RemoveC2KObject()); - predInit("WriteProperty", "Writes a property to the Item", new WriteProperty()); - predInit("WriteViewpoint", "Writes a viewpoint to the Item", new WriteViewpoint()); - predInit("AddNewCollectionDescription", "Creates a new collection description in this Item", new AddNewCollectionDescription()); - predInit("CreateNewCollectionVersion", "Creates a new numbered collection version in this Item from the current one.", new CreateNewCollectionVersion()); - predInit("AddNewSlot", "Creates a new slot in the given aggregation, that holds instances of the item description of the given key", new AddNewSlot()); - predInit("AssignItemToSlot", "Assigns the referenced entity to a pre-existing slot in an aggregation", new AssignItemToSlot()); - predInit("ClearSlot", "Clears an aggregation member slot, given a slot no or entity key", new ClearSlot()); - predInit("RemoveSlotFromCollection", "Removed the given slot from the aggregation", new RemoveSlotFromCollection()); - predInit("AddMemberToCollection", "Creates a new member slot for the given item in a dependency, and assigns the item", new AddMemberToCollection()); - predInit("Import", "Imports an outcome into the Item, with a given schema and viewpoint", new Import()); - - } - - public void predInit(String alias, String Description, PredefinedStep act) - { - act.setName(alias); - act.setType(alias); - act.getProperties().put("Description", Description); - act.setCentrePoint(new GraphPoint()); - act.setIsPredefined(true); - addChild(act, new GraphPoint(100, 75 * ++num)); - } - @Override - public boolean verify() - { - return true; - } - @Override - public String getErrors() - { - return "predefined"; - } - @Override - public boolean getActive() - { - return true; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java deleted file mode 100644 index ef7d16b..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - - -import java.util.Arrays; - -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2005/11/15 15:56:38 $ - * @version $Revision: 1.28 $ - **************************************************************************/ -public class RemoveC2KObject extends PredefinedStep -{ - public RemoveC2KObject() - { - super(); - getProperties().put("Agent Role", "Admin"); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, PersistencyException { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "RemoveC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) - throw new InvalidDataException("RemoveC2KObject: Invalid parameters "+Arrays.toString(params)); - String path = params[0]; - - try - { - Gateway.getStorage().remove( item, path, null ); - } - catch( PersistencyException ex ) - { - throw new PersistencyException("RemoveC2KObject: Error removing object '"+path+"': "+ex.getMessage()); - } - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java deleted file mode 100644 index 3308003..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - - - -import java.util.Arrays; - -import com.c2kernel.common.CannotManageException; -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.ItemPath; -import com.c2kernel.lookup.LookupManager; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class RemoveDomainPath extends PredefinedStep -{ - public RemoveDomainPath() - { - super(); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "RemoveDomainPath: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) throw new InvalidDataException("RemoveDomainPath: Invalid parameters "+Arrays.toString(params)); - - DomainPath domainPath = new DomainPath(params[0]); - if (!domainPath.exists()) - throw new ObjectNotFoundException("RemoveDomainPath: Domain path "+domainPath.toString()+" does not exist."); - - if (domainPath.getType()!=DomainPath.ENTITY) - - try { - if (!domainPath.getItemPath().equals(item)) - throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" is not an alias of the current Item "+item); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" is a context."); - } - - LookupManager lookupManager = Gateway.getLookupManager(); - lookupManager.delete(domainPath); - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java deleted file mode 100644 index 7bd921b..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - - -import java.util.Arrays; - -import com.c2kernel.collection.Collection; -import com.c2kernel.collection.CollectionMember; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.8 $ - **************************************************************************/ -public class RemoveSlotFromCollection extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castor - **************************************************************************/ - public RemoveSlotFromCollection() - { - super(); - } - - - /** - * Params: - * 0 - collection name - * 1 - slot number OR if null: - * 2 - target entity key - * @throws ObjectNotFoundException - * @throws PersistencyException - */ - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, PersistencyException { - - String collName; - int slotNo = -1; - ItemPath currentChild = null; - Collection coll; - - // extract parameters - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "RemoveSlotFromCollection: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - - try { - collName = params[0]; - if (params.length>1 && params[1].length()>0) slotNo = Integer.parseInt(params[1]); - if (params.length>2 && params[2].length()>0) currentChild = new ItemPath(params[2]); - } catch (Exception e) { - throw new InvalidDataException("RemoveSlotFromCollection: Invalid parameters "+Arrays.toString(params)); - } - - if (slotNo == -1 && currentChild == null) - throw new InvalidDataException("RemoveSlotFromCollection: Must give either slot number or entity key"); - - // load collection - try { - coll = (Collection)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null); - } catch (PersistencyException ex) { - Logger.error(ex); - throw new PersistencyException("RemoveSlotFromCollection: Error loading collection '\"+collName+\"': "+ex.getMessage()); - } - - // check the slot is there if it's given by id - CollectionMember slot = null; - if (slotNo > -1) { - slot = coll.getMember(slotNo); - } - - // if both parameters are supplied, check the given item is actually in that slot - if (slot != null && currentChild != null && !slot.getItemPath().equals(currentChild)) { - throw new ObjectNotFoundException("RemoveSlotFromCollection: Item "+currentChild+" was not in slot "+slotNo); - } - - if (slotNo == -1) { // find slot from entity key - for (CollectionMember member : coll.getMembers().list) { - if (member.getItemPath().equals(currentChild)) { - slotNo = member.getID(); - break; - } - } - } - if (slotNo == -1) { - throw new ObjectNotFoundException("Could not find "+currentChild+" in collection "+coll.getName()); - } - - // Remove the slot - coll.removeMember(slotNo); - - // Store the collection - try { - Gateway.getStorage().put(item, coll, null); - } catch (PersistencyException e) { - Logger.error(e); - throw new PersistencyException("Error storing collection"); - } - - return requestData; - - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java deleted file mode 100644 index f2d34c4..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - -//Java -import java.util.Arrays; - -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.graph.model.GraphPoint; -import com.c2kernel.lifecycle.instance.CompositeActivity; -import com.c2kernel.lifecycle.instance.Workflow; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class ReplaceDomainWorkflow extends PredefinedStep -{ - public ReplaceDomainWorkflow() - { - super(); - getProperties().put("Agent Role", "Admin"); - } - - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, PersistencyException { - - Workflow lifeCycle = getWf(); - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) throw new InvalidDataException("AddC2KObject: Invalid parameters "+Arrays.toString(params)); - - lifeCycle.getChildGraphModel().removeVertex(lifeCycle.search("workflow/domain")); - CompositeActivity domain; - try { - domain = (CompositeActivity) Gateway.getMarshaller().unmarshall(params[0]); - } catch (Exception e) { - Logger.error(e); - throw new InvalidDataException("ReplaceDomainWorkflow: Could not unmarshall new workflow: "+e.getMessage()); - } - domain.setName("domain"); - lifeCycle.initChild(domain, true, new GraphPoint(150, 100)); - // if new workflow, activate it, otherwise refresh the jobs - if (!domain.active) lifeCycle.run(agent, item); - else lifeCycle.refreshJobs(item); - - // store new wf - try { - Gateway.getStorage().put(item, lifeCycle, null); - } catch (PersistencyException e) { - throw new PersistencyException("ReplaceDomainWorkflow: Could not write new workflow to storage: "+e.getMessage()); - } - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java deleted file mode 100644 index 2813f43..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - -import java.util.Arrays; - -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.property.Property; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $ - * @version $Revision: 1.3 $ - **************************************************************************/ -public class WriteProperty extends PredefinedStep -{ - /************************************************************************** - * Constructor for Castror - **************************************************************************/ - public WriteProperty() - { - super(); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectCannotBeUpdated, ObjectNotFoundException, PersistencyException { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "WriteProperty: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - - if (params.length != 2) - throw new InvalidDataException("WriteProperty: invalid parameters "+Arrays.toString(params)); - - String name = params[0]; - String newValue = params[1]; - - Property prop; - - try { - prop = (Property)Gateway.getStorage().get(item, ClusterStorage.PROPERTY+"/"+name, null); - if (!prop.isMutable() && !newValue.equals(prop.getValue())) - throw new ObjectCannotBeUpdated("WriteProperty: Property '"+name+"' is not mutable."); - prop.setValue(newValue); - Gateway.getStorage().put(item, prop, null); - } catch (ObjectNotFoundException e) { - throw new ObjectNotFoundException("WriteProperty: Property '"+name+"' not found."); - } - - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java deleted file mode 100644 index a8a17ce..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined; - -import java.util.Arrays; - -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.events.Event; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.persistency.outcome.Viewpoint; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class WriteViewpoint extends PredefinedStep { - - public WriteViewpoint() { - super(); - } - - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, PersistencyException { - - String schemaName; - String viewName; - int evId; - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "WriteViewpoint: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - - // outcometype, name and evId. Event and Outcome should be checked so schema version should be discovered. - if (params.length != 3) - throw new InvalidDataException("WriteViewpoint: Invalid parameters "+Arrays.toString(params)); - - schemaName = params[0]; - viewName = params[1]; - - try { - evId = Integer.parseInt(params[2]); - } catch (NumberFormatException ex) { - throw new InvalidDataException("WriteViewpoint: Parameter 3 (EventId) must be an integer"); - } - - // Find event - - Event ev; - try { - ev = (Event)Gateway.getStorage().get(item, ClusterStorage.HISTORY+"/"+evId, null); - } catch (PersistencyException e) { - Logger.error(e); - throw new PersistencyException("WriteViewpoint: Could not load event "+evId); - } - - // Write new viewpoint - Viewpoint newView = new Viewpoint(item, schemaName, viewName, ev.getSchemaVersion(), evId); - try { - Gateway.getStorage().put(item, newView, null); - } catch (PersistencyException e) { - Logger.error(e); - throw new PersistencyException("WriteViewpoint: Could not store new viewpoint"); - } - return requestData; - } - -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/AgentPredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/AgentPredefinedStepContainer.java deleted file mode 100644 index 6ded51a..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/AgentPredefinedStepContainer.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.agent; - -import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer; - - -/************************************************************************** - * - * $Revision: 1.2 $ - * $Date: 2005/06/02 10:19:33 $ - * - * Copyright (C) 2003 CERN - European Organization for Nuclear Research - * All rights reserved. - **************************************************************************/ - -public class AgentPredefinedStepContainer extends PredefinedStepContainer { - - - @Override - public void createChildren() - { - super.createChildren(); - predInit("CreateAgentFromDescription", "Create a new item using this item as its description", new CreateAgentFromDescription()); - predInit("RemoveAgent", "Deletes the Agent", new RemoveAgent()); - predInit("SetAgentPassword", "Changes the Agent's password", new SetAgentPassword()); - predInit("SetAgentRoles", "Sets the roles of the Agent", new SetAgentRoles()); - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java deleted file mode 100644 index a2dfeae..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.agent; - -import java.util.Arrays; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.entity.CorbaServer; -import com.c2kernel.entity.agent.ActiveEntity; -import com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.lookup.RolePath; -import com.c2kernel.process.Gateway; -import com.c2kernel.property.PropertyArrayList; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2005/10/13 08:13:58 $ - * @version $Revision: 1.47 $ - **************************************************************************/ -public class CreateAgentFromDescription extends CreateItemFromDescription -{ - public CreateAgentFromDescription() - { - super(); - } - - /** - * Params: - *
  1. New Agent name
  2. - *
  3. Description version to use
  4. - *
  5. Comma-delimited Role names to assign to the agent. Must already exist.
  6. - *
  7. Initial properties to set in the new Agent
  8. - *
- * @throws ObjectNotFoundException - * @throws InvalidDataException The input parameters were incorrect - * @throws ObjectAlreadyExistsException The Agent already exists - * @throws CannotManageException The Agent could not be created - * @throws ObjectCannotBeUpdated The addition of the new entries into the LookupManager failed - * @see com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription#runActivityLogic(com.c2kernel.lookup.AgentPath, int, int, java.lang.String) - */ - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws ObjectNotFoundException, InvalidDataException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "CreateAgentFromDescription: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length < 3 || params.length > 4) - throw new InvalidDataException("CreateAgentFromDescription: Invalid parameters "+Arrays.toString(params)); - - String newName = params[0]; - String descVer = params[1]; - String roles = params[2]; - PropertyArrayList initProps = - params.length > 3 ? getInitProperties(params[3]):new PropertyArrayList(); - - Logger.msg(1, "CreateAgentFromDescription::request() - Starting."); - - // check if given roles exist - String[] roleArr = roles.split(","); - for(int i=0; i requestedRoles = new ArrayList(); - for (int i=0; i rolesToRemove = new ArrayList(); - for (RolePath existingRole : currentRoles) { // - if (requestedRoles.contains(existingRole)) // if we have it, and it's requested, then it will be kept - requestedRoles.remove(existingRole); // so remove it from request - this will be left with roles to be added - else - rolesToRemove.add(existingRole); // else this role will be removed - } - - // remove roles not in new list - for (RolePath roleToRemove : rolesToRemove) - try { - Gateway.getLookupManager().removeRole(targetAgent, roleToRemove); - } catch (Exception e) { - Logger.error(e); - throw new InvalidDataException("Error removing role "+roleToRemove.getName()); - } - - // add requested roles we don't already have - for (RolePath roleToAdd : requestedRoles) - try { - Gateway.getLookupManager().addRole(targetAgent, roleToAdd); - } catch (Exception e) { - Logger.error(e); - throw new InvalidDataException("Error adding role "+roleToAdd.getName()); - } - - return requestData; - } - -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java deleted file mode 100644 index 140f68c..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.item; - -import com.c2kernel.collection.Collection; -import com.c2kernel.collection.CollectionArrayList; -import com.c2kernel.collection.CollectionDescription; -import com.c2kernel.collection.CollectionMember; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.entity.CorbaServer; -import com.c2kernel.entity.TraceableEntity; -import com.c2kernel.lifecycle.CompositeActivityDef; -import com.c2kernel.lifecycle.instance.CompositeActivity; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.persistency.ClusterStorage; -import com.c2kernel.process.Gateway; -import com.c2kernel.property.Property; -import com.c2kernel.property.PropertyArrayList; -import com.c2kernel.property.PropertyDescriptionList; -import com.c2kernel.property.PropertyUtility; -import com.c2kernel.utils.LocalObjectLoader; -import com.c2kernel.utils.Logger; - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2005/10/13 08:13:58 $ - * @version $Revision: 1.47 $ - **************************************************************************/ -public class CreateItemFromDescription extends PredefinedStep -{ - public CreateItemFromDescription() - { - super(); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath itemPath, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated, PersistencyException { - - String[] input = getDataList(requestData); - String newName = input[0]; - String domPath = input[1]; - String descVer = input.length > 2 ? input[2]:"last"; - PropertyArrayList initProps = - input.length > 3?getInitProperties(input[3]):new PropertyArrayList(); - - Logger.msg(1, "CreateItemFromDescription - Starting."); - - // check if the path is already taken - DomainPath context = new DomainPath(new DomainPath(domPath), newName); - //Logger.debug(8,"context "+context.getItemPath()+" "+context.getPath()+" "+context.getString()); - if (context.exists()) - throw new ObjectAlreadyExistsException("The path " +context+ " exists already."); - - // get init objects - - /* ITEM CREATION */ - - // generate new entity key - Logger.msg(6, "CreateItemFromDescription - Requesting new item path"); - ItemPath newItemPath = new ItemPath(); - - // resolve the item factory - Logger.msg(6, "CreateItemFromDescription - Resolving item factory"); - - // create the Item object - Logger.msg(3, "CreateItemFromDescription - Creating Item"); - CorbaServer factory = Gateway.getCorbaServer(); - if (factory == null) throw new CannotManageException("This process cannot create new Items"); - TraceableEntity newItem = factory.createItem(newItemPath); - Gateway.getLookupManager().add(newItemPath); - - - // initialise it with its properties and workflow - - Logger.msg(3, "CreateItemFromDescription - Initializing Item"); - - try { - newItem.initialise( - agent.getSystemKey(), - Gateway.getMarshaller().marshall(getNewProperties(itemPath, descVer, initProps, newName, agent)), - Gateway.getMarshaller().marshall(getNewWorkflow(itemPath, descVer)), - Gateway.getMarshaller().marshall(getNewCollections(itemPath, descVer)) - ); - } catch (PersistencyException e) { - throw e; - } catch (Exception e) { - throw new InvalidDataException("CreateAgentFromDescription: Problem initializing new Agent. See log: "+e.getMessage()); - } - // add its domain path - Logger.msg(3, "CreateItemFromDescription - Creating "+context); - context.setItemPath(newItemPath); - Gateway.getLookupManager().add(context); - return requestData; - } - - protected PropertyArrayList getInitProperties(String input) throws InvalidDataException { - try { - return (PropertyArrayList)Gateway.getMarshaller().unmarshall(input); - } catch (Exception e) { - Logger.error(e); - throw new InvalidDataException("Initial property parameter was not a marshalled PropertyArrayList: "+input); - } - } - - protected PropertyArrayList getNewProperties(ItemPath itemPath, String descVer, PropertyArrayList initProps, String newName, AgentPath agent) throws ObjectNotFoundException, InvalidDataException { - // copy properties -- intend to create from propdesc - PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer); - PropertyArrayList props = pdList.instantiate(initProps); - // set Name prop or create if not present - boolean foundName = false; - for (Property prop : props.list) { - if (prop.getName().equals("Name")) { - foundName = true; - prop.setValue(newName); - } - } - if (!foundName) props.list.add(new Property("Name", newName, true)); - props.list.add( new Property("Creator", agent.getAgentName(), false)); - return props; - } - - protected CompositeActivity getNewWorkflow(ItemPath itemPath, String descVer) throws ObjectNotFoundException, InvalidDataException, PersistencyException { - // find the workflow def for the given description version - - String wfDefName = null; Integer wfDefVer = null; - - Collection thisCol = (Collection)Gateway.getStorage().get(itemPath, ClusterStorage.COLLECTION+"/workflow/"+descVer, null); - CollectionMember wfMember = thisCol.getMembers().list.get(0); - wfDefName = wfMember.resolveItem().getName(); - Object wfVerObj = wfMember.getProperties().get("Version"); - try { - wfDefVer = Integer.parseInt(wfVerObj.toString()); - } catch (NumberFormatException ex) { - throw new InvalidDataException("Invalid workflow version number: "+wfVerObj.toString()); - } - - // load workflow def - if (wfDefName == null) - throw new InvalidDataException("No workflow given or defined"); - if (wfDefVer == null) - throw new InvalidDataException("No workflow def version given"); - - try { - CompositeActivityDef wfDef = (CompositeActivityDef)LocalObjectLoader.getActDef(wfDefName, wfDefVer); - return (CompositeActivity)wfDef.instantiate(); - } catch (ObjectNotFoundException ex) { - throw new InvalidDataException("Workflow def '"+wfDefName+"'v"+wfDefVer+" not found"); - } catch (ClassCastException ex) { - throw new InvalidDataException("Activity def '"+wfDefName+"' was not Composite"); - } - } - - protected CollectionArrayList getNewCollections(ItemPath itemPath, String descVer) throws ObjectNotFoundException, PersistencyException { - // loop through collections, collecting instantiated descriptions and finding the default workflow def - CollectionArrayList colls = new CollectionArrayList(); - String[] collNames = Gateway.getStorage().getClusterContents(itemPath, ClusterStorage.COLLECTION); - for (String collName : collNames) { - Collection thisCol = (Collection)Gateway.getStorage().get(itemPath, ClusterStorage.COLLECTION+"/"+collName+"/"+descVer, null); - if (thisCol instanceof CollectionDescription) { - CollectionDescription thisDesc = (CollectionDescription)thisCol; - colls.put(thisDesc.newInstance()); - } - } - return colls; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java deleted file mode 100644 index a34b202..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.item; - - - -import java.util.Iterator; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.common.PersistencyException; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.lookup.Path; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - - -/************************************************************************** - * - * @author $Author: abranson $ $Date: 2005/11/15 15:56:38 $ - * @version $Revision: 1.10 $ - **************************************************************************/ -public class Erase extends PredefinedStep -{ - public Erase() - { - super(); - getProperties().put("Agent Role", "Admin"); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, PersistencyException { - - Logger.msg(1, "Erase::request() - Starting."); - - Iterator domPaths = Gateway.getLookup().searchAliases(item); - while (domPaths.hasNext()) { - DomainPath path = (DomainPath)domPaths.next(); - // delete them - if (path.getItemPath().equals(item)) - Gateway.getLookupManager().delete(path); - } - - //clear out all storages - Gateway.getStorage().removeCluster(item, "", null); - - //remove entity path - Gateway.getLookupManager().delete(item); - - Logger.msg(1, "Erase::request() - DONE."); - return requestData; - } - -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/ItemPredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/ItemPredefinedStepContainer.java deleted file mode 100644 index 57aefa3..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/ItemPredefinedStepContainer.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.item; - -import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer; - - -/************************************************************************** - * - * $Revision: 1.2 $ - * $Date: 2005/06/02 10:19:33 $ - * - * Copyright (C) 2003 CERN - European Organization for Nuclear Research - * All rights reserved. - **************************************************************************/ - -public class ItemPredefinedStepContainer extends PredefinedStepContainer { - - - @Override - public void createChildren() - { - super.createChildren(); - predInit("CreateItemFromDescription", "Create a new item using this item as its description", new CreateItemFromDescription()); - predInit("Erase", "Deletes all objects and domain paths for this item.", new Erase()); - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java deleted file mode 100644 index e6bfba9..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.server; - -import java.util.Arrays; -import java.util.Stack; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class AddDomainContext extends PredefinedStep { - - public AddDomainContext() { - super(); - } - - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "AddDomainContext: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) throw new InvalidDataException("AddDomainContext: Invalid parameters "+Arrays.toString(params)); - - DomainPath pathToAdd = new DomainPath(params); - if (pathToAdd.exists()) - throw new ObjectAlreadyExistsException("Context "+pathToAdd+" already exists"); - // collect parent paths if they don't exist - Stack pathsToAdd = new Stack(); - while(pathToAdd!= null && !pathToAdd.exists()) { - pathsToAdd.push(pathToAdd); - pathToAdd = pathToAdd.getParent(); - } - while(!pathsToAdd.empty()) { - pathToAdd = pathsToAdd.pop(); - Gateway.getLookupManager().add(pathToAdd); - } - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java deleted file mode 100644 index 92f4357..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.server; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.imports.ImportAgent; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class CreateNewAgent extends PredefinedStep -{ - public CreateNewAgent() - { - super(); - getProperties().put("SchemaType", "Agent"); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException { - - String redactedRequestData; - - ImportAgent newAgent; - try { - newAgent = (ImportAgent)Gateway.getMarshaller().unmarshall(requestData); - } catch (Exception e1) { - Logger.error(e1); - throw new InvalidDataException("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData); - } - newAgent.create(agent, true); - newAgent.setPassword("REDACTED"); - try { - redactedRequestData = Gateway.getMarshaller().marshall(newAgent); - } catch (Exception e) { - Logger.error(e); - throw new InvalidDataException("CreateNewAgent: Couldn't marshall new Agent for outcome: "+newAgent); - } - return redactedRequestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java deleted file mode 100644 index fde9f82..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.server; - - - - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidCollectionModification; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.imports.ImportItem; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class CreateNewItem extends PredefinedStep -{ - public CreateNewItem() - { - super(); - getProperties().put("SchemaType", "Item"); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, InvalidCollectionModification { - - ImportItem newItem; - try { - newItem = (ImportItem)Gateway.getMarshaller().unmarshall(requestData); - } catch (Exception e) { - Logger.error(e); - throw new InvalidDataException("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData); - } - newItem.create(agent, false); - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java deleted file mode 100644 index f99e54c..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewRole.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.server; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.entity.imports.ImportRole; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class CreateNewRole extends PredefinedStep -{ - public CreateNewRole() - { - super(); - getProperties().put("SchemaType", "Role"); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException { - - - ImportRole newRole; - try { - newRole = (ImportRole)Gateway.getMarshaller().unmarshall(requestData); - } catch (Exception e) { - Logger.error(e); - throw new InvalidDataException("CreateNewAgent: Couldn't unmarshall new Agent: "+requestData); - } - newRole.create(agent, true); - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java deleted file mode 100644 index a4520aa..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.server; - -import java.util.Arrays; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class RemoveDomainContext extends PredefinedStep { - public RemoveDomainContext() { - super(); - } - - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "RemoveDomainContext: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) throw new InvalidDataException("RemoveDomainContext: Invalid parameters "+Arrays.toString(params)); - - DomainPath pathToDelete = new DomainPath(params[0]); - if (!pathToDelete.exists()) - throw new ObjectNotFoundException("Context "+pathToDelete+" does not exist"); - - try { - pathToDelete.getItemPath(); - throw new InvalidDataException("Path "+pathToDelete+" is an Entity. Use its own Erase step instead, or RemoveAgent."); - } catch (ObjectNotFoundException ex) { } - - if (Gateway.getLookup().getChildren(pathToDelete).hasNext()) - throw new ObjectCannotBeUpdated("Context "+pathToDelete+" is not empty. Cannot delete."); - - Gateway.getLookupManager().delete(pathToDelete); - return requestData; - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java deleted file mode 100644 index a75b98c..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveRole.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.server; - -import java.util.Arrays; - -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.ItemPath; -import com.c2kernel.lookup.LookupManager; -import com.c2kernel.lookup.RolePath; -import com.c2kernel.process.Gateway; -import com.c2kernel.utils.Logger; - -public class RemoveRole extends PredefinedStep -{ - public RemoveRole() - { - super(); - } - - //requestdata is xmlstring - @Override - protected String runActivityLogic(AgentPath agent, ItemPath item, - int transitionID, String requestData) throws InvalidDataException, CannotManageException, ObjectNotFoundException, ObjectCannotBeUpdated { - - String[] params = getDataList(requestData); - if (Logger.doLog(3)) Logger.msg(3, "RemoveRole: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params)); - if (params.length != 1) throw new InvalidDataException("RemoveRole: Invalid parameters "+Arrays.toString(params)); - - LookupManager lookup = Gateway.getLookupManager(); - - RolePath thisRole; AgentPath[] agents; - thisRole = lookup.getRolePath(params[0]); - agents = Gateway.getLookup().getAgents(thisRole); - - if (agents.length > 0) - throw new ObjectCannotBeUpdated("Cannot remove role. "+agents.length+" agents still hold it."); - - lookup.delete(thisRole); - - return requestData; - - } -} diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/ServerPredefinedStepContainer.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/ServerPredefinedStepContainer.java deleted file mode 100644 index 35ecd94..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/ServerPredefinedStepContainer.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * This file is part of the CRISTAL-iSE kernel. - * Copyright (c) 2001-2014 The CRISTAL Consortium. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * http://www.fsf.org/licensing/licenses/lgpl.html - */ -package com.c2kernel.lifecycle.instance.predefined.server; - -import com.c2kernel.graph.model.GraphPoint; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; -import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer; - -/************************************************************************** - * - * $Revision: 1.2 $ - * $Date: 2005/06/02 10:19:33 $ - * - * Copyright (C) 2003 CERN - European Organization for Nuclear Research - * All rights reserved. - **************************************************************************/ - -public class ServerPredefinedStepContainer extends PredefinedStepContainer { - - - @Override - public void createChildren() - { - super.createChildren(); - serverPredInit("CreateNewItem", "Creates a new Item in this Server without description.", new CreateNewItem()); - serverPredInit("CreateNewAgent", "Creates a new Agent in this Server without description.", new CreateNewAgent()); - serverPredInit("CreateNewRole", "Creates a new Role in this Server.", new CreateNewRole()); - serverPredInit("RemoveRole", "Removes a Role from this Server.", new RemoveRole()); - serverPredInit("RemoveDomainContext", "Deletes an existing context in the domain tree, but only if empty", new RemoveDomainContext()); - serverPredInit("AddDomainContext", "Creates an empty domain context in the tree", new AddDomainContext()); - } - - public void serverPredInit(String alias, String Description, PredefinedStep act) - { - act.setName(alias); - act.setType(alias); - act.getProperties().put("Description", Description); - act.getProperties().put("Agent Role", "Admin"); - act.setCentrePoint(new GraphPoint()); - act.setIsPredefined(true); - addChild(act, new GraphPoint(100, 75 * ++num)); - } - -} -- cgit v1.2.3