Search in sources :

Example 1 with ErrorTrace

use of alma.ACSErr.ErrorTrace in project ACS by ACS-Community.

the class AcsJCompletion method fromCorbaCompletion.

/**
	 * Factory method to create an <code>AcsJCompletion</code> from an existing CORBA completion.
	 * Note that the new <code>AcsJCompletion</code> is a direct translation, not a wrapper.
	 * <p>
	 * If <code>corbaCompletion</code> has error information attached,
	 * this will be converted, and type/code of the top-exception will 
	 * have precedence over type/code stored redundantly in <code>corbaCompletion</code>.
	 * <p> 
	 * To be used on the client side of a remote call.
	 * @param completion
	 */
public static AcsJCompletion fromCorbaCompletion(Completion corbaCompletion) {
    if (corbaCompletion == null)
        throw new NullPointerException("argument 'completion' must not be null!");
    AcsJCompletion jcompletion = new AcsJCompletion();
    // does completion have error info attached? If so, convert from CORBA structs to Java exc.
    if (corbaCompletion.previousError != null && corbaCompletion.previousError.length > 0) {
        AcsJException jex = null;
        ErrorTrace et = corbaCompletion.previousError[0];
        Throwable thr = CorbaExceptionConverter.recursiveGetThrowable(et);
        if (!(thr instanceof AcsJException)) {
            // just in case... should never happen, as CorbaExceptionConverter.recursiveGetThrowable
            // already substitutes non-AcsJ exceptions with DefaultAcsJException...			
            jex = new DefaultAcsJException(et);
        } else {
            jex = (AcsJException) thr;
        }
        jcompletion.init(jex);
    } else {
        jcompletion.init(corbaCompletion.type, corbaCompletion.code);
    }
    return jcompletion;
}
Also used : ErrorTrace(alma.ACSErr.ErrorTrace)

Example 2 with ErrorTrace

use of alma.ACSErr.ErrorTrace in project ACS by ACS-Community.

the class AcsJException method createSingleErrorTrace.

/**
     * Creates an <code>ErrorTrace</code> object that represents this exception.
     * Linked exceptions are not considered, so the returned <code>ErrorTrace.previousError</code> is left as <code>null</code>.
     */
protected ErrorTrace createSingleErrorTrace() {
    ErrorTrace et = new ErrorTrace();
    et.host = m_host;
    et.process = m_process;
    et.sourceObject = m_sourceObject;
    et.lineNum = m_line;
    et.routine = m_method;
    et.file = m_file;
    et.errorType = getErrorType();
    et.errorCode = getErrorCode();
    et.severity = getSeverity();
    et.thread = m_threadName;
    et.timeStamp = UTCUtility.utcJavaToOmg(m_timeMilli);
    et.data = getNameValueArray();
    et.shortDescription = getShortDescription();
    addExceptionProperties(this, et);
    return et;
}
Also used : ErrorTrace(alma.ACSErr.ErrorTrace)

Example 3 with ErrorTrace

use of alma.ACSErr.ErrorTrace in project ACS by ACS-Community.

the class AcsJException method recursiveGetErrorTrace.

/**
	 * Translates a <code>Throwable</code> to an <code>ErrorTrace</code>.
	 * <p>
	 * If <code>thr</code> is a subclass of <code>AcsJException</code>,
	 * then the various data fields of the <code>ErrorTrace</code> object
	 * are properly filled. Otherwise defaults are used.
	 * <p>
	 * If <code>thr</code> has other <code>Throwable</code>s chained up
	 * (see {@link Throwable#getCause}) then these will also be translated,
	 * and the resulting <code>ErrorTrace</code> objects will be linked together.
	 * 
	 * @param thr
	 * @return ErrorTrace
	 */
private static ErrorTrace recursiveGetErrorTrace(Throwable thr, long defaultTimeMilli) {
    ErrorTrace et = createSingleErrorTrace(thr, defaultTimeMilli);
    // if present, chain up the underlying exception(s)
    Throwable cause = thr.getCause();
    if (cause != null) {
        ErrorTrace causeErrorTrace = recursiveGetErrorTrace(cause, --defaultTimeMilli);
        if (et.previousError == null || et.previousError.length != 1) {
            et.previousError = new ErrorTrace[1];
        }
        et.previousError[0] = causeErrorTrace;
    } else {
        et.previousError = new ErrorTrace[0];
    }
    return et;
}
Also used : ErrorTrace(alma.ACSErr.ErrorTrace)

Example 4 with ErrorTrace

use of alma.ACSErr.ErrorTrace in project ACS by ACS-Community.

the class CompletionEventPublisherClient method publishEvent.

/**
	 * Publish a {@link StructWithACompletion}.
	 * 
	 * At the present this tests shall pass because of the workaround described
	 * in the ticket (i.e. added another typedef for for the sequence in the
	 * {@link Completion}).
	 */
private void publishEvent() {
    m_logger.info("Going to publish an event");
    // Create and initialize an event with a Completion
    Completion c = new Completion();
    c.code = 100;
    c.timeStamp = System.currentTimeMillis();
    c.type = 101;
    // ICT-3870 error happens also without any ErorTrace in the previuError property 
    // of the COmpletion but this way it is more compete
    ErrorTrace event = new ErrorTrace();
    event.previousError = new ErrorTrace[0];
    event.errorCode = 1;
    event.errorType = 2;
    event.file = "filename";
    event.host = "hostname";
    event.lineNum = 3;
    event.process = "processname";
    event.routine = "reoutinename";
    event.severity = Severity.Alert;
    NameValue nv = new NameValue();
    nv.name = "NameValue name";
    nv.value = "NameValue value";
    event.data = new NameValue[0];
    event.shortDescription = "short desc";
    event.sourceObject = "src obj";
    event.thread = "thread name";
    event.timeStamp = System.currentTimeMillis();
    c.previousError = new ErrorTrace[1];
    c.previousError[0] = event;
    try {
        m_supplier.publishEvent(c);
        m_logger.info("Event successfull published.");
    } catch (Throwable t) {
        m_logger.log(AcsLogLevel.ERROR, "Error publishing the event with a Completion", t);
    }
}
Also used : NameValue(alma.ACSErr.NameValue) ErrorTrace(alma.ACSErr.ErrorTrace) Completion(alma.ACSErr.Completion)

Example 5 with ErrorTrace

use of alma.ACSErr.ErrorTrace in project ACS by ACS-Community.

the class DefaultAcsJException method toCorbaException.

/**
	 * Unlike other exception classes, this class does not correspond directly
	 * to an IDL defined type safe exception.
	 * Therefore, the returned UserException is an instance of 
	 * <code>alma.ACSErr.ACSException</code>.
	 * 
	 * @see alma.acs.exceptions.AcsJException#toCorbaException()
	 */
public UserException toCorbaException() {
    ErrorTrace et = getErrorTrace();
    ACSException acsEx = new ACSException(et);
    return acsEx;
}
Also used : ErrorTrace(alma.ACSErr.ErrorTrace) ACSException(alma.ACSErr.ACSException)

Aggregations

ErrorTrace (alma.ACSErr.ErrorTrace)10 Completion (alma.ACSErr.Completion)2 ACSException (alma.ACSErr.ACSException)1 NameValue (alma.ACSErr.NameValue)1 ACSErrTest1AcsJCompletion (alma.ACSErrTypeTest.wrappers.ACSErrTest1AcsJCompletion)1 ACSErrTest2AcsJCompletion (alma.ACSErrTypeTest.wrappers.ACSErrTest2AcsJCompletion)1 ACSErrTest3AcsJCompletion (alma.ACSErrTypeTest.wrappers.ACSErrTest3AcsJCompletion)1 ACSErrTestOKAcsJCompletion (alma.ACSErrTypeTest.wrappers.ACSErrTestOKAcsJCompletion)1 AcsJACSErrTest1Ex (alma.ACSErrTypeTest.wrappers.AcsJACSErrTest1Ex)1 AcsJACSErrTest2Ex (alma.ACSErrTypeTest.wrappers.AcsJACSErrTest2Ex)1 AcsJACSErrTest3Ex (alma.ACSErrTypeTest.wrappers.AcsJACSErrTest3Ex)1 Field (java.lang.reflect.Field)1 LogRecord (java.util.logging.LogRecord)1 UserException (org.omg.CORBA.UserException)1