use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class ClientProxyImpl method login.
/*********************** Helper methods ***********************/
/**
* Login to the manager and obtain handle.
*
* @param manager CORBA <code>maci::Manager</code> reference, non-<code>null</code>
* @return boolean
*/
public boolean login(ORB orb, Manager manager) {
assert (orb != null);
assert (manager != null);
this.manager = manager;
try {
ClientInfo clientInfo = manager.login(this._this(orb));
if (clientInfo != null && clientInfo.h != 0) {
client.setHandle(clientInfo.h);
logger.info("Successfully logged in to the Manager.");
return true;
}
} catch (Exception ex) {
return false;
}
return false;
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class ManagerProxyImpl method get_client_info.
/**
* Get all the information that the Manager has about its known clients.
* To invoke this method, the caller must have INTROSPECT_MANAGER access rights, or it must be the object whose info it is requesting.
* Calling this function does not affect the internal state of the Manager.
*
* @param id Identification of the caller.
* @param h Handles of the clients whose information is requested. If this is an empty sequence, the name_wc parameter is used.
* @param name_wc Wildcard that the clients's name must match in order for its information to be returned.
* @return A sequence of ClientInfo structures containing the entire Manager's knowledge about the containers.
* If access is denied to a subset of objects, the handles to those objects are set to 0.
*/
public ClientInfo[] get_client_info(int id, int[] h, String name_wc) throws NoPermissionEx {
pendingRequests.incrementAndGet();
try {
// invalid info (replacement for null)
final ClientInfo invalidInfo = new ClientInfo(0, null, new int[0], "<invalid>", 0);
// returned value
ClientInfo[] retVal = null;
// transform to CORBA specific
com.cosylab.acs.maci.ClientInfo[] infos = manager.getClientInfo(id, h, name_wc);
if (infos != null) {
retVal = new ClientInfo[infos.length];
for (int i = 0; i < infos.length; i++) if (infos[i] == null)
retVal[i] = invalidInfo;
else
retVal[i] = new ClientInfo(infos[i].getHandle(), ((ClientProxy) infos[i].getClient()).getClient(), infos[i].getComponents().toArray(), infos[i].getName(), mapAccessRights(infos[i].getAccessRights()));
} else
retVal = new ClientInfo[0];
return retVal;
} catch (BadParametersException bpe) {
BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(bpe.getMessage());
} catch (NoResourcesException nre) {
NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
reportException(hnre);
// rethrow CORBA specific
throw new NO_RESOURCES(nre.getMessage());
} catch (AcsJNoPermissionEx npe) {
// rethrow CORBA specific
throw npe.toNoPermissionEx();
} catch (Throwable ex) {
CoreException hce = new CoreException(ex.getMessage(), ex);
reportException(hce);
// rethrow CORBA specific
throw new UNKNOWN(ex.getMessage());
} finally {
pendingRequests.decrementAndGet();
}
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class BlockingPingClient method execute.
/**
* Main routine.
*/
public void execute(long sleepTimeMs) {
initializeCORBA();
Manager manager = resolveManager();
if (manager != null) {
ClientInfo clientInfo = login(manager, sleepTimeMs);
if (clientInfo != null) {
System.out.println("All initialization done.");
run();
logout(manager, clientInfo);
}
}
finalizeCORBA();
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class ManagerDynComponentTest method test.
/**
* Main test routine.
*/
public void test() {
initializeCORBA();
Manager manager = resolveManager();
if (manager != null) {
ClientInfo clientInfo = login(manager);
if (clientInfo != null) {
System.out.println("All initialization done.");
try {
/* ------------------------------------------------- */
manager.restart_component(clientInfo.h, "invalid");
manager.get_component(clientInfo.h, "MOUNT1", true);
manager.restart_component(clientInfo.h, "MOUNT1");
try {
manager.get_default_component(clientInfo.h, "invalid");
System.err.println("NoDefaultComponent exception expected.");
} catch (NoDefaultComponentEx nde) {
// this is OK
}
try {
manager.get_dynamic_component(clientInfo.h, new ComponentSpec("*", "invalidType", "*", "*"), true);
System.err.println("InvalidComponentSpec exception expected.");
} catch (InvalidComponentSpecEx ics) {
// this is OK
}
/* ------------------------------------------------- */
ComponentInfo componentInfo = manager.get_dynamic_component(clientInfo.h, new ComponentSpec("FULL_DYNAMIC", "IDL:alma/PS/PowerSupply:1.0", "acsexmplPS", "Container"), true);
System.out.println(componentInfo.h);
} catch (Exception ex) {
ex.printStackTrace();
}
logout(manager, clientInfo);
}
}
finalizeCORBA();
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class DeploymentTree method showContextMenu.
/**
* @param evt
*/
protected void showContextMenu(MouseEvent evt) {
TreePath targetPath = this.getClosestPathForLocation(evt.getX(), evt.getY());
if (targetPath == null) {
// clicked into a totally empty tree (no manager shown): ignore click.
return;
}
setSelectionPath(targetPath);
if (targetPath.getPathCount() == 1) {
// that has no function besides looking good
return;
}
// the supervisor (which is in the rootnode) for this subtree
selectedSupervisor = maciSupervisor(((SortingTreeNode) targetPath.getPathComponent(1)));
// the node the mouse was clicked on
target = (SortingTreeNode) targetPath.getLastPathComponent();
Object userObject = target.getUserObject();
ContextMenu menu;
if (userObject instanceof IMaciSupervisor) {
menu = managerContextMenu;
} else if (userObject instanceof ContainerInfo) {
menu = containerContextMenu;
} else if (userObject instanceof ClientInfo) {
menu = clientContextMenu;
} else if (userObject instanceof ComponentInfo) {
menu = componentContextMenu;
} else if (userObject instanceof FolderInfo) {
menu = folderContextMenu;
} else if (userObject instanceof InfoDetail) {
// msc 2012-06: help user navigate in large datasets (cf. COMP-3684)
// this menu is built dynamically from rather expensive information.
menu = new ContextMenu(false);
int[] selectedHandles = ((SortingTreeNode) target).representedHandles;
if (selectedHandles.length > 0) {
menu.add(new JLabel(" Scroll to ..."));
menu.add(new JSeparator(JSeparator.HORIZONTAL));
SortingTreeNode mgrNode = (SortingTreeNode) target.getPath()[1];
List<Object> list = new ArrayList<Object>();
list.add(mgrNode);
for (SortingTreeNode top : mgrNode.childrens()) list.addAll(Collections.list(top.children()));
for (Object obj : list) {
final SortingTreeNode elem = (SortingTreeNode) obj;
for (int i = 0; i < selectedHandles.length; i++) {
if (elem.represents(selectedHandles[i])) {
Object elemUserObject = elem.getUserObject();
String elemName = null;
if (elemUserObject instanceof ComponentInfo)
elemName = ((ComponentInfo) elemUserObject).name;
else if (elemUserObject instanceof ContainerInfo)
elemName = ((ContainerInfo) elemUserObject).name;
else if (elemUserObject instanceof ClientInfo)
elemName = ((ClientInfo) elemUserObject).name;
else if (elemUserObject instanceof MaciSupervisor)
elemName = "Manager";
if (elemName != null) {
menu.add(new AbstractAction(selectedHandles[i] + " = " + elemName) {
@Override
public void actionPerformed(ActionEvent evt) {
DeploymentTree.this.scrollPathToVisible(new TreePath(elem.getPath()));
}
});
}
}
}
}
}
} else {
return;
}
menu.show(this, evt.getX(), evt.getY());
}
Aggregations