use of org.cristalise.kernel.common.ObjectAlreadyExistsException in project kernel by cristal-ise.
the class AggregationDescription method newInstance.
/**
* For each member get the {@link PropertyDescriptionList} of the member item and look for an explicit version
*/
@Override
public Aggregation newInstance() throws ObjectNotFoundException {
AggregationInstance newInstance = new AggregationInstance(getName());
for (int i = 0; i < size(); i++) {
AggregationMember mem = mMembers.list.get(i);
//
String descVer = getDescVer(mem);
PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath(), descVer, null);
if (pdList != null) {
// create the new props of the member object
try {
Vertex v = getLayout().getVertexById(mem.getID());
newInstance.addMember(null, PropertyUtility.convertTransitiveProperties(pdList), pdList.getClassProps(), v.getCentrePoint(), v.getWidth(), v.getHeight());
} catch (InvalidCollectionModification e) {
} catch (ObjectAlreadyExistsException e) {
}
} else {
Logger.error("AggregationDescription::newInstance() There is no PropertyDescription. Cannot instantiate. " + mem.getItemPath());
return null;
}
}
return newInstance;
}
use of org.cristalise.kernel.common.ObjectAlreadyExistsException in project kernel by cristal-ise.
the class CreateAgentFromDescription method runActivityLogic.
/**
* Params:
* <ol>
* <li>Agent name</li>
* <li>Domain context</li>
* <li>Comma-delimited Role names to assign to the Agent</li>
* <li>Password (optional)</li>
* <li>Initial properties to set in the new Agent (optional)</li>
* <li>Description version to use(optional)</li>
* </ol>
* @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
* @throws PersistencyException
* @see org.cristalise.kernel.lifecycle.instance.predefined.item.CreateItemFromDescription#runActivityLogic(AgentPath, ItemPath, int, String, Object)
*/
@Override
protected String runActivityLogic(AgentPath agentPath, ItemPath descItemPath, int transitionID, String requestData, Object locker) throws ObjectNotFoundException, InvalidDataException, ObjectAlreadyExistsException, CannotManageException, ObjectCannotBeUpdated, PersistencyException {
String[] input = getDataList(requestData);
String newName = input[0];
String contextS = input[1];
String[] roles = input[2].split(",");
String pwd = input.length > 3 ? input[3] : "";
String descVer = input.length > 4 ? input[4] : "last";
PropertyArrayList initProps = input.length > 5 ? unmarshallInitProperties(input[5]) : new PropertyArrayList();
// generate new agent path with new UUID
Logger.msg(1, "CreateAgentFromDescription - Requesting new agent path name:" + newName);
AgentPath newAgentPath = new AgentPath(new ItemPath(), newName);
// check if the agent's name is already taken
if (Gateway.getLookup().exists(newAgentPath))
throw new ObjectAlreadyExistsException("The agent name " + newName + " exists already.");
DomainPath context = new DomainPath(new DomainPath(contextS), newName);
if (context.exists())
throw new ObjectAlreadyExistsException("The path " + context + " exists already.");
ActiveEntity newAgent = createAgentAddRoles(newAgentPath, roles, pwd);
initialiseItem(newAgent, agentPath, descItemPath, initProps, newName, descVer, context, newAgentPath, locker);
// censor password from outcome
if (input.length > 3)
input[3] = "REDACTED";
return bundleData(input);
}
use of org.cristalise.kernel.common.ObjectAlreadyExistsException in project kernel by cristal-ise.
the class AddDomainContext method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
String[] params = getDataList(requestData);
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[0]);
if (pathToAdd.exists())
throw new ObjectAlreadyExistsException("Context " + pathToAdd + " already exists");
// collect parent paths if they don't exist
Stack<DomainPath> pathsToAdd = new Stack<DomainPath>();
while (pathToAdd != null && !pathToAdd.exists()) {
pathsToAdd.push(pathToAdd);
pathToAdd = pathToAdd.getParent();
}
while (!pathsToAdd.empty()) {
pathToAdd = pathsToAdd.pop();
Gateway.getLookupManager().add(pathToAdd);
}
return requestData;
}
use of org.cristalise.kernel.common.ObjectAlreadyExistsException 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.ObjectAlreadyExistsException 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());
}
}
Aggregations