Search in sources :

Example 56 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class ExtendedResourceRecord method otsRecord.

private final OTSAbstractRecord otsRecord() {
    try {
        if (_otsARHandle == null && _resourceHandle != null) {
            _otsARHandle = com.arjuna.ArjunaOTS.OTSAbstractRecordHelper.unchecked_narrow(_resourceHandle);
            lastRecord = RecordType.LASTRESOURCE == _otsARHandle.type_id();
        }
        if (_otsARHandle == null)
            throw new BAD_PARAM();
        else
            return _otsARHandle;
    } catch (Exception e) {
        return null;
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException)

Example 57 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class ResourceRecord method resourceHandle.

public final Resource resourceHandle() {
    if ((_resourceHandle == null) && (_stringifiedResourceHandle != null)) {
        try {
            org.omg.CORBA.ORB theOrb = ORBManager.getORB().orb();
            if (theOrb == null)
                throw new UNKNOWN();
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ResourceRecord: About to string_to_object on " + _stringifiedResourceHandle);
            }
            org.omg.CORBA.Object optr = theOrb.string_to_object(_stringifiedResourceHandle);
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ResourceRecord: Successfully stringed to object, next try to narrow");
            }
            theOrb = null;
            _resourceHandle = org.omg.CosTransactions.ResourceHelper.narrow(optr);
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ResourceRecord: Successfully narrowed");
            }
            if (_resourceHandle == null)
                throw new BAD_PARAM();
            else {
                optr = null;
            }
        } catch (SystemException e) {
            if (jtsLogger.logger.isTraceEnabled()) {
                jtsLogger.logger.trace("ResourceRecord: Failed to narrow to Resource");
            }
        }
    }
    return _resourceHandle;
}
Also used : SystemException(org.omg.CORBA.SystemException) BAD_PARAM(org.omg.CORBA.BAD_PARAM) UNKNOWN(org.omg.CORBA.UNKNOWN)

Example 58 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class ResourceRecord method nestedAbort.

/**
 * General nesting rules:
 *
 * Only SubtransactionAware resources get registered with nested actions.
 * The ResourceRecord creator is assumed to ensure that plain Resources
 * are only registered with the appropriate top level action.
 *
 * That said the _propagateRecord flag ensures that resources registered
 * via register_subtran only take part in the action they where registered
 * in after which they are dropped
 */
public int nestedAbort() {
    if (jtsLogger.logger.isTraceEnabled()) {
        jtsLogger.logger.trace("ResourceRecord::nestedAbort() for " + order());
    }
    /*
	 * We shouldn't need to check committed since aborted nested actions
	 * will drop these resources.
	 */
    SubtransactionAwareResource staResource = null;
    int o = TwoPhaseOutcome.FINISH_ERROR;
    try {
        /*
	     * Must be an staResource to get here.
	     */
        staResource = org.omg.CosTransactions.SubtransactionAwareResourceHelper.narrow(resourceHandle());
        if (staResource == null)
            throw new BAD_PARAM(0, CompletionStatus.COMPLETED_NO);
    } catch (Exception exEnv) {
        // not a sub tran resource, so ignore;
        o = TwoPhaseOutcome.FINISH_OK;
    }
    if (staResource != null) {
        try {
            staResource.rollback_subtransaction();
            o = TwoPhaseOutcome.FINISH_OK;
        } catch (Exception e) {
            o = TwoPhaseOutcome.FINISH_ERROR;
        }
        staResource = null;
    }
    /*
	 * Now release the parent as it is about to be destroyed
	 * anyway.
	 *
	 * The parent may have already been released if abort is
	 * being called because commit failed.
	 */
    _parentCoordHandle = null;
    return o;
}
Also used : SubtransactionAwareResource(org.omg.CosTransactions.SubtransactionAwareResource) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SystemException(org.omg.CORBA.SystemException) IOException(java.io.IOException)

Example 59 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class Helper method localAction.

/**
 * Given a Control_ptr determine if this is a reference to a local
 * action, and if so return the raw BasicAction pointer.
 */
public static final BasicAction localAction(org.omg.CosTransactions.Control control) {
    if (control == null)
        return null;
    if (control instanceof ControlImple) {
        try {
            ControlImple c = (ControlImple) control;
            return (BasicAction) c.getImplHandle();
        } catch (Exception e) {
        }
    }
    try {
        UidCoordinator coord = Helper.getUidCoordinator(control);
        if (coord != null) {
            Uid u = Helper.getUid(coord);
            coord = null;
            return ActionManager.manager().get(u);
        } else
            throw new BAD_PARAM();
    } catch (Exception e) {
    /*
	     * Can't be an Arjuna action, so ignore.
	     */
    }
    return null;
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) UidCoordinator(com.arjuna.ArjunaOTS.UidCoordinator) BasicAction(com.arjuna.ats.arjuna.coordinator.BasicAction) BAD_PARAM(org.omg.CORBA.BAD_PARAM) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple)

Example 60 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project narayana by jbosstm.

the class InterpositionClientRequestInterceptorImpl method send_request.

public void send_request(ClientRequestInfo request_info) throws SystemException {
    if (jtsLogger.logger.isTraceEnabled()) {
        trace_request("send_request", request_info);
    }
    if (systemCall(request_info))
        return;
    final boolean otsAlwaysPropagate = InterceptorInfo.getAlwaysPropagate();
    try {
        if (!otsAlwaysPropagate) {
            TransactionalObject ptr = TransactionalObjectHelper.narrow(request_info.target());
            if (ptr == null)
                throw new BAD_PARAM();
        } else {
            /**
             * If the value is not null then we are currently in use *
             */
            if (_inUse.get() != null) {
                return;
            } else {
                _inUse.set(_inUse);
            }
        }
        try {
            /*
		 * We get back an Any, which contains a key which we must
		 * now use to get the actual transaction context. This saves
		 * use having to pack and unpack the context every time it
		 * changes, even if we don't then make a remote invocation.
		 */
            Any localData = request_info.get_slot(_localSlot);
            String threadId = null;
            boolean problem = false;
            Any data = null;
            if (localData.type().kind().value() != TCKind._tk_null) {
                if ((threadId = localData.extract_string()) == null)
                    throw new UNKNOWN(jtsLogger.i18NLogger.get_orbspecific_javaidl_interceptors_interposition_invalidparam());
            } else
                threadId = ThreadUtil.getThreadId();
            if (threadId != null) {
                ControlWrapper theControl = OTSImpleManager.current().contextManager().current(threadId);
                if (theControl != null) {
                    try {
                        Coordinator theCoordinator = theControl.get_coordinator();
                        PropagationContext ctx = null;
                        if (theCoordinator != null) {
                            final Coordinator finalTheCoordinator = theCoordinator;
                            try {
                                ctx = doPrivileged(new PrivilegedExceptionAction<PropagationContext>() {

                                    @Override
                                    public PropagationContext run() throws Unavailable {
                                        return finalTheCoordinator.get_txcontext();
                                    }
                                });
                            } catch (PrivilegedActionException pex) {
                                throw pex.getException();
                            }
                            data = packPropagationContext(ctx);
                            theCoordinator = null;
                        } else
                            throw new Unavailable();
                    } catch (Unavailable ex) {
                        /*
			     * We may have to make calls during
			     * commit (e.g., after_completion)
			     * which are valid, but which will get
			     * Unavailable.
			     */
                        problem = true;
                    }
                } else
                    problem = true;
            } else
                problem = true;
            if (problem) {
                if (InterceptorInfo.getNeedTranContext())
                    throw new TRANSACTION_REQUIRED();
            }
            if (data != null) {
                byte[] octets;
                try {
                    final Any finalData = data;
                    octets = doPrivileged(new PrivilegedExceptionAction<byte[]>() {

                        @Override
                        public byte[] run() throws org.omg.CORBA.UserException {
                            return _codec.encode_value(finalData);
                        }
                    });
                } catch (PrivilegedActionException pex) {
                    throw pex.getException();
                }
                ServiceContext service_context = new ServiceContext(OTSManager.serviceId, octets);
                request_info.add_request_service_context(service_context, true);
            }
        } catch (SystemException e) {
            throw e;
        } catch (Exception ex) {
            throw new UNKNOWN(ex.toString());
        } finally {
            /**
             * If we are set to always propagate then ensure we clear the inuse flag *
             */
            if (otsAlwaysPropagate) {
                _inUse.set(null);
            }
        }
    } catch (BAD_PARAM ex) {
    // narrow failed, so not a transactional object.
    }
}
Also used : PropagationContext(org.omg.CosTransactions.PropagationContext) PrivilegedActionException(java.security.PrivilegedActionException) ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) Coordinator(org.omg.CosTransactions.Coordinator) Any(org.omg.CORBA.Any) SystemException(org.omg.CORBA.SystemException) PrivilegedActionException(java.security.PrivilegedActionException) Unavailable(org.omg.CosTransactions.Unavailable) SystemException(org.omg.CORBA.SystemException) ControlWrapper(com.arjuna.ats.internal.jts.ControlWrapper) TransactionalObject(org.omg.CosTransactions.TransactionalObject) UNKNOWN(org.omg.CORBA.UNKNOWN) TRANSACTION_REQUIRED(org.omg.CORBA.TRANSACTION_REQUIRED)

Aggregations

BAD_PARAM (org.omg.CORBA.BAD_PARAM)69 SystemException (org.omg.CORBA.SystemException)31 UNKNOWN (org.omg.CORBA.UNKNOWN)27 Any (org.omg.CORBA.Any)22 ServiceContext (org.omg.IOP.ServiceContext)21 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)13 BadParametersException (com.cosylab.acs.maci.BadParametersException)13 CoreException (com.cosylab.acs.maci.CoreException)13 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)13 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)12 TRANSACTION_REQUIRED (org.omg.CORBA.TRANSACTION_REQUIRED)12 Coordinator (org.omg.CosTransactions.Coordinator)12 UidCoordinator (com.arjuna.ArjunaOTS.UidCoordinator)9 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)8 Object (org.omg.CORBA.Object)8 Unavailable (org.omg.CosTransactions.Unavailable)8 FormatMismatch (org.omg.IOP.CodecPackage.FormatMismatch)8 TypeMismatch (org.omg.IOP.CodecPackage.TypeMismatch)8 URI (java.net.URI)7 URISyntaxException (java.net.URISyntaxException)7