use of org.cristalise.kernel.common.InvalidCollectionModification in project kernel by cristal-ise.
the class ItemImplementation method delegatedAction.
@Override
public String delegatedAction(SystemKey agentId, SystemKey delegateId, String stepPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, ObjectNotFoundException, InvalidDataException, PersistencyException, ObjectAlreadyExistsException, InvalidCollectionModification {
Workflow lifeCycle = null;
try {
AgentPath agent = new AgentPath(agentId);
AgentPath delegate = delegateId == null ? null : new AgentPath(delegateId);
Logger.msg(1, "ItemImplementation::request(" + mItemPath + ") - Transition " + transitionID + " on " + stepPath + " by " + (delegate == null ? "" : delegate + " on behalf of ") + agent);
// TODO: check if delegate is allowed valid for agent
lifeCycle = (Workflow) mStorage.get(mItemPath, ClusterType.LIFECYCLE + "/workflow", null);
String finalOutcome = lifeCycle.requestAction(agent, delegate, stepPath, mItemPath, transitionID, requestData);
// store the workflow if we've changed the state of the domain wf
if (!(stepPath.startsWith("workflow/predefined")))
mStorage.put(mItemPath, lifeCycle, lifeCycle);
// remove entity path if transaction was successful
if (stepPath.equals("workflow/predefined/Erase")) {
Logger.msg("Erasing item path " + mItemPath.toString());
Gateway.getLookupManager().delete(mItemPath);
}
mStorage.commit(lifeCycle);
return finalOutcome;
} catch (AccessRightsException | InvalidTransitionException | ObjectNotFoundException | PersistencyException | InvalidDataException | ObjectAlreadyExistsException | InvalidCollectionModification ex) {
if (Logger.doLog(8))
Logger.error(ex);
String errorOutcome = handleError(agentId, delegateId, stepPath, lifeCycle, ex);
if (StringUtils.isBlank(errorOutcome)) {
mStorage.abort(lifeCycle);
throw ex;
} else {
mStorage.commit(lifeCycle);
return errorOutcome;
}
} catch (InvalidAgentPathException | ObjectCannotBeUpdated | CannotManageException ex) {
if (Logger.doLog(8))
Logger.error(ex);
String errorOutcome = handleError(agentId, delegateId, stepPath, lifeCycle, ex);
if (StringUtils.isBlank(errorOutcome)) {
mStorage.abort(lifeCycle);
throw new InvalidDataException(ex.getClass().getName() + " - " + ex.getMessage());
} else {
mStorage.commit(lifeCycle);
return errorOutcome;
}
} catch (Exception ex) {
// non-CORBA exception hasn't been caught!
Logger.error("Unknown Error: requestAction on " + mItemPath + " by " + agentId + " executing " + stepPath);
Logger.error(ex);
String errorOutcome = handleError(agentId, delegateId, stepPath, lifeCycle, ex);
if (StringUtils.isBlank(errorOutcome)) {
mStorage.abort(lifeCycle);
throw new InvalidDataException("Extraordinary Exception during execution:" + ex.getClass().getName() + " - " + ex.getMessage());
} else {
mStorage.commit(lifeCycle);
return errorOutcome;
}
}
}
use of org.cristalise.kernel.common.InvalidCollectionModification in project kernel by cristal-ise.
the class Dependency method addMember.
/**
*/
@Override
public DependencyMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws InvalidCollectionModification, ObjectAlreadyExistsException {
if (itemPath == null)
throw new InvalidCollectionModification("Cannot add empty slot to Dependency collection");
if (contains(itemPath))
throw new ObjectAlreadyExistsException("Item " + itemPath + " already exists in Dependency " + getName());
if (classProps != null && !classProps.equals(mClassProps))
throw new InvalidCollectionModification("Cannot change classProps in dependency member");
DependencyMember depMember = new DependencyMember();
depMember.setID(getCounter());
// merge props
CastorHashMap newProps = new CastorHashMap();
for (Object name : props.keySet()) {
String key = (String) name;
newProps.put(key, props.get(key));
}
// class props override local
for (Object name : mProperties.keySet()) {
String key = (String) name;
newProps.put(key, mProperties.get(key));
}
depMember.setProperties(newProps);
depMember.setClassProps(mClassProps);
// assign entity
depMember.assignItem(itemPath);
mMembers.list.add(depMember);
Logger.msg(8, "Dependency.addMember(" + itemPath + ") added to children.");
return depMember;
}
use of org.cristalise.kernel.common.InvalidCollectionModification in project kernel by cristal-ise.
the class DependencyMember method assignItem.
@Override
public void assignItem(ItemPath itemPath) throws InvalidCollectionModification {
if (itemPath != null) {
if (mClassProps == null || getProperties() == null)
throw new InvalidCollectionModification("ClassProps not yet set. Cannot check membership validity.");
// for each mandatory prop check if its in the member property and has the matching value
StringTokenizer sub = new StringTokenizer(mClassProps, ",");
while (sub.hasMoreTokens()) {
String aClassProp = sub.nextToken();
try {
String memberValue = (String) getProperties().get(aClassProp);
Property ItemProperty = (Property) Gateway.getStorage().get(itemPath, ClusterType.PROPERTY + "/" + aClassProp, null);
if (ItemProperty == null)
throw new InvalidCollectionModification("Property " + aClassProp + " does not exist for item " + itemPath);
if (!ItemProperty.getValue().equalsIgnoreCase(memberValue))
throw new InvalidCollectionModification("DependencyMember::checkProperty() Values of mandatory prop " + aClassProp + " do not match " + ItemProperty.getValue() + "!=" + memberValue);
} catch (Exception ex) {
Logger.error(ex);
throw new InvalidCollectionModification("Error checking properties");
}
}
}
mItemPath = itemPath;
mItem = null;
}
use of org.cristalise.kernel.common.InvalidCollectionModification in project kernel by cristal-ise.
the class AggregationMember method assignItem.
@Override
public void assignItem(ItemPath itemPath) throws InvalidCollectionModification {
if (itemPath != null) {
if (mClassProps == null || getProperties() == null)
throw new InvalidCollectionModification("ClassProps not yet set. Cannot check membership validity.");
// for each mandatory prop check if its in the member property and has the matching value
StringTokenizer sub = new StringTokenizer(mClassProps, ",");
while (sub.hasMoreTokens()) {
String aClassProp = sub.nextToken();
try {
String memberValue = (String) getProperties().get(aClassProp);
Property ItemProperty = (Property) Gateway.getStorage().get(itemPath, ClusterType.PROPERTY + "/" + aClassProp, null);
if (ItemProperty == null)
throw new InvalidCollectionModification("Property " + aClassProp + " does not exist for item " + itemPath);
if (ItemProperty.getValue() == null || !ItemProperty.getValue().equalsIgnoreCase(memberValue))
throw new InvalidCollectionModification("Value of mandatory prop " + aClassProp + " does not match: " + ItemProperty.getValue() + "!=" + memberValue);
} catch (InvalidCollectionModification ex) {
throw ex;
} catch (Exception ex) {
Logger.error(ex);
throw new InvalidCollectionModification("Error checking properties");
}
}
}
mItemPath = itemPath;
mItem = null;
mItemName = null;
}
use of org.cristalise.kernel.common.InvalidCollectionModification in project kernel by cristal-ise.
the class Dependency method addMember.
/**
* Add a member to the Dependency
*
* @param itemPath the Item to be added as a Member
* @return DependencyMember the newly created DependencyMember
* @throws InvalidCollectionModification if Item is null or the Properties of the Item (e.g. Type) does not match the Collection's
* @throws ObjectAlreadyExistsException Item is already a member
*/
public DependencyMember addMember(ItemPath itemPath) throws InvalidCollectionModification, ObjectAlreadyExistsException {
if (itemPath == null)
throw new InvalidCollectionModification("Cannot add empty slot to Dependency collection");
if (contains(itemPath))
throw new ObjectAlreadyExistsException("Item " + itemPath + " already exists in Dependency " + getName());
// create member object
DependencyMember depMember = new DependencyMember();
depMember.setID(getCounter());
depMember.setProperties((CastorHashMap) mProperties.clone());
depMember.setClassProps(mClassProps);
// assign entity
depMember.assignItem(itemPath);
mMembers.list.add(depMember);
Logger.msg(8, "Dependency.addMember(" + itemPath + ") added to children.");
return depMember;
}
Aggregations