use of org.cristalise.kernel.lookup.AgentPath in project kernel by cristal-ise.
the class SetAgentPassword method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException {
String[] params = getDataList(requestData);
Logger.msg(3, "SetAgentPassword: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("SetAgentPassword: Invalid parameters " + Arrays.toString(params));
try {
AgentPath targetAgent = new AgentPath(item);
if (!targetAgent.equals(agent) && !agent.hasRole("Admin")) {
throw new InvalidDataException("Agent passwords may only be set by those Agents or by an Administrator");
}
Gateway.getLookupManager().setAgentPassword(targetAgent, params[0]);
// censor password from outcome
params[0] = "REDACTED";
return bundleData(params);
} catch (InvalidItemPathException ex) {
Logger.error(ex);
throw new InvalidDataException("Can only set password on an Agent. " + item + " is an Item.");
} catch (NoSuchAlgorithmException e) {
Logger.error(e);
throw new InvalidDataException("Cryptographic libraries for password hashing not found.");
}
}
use of org.cristalise.kernel.lookup.AgentPath in project kernel by cristal-ise.
the class RemoveRole method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, CannotManageException, ObjectNotFoundException, ObjectCannotBeUpdated {
String[] params = getDataList(requestData);
Logger.msg(3, "RemoveRole: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("RemoveRole must have one paramater:" + Arrays.toString(params));
LookupManager lookup = Gateway.getLookupManager();
RolePath thisRole = lookup.getRolePath(params[0]);
AgentPath[] agents = Gateway.getLookup().getAgents(thisRole);
if (agents.length > 0)
throw new ObjectCannotBeUpdated("Cannot remove role as " + agents.length + " other agents still hold it.");
lookup.delete(thisRole);
return requestData;
}
use of org.cristalise.kernel.lookup.AgentPath in project kernel by cristal-ise.
the class Erase method runActivityLogic.
// requestdata is xmlstring
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, PersistencyException {
Logger.msg(1, "Erase::request() - Starting item:" + item.getUUID());
Iterator<Path> domPaths = Gateway.getLookup().searchAliases(item);
while (domPaths.hasNext()) {
DomainPath path = (DomainPath) domPaths.next();
// delete them
if (path.getItemPath().equals(item))
Gateway.getLookupManager().delete(path);
}
// clear out all storages
Gateway.getStorage().removeCluster(item, "", locker);
Logger.msg(1, "Erase::request() - DONE item:" + item.getUUID());
return requestData;
}
use of org.cristalise.kernel.lookup.AgentPath 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.AgentPath 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();
}
}
Aggregations