use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class MemberSubscription method loadChildren.
private void loadChildren() {
C newMember;
ProxyObserver<C> observer = getObserver();
// reaped
if (observer == null)
return;
try {
// fetch contents of path
String children = subject.queryData(interest + "/all");
StringTokenizer tok = new StringTokenizer(children, ",");
ArrayList<String> newContents = new ArrayList<String>();
while (tok.hasMoreTokens()) newContents.add(tok.nextToken());
// look to see what's new
for (String newChild : newContents) {
// load child object
try {
newMember = (C) subject.getObject(interest + "/" + newChild);
contents.remove(newChild);
observer.add(newMember);
} catch (ObjectNotFoundException ex) {
observer.control(ERROR, "Listed member " + newChild + " was not found.");
} catch (ClassCastException ex) {
Logger.error(ex);
observer.control(ERROR, "Listed member " + newChild + " was the wrong type.");
}
}
// report what's left in old contents as deleted
for (String oldChild : contents) {
observer.remove(interest + "/" + oldChild);
}
// replace contents arraylist
contents = newContents;
// report that we're done
observer.control(END, null);
} catch (Exception ex) {
observer.control(ERROR, "Query on " + interest + " failed with " + ex.getMessage());
}
Logger.msg(5, "MemberSubscription.loadChildren() - DONE interest:" + interest);
}
use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class Bootstrap method createServerItem.
public static void createServerItem() throws Exception {
LookupManager lookupManager = Gateway.getLookupManager();
String serverName = Gateway.getProperties().getString("ItemServer.name", InetAddress.getLocalHost().getHostName());
thisServerPath = new DomainPath("/servers/" + serverName);
ItemPath serverItem;
try {
serverItem = thisServerPath.getItemPath();
} catch (ObjectNotFoundException ex) {
Logger.msg("Creating server item " + thisServerPath);
serverItem = new ItemPath();
Gateway.getCorbaServer().createItem(serverItem);
lookupManager.add(serverItem);
thisServerPath.setItemPath(serverItem);
lookupManager.add(thisServerPath);
}
int proxyPort = Gateway.getProperties().getInt("ItemServer.Proxy.port", 1553);
Gateway.getStorage().put(serverItem, new Property(NAME, serverName, false), null);
Gateway.getStorage().put(serverItem, new Property(TYPE, "Server", false), null);
Gateway.getStorage().put(serverItem, new Property(KERNEL_VERSION, Gateway.getKernelVersion(), true), null);
Gateway.getStorage().put(serverItem, new Property("ProxyPort", String.valueOf(proxyPort), false), null);
Gateway.getStorage().put(serverItem, new Property("ConsolePort", String.valueOf(Logger.getConsolePort()), true), null);
Gateway.getProxyManager().connectToProxyServer(serverName, proxyPort);
}
use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class Bootstrap method checkAgent.
/**
* Checks for the existence of a agents so it can be used
*
* @param name
* @param pass
* @param rolePath
* @param uuid
* @return the Proxy representing the Agent
* @throws Exception
*/
private static AgentProxy checkAgent(String name, String pass, RolePath rolePath, String uuid) throws Exception {
Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '" + name + "' agent.");
LookupManager lookup = Gateway.getLookupManager();
try {
AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(lookup.getAgentPath(name));
systemAgents.put(name, agentProxy);
Logger.msg(3, "Bootstrap.checkAgent() - Agent '" + name + "' found.");
return agentProxy;
} catch (ObjectNotFoundException ex) {
}
Logger.msg("Bootstrap.checkAgent() - Agent '" + name + "' not found. Creating.");
try {
AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
Gateway.getCorbaServer().createAgent(agentPath);
lookup.add(agentPath);
if (StringUtils.isNotBlank(pass))
lookup.setAgentPassword(agentPath, pass);
// assign admin role
Logger.msg("Bootstrap.checkAgent() - Assigning role '" + rolePath.getName() + "'");
Gateway.getLookupManager().addRole(agentPath, rolePath);
Gateway.getStorage().put(agentPath, new Property(NAME, name, true), null);
Gateway.getStorage().put(agentPath, new Property(TYPE, "Agent", false), null);
AgentProxy agentProxy = Gateway.getProxyManager().getAgentProxy(agentPath);
// TODO: properly init agent here with wf, props and colls
// agentProxy.initialise(agentId, itemProps, workflow, colls);
systemAgents.put(name, agentProxy);
return agentProxy;
} catch (Exception ex) {
Logger.error("Unable to create '" + name + "' Agent.");
throw ex;
}
}
use of org.cristalise.kernel.common.ObjectNotFoundException in project kernel by cristal-ise.
the class CreateItemFromDescription method initialiseItem.
/**
* @param agent
* @param descItemPath
* @param locker
* @param input
* @param newName
* @param descVer
* @param context
* @param newItemPath
* @param newItem
* @throws ObjectCannotBeUpdated
* @throws CannotManageException
* @throws InvalidDataException
* @throws ObjectAlreadyExistsException
* @throws PersistencyException
* @throws ObjectNotFoundException
*/
protected void initialiseItem(ItemOperations newItem, AgentPath agent, ItemPath descItemPath, PropertyArrayList initProps, String newName, String descVer, DomainPath context, ItemPath newItemPath, Object locker) throws ObjectCannotBeUpdated, CannotManageException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException {
// initialise it with its properties and workflow
Logger.msg(3, "CreateItemFromDescription.initialiseItem() - Initializing Item:" + newName);
try {
PropertyArrayList newProps = instantiateProperties(descItemPath, descVer, initProps, newName, agent, locker);
CollectionArrayList newColls = instantiateCollections(descItemPath, descVer, newProps, locker);
CompositeActivity newWorkflow = instantiateWorkflow(descItemPath, descVer, locker);
newItem.initialise(agent.getSystemKey(), Gateway.getMarshaller().marshall(newProps), Gateway.getMarshaller().marshall(newWorkflow), Gateway.getMarshaller().marshall(newColls));
} catch (MarshalException | ValidationException | AccessRightsException | IOException | MappingException | InvalidCollectionModification e) {
Logger.error(e);
Gateway.getLookupManager().delete(newItemPath);
throw new InvalidDataException("CreateItemFromDescription: Problem initializing new Item. See log: " + e.getMessage());
} catch (InvalidDataException | ObjectNotFoundException | PersistencyException e) {
Logger.error(e);
Gateway.getLookupManager().delete(newItemPath);
throw e;
}
// add its domain path
Logger.msg(3, "CreateItemFromDescription - Creating " + context);
context.setItemPath(newItemPath);
Gateway.getLookupManager().add(context);
}
use of org.cristalise.kernel.common.ObjectNotFoundException 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