use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class AddNewCollectionDescription method runActivityLogic.
/**
* Params: 0 - collection name 1 - collection type (Aggregation, Dependency)
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException {
// 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));
String collName = params[0];
String collType = params[1];
// check if collection already exists
try {
Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
throw new ObjectAlreadyExistsException("Collection '" + collName + "' already exists");
} catch (ObjectNotFoundException ex) {
// collection doesn't exist
}
CollectionDescription<?> newCollDesc;
if (collType.equalsIgnoreCase("Aggregation"))
newCollDesc = new AggregationDescription(collName);
else if (collType.equalsIgnoreCase("Dependency"))
newCollDesc = new DependencyDescription(collName);
else
throw new InvalidDataException("AddNewCollectionDescription: Invalid type: '" + collType + "' /Aggregation or Dependency)");
// store it
try {
Gateway.getStorage().put(item, newCollDesc, locker);
} catch (PersistencyException e) {
throw new PersistencyException("AddNewCollectionDescription: Error saving new collection '" + collName + "': " + e.getMessage());
}
return requestData;
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class CreateItemFromDescription method initialiseItem.
/**
* @param agent
* @param descItemPath
* @param locker
* @param input
* @param newName
* @param descVer
* @param context
* @param newItemPath
* @param newItem
* @throws ObjectCannotBeUpdated
* @throws CannotManageException
* @throws InvalidDataException
* @throws ObjectAlreadyExistsException
* @throws PersistencyException
* @throws ObjectNotFoundException
*/
protected void initialiseItem(ItemOperations newItem, AgentPath agent, ItemPath descItemPath, PropertyArrayList initProps, String newName, String descVer, DomainPath context, ItemPath newItemPath, Object locker) throws ObjectCannotBeUpdated, CannotManageException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException {
// initialise it with its properties and workflow
Logger.msg(3, "CreateItemFromDescription.initialiseItem() - Initializing Item:" + newName);
try {
PropertyArrayList newProps = instantiateProperties(descItemPath, descVer, initProps, newName, agent, locker);
CollectionArrayList newColls = instantiateCollections(descItemPath, descVer, newProps, locker);
CompositeActivity newWorkflow = instantiateWorkflow(descItemPath, descVer, locker);
newItem.initialise(agent.getSystemKey(), Gateway.getMarshaller().marshall(newProps), Gateway.getMarshaller().marshall(newWorkflow), Gateway.getMarshaller().marshall(newColls));
} catch (MarshalException | ValidationException | AccessRightsException | IOException | MappingException | InvalidCollectionModification e) {
Logger.error(e);
Gateway.getLookupManager().delete(newItemPath);
throw new InvalidDataException("CreateItemFromDescription: Problem initializing new Item. See log: " + e.getMessage());
} catch (InvalidDataException | ObjectNotFoundException | PersistencyException e) {
Logger.error(e);
Gateway.getLookupManager().delete(newItemPath);
throw e;
}
// add its domain path
Logger.msg(3, "CreateItemFromDescription - Creating " + context);
context.setItemPath(newItemPath);
Gateway.getLookupManager().add(context);
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class BulkImport method importAgentPath.
public AgentPath importAgentPath(ItemPath item, Object locker) throws PersistencyException {
try {
AgentPath agentPath = (AgentPath) importCluster.get(item, PATH + "/Item");
Gateway.getLookupManager().add(agentPath);
Gateway.getLookupManager().setAgentPassword(agentPath, "aaa");
return agentPath;
} catch (ObjectCannotBeUpdated | ObjectAlreadyExistsException | CannotManageException | ObjectNotFoundException | NoSuchAlgorithmException e) {
Logger.error(e);
throw new PersistencyException(e.getMessage());
}
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class BulkImport method importItemPath.
public ItemPath importItemPath(ItemPath item, Object locker) throws PersistencyException {
try {
ItemPath itemPath = (ItemPath) importCluster.get(item, PATH + "/Item");
Gateway.getLookupManager().add(itemPath);
return itemPath;
} catch (ObjectCannotBeUpdated | ObjectAlreadyExistsException | CannotManageException e) {
Logger.error(e);
throw new PersistencyException(e.getMessage());
}
}
use of org.cristalise.kernel.common.PersistencyException in project kernel by cristal-ise.
the class CreateNewItem method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, InvalidCollectionModification {
try {
ImportItem newItem = (ImportItem) Gateway.getMarshaller().unmarshall(requestData);
newItem.create(agent, false);
return requestData;
} catch (MarshalException | ValidationException | IOException | MappingException e) {
Logger.error(e);
throw new InvalidDataException("CreateNewItem: Couldn't unmarshall new Item: " + requestData);
} catch (PersistencyException e) {
Logger.error(e);
throw new InvalidDataException("CreateNewItem: " + e.getMessage());
}
}
Aggregations