Search in sources :

Example 1 with ImportAgent

use of org.cristalise.kernel.entity.imports.ImportAgent in project kernel by cristal-ise.

the class CreateNewAgent method runActivityLogic.

@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException {
    try {
        ImportAgent newAgent = (ImportAgent) Gateway.getMarshaller().unmarshall(requestData);
        newAgent.create(agent, true);
        newAgent.setPassword("REDACTED");
        return Gateway.getMarshaller().marshall(newAgent);
    } catch (MarshalException | ValidationException | IOException | MappingException e) {
        Logger.error(e);
        throw new InvalidDataException("CreateNewAgent: Couldn't unmarshall new Agent: " + requestData);
    }
}
Also used : MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) IOException(java.io.IOException) ImportAgent(org.cristalise.kernel.entity.imports.ImportAgent) MappingException(org.exolab.castor.mapping.MappingException)

Example 2 with ImportAgent

use of org.cristalise.kernel.entity.imports.ImportAgent in project kernel by cristal-ise.

the class Module method importAgents.

/**
 * @param systemAgent
 * @param reset
 * @throws Exception
 */
private void importAgents(AgentProxy systemAgent, boolean reset) throws Exception {
    for (ImportAgent thisAgent : imports.getAgents()) {
        if (Bootstrap.shutdown)
            return;
        try {
            Gateway.getLookup().getAgentPath(thisAgent.name);
            Logger.msg(3, "Module.importAgents() - Agent '" + thisAgent.name + "' found.");
            continue;
        } catch (ObjectNotFoundException ex) {
        }
        Logger.msg("Module.importAgents() - Agent '" + thisAgent.name + "' not found. Creating.");
        addItemToContents(thisAgent.create(systemAgent.getPath(), reset));
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) ImportAgent(org.cristalise.kernel.entity.imports.ImportAgent)

Aggregations

ImportAgent (org.cristalise.kernel.entity.imports.ImportAgent)2 IOException (java.io.IOException)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 MappingException (org.exolab.castor.mapping.MappingException)1 MarshalException (org.exolab.castor.xml.MarshalException)1 ValidationException (org.exolab.castor.xml.ValidationException)1