Search in sources :

Example 1 with ImportRole

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

the class CreateNewRole method runActivityLogic.

@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException {
    try {
        ImportRole newRole = (ImportRole) Gateway.getMarshaller().unmarshall(requestData);
        if (Gateway.getLookup().exists(new RolePath(newRole.getName(), newRole.jobList)))
            throw new ObjectAlreadyExistsException("CreateNewRole: Role '" + newRole.getName() + "' already exists.");
        newRole.create(agent, true);
        return requestData;
    } catch (MarshalException | ValidationException | IOException | MappingException e) {
        Logger.error(e);
        throw new InvalidDataException("CreateNewRole: Couldn't unmarshall new Role: " + requestData);
    }
}
Also used : MarshalException(org.exolab.castor.xml.MarshalException) ValidationException(org.exolab.castor.xml.ValidationException) ImportRole(org.cristalise.kernel.entity.imports.ImportRole) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) IOException(java.io.IOException) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException) RolePath(org.cristalise.kernel.lookup.RolePath) MappingException(org.exolab.castor.mapping.MappingException)

Aggregations

IOException (java.io.IOException)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)1 ImportRole (org.cristalise.kernel.entity.imports.ImportRole)1 RolePath (org.cristalise.kernel.lookup.RolePath)1 MappingException (org.exolab.castor.mapping.MappingException)1 MarshalException (org.exolab.castor.xml.MarshalException)1 ValidationException (org.exolab.castor.xml.ValidationException)1