Search in sources :

Example 1 with AcsJObjectExplorerConnectEx

use of alma.objexpErrType.wrappers.AcsJObjectExplorerConnectEx 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 + "'.");
}
Also used : AcsJComponentDeactivationFailedEx(alma.maciErrType.wrappers.AcsJComponentDeactivationFailedEx) ComponentDeactivationFailedEx(alma.maciErrType.ComponentDeactivationFailedEx) AcsJObjectExplorerInterfaceRepositoryAccessEx(alma.objexpErrType.wrappers.AcsJObjectExplorerInterfaceRepositoryAccessEx) AcsJException(alma.acs.exceptions.AcsJException) CannotGetComponentEx(alma.maciErrType.CannotGetComponentEx) CannotDeactivateComponentEx(alma.maciErrType.CannotDeactivateComponentEx) AcsJCannotDeactivateComponentEx(alma.maciErrType.wrappers.AcsJCannotDeactivateComponentEx) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) AcsJException(alma.acs.exceptions.AcsJException) DataException(si.ijs.acs.objectexplorer.engine.DataException) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) AcsJObjectExplorerConnectEx(alma.objexpErrType.wrappers.AcsJObjectExplorerConnectEx) ComponentDeactivationUncleanEx(alma.maciErrType.ComponentDeactivationUncleanEx) AcsJComponentDeactivationUncleanEx(alma.maciErrType.wrappers.AcsJComponentDeactivationUncleanEx) NoPermissionEx(alma.maciErrType.NoPermissionEx) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ComponentInfo(si.ijs.maci.ComponentInfo)

Aggregations

AcsJException (alma.acs.exceptions.AcsJException)1 CannotDeactivateComponentEx (alma.maciErrType.CannotDeactivateComponentEx)1 CannotGetComponentEx (alma.maciErrType.CannotGetComponentEx)1 ComponentDeactivationFailedEx (alma.maciErrType.ComponentDeactivationFailedEx)1 ComponentDeactivationUncleanEx (alma.maciErrType.ComponentDeactivationUncleanEx)1 NoPermissionEx (alma.maciErrType.NoPermissionEx)1 AcsJCannotDeactivateComponentEx (alma.maciErrType.wrappers.AcsJCannotDeactivateComponentEx)1 AcsJComponentDeactivationFailedEx (alma.maciErrType.wrappers.AcsJComponentDeactivationFailedEx)1 AcsJComponentDeactivationUncleanEx (alma.maciErrType.wrappers.AcsJComponentDeactivationUncleanEx)1 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)1 AcsJObjectExplorerConnectEx (alma.objexpErrType.wrappers.AcsJObjectExplorerConnectEx)1 AcsJObjectExplorerInterfaceRepositoryAccessEx (alma.objexpErrType.wrappers.AcsJObjectExplorerInterfaceRepositoryAccessEx)1 DataException (si.ijs.acs.objectexplorer.engine.DataException)1 IntrospectionInconsistentException (si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)1 NonStickyConnectFailedRemoteException (si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)1 RemoteException (si.ijs.acs.objectexplorer.engine.RemoteException)1 ComponentInfo (si.ijs.maci.ComponentInfo)1