Search in sources :

Example 1 with OriginatorType

use of org.talend.esb.sam._2011._03.common.OriginatorType in project tesb-rt-se by Talend.

the class EventMapper method mapOriginator.

/**
 * Mapping originator.
 *
 * @param originator the originator
 * @return the originator type
 */
private static OriginatorType mapOriginator(Originator originator) {
    if (originator == null) {
        return null;
    }
    OriginatorType origType = new OriginatorType();
    origType.setProcessId(originator.getProcessId());
    origType.setIp(originator.getIp());
    origType.setHostname(originator.getHostname());
    origType.setCustomId(originator.getCustomId());
    origType.setPrincipal(originator.getPrincipal());
    return origType;
}
Also used : OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType)

Example 2 with OriginatorType

use of org.talend.esb.sam._2011._03.common.OriginatorType in project tesb-rt-se by Talend.

the class EventTypeMapperTest method testEmpty.

/**
 * Test with empty eventType parts to check for Nullpointer exceptions
 */
@Test
public void testEmpty() {
    EventType eventType = new EventType();
    EventTypeMapper.map(eventType);
    eventType.setCustomInfo(new CustomInfoType());
    EventTypeMapper.map(eventType);
    eventType.setMessageInfo(new MessageInfoType());
    EventTypeMapper.map(eventType);
    eventType.setOriginator(new OriginatorType());
    EventTypeMapper.map(eventType);
}
Also used : CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType) Test(org.junit.Test)

Example 3 with OriginatorType

use of org.talend.esb.sam._2011._03.common.OriginatorType in project tesb-rt-se by Talend.

the class AgentActivator method createEventType.

/**
 * Creates the event type.
 *
 * @param type the EventEnumType
 * @return the event type
 */
private EventType createEventType(EventEnumType type) {
    EventType eventType = new EventType();
    eventType.setTimestamp(Converter.convertDate(new Date()));
    eventType.setEventType(type);
    OriginatorType origType = new OriginatorType();
    origType.setProcessId(Converter.getPID());
    try {
        InetAddress inetAddress = InetAddress.getLocalHost();
        origType.setIp(inetAddress.getHostAddress());
        origType.setHostname(inetAddress.getHostName());
    } catch (UnknownHostException e) {
        origType.setHostname("Unknown hostname");
        origType.setIp("Unknown ip address");
    }
    eventType.setOriginator(origType);
    String path = System.getProperty("karaf.home");
    CustomInfoType ciType = new CustomInfoType();
    CustomInfoType.Item cItem = new CustomInfoType.Item();
    cItem.setKey("path");
    cItem.setValue(path);
    ciType.getItem().add(cItem);
    eventType.setCustomInfo(ciType);
    return eventType;
}
Also used : UnknownHostException(java.net.UnknownHostException) CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) InetAddress(java.net.InetAddress) Date(java.util.Date)

Example 4 with OriginatorType

use of org.talend.esb.sam._2011._03.common.OriginatorType in project tesb-rt-se by Talend.

the class EventMapper method map.

/**
 * convert Event bean to EventType manually.
 *
 * @param event the event
 * @return the event type
 */
public static EventType map(Event event) {
    EventType eventType = new EventType();
    eventType.setTimestamp(Converter.convertDate(event.getTimestamp()));
    eventType.setEventType(convertEventType(event.getEventType()));
    OriginatorType origType = mapOriginator(event.getOriginator());
    eventType.setOriginator(origType);
    MessageInfoType miType = mapMessageInfo(event.getMessageInfo());
    eventType.setMessageInfo(miType);
    eventType.setCustomInfo(convertCustomInfo(event.getCustomInfo()));
    eventType.setContentCut(event.isContentCut());
    if (event.getContent() != null) {
        DataHandler datHandler = getDataHandlerForString(event);
        eventType.setContent(datHandler);
    }
    return eventType;
}
Also used : EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) DataHandler(javax.activation.DataHandler) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType)

Aggregations

OriginatorType (org.talend.esb.sam._2011._03.common.OriginatorType)4 EventType (org.talend.esb.sam._2011._03.common.EventType)3 CustomInfoType (org.talend.esb.sam._2011._03.common.CustomInfoType)2 MessageInfoType (org.talend.esb.sam._2011._03.common.MessageInfoType)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 DataHandler (javax.activation.DataHandler)1 Test (org.junit.Test)1