{
try
{
TopicSpaceSet aSet = m_notificationProducerResource.getTopicSpaceSet( );
TopicSpace aTopicSpace = aSet.getTopicSpace( MuwsConstants.NSURI_MUWS_PART2_TOPICS );
ManagementEventTopic operationalStatus = (ManagementEventTopic) aTopicSpace.getTopic( OperationalStatusCapability.TOPIC_NAME );
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.LangString lStringC = LangString.Factory.newInstance( );
lStringC.setLang( "en" );
if ( operationalStatus == null )
{
throw new Exception( "The topic is not set" );
}
Situation aSituation = new SituationImpl( new CategoryImpl( MuwsConstants.SITUATION_AVAILABILITY ) );
if ( firstEvent )
{
aSituation.setSeverity( (short) 4 );
lStringC.setStringValue( "Available disk space is too low" );
aSituation.setSuccessDisposition( Boolean.FALSE );
m_correlationId = ((UUID) IdentifierUtils.UUID_VERSION_FOUR_GENERATOR.nextIdentifier()).toString();
}
else
{
aSituation.setSeverity( (short) 1 );
lStringC.setStringValue( "Available disk space is OK" );
aSituation.setSuccessDisposition( Boolean.TRUE );
}
LangStringImpl lstring = new LangStringImpl( lStringC );
aSituation.setMessage( lstring );
XmlBeansManagementEvent event = new XmlBeansManagementEvent( aSituation );
// set resource Reporter and source ResourceId
ResourcePropertySet propSet = m_notificationProducerResource.getResourcePropertySet( );
ResourceProperty resourceId = propSet.get( ApplicationPropertyQNames.RESOURCEID );
String Id = null;
Iterator propElemIter = resourceId.iterator( );
while ( propElemIter.hasNext( ) )
{
XmlObject propElem = (XmlObject) propElemIter.next( );
if ( propElem instanceof XmlAnyUriImpl )
{
XmlAnyUriImpl aUri = (XmlAnyUriImpl) propElem;
Id = aUri.getStringValue( );
event.setReporterResourceId( Id );
event.setSourceResourceId( Id );
}
else
{
throw new Exception( " ResourceId property should be instanceof XmlAnyUriImpl" );
}
}
//set custom CorrelationId
Object[] corId = new Object[1];
CorrelationIdDocument id = CorrelationIdDocument.Factory.newInstance( );
id.setCorrelationId( m_correlationId );
corId[0] = id;
event.setAny( corId );
// Topic publish event to the subscribers
operationalStatus.publish( event );
}
catch ( Exception e )
{
LOG.info( "Error: OperationalEvent " + e.toString( ) );