Search in sources :

Example 1 with LongCompletionCallback

use of com.cosylab.acs.maci.Manager.LongCompletionCallback in project ACS by ACS-Community.

the class ManagerProxyImpl method release_component_async.

public void release_component_async(int id, String component_url, CBlong callback, CBDescIn desc) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // simply release Component
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        final CBlong fcallback = callback;
        final CBDescOut descOut = new CBDescOut(0, desc.id_tag);
        LongCompletionCallback lcc = null;
        if (callback != null) {
            lcc = new LongCompletionCallback() {

                public void failed(int result, Throwable exception) {
                    if (exception instanceof AcsJException) {
                        AcsJException aex = (AcsJException) exception;
                        fcallback.done(result, aex.toAcsJCompletion().toCorbaCompletion(), descOut);
                    } else {
                        AcsJUnexpectedExceptionEx uex = new AcsJUnexpectedExceptionEx(exception);
                        fcallback.done(result, uex.toAcsJCompletion().toCorbaCompletion(), descOut);
                    }
                }

                public void done(int result) {
                    fcallback.done(result, new ACSErrOKAcsJCompletion().toCorbaCompletion(), descOut);
                }
            };
        }
        manager.releaseComponentAsync(id, uri, lcc);
    } catch (AcsJNoPermissionEx nop) {
        reportException(nop);
        // rethrow CORBA specific
        throw nop.toNoPermissionEx();
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } 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 (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : CBDescOut(alma.ACS.CBDescOut) AcsJException(alma.acs.exceptions.AcsJException) BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) LongCompletionCallback(com.cosylab.acs.maci.Manager.LongCompletionCallback) URI(java.net.URI) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) CBlong(alma.ACS.CBlong) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) ACSErrOKAcsJCompletion(alma.ACSErrTypeOK.wrappers.ACSErrOKAcsJCompletion) UNKNOWN(org.omg.CORBA.UNKNOWN) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Aggregations

CBDescOut (alma.ACS.CBDescOut)1 CBlong (alma.ACS.CBlong)1 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)1 ACSErrOKAcsJCompletion (alma.ACSErrTypeOK.wrappers.ACSErrOKAcsJCompletion)1 AcsJException (alma.acs.exceptions.AcsJException)1 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)1 BadParametersException (com.cosylab.acs.maci.BadParametersException)1 CoreException (com.cosylab.acs.maci.CoreException)1 LongCompletionCallback (com.cosylab.acs.maci.Manager.LongCompletionCallback)1 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 BAD_PARAM (org.omg.CORBA.BAD_PARAM)1 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)1 UNKNOWN (org.omg.CORBA.UNKNOWN)1