use of org.opennms.api.integration.ticketing.PluginException in project opennms by OpenNMS.
the class OtrsTicketerPluginTest method testGet.
public void testGet() {
TicketIDAndNumber idAndNumber = null;
Ticket newTicket = null;
String summary = new String("Ticket created by testGet()");
String details = new String("This ticketwas created by OtrsTicketerPluginTest");
try {
idAndNumber = createTicketAndArticle(summary, details);
} catch (InterruptedException e) {
e.printStackTrace();
}
// now construct a ticket by hand.
Ticket ticket = new Ticket();
ticket.setId(String.valueOf(idAndNumber.getTicketNumber()));
ticket.setState(Ticket.State.OPEN);
ticket.setSummary(summary);
ticket.setDetails(details);
ticket.setUser(defaultUser);
try {
newTicket = m_ticketer.get(ticket.getId());
} catch (PluginException e) {
e.printStackTrace();
}
assertTicketEquals(ticket, newTicket);
}
use of org.opennms.api.integration.ticketing.PluginException in project opennms by OpenNMS.
the class RtTicketerPlugin method get.
/**
* {@inheritDoc}
*
* Gets ticket details from the RT trouble ticket system
*/
@Override
public Ticket get(final String ticketId) throws PluginException {
Ticket ticket = null;
RTTicket rtt = null;
try {
rtt = m_requestTracker.getTicket(Long.valueOf(ticketId), false);
} catch (final RequestTrackerException e) {
throw new PluginException(e);
}
if (rtt != null) {
ticket = new Ticket();
ticket.setState(rtToOpenNMSState(rtt.getStatus()));
ticket.setId(rtt.getId().toString());
ticket.setUser(StringUtils.join(rtt.getRequestors(), ", "));
ticket.setSummary(rtt.getSubject());
ticket.setDetails(rtt.getText());
} else {
throw new PluginException("could not find ticket in RT for Ticket: " + ticketId);
}
return ticket;
}
use of org.opennms.api.integration.ticketing.PluginException in project opennms by OpenNMS.
the class RtTicketerPluginTest method testUpdateAndGet.
public void testUpdateAndGet() {
try {
m_ticketer.saveOrUpdate(m_ticket);
Ticket savedTicket = m_ticketer.get(m_ticket.getId());
assertTicketEquals(m_ticket, savedTicket);
m_ticket.setState(Ticket.State.CLOSED);
m_ticketer.saveOrUpdate(m_ticket);
System.out.println("before update, ticket status was " + savedTicket.getState().toString());
Ticket updatedTicket = m_ticketer.get(m_ticket.getId());
System.out.println("after update, ticket status was " + updatedTicket.getState().toString());
assertTicketEquals(m_ticket, updatedTicket);
} catch (PluginException e) {
fail("Something failed in the ticketer plugin");
e.printStackTrace();
}
}
use of org.opennms.api.integration.ticketing.PluginException in project opennms by OpenNMS.
the class RemedyTicketerPluginTest method testOpenCloseStatus.
public void testOpenCloseStatus() {
testSaveAndGet();
try {
assertEquals(State.OPEN, m_ticket.getState());
// Close the Ticket
m_ticket.setState(State.CLOSED);
m_ticketer.saveOrUpdate(m_ticket);
Ticket ticket = m_ticketer.get(m_ticketId);
assertEquals(State.CLOSED, ticket.getState());
//Reopen The Ticket
m_ticket.setState(State.OPEN);
m_ticketer.saveOrUpdate(m_ticket);
ticket = m_ticketer.get(m_ticketId);
assertEquals(State.OPEN, ticket.getState());
//Cancel the Ticket
m_ticket.setState(State.CANCELLED);
m_ticketer.saveOrUpdate(m_ticket);
ticket = m_ticketer.get(m_ticketId);
assertEquals(State.CANCELLED, ticket.getState());
// try to close
m_ticket.setState(State.CLOSED);
m_ticketer.saveOrUpdate(m_ticket);
// but still cancelled
ticket = m_ticketer.get(m_ticketId);
assertEquals(State.CANCELLED, ticket.getState());
// try to re open
m_ticket.setState(State.OPEN);
m_ticketer.saveOrUpdate(m_ticket);
// but still cancelled
ticket = m_ticketer.get(m_ticketId);
assertEquals(State.CANCELLED, ticket.getState());
} catch (PluginException e) {
e.printStackTrace();
}
}
use of org.opennms.api.integration.ticketing.PluginException in project opennms by OpenNMS.
the class DefaultTicketerServiceLayer method createTicketForAlarm.
/*
* (non-Javadoc)
* @see org.opennms.netmgt.ticketd.TicketerServiceLayer#createTicketForAlarm(int)
*/
/** {@inheritDoc} */
@Override
public void createTicketForAlarm(int alarmId, Map<String, String> attributes) {
OnmsAlarm alarm = m_alarmDao.get(alarmId);
if (alarm == null) {
LOG.error("No alarm with id {} was found. No ticket will be created.", alarmId);
return;
}
if (SKIP_CREATE_WHEN_CLEARED) {
final OnmsSeverity currentSeverity = alarm.getSeverity();
if (currentSeverity != null && currentSeverity.equals(OnmsSeverity.CLEARED)) {
LOG.info("Alarm with id {} is currently cleared. No ticket will be created.", alarmId);
return;
}
}
Ticket ticket = createTicketFromAlarm(alarm, attributes);
try {
m_ticketerPlugin.saveOrUpdate(ticket);
alarm.setTTicketId(ticket.getId());
alarm.setTTicketState(TroubleTicketState.OPEN);
} catch (PluginException e) {
alarm.setTTicketState(TroubleTicketState.CREATE_FAILED);
LOG.error("Unable to create ticket for alarm: {}", e.getMessage(), e);
m_eventIpcManager.sendNow(createEvent(e.getMessage()));
}
m_alarmDao.saveOrUpdate(alarm);
}
Aggregations