/************************************************************************** * CreateNewAgent.java * * Copyright (C) 2001 CERN - European Organization for Nuclear Research * All rights reserved. **************************************************************************/ package com.c2kernel.lifecycle.instance.predefined.server; import com.c2kernel.common.InvalidDataException; 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 { String redactedRequestData; try { ImportAgent newAgent = (ImportAgent)Gateway.getMarshaller().unmarshall(requestData); newAgent.create(agent, true); newAgent.setPassword("REDACTED"); redactedRequestData = Gateway.getMarshaller().marshall(newAgent); return redactedRequestData; } catch (Exception ex) { Logger.error(ex); throw new InvalidDataException("Error creating agent", ""); } } }