use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class TraceableLocator method preinvoke.
/**
************************************************************************
*
*************************************************************************
*/
@Override
public org.omg.PortableServer.Servant preinvoke(byte[] oid, org.omg.PortableServer.POA poa, String operation, org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie) {
ByteBuffer bb = ByteBuffer.wrap(oid);
long msb = bb.getLong();
long lsb = bb.getLong();
ItemPath syskey = new ItemPath(new SystemKey(msb, lsb));
Logger.msg(1, "===========================================================");
Logger.msg(1, "Item called at " + new Timestamp(System.currentTimeMillis()) + ": " + operation + "(" + syskey + ").");
try {
return Gateway.getCorbaServer().getItem(syskey);
} catch (ObjectNotFoundException ex) {
Logger.error("ObjectNotFoundException::TraceableLocator::preinvoke() " + ex.toString());
throw new org.omg.CORBA.OBJECT_NOT_EXIST();
}
}
use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class ImportItem method create.
/**
*/
@Override
public Path create(AgentPath agentPath, boolean reset) throws InvalidDataException, ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException, InvalidCollectionModification, PersistencyException {
domainPath = new DomainPath(new DomainPath(initialPath), name);
if (domainPath.exists()) {
ItemPath domItem = domainPath.getItemPath();
if (!getItemPath().equals(domItem)) {
throw new CannotManageException("Item " + domainPath + " was found with the wrong itemPath (" + domainPath.getItemPath() + " vs " + getItemPath() + ")");
}
} else
isDOMPathExists = false;
TraceableEntity newItem = getTraceableEntitiy();
// (re)initialise the new item with properties, workflow and collections
try {
newItem.initialise(agentPath.getSystemKey(), Gateway.getMarshaller().marshall(createItemProperties()), Gateway.getMarshaller().marshall(createCompositeActivity()), Gateway.getMarshaller().marshall(createCollections()));
} catch (Exception ex) {
Logger.error("Error initialising new item " + ns + "/" + name);
Logger.error(ex);
if (isNewItem)
Gateway.getLookupManager().delete(itemPath);
throw new CannotManageException("Problem initialising new item. See server log:" + ex.getMessage());
}
History hist = new History(getItemPath(), null);
// import outcomes
for (ImportOutcome thisOutcome : outcomes) {
String outcomeData = thisOutcome.getData(ns);
// load schema and state machine
Schema schema = LocalObjectLoader.getSchema(thisOutcome.schema, thisOutcome.version);
// parse new outcome and validate
Outcome newOutcome = new Outcome(-1, outcomeData, schema);
newOutcome.validateAndCheck();
Viewpoint impView;
try {
impView = (Viewpoint) Gateway.getStorage().get(getItemPath(), ClusterType.VIEWPOINT + "/" + thisOutcome.schema + "/" + thisOutcome.viewname, null);
if (newOutcome.isIdentical(impView.getOutcome())) {
Logger.msg(5, "ImportItem.create() - View " + thisOutcome.schema + "/" + thisOutcome.viewname + " in " + ns + "/" + name + " identical, no update required");
continue;
} else {
Logger.msg("ImportItem.create() - Difference found in view " + thisOutcome.schema + "/" + thisOutcome.viewname + " in " + ns + "/" + name);
if (!reset && !impView.getEvent().getStepPath().equals("Import")) {
Logger.msg("ImportItem.create() - Last edit was not done by import, and reset not requested. Not overwriting.");
continue;
}
}
} catch (ObjectNotFoundException ex) {
Logger.msg("ImportItem.create() - View " + thisOutcome.schema + "/" + thisOutcome.viewname + " not found in " + ns + "/" + name + ". Creating.");
impView = new Viewpoint(getItemPath(), schema, thisOutcome.viewname, -1);
}
// write new view/outcome/event
Event newEvent = hist.addEvent(agentPath, null, "Admin", "Import", "Import", "Import", schema, Bootstrap.getPredefSM(), PredefinedStep.DONE, thisOutcome.viewname);
newOutcome.setID(newEvent.getID());
impView.setEventId(newEvent.getID());
Gateway.getStorage().put(getItemPath(), newOutcome, null);
Gateway.getStorage().put(getItemPath(), impView, null);
}
// register domain path (before collections in case of recursive collections)
if (!isDOMPathExists) {
domainPath.setItemPath(getItemPath());
Gateway.getLookupManager().add(domainPath);
}
return domainPath;
}
use of org.cristalise.kernel.lookup.ItemPath 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.lookup.ItemPath in project kernel by cristal-ise.
the class ProxyManager method getProxy.
public ItemProxy getProxy(Path path) throws ObjectNotFoundException {
ItemPath itemPath;
if (path instanceof ItemPath)
itemPath = (ItemPath) path;
else
itemPath = path.getItemPath();
Logger.msg(8, "ProxyManager::getProxy(" + path.toString() + ")");
return getProxy(itemPath.getIOR(), itemPath);
}
use of org.cristalise.kernel.lookup.ItemPath in project kernel by cristal-ise.
the class ProxyManager method reportCurrentProxies.
/**
* A utility to Dump the current proxies loaded
*
* @param logLevel the selectd log level
*/
public void reportCurrentProxies(int logLevel) {
if (!Logger.doLog(logLevel))
return;
Logger.msg(logLevel, "Current proxies: ");
try {
synchronized (proxyPool) {
Iterator<ItemPath> i = proxyPool.keySet().iterator();
for (int count = 0; i.hasNext(); count++) {
ItemPath nextProxy = i.next();
ItemProxy thisProxy = proxyPool.get(nextProxy);
if (thisProxy != null) {
Logger.msg(logLevel, "" + count + ": " + proxyPool.get(nextProxy).getClass().getName() + ": " + nextProxy);
}
}
}
} catch (ConcurrentModificationException ex) {
Logger.msg(logLevel, "Proxy cache modified. Aborting.");
}
}
Aggregations