Search in sources :

Example 1 with AcsJUnexpectedExceptionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx in project ACS by ACS-Community.

the class AlarmSystemContainerServices method getPOAForOffshoots.

public POA getPOAForOffshoots(POA componentPOA) throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
    final String offshootPoaName = "offshootPoa";
    POA offshootPoa = null;
    synchronized (componentPOA) {
        try {
            // can we reuse it?
            offshootPoa = componentPOA.find_POA(offshootPoaName, false);
        } catch (AdapterNonExistent e) {
            logger.finest("will have to create offshoot POA");
            if (m_offshootPolicies == null) {
                m_offshootPolicies = new Policy[4];
                m_offshootPolicies[0] = componentPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
                m_offshootPolicies[1] = componentPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
                m_offshootPolicies[2] = componentPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
                m_offshootPolicies[3] = componentPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
            }
            try {
                offshootPoa = componentPOA.create_POA(offshootPoaName, alSysCorbaServer.getRootPOA().the_POAManager(), m_offshootPolicies);
                logger.finest("successfully created offshoot POA");
            } catch (InvalidPolicy ex) {
                AcsJContainerEx ex2 = new AcsJContainerEx(ex);
                ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
                throw ex2;
            } catch (AdapterAlreadyExists ex) {
                // we sync on componentPOA, so this should never happen
                throw new AcsJUnexpectedExceptionEx(ex);
            }
        }
    }
    return offshootPoa;
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) POA(org.omg.PortableServer.POA) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AdapterAlreadyExists(org.omg.PortableServer.POAPackage.AdapterAlreadyExists) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) AdapterNonExistent(org.omg.PortableServer.POAPackage.AdapterNonExistent)

Example 2 with AcsJUnexpectedExceptionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx in project ACS by ACS-Community.

the class LaserComponent method submitAlarm.

/**
	 * IDL method: submit an alarm without.
	 * <P>
	 * Build a message to sent to the {@link AlarmMessageProcessorImpl#process(Message)}.
	 * 
	 * @param triplet The triplet of the alarm
	 * @param active if <code>true</code> the alarm is active
	 * @param sourceHostName The name of the host of the source
	 * @param timestamp The timestamp of the source
	 * @param alarmProperties Additional user-defined properties of the alarm
	 */
public synchronized void submitAlarm(Triplet triplet, boolean active, String sourceHostName, String sourceName, long timestamp, Property[] alarmProperties) throws BadParameterEx, UnexpectedExceptionEx {
    cern.laser.source.alarmsysteminterface.impl.message.FaultState fs = new cern.laser.source.alarmsysteminterface.impl.message.FaultState();
    fs.setCode(triplet.faultCode);
    fs.setMember(triplet.faultMember);
    fs.setFamily(triplet.faultFamily);
    logger.log(AcsLogLevel.DEBUG, "Submitting alarm <" + triplet.faultFamily + ", " + triplet.faultMember + ", " + triplet.faultCode + "> active=" + active);
    // Properties
    cern.laser.source.alarmsysteminterface.impl.message.Properties props = new cern.laser.source.alarmsysteminterface.impl.message.Properties();
    if (alarmProperties != null) {
        for (Property p : alarmProperties) {
            cern.laser.source.alarmsysteminterface.impl.message.Property propToAdd = new cern.laser.source.alarmsysteminterface.impl.message.Property();
            propToAdd.setName(p.property_name);
            propToAdd.setValue(p.property_value.toString());
            props.addProperty(propToAdd);
        }
    }
    fs.setUserProperties(props);
    // Timestamp
    long javaTime = UTCUtility.utcOmgToJava(timestamp);
    long seconds = javaTime / 1000;
    long milliseconds = javaTime % 1000;
    String tStamp = IsoDateFormat.formatCurrentDate();
    fs.setUserTimestamp(tStamp);
    // Descriptor
    if (active) {
        fs.setDescriptor(ACSFaultState.ACTIVE);
    } else {
        fs.setDescriptor(ACSFaultState.TERMINATE);
    }
    // Build the message
    TextMessage message;
    try {
        message = buildMessage(fs, sourceHostName, sourceName);
    } catch (IllegalArgumentException ie) {
        AcsJBadParameterEx ex = new AcsJBadParameterEx(ie);
        throw ex.toBadParameterEx();
    } catch (Throwable t) {
        AcsJUnexpectedExceptionEx ex = new AcsJUnexpectedExceptionEx(t);
        throw ex.toUnexpectedExceptionEx();
    }
    // Inject the message
    try {
        onMessage(message.getText());
    } catch (Throwable t) {
        AcsJUnexpectedExceptionEx ex = new AcsJUnexpectedExceptionEx(t);
        throw ex.toUnexpectedExceptionEx();
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) ACSFaultState(alma.alarmsystem.source.ACSFaultState) FaultState(cern.laser.source.alarmsysteminterface.impl.message.FaultState) LaserCoreFaultState(alma.alarmsystem.core.alarms.LaserCoreFaultState) FaultState(cern.laser.source.alarmsysteminterface.impl.message.FaultState) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) Property(org.omg.CosPropertyService.Property) ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) TextMessage(javax.jms.TextMessage)

Example 3 with AcsJUnexpectedExceptionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx in project ACS by ACS-Community.

the class ManagerContainerServices method checkOffShootPOA.

/**
	 * Creates the shared offshoot poa on demand 
	 */
public void checkOffShootPOA() throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
    final String offshootPoaName = "offshootPoa";
    synchronized (clientPOA) {
        try {
            // can we reuse it?
            offshootPoa = clientPOA.find_POA(offshootPoaName, false);
        } catch (AdapterNonExistent e) {
            logger.finest("will have to create offshoot POA");
            if (offshootPolicies == null) {
                offshootPolicies = new Policy[4];
                offshootPolicies[0] = clientPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
                offshootPolicies[1] = clientPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
                offshootPolicies[2] = clientPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
                offshootPolicies[3] = clientPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
            }
            try {
                offshootPoa = clientPOA.create_POA(offshootPoaName, clientPOA.the_POAManager(), offshootPolicies);
                logger.finest("successfully created offshoot POA");
            } catch (InvalidPolicy ex) {
                AcsJContainerEx ex2 = new AcsJContainerEx(ex);
                ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
                throw ex2;
            } catch (AdapterAlreadyExists ex) {
                // we sync on componentPOA, so this should never happen
                throw new AcsJUnexpectedExceptionEx(ex);
            }
        }
    }
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AdapterAlreadyExists(org.omg.PortableServer.POAPackage.AdapterAlreadyExists) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) AdapterNonExistent(org.omg.PortableServer.POAPackage.AdapterNonExistent)

Example 4 with AcsJUnexpectedExceptionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx in project ACS by ACS-Community.

the class EventSupplierSpr2005067Impl method sendEvents.

/** Sends some events to an event channel.
    * @param param number of events to send
    */
public void sendEvents(short param) {
    /* 
	* This is OK
	*/
    m_logger.info("Now sending ControlSystemChangeOfStateEvent2 events. This should always be OK");
    try {
        ControlSystemChangeOfStateEvent2 t_block = new ControlSystemChangeOfStateEvent2(alma.SPR2005067.SystemState.INACCESSIBLE, alma.SPR2005067.SystemSubstate.STARTING_UP_PASS1, false, 0);
        for (short i = 0; i < param; i++) {
            m_supplier.publishEvent(t_block);
        }
    } catch (AcsJException e) {
        /*
	    * Here I just log the error trace.
	    * It would be nicer to throw it to the caller,
	    * but the interface of sendEvents does not allow it.
	    * We should change that interface.
	    */
        AcsJGenericErrorEx ex = new AcsJGenericErrorEx("This exception publishing events should have never occurred", e);
        ex.log(m_logger);
    } catch (Throwable thr) {
        AcsJUnexpectedExceptionEx ex = new AcsJUnexpectedExceptionEx("Got unexpected exception", thr);
        /*
	    * Here I just log the error trace.
	    * It would be nicer to throw it to the caller,
	    * but the interface of sendEvents does not allow it.
	    * We should change that interface.
	    */
        ex.log(m_logger);
    }
    /*
	* This fails with JacORB (tested up to version 2.2.4)
	* See SPR 2005067
	*/
    m_logger.info("Now sending ControlSystemChangeOfStateEvent events. This FAILS now but should be OK as well. See SPR2005067");
    try {
        ControlSystemChangeOfStateEvent t_block = new ControlSystemChangeOfStateEvent(alma.SPR2005067.SystemState.INACCESSIBLE, alma.SPR2005067.SystemSubstate.STARTING_UP_PASS1, alma.SPR2005067.SystemState.INACCESSIBLE, alma.SPR2005067.SystemSubstate.STARTING_UP_PASS1, false, 0);
        for (short i = 0; i < param; i++) {
            m_supplier.publishEvent(t_block);
        }
    } catch (AcsJException e) {
        /*
	    * Here I just log the error trace.
	    * It would be nicer to throw it to the caller,
	    * but the interface of sendEvents does not allow it.
	    * We should change that interface.
	    */
        AcsJGenericErrorEx ex = new AcsJGenericErrorEx("This exception is due to SPR2005067", e);
        ex.log(m_logger);
    } catch (Throwable thr) {
        /*
	    * The message int the exception logged is incomplete.
	    * Look at the println and compare to see the difference
	    */
        System.err.println(thr);
        AcsJUnexpectedExceptionEx ex = new AcsJUnexpectedExceptionEx("Got unexpected exception", thr);
        /*
	    * Here I just log the error trace.
	    * It would be nicer to throw it to the caller,
	    * but the interface of sendEvents does not allow it.
	    * We should change that interface.
	    */
        ex.log(m_logger);
    }
}
Also used : AcsJGenericErrorEx(alma.ACSErrTypeCommon.wrappers.AcsJGenericErrorEx) AcsJException(alma.acs.exceptions.AcsJException) ControlSystemChangeOfStateEvent2(alma.SPR2005067.ControlSystemChangeOfStateEvent2) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) ControlSystemChangeOfStateEvent(alma.SPR2005067.ControlSystemChangeOfStateEvent)

Example 5 with AcsJUnexpectedExceptionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx 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)

Aggregations

AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)10 AcsJException (alma.acs.exceptions.AcsJException)4 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)3 Policy (org.omg.CORBA.Policy)3 AdapterAlreadyExists (org.omg.PortableServer.POAPackage.AdapterAlreadyExists)3 AdapterNonExistent (org.omg.PortableServer.POAPackage.AdapterNonExistent)3 InvalidPolicy (org.omg.PortableServer.POAPackage.InvalidPolicy)3 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)2 AcsJGenericErrorEx (alma.ACSErrTypeCommon.wrappers.AcsJGenericErrorEx)2 NameComponent (org.omg.CosNaming.NameComponent)2 POA (org.omg.PortableServer.POA)2 CBDescOut (alma.ACS.CBDescOut)1 CBlong (alma.ACS.CBlong)1 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)1 ACSErrOKAcsJCompletion (alma.ACSErrTypeOK.wrappers.ACSErrOKAcsJCompletion)1 ControlSystemChangeOfStateEvent (alma.SPR2005067.ControlSystemChangeOfStateEvent)1 ControlSystemChangeOfStateEvent2 (alma.SPR2005067.ControlSystemChangeOfStateEvent2)1 LaserCoreFaultState (alma.alarmsystem.core.alarms.LaserCoreFaultState)1 ACSFaultState (alma.alarmsystem.source.ACSFaultState)1 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)1