use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class ACSRemoteAccess method resolveNamingServiceContext.
private NamingContext resolveNamingServiceContext(si.ijs.maci.Manager manager) {
listenersDispatcher.publishReport("Resolving Naming Service...");
org.omg.CORBA.Object nameService = null;
try {
nameService = manager.get_service(0, NAME_SERVICE, false);
} catch (NoPermissionEx e) {
throw new IllegalStateException("Failed to obtaine NameService from the manager. No permission");
} catch (CannotGetComponentEx e) {
throw new IllegalStateException("Failed to obtain NameService from the manager.");
} catch (ComponentNotAlreadyActivatedEx e) {
throw new IllegalStateException("Failed to obtaine NameService from the manager.");
} catch (ComponentConfigurationNotFoundEx e) {
throw new IllegalStateException("Failed to obtaine NameService from the manager.");
}
NamingContext namingContext = null;
try {
namingContext = org.omg.CosNaming.NamingContextHelper.narrow(nameService);
} catch (Exception e) {
listenersDispatcher.publishReport("Exception occurred when narrowing Naming Service Context from the Naming Service.");
System.out.println("Exception in resloveNamingServiceContext(): " + e);
return null;
}
listenersDispatcher.publishReport("Naming Service resolved.");
return namingContext;
}
use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class ManagerProxy method releaseComponentAsync.
public void releaseComponentAsync(int id, URI curl, LongCompletionCallback callback) throws AcsJNoPermissionEx, AcsJBadParameterEx {
try {
final LongCompletionCallback fcallback = callback;
CBlongPOA cbo = new CBlongPOA() {
public boolean negotiate(long time_to_transmit, CBDescOut desc) {
return false;
}
public void working(int value, Completion c, CBDescOut desc) {
// noop
}
public void done(int value, Completion c, CBDescOut desc) {
if (c.code == 0 && c.type == 0)
fcallback.done(value);
else
// TODO maybe convert to specific exceptions
fcallback.failed(value, AcsJCompletion.fromCorbaCompletion(c).getAcsJException());
}
};
CBDescIn desc = new CBDescIn(0, 0, 0);
manager.release_component_async(id, curl.toString(), cbo._this(), desc);
} catch (NoPermissionEx nop) {
throw new AcsJNoPermissionEx(nop);
}
}
use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class SimpleMasterComponentTest 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.");
//
// get component
//
final String COMPONENT_NAME = "SIMPLEMASTERCOMPONENT1";
org.omg.CORBA.Object obj;
try {
obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
SimpleMasterComponent simpleMasterComponent = SimpleMasterComponentHelper.narrow(obj);
ROstringSeq currentStateHierarchy = simpleMasterComponent.currentStateHierarchy();
// syncvalue retrival
System.out.println("Current state hierarchy: " + getStringArray(currentStateHierarchy.get_sync(new CompletionHolder())));
System.out.println("Monitoring - 1s interval...");
// create a monitor
MonitorstringSeq monitor = currentStateHierarchy.create_monitor(new CBstringSeqImpl()._this(orb), new CBDescIn());
// sleep for a while
try {
Thread.sleep(10000);
} catch (InterruptedException ie) {
}
;
monitor.set_timer_trigger(0);
monitor.set_value_trigger(new String[0], true);
System.out.println("On-change monitoring...");
// sleep for a while
try {
Thread.sleep(10000);
} catch (InterruptedException ie) {
}
;
monitor.destroy();
} catch (Exception e) {
// CannotGetComponentEx, ComponentConfigurationNotFoundEx
System.err.println("Failed to obtain component: " + COMPONENT_NAME);
}
// release now
try {
manager.release_component(clientInfo.h, COMPONENT_NAME);
} catch (NoPermissionEx ex) {
ex.printStackTrace();
}
logout(manager, clientInfo);
}
}
finalizeCORBA();
}
use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class BACIRemoteAccess method explodeRootNodeByName.
/**
* Explodes the root node and groups the devices by their parent devices.
* Warning: explodeRootNodeByType() has to be called at least once before this method is called!
* @return
*/
public synchronized OETreeNode[] explodeRootNodeByName() {
if (manager == null)
resolveManager();
notifier.reportDebug("BACIRemoteAccess::explodeRootNodeByName", "Querying manager for all instances of all types...");
long time1 = System.currentTimeMillis();
int[] handles = new int[0];
try {
infos = manager.get_component_info(handle, handles, "*", "*", false);
} catch (NoPermissionEx npe) {
notifier.reportError("Nopermission to get component info", npe);
}
long time2 = System.currentTimeMillis();
notifier.reportDebug("BACIRemoteAccess::explodeRootNodeByName", "Query OK. Completed in " + (time2 - time1) + " ms.");
TreeMap tempDomains = new TreeMap();
TreeMap tempDummies = new TreeMap();
Vector rootDummies = new Vector();
for (int i = 0; i < infos.length; i++) {
String curl = infos[i].name;
String domain = BACICURLResolver.resolveDomain(curl);
String cob = BACICURLResolver.resolveName(curl);
RemoteNodeCouple rnc = (RemoteNodeCouple) devices.get(curl);
if (rnc == null) {
notifier.reportError("BACIRemoteAccess::explodeRootNodeByName - Unexpected null pointer (rnc).");
continue;
}
if (rnc.deviceByName == null) {
notifier.reportError("BACIRemoteAccess::explodeRootNodeByName - Unexpected null pointer (rnc.deviceByName).");
continue;
}
String[] names = cob.split("/", 2);
if (domain.equals(BACICURLResolver.ROOT_DOMAIN)) {
BACITreeDataNode dummyNode = (BACITreeDataNode) tempDummies.get(names[0]);
if (names.length > 1) {
boolean doHierarchy = dummyNode instanceof BACIRemoteNode;
if (dummyNode == null || doHierarchy) {
BACITreeDataNode oldDummy = dummyNode;
dummyNode = new BACITreeDataNode(DUMMY, names[0], BACICURLResolver.getFirstLevelCurl(curl), parent.getTreeByName(), getIcon(DOMAIN));
dummyNode.childrenHolder = new ArrayList();
tempDummies.put(names[0], dummyNode);
rootDummies.add(dummyNode);
if (doHierarchy)
dummyNode.childrenHolder.add(oldDummy);
}
String[] arrNames = names[1].split("/");
//System.out.println("DEBUG "+ names[1]);
getTreeForName(dummyNode, 0, arrNames);
} else {
if (dummyNode == null) {
tempDummies.put(names[0], rnc.deviceByName);
} else {
dummyNode.childrenHolder.add(0, rnc.deviceByName);
}
}
} else {
//TODO: Domain part not yet tested - should set up test environment with domains and do extensive testing.
if (domain.startsWith("/"))
domain = domain.substring(1);
int index = domain.indexOf('/');
String dpart = null;
if (index != -1)
dpart = domain.substring(0, index);
else
dpart = domain;
BACITreeDataNode node = (BACITreeDataNode) tempDomains.get(dpart);
if (node == null) {
node = new BACITreeDataNode(DOMAIN, dpart, infos[i], parent.getTreeByName(), getIcon(DOMAIN));
node.childrenHolder = new ArrayList();
if (index != -1)
node.domainRemainder = dpart + "/";
else
node.domainRemainder = dpart;
tempDomains.put(dpart, node);
}
BACITreeDataNode dummyNode = (BACITreeDataNode) tempDummies.get(names[0]);
if (names.length > 1) {
if (dummyNode == null) {
dummyNode = new BACITreeDataNode(DUMMY, names[0], BACICURLResolver.getFirstLevelCurl(curl), parent.getTree(), getIcon(DOMAIN));
dummyNode.childrenHolder = new ArrayList();
node.childrenHolder.add(0, rnc.deviceByName);
rootDummies.add(dummyNode);
}
String[] arrNames = names[1].split("/");
//System.out.println("DEBUG "+ names[1]);
getTreeForName(dummyNode, 0, arrNames);
} else {
if (dummyNode == null) {
node.childrenHolder.add(0, rnc.deviceByName);
} else {
dummyNode.childrenHolder.add(0, rnc.deviceByName);
}
}
}
}
for (int i = 0; i < rootDummies.size(); i++) {
BACITreeDataNode tmpNode = (BACITreeDataNode) rootDummies.get(i);
for (int j = 0; j < tmpNode.childrenHolder.size(); j++) {
if (tmpNode.childrenHolder.get(j) instanceof BACIRemoteNode) {
continue;
} else {
removeSingleDeviceDummies(tmpNode, j, (BACITreeDataNode) tmpNode.childrenHolder.get(j));
}
}
}
BACITreeDataNode[] arrayDummies = new BACITreeDataNode[tempDummies.size()];
tempDummies.values().toArray(arrayDummies);
BACITreeDataNode[] arrayDomains = new BACITreeDataNode[tempDomains.size()];
tempDomains.values().toArray(arrayDomains);
BACITreeDataNode[] retVal = new BACITreeDataNode[arrayDummies.length + arrayDomains.length];
System.arraycopy(arrayDomains, 0, retVal, 0, arrayDomains.length);
System.arraycopy(arrayDummies, 0, retVal, arrayDomains.length, arrayDummies.length);
notifier.reportDebug("BACIRemoteAccess::explodeRootNodeByName", "Root nodes processing complete.");
return retVal;
}
use of alma.maciErrType.NoPermissionEx in project ACS by ACS-Community.
the class BACIRemoteAccess method internalManagerConnect.
/**
* Insert the method's description here.
* Creation date: (2.11.2000 0:34:52)
* @param node si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
*/
private void internalManagerConnect(BACIRemoteNode baciNode) throws AcsJObjectExplorerConnectEx {
/* we are connecting directly to the Manager to obtain the object reference */
//System.out.println("DEBUG: imc "+baciNode);
String curl = (String) baciNode.getUserObject();
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Requesting component: '" + curl + "', activate = true");
notifier.reportMessage("Connecting to '" + curl + "'.");
baciNode.setNonSticky(connectNonSticky);
org.omg.CORBA.Object obj = null;
if (connectNonSticky) {
try {
obj = manager.get_component_non_sticky(handle, curl);
} catch (Throwable e) {
String message = "Connection to component '" + curl + "' failed. \n" + "'Connect as non-sticky' mode is enabled: in this mode component will not be activated by ObjectExplorer,\n" + "only already activated components can be accessed.";
int ans = choiceForNonStickyComponentConnection(message);
switch(ans) {
case 0:
baciNode.setNonSticky(false);
System.out.println("BACIRemoteAccess.internalManagerConnect setNonSticky to " + baciNode.isNonSticky() + " @ " + baciNode.hashCode());
break;
case 1:
baciEngineMenu.setNonSticky(false);
baciNode.setNonSticky(false);
break;
case 2:
{
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
default:
{
// should not happen.
notifier.reportError("Unexpected choice.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
}
}
}
try {
if (obj == null) {
obj = manager.get_component(handle, curl, true);
}
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Manager returns OK");
}/*
* We wrap into a specific exception and report up
*/
catch (CannotGetComponentEx e) {
notifier.reportError("Connection to component '" + curl + "' failed.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
} catch (org.omg.CORBA.TRANSIENT e) {
notifier.reportError("Connection to component '" + curl + "' failed.\nCouldn't connect to the manager.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
} catch (Throwable e) {
notifier.reportError("Connection to component '" + curl + "' failed.\nUnknown Reason.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
String irfid = null;
try {
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Querying component '" + curl + "' for CORBA type id.");
ComponentInfo[] cobInfos = manager.get_component_info(handle, new int[0], curl, "*", true);
if (cobInfos.length != 1) {
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx();
acsjex.setReason("Manager did not return valid ComponentInfo for '" + curl + "'.");
throw acsjex;
}
irfid = cobInfos[0].type;
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "component '" + curl + "' has id: " + irfid);
} catch (Exception e) {
notifier.reportError("Cannot retrieve Interface Repository ID for component '" + curl + "'", e);
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
// baciNode.setNonSticky(connectNonSticky);
baciNode.setCORBARef(obj);
try {
baciNode.setIFDesc(getIFDesc(irfid));
if (baciNode.getIFDesc() != null)
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "IR Query OK.");
else {
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx();
acsjex.setCurl(curl);
acsjex.setReason("Cannot retrieve Interface Repository description for component for '" + curl + "'.");
throw acsjex;
}
} catch (Exception e) {
baciNode.setCORBARef(null);
notifier.reportError("Failed to retrieve interface description from IR, releasing component on Manager, if needed.", e);
AcsJException releaseCompEx = null;
try {
if (manager != null && obj != null && !baciNode.isNonSticky()) {
manager.release_component(handle, curl);
}
} catch (NoPermissionEx npe) {
releaseCompEx = AcsJNoPermissionEx.fromNoPermissionEx(npe);
} catch (CannotDeactivateComponentEx ex) {
// @TODO remove this catch once we remove this ex from maci.idl
releaseCompEx = AcsJCannotDeactivateComponentEx.fromCannotDeactivateComponentEx(ex);
} catch (ComponentDeactivationUncleanEx ex) {
releaseCompEx = AcsJComponentDeactivationUncleanEx.fromComponentDeactivationUncleanEx(ex);
} catch (ComponentDeactivationFailedEx ex) {
releaseCompEx = AcsJComponentDeactivationFailedEx.fromComponentDeactivationFailedEx(ex);
}
if (releaseCompEx != null) {
notifier.reportError("Failed to release component", releaseCompEx);
logACSException(releaseCompEx);
}
AcsJObjectExplorerInterfaceRepositoryAccessEx acsjex = new AcsJObjectExplorerInterfaceRepositoryAccessEx(e);
acsjex.setCurl(curl);
acsjex.setIRid(irfid);
AcsJObjectExplorerConnectEx acsjex2 = new AcsJObjectExplorerConnectEx(acsjex);
acsjex2.setCurl(curl);
throw acsjex2;
}
notifier.reportMessage("Connected to '" + curl + "'.");
}
Aggregations