Search in sources :

Example 1 with DataException

use of si.ijs.acs.objectexplorer.engine.DataException in project ACS by ACS-Community.

the class BACIIntrospector method extractTypedef.

/**
 * Insert the method's description here.
 * Creation date: (7.11.2000 1:00:12)
 * @return java.lang.Object
 * @param argument org.omg.CORBA.Any
 */
public java.lang.Object extractTypedef(TypeCode tc, Any argument) {
    if (argument == null)
        throw new NullPointerException("argument");
    DynAny dany;
    try {
        dany = ra.getDynFact().create_dyn_any(argument);
    } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
        e.printStackTrace();
        return null;
    }
    DynStruct str = (DynStruct) dany;
    try {
        if (tc.kind() == TCKind.tk_struct) {
            DataStruct ds = new DataStruct(dany.type().id());
            for (int i = 0; i < str.component_count(); i++) {
                ds.add(str.current_member_name(), extractAny(str.current_component().to_any()));
                str.next();
            }
            return ds;
        } else {
            DataException de = new DataException(dany.type().id());
            for (int i = 0; i < str.component_count(); i++) {
                de.add(str.current_member_name(), extractAny(str.current_component().to_any()));
                str.next();
            }
            return de;
        }
    } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch e) {
        e.printStackTrace();
        return null;
    } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue e) {
        e.printStackTrace();
        return null;
    } catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
        e.printStackTrace();
        return null;
    }
}
Also used : DynStruct(org.omg.DynamicAny.DynStruct) DataStruct(si.ijs.acs.objectexplorer.engine.DataStruct) DataException(si.ijs.acs.objectexplorer.engine.DataException) DynAny(org.omg.DynamicAny.DynAny)

Example 2 with DataException

use of si.ijs.acs.objectexplorer.engine.DataException in project ACS by ACS-Community.

the class BACIRemoteAccess method logACSException.

/**
	 * Logs ACSException.
	 * @param exceptionThrown
	 */
private void logACSException(Exception exceptionThrown) {
    /* all user exception is expected to be using ACS Error System */
    if (exceptionThrown instanceof DataException) {
        DataException de = (DataException) exceptionThrown;
        /*
			 * This is just to probe if we have an ACS Exception.
			 * All applications should deal with ACS Exception and we want 
			 * to issue a warning if this is not the case.
			 * In this case we get an exception and the trap will log the warning.
			 */
        if (de.get("errorTrace") != null) {
            AcsJObjectExplorerReportEx objexpEx = new AcsJObjectExplorerReportEx(exceptionThrown);
            objexpEx.log(BACILogger.getLogger());
        } else {
            AcsJObjectExplorerReportEx notAnAcsEx = new AcsJObjectExplorerReportEx(exceptionThrown);
            notAnAcsEx.setContext("Logging a User Exception that is NOT an ACS Exception");
            notAnAcsEx.log(BACILogger.getLogger());
            notifier.reportDebug("BACIRemoteAccess::logACSExcpetion", "Failed to wrap user exception into native ACS Error System exception" + " for '" + de.id() + "'.");
        }
    } else /* End if org.omg.CORBA.UserException */
    if (exceptionThrown instanceof alma.acs.exceptions.AcsJException) {
        AcsJObjectExplorerReportEx objexpEx = new AcsJObjectExplorerReportEx(exceptionThrown);
        objexpEx.log(BACILogger.getLogger());
    } else if (exceptionThrown instanceof org.omg.CORBA.SystemException) {
        org.omg.CORBA.SystemException corbaSys = (org.omg.CORBA.SystemException) exceptionThrown;
        AcsJCORBAProblemEx corbaProblemEx = new AcsJCORBAProblemEx(exceptionThrown);
        corbaProblemEx.setMinor(corbaSys.minor);
        corbaProblemEx.setCompletionStatus(corbaSys.completed.value());
        corbaProblemEx.setInfo(corbaSys.toString());
        AcsJObjectExplorerReportEx objexpEx = new AcsJObjectExplorerReportEx(corbaProblemEx);
        objexpEx.log(BACILogger.getLogger());
    } else {
        AcsJUnexpectedExceptionEx unexpectedEx = new AcsJUnexpectedExceptionEx(exceptionThrown);
        AcsJObjectExplorerReportEx objexpEx = new AcsJObjectExplorerReportEx(unexpectedEx);
        objexpEx.log(BACILogger.getLogger());
        notifier.reportDebug("BACIRemoteAccess::logACSException", "Received an unexpected exception: " + " '" + exceptionThrown.getClass().getName() + "'.");
    }
}
Also used : DataException(si.ijs.acs.objectexplorer.engine.DataException) AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx) AcsJException(alma.acs.exceptions.AcsJException) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) AcsJObjectExplorerReportEx(alma.objexpErrType.wrappers.AcsJObjectExplorerReportEx)

Example 3 with DataException

use of si.ijs.acs.objectexplorer.engine.DataException in project ACS by ACS-Community.

the class BACIIntrospector method insertTypedef.

public Any insertTypedef(TypeCode tc, java.lang.Object obj) {
    DynAny dany;
    try {
        dany = ra.getDynFact().create_dyn_any_from_type_code(tc);
    } catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
        e.printStackTrace();
        return null;
    }
    //Class<?> cl = getClassType(tc);
    DynStruct str = (DynStruct) dany;
    NameDynAnyPair[] mems = str.get_members_as_dyn_any();
    try {
        if (tc.kind() == TCKind.tk_struct) {
            DataStruct ds = (DataStruct) obj;
            for (int i = 0; i < mems.length; i++) {
                mems[i].value.from_any(insertAny(mems[i].value.to_any(), ds.get(mems[i].id)));
            }
        } else {
            DataException de = (DataException) obj;
            for (int i = 0; i < mems.length; i++) {
                mems[i].value.from_any(insertAny(mems[i].value.to_any(), de.get(mems[i].id)));
            }
        }
        str.set_members_as_dyn_any(mems);
    } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch e) {
        e.printStackTrace();
        return null;
    } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue e) {
        e.printStackTrace();
        return null;
    }
    //displayAny(dany.to_any());
    return dany.to_any();
}
Also used : DynStruct(org.omg.DynamicAny.DynStruct) DataStruct(si.ijs.acs.objectexplorer.engine.DataStruct) DataException(si.ijs.acs.objectexplorer.engine.DataException) NameDynAnyPair(org.omg.DynamicAny.NameDynAnyPair) DynAny(org.omg.DynamicAny.DynAny)

Aggregations

DataException (si.ijs.acs.objectexplorer.engine.DataException)3 DynAny (org.omg.DynamicAny.DynAny)2 DynStruct (org.omg.DynamicAny.DynStruct)2 DataStruct (si.ijs.acs.objectexplorer.engine.DataStruct)2 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)1 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)1 AcsJException (alma.acs.exceptions.AcsJException)1 AcsJObjectExplorerReportEx (alma.objexpErrType.wrappers.AcsJObjectExplorerReportEx)1 NameDynAnyPair (org.omg.DynamicAny.NameDynAnyPair)1