use of org.cristalise.kernel.lookup.DomainPath in project kernel by cristal-ise.
the class RemoveDomainPath 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);
if (Logger.doLog(3))
Logger.msg(3, "RemoveDomainPath: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("RemoveDomainPath: Invalid parameters " + Arrays.toString(params));
DomainPath domainPath = new DomainPath(params[0]);
if (!domainPath.exists()) {
throw new ObjectNotFoundException("RemoveDomainPath: Domain path " + domainPath + " does not exist.");
}
if (!domainPath.getItemPath().equals(item)) {
throw new InvalidDataException("RemoveDomainPath: Domain path " + domainPath + " is not an alias of the current Item " + item);
}
Gateway.getLookupManager().delete(domainPath);
return requestData;
}
use of org.cristalise.kernel.lookup.DomainPath in project kernel by cristal-ise.
the class AddDomainContext method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
String[] params = getDataList(requestData);
Logger.msg(3, "AddDomainContext: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("AddDomainContext: Invalid parameters " + Arrays.toString(params));
DomainPath pathToAdd = new DomainPath(params[0]);
if (pathToAdd.exists())
throw new ObjectAlreadyExistsException("Context " + pathToAdd + " already exists");
// collect parent paths if they don't exist
Stack<DomainPath> pathsToAdd = new Stack<DomainPath>();
while (pathToAdd != null && !pathToAdd.exists()) {
pathsToAdd.push(pathToAdd);
pathToAdd = pathToAdd.getParent();
}
while (!pathsToAdd.empty()) {
pathToAdd = pathsToAdd.pop();
Gateway.getLookupManager().add(pathToAdd);
}
return requestData;
}
use of org.cristalise.kernel.lookup.DomainPath in project kernel by cristal-ise.
the class AddDomainPath method runActivityLogic.
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectCannotBeUpdated, ObjectAlreadyExistsException, CannotManageException {
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddDomainPath: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 1)
throw new InvalidDataException("AddDomainPath: Invalid parameters: " + Arrays.toString(params));
Gateway.getLookupManager().add(new DomainPath(params[0], item));
return requestData;
}
use of org.cristalise.kernel.lookup.DomainPath in project kernel by cristal-ise.
the class ProxyManager method informTreeSubscribers.
private void informTreeSubscribers(boolean state, String path) {
DomainPath last = new DomainPath(path);
DomainPath parent;
boolean first = true;
synchronized (treeSubscribers) {
while ((parent = last.getParent()) != null) {
ArrayList<DomainPathSubscriber> currentKeys = new ArrayList<DomainPathSubscriber>();
currentKeys.addAll(treeSubscribers.keySet());
for (DomainPathSubscriber sub : currentKeys) {
DomainPath interest = treeSubscribers.get(sub);
if (interest != null && interest.equals(parent)) {
if (state == ProxyMessage.ADDED)
sub.pathAdded(last);
else if (first)
sub.pathRemoved(last);
}
}
last = parent;
first = false;
}
}
}
use of org.cristalise.kernel.lookup.DomainPath 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);
}
Aggregations