Search in sources :

Example 1 with PluginException

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);
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) PluginException(org.opennms.api.integration.ticketing.PluginException) TicketIDAndNumber(org.opennms.integration.otrs.ticketservice.TicketIDAndNumber)

Example 2 with PluginException

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;
}
Also used : RTTicket(org.opennms.netmgt.rt.RTTicket) Ticket(org.opennms.api.integration.ticketing.Ticket) RequestTrackerException(org.opennms.netmgt.rt.RequestTrackerException) RTTicket(org.opennms.netmgt.rt.RTTicket) PluginException(org.opennms.api.integration.ticketing.PluginException)

Example 3 with PluginException

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();
    }
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) PluginException(org.opennms.api.integration.ticketing.PluginException)

Example 4 with PluginException

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();
    }
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) PluginException(org.opennms.api.integration.ticketing.PluginException)

Example 5 with PluginException

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);
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) PluginException(org.opennms.api.integration.ticketing.PluginException)

Aggregations

PluginException (org.opennms.api.integration.ticketing.PluginException)23 Ticket (org.opennms.api.integration.ticketing.Ticket)16 Test (org.junit.Test)5 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)4 ExecutionException (java.util.concurrent.ExecutionException)3 BasicIssue (com.atlassian.jira.rest.client.api.domain.BasicIssue)2 Issue (com.atlassian.jira.rest.client.api.domain.Issue)2 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)2 RTTicket (org.opennms.netmgt.rt.RTTicket)2 RequestTrackerException (org.opennms.netmgt.rt.RequestTrackerException)2 JiraRestClient (com.atlassian.jira.rest.client.api.JiraRestClient)1 Comment (com.atlassian.jira.rest.client.api.domain.Comment)1 ServerInfo (com.atlassian.jira.rest.client.api.domain.ServerInfo)1 Transition (com.atlassian.jira.rest.client.api.domain.Transition)1 IssueInputBuilder (com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder)1 TransitionInput (com.atlassian.jira.rest.client.api.domain.input.TransitionInput)1 TicketIDAndNumber (org.opennms.integration.otrs.ticketservice.TicketIDAndNumber)1