use of org.cristalise.kernel.property.Property 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.property.Property in project kernel by cristal-ise.
the class CreateItemFromDescription method instantiateProperties.
/**
* @param descItemPath
* @param descVer
* @param initProps
* @param newName
* @param agent
* @param locker
* @return props
* @throws ObjectNotFoundException
* @throws InvalidDataException
*/
protected PropertyArrayList instantiateProperties(ItemPath descItemPath, String descVer, PropertyArrayList initProps, String newName, AgentPath agent, Object locker) throws ObjectNotFoundException, InvalidDataException {
// copy properties -- intend to create from propdesc
PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(descItemPath, descVer, locker);
PropertyArrayList props = pdList.instantiate(initProps);
// set Name prop or create if not present
boolean foundName = false;
for (Property prop : props.list) {
if (prop.getName().equals(NAME.toString())) {
foundName = true;
prop.setValue(newName);
break;
}
}
if (!foundName)
props.list.add(new Property(NAME, newName, true));
props.list.add(new Property(CREATOR, agent.getAgentName(), false));
return props;
}
use of org.cristalise.kernel.property.Property in project kernel by cristal-ise.
the class Module method replaceProp.
private void replaceProp(Property newProp) {
for (Property prop : properties) {
if (prop.getName().equals(newProp.getName())) {
prop.setMutable(newProp.isMutable());
prop.setValue(newProp.getValue());
return;
}
}
properties.add(newProp);
}
use of org.cristalise.kernel.property.Property in project kernel by cristal-ise.
the class DescriptionObjectCache method findItem.
public ItemPath findItem(String name) throws ObjectNotFoundException, InvalidDataException {
if (Gateway.getLookup() == null)
throw new ObjectNotFoundException("Cannot find Items without a Lookup");
// first check for a UUID name
try {
ItemPath resItem = new ItemPath(name);
if (resItem.exists())
return resItem;
} catch (InvalidItemPathException ex) {
}
// then check for a direct path
DomainPath directPath = new DomainPath(name);
if (directPath.exists() && directPath.getItemPath() != null) {
return directPath.getItemPath();
}
// else search for it in the whole tree using property description
Property[] searchProps = new Property[classIdProps.length + 1];
searchProps[0] = new Property(NAME, name);
System.arraycopy(classIdProps, 0, searchProps, 1, classIdProps.length);
Iterator<Path> e = Gateway.getLookup().search(new DomainPath(), searchProps);
if (e.hasNext()) {
Path defPath = e.next();
if (e.hasNext())
throw new ObjectNotFoundException("Too many matches for " + getTypeCode() + " " + name);
if (defPath.getItemPath() == null)
throw new InvalidDataException(getTypeCode() + " " + name + " was found, but was not an Item");
return defPath.getItemPath();
} else {
throw new ObjectNotFoundException("No match for " + getTypeCode() + " " + name);
}
}
Aggregations