use of org.cristalise.kernel.lookup.InvalidItemPathException in project kernel by cristal-ise.
the class AddMemberToCollection method runActivityLogic.
/**
* <pre>
* Generates a new slot in a Dependency for the given item
*
* Params:
* 0 - collection name
* 1 - target entity key
* 2 - slot properties
* </pre>
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException, InvalidCollectionModification {
String collName;
ItemPath newChild;
Dependency dep;
CastorHashMap props = null;
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddMemberToCollection: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
try {
collName = params[0];
try {
newChild = new ItemPath(params[1]);
} catch (InvalidItemPathException e) {
newChild = new DomainPath(params[1]).getItemPath();
}
if (params.length > 2) {
Logger.msg(5, "AddMemberToCollection: Unmarshalling Properties:" + params[2]);
props = (CastorHashMap) Gateway.getMarshaller().unmarshall(params[2]);
}
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("AddMemberToCollection: Invalid parameters " + Arrays.toString(params));
}
// load collection
C2KLocalObject collObj = Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
if (!(collObj instanceof Dependency))
throw new InvalidDataException("AddMemberToCollection operates on Dependency only.");
dep = (Dependency) collObj;
// find member and assign entity
if (props == null)
dep.addMember(newChild);
else
dep.addMember(newChild, props, dep.getClassProps());
Gateway.getStorage().put(item, dep, locker);
return requestData;
}
use of org.cristalise.kernel.lookup.InvalidItemPathException in project kernel by cristal-ise.
the class AssignItemToSlot method runActivityLogic.
/**
* Params: 0 - collection name 1 - slot number 2 - target entity key
*
* @throws ObjectNotFoundException
* @throws PersistencyException
* @throws ObjectCannotBeUpdated
* @throws InvalidCollectionModification
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, PersistencyException, ObjectCannotBeUpdated, InvalidCollectionModification {
String collName;
int slotNo;
ItemPath childItem;
Aggregation agg;
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AssignItemToSlot: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
try {
collName = params[0];
slotNo = Integer.parseInt(params[1]);
try {
childItem = new ItemPath(params[2]);
} catch (InvalidItemPathException e) {
childItem = new DomainPath(params[2]).getItemPath();
}
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("AssignItemToSlot: Invalid parameters " + Arrays.toString(params));
}
// load collection
C2KLocalObject collObj;
try {
collObj = Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
} catch (PersistencyException ex) {
Logger.error(ex);
throw new PersistencyException("AssignItemToSlot: Error loading collection '\"+collName+\"': " + ex.getMessage());
}
if (!(collObj instanceof Aggregation))
throw new InvalidDataException("AssignItemToSlot: AssignItemToSlot operates on Aggregation collections only.");
agg = (Aggregation) collObj;
// find member and assign entity
boolean stored = false;
for (AggregationMember member : agg.getMembers().list) {
if (member.getID() == slotNo) {
if (member.getItemPath() != null)
throw new ObjectCannotBeUpdated("AssignItemToSlot: Member slot " + slotNo + " not empty");
member.assignItem(childItem);
stored = true;
break;
}
}
if (!stored) {
throw new ObjectNotFoundException("AssignItemToSlot: Member slot " + slotNo + " not found.");
}
try {
Gateway.getStorage().put(item, agg, locker);
} catch (PersistencyException e) {
throw new PersistencyException("AssignItemToSlot: Error saving collection '" + collName + "': " + e.getMessage());
}
return requestData;
}
use of org.cristalise.kernel.lookup.InvalidItemPathException in project kernel by cristal-ise.
the class ItemImplementation method queryLifeCycle.
/**
*/
@Override
public String queryLifeCycle(SystemKey agentId, boolean filter) throws AccessRightsException, ObjectNotFoundException, PersistencyException {
Logger.msg(1, "ItemImplementation::queryLifeCycle(" + mItemPath + ") - agent: " + agentId);
try {
AgentPath agent;
try {
agent = new AgentPath(agentId);
} catch (InvalidItemPathException e) {
throw new AccessRightsException("Agent " + agentId + " doesn't exist");
}
Workflow wf = (Workflow) mStorage.get(mItemPath, ClusterType.LIFECYCLE + "/workflow", null);
JobArrayList jobBag = new JobArrayList();
CompositeActivity domainWf = (CompositeActivity) wf.search("workflow/domain");
jobBag.list = filter ? domainWf.calculateJobs(agent, mItemPath, true) : domainWf.calculateAllJobs(agent, mItemPath, true);
Logger.msg(1, "ItemImplementation::queryLifeCycle(" + mItemPath + ") - Returning " + jobBag.list.size() + " jobs.");
try {
return Gateway.getMarshaller().marshall(jobBag);
} catch (Exception e) {
Logger.error(e);
throw new PersistencyException("Error marshalling job bag");
}
} catch (AccessRightsException | ObjectNotFoundException | PersistencyException e) {
Logger.error(e);
throw e;
} catch (Throwable ex) {
Logger.error("ItemImplementation::queryLifeCycle(" + mItemPath + ") - Unknown error");
Logger.error(ex);
throw new PersistencyException("Unknown error querying jobs. Please see server log.");
}
}
use of org.cristalise.kernel.lookup.InvalidItemPathException in project kernel by cristal-ise.
the class ActiveLocator method preinvoke.
/**
************************************************************************
*
*************************************************************************
*/
@Override
public org.omg.PortableServer.Servant preinvoke(byte[] oid, org.omg.PortableServer.POA poa, String operation, org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie) {
try {
ByteBuffer bb = ByteBuffer.wrap(oid);
long msb = bb.getLong();
long lsb = bb.getLong();
AgentPath syskey = new AgentPath(new SystemKey(msb, lsb));
Logger.msg(1, "===========================================================");
Logger.msg(1, "Agent called at " + new Timestamp(System.currentTimeMillis()) + ": " + operation + "(" + syskey + ").");
return Gateway.getCorbaServer().getAgent(syskey);
} catch (ObjectNotFoundException ex) {
Logger.error("ObjectNotFoundException::ActiveLocator::preinvoke() " + ex.toString());
throw new org.omg.CORBA.OBJECT_NOT_EXIST();
} catch (InvalidItemPathException ex) {
Logger.error("InvalidItemPathException::ActiveLocator::preinvoke() " + ex.toString());
throw new org.omg.CORBA.INV_OBJREF();
}
}
use of org.cristalise.kernel.lookup.InvalidItemPathException in project kernel by cristal-ise.
the class Job method setAgentUUID.
/**
* Used by castor to unmarshall from XML
*
* @param uuid the string representation of UUID
* @throws InvalidItemPathException Cannot set UUID of agent and delegate from parameter
*/
public void setAgentUUID(String uuid) throws InvalidItemPathException {
if (StringUtils.isBlank(uuid)) {
agentPath = null;
delegatePath = null;
} else if (uuid.contains(":")) {
String[] agentStr = uuid.split(":");
if (agentStr.length != 2)
throw new InvalidItemPathException("Cannot set UUID of agent and delegate from string:" + uuid);
setAgentPath(new AgentPath(agentStr[0]));
setDelegatePath(new AgentPath(agentStr[1]));
} else
setAgentPath(new AgentPath(uuid));
}
Aggregations