Search in sources :

Example 1 with ArticleCore

use of org.opennms.integration.otrs.ticketservice.ArticleCore in project opennms by OpenNMS.

the class OtrsTicketerPlugin method updateOTRSArticle.

private void updateOTRSArticle(Long otrsTicketNumber, Ticket newTicket, TicketServicePort_PortType port, Credentials creds) throws RemoteException {
    ArticleCore newOtrsArticle = new ArticleCore();
    // All OTRS article fields from ticket
    LOG.debug("Adding a new article to ticket: {}", otrsTicketNumber);
    switch(newTicket.getState()) {
        case OPEN:
            // ticket is new
            newOtrsArticle.setBody(m_configDao.getTicketOpenedMessage());
            break;
        case CANCELLED:
            // not sure how often we see this
            newOtrsArticle.setBody(m_configDao.getTicketCancelledMessage());
            break;
        case CLOSED:
            // closed successful
            newOtrsArticle.setBody(m_configDao.getTicketClosedMessage());
            break;
        default:
            LOG.debug("No valid OpenNMS state on ticket");
            newOtrsArticle.setBody(m_configDao.getTicketUpdatedMessage());
    }
    newOtrsArticle.setTicketNumber(otrsTicketNumber);
    newOtrsArticle.setFrom(m_configDao.getArticleFrom());
    newOtrsArticle.setUser(m_configDao.getDefaultUser());
    newOtrsArticle.setSubject(m_configDao.getArticleUpdateSubject());
    // All OTRS article fields from defaults
    newOtrsArticle.setArticleType(m_configDao.getArticleType());
    newOtrsArticle.setSenderType(m_configDao.getArticleSenderType());
    newOtrsArticle.setContentType(m_configDao.getArticleContentType());
    newOtrsArticle.setHistoryType(m_configDao.getArticleHistoryType());
    newOtrsArticle.setHistoryComment(m_configDao.getArticleHistoryComment());
    port.articleCreate(newOtrsArticle, creds);
}
Also used : ArticleCore(org.opennms.integration.otrs.ticketservice.ArticleCore)

Example 2 with ArticleCore

use of org.opennms.integration.otrs.ticketservice.ArticleCore in project opennms by OpenNMS.

the class OtrsTicketerPluginTest method createTicketAndArticle.

// This is just to bootstrap a saved ticket so that we can get it back later
private TicketIDAndNumber createTicketAndArticle(String ticketSubject, String articleBody) throws InterruptedException {
    TicketIDAndNumber idAndNumber = null;
    m_configDao = new DefaultOtrsConfigDao();
    TicketCore otrsTicket = new TicketCore();
    Credentials creds = new Credentials(m_configDao.getUserName(), m_configDao.getPassword());
    otrsTicket.setLock(m_configDao.getLock());
    otrsTicket.setQueue(m_configDao.getQueue());
    otrsTicket.setPriority(m_configDao.getPriority());
    otrsTicket.setState(m_configDao.getState());
    otrsTicket.setOwnerID(m_configDao.getOwnerID());
    otrsTicket.setUser(defaultUser);
    otrsTicket.setTitle(ticketSubject);
    Integer articleId = null;
    TicketServiceLocator service = new TicketServiceLocator();
    service.setTicketServicePortEndpointAddress(m_configDao.getEndpoint());
    TicketServicePort_PortType port = null;
    try {
        port = service.getTicketServicePort();
    } catch (ServiceException e1) {
        e1.printStackTrace();
    }
    try {
        idAndNumber = port.ticketCreate(otrsTicket, creds);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    ArticleCore otrsArticle = new ArticleCore();
    otrsArticle.setArticleType(m_configDao.getArticleType());
    otrsArticle.setSenderType(m_configDao.getArticleSenderType());
    otrsArticle.setContentType(m_configDao.getArticleContentType());
    otrsArticle.setHistoryType(m_configDao.getArticleHistoryType());
    otrsArticle.setHistoryComment(m_configDao.getArticleHistoryComment());
    otrsArticle.setSenderType(m_configDao.getArticleSenderType());
    otrsArticle.setSubject(defaultArticleSubject);
    otrsArticle.setFrom(m_configDao.getArticleFrom());
    otrsArticle.setBody(defaultArticleBody);
    otrsArticle.setUser(defaultUser);
    otrsArticle.setTicketID(idAndNumber.getTicketID());
    otrsArticle.setBody(articleBody);
    try {
        articleId = port.articleCreate(otrsArticle, creds);
        assertNotNull(articleId);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    return idAndNumber;
}
Also used : ArticleCore(org.opennms.integration.otrs.ticketservice.ArticleCore) ServiceException(javax.xml.rpc.ServiceException) DefaultOtrsConfigDao(org.opennms.netmgt.ticketer.otrs.common.DefaultOtrsConfigDao) TicketServicePort_PortType(org.opennms.integration.otrs.ticketservice.TicketServicePort_PortType) RemoteException(java.rmi.RemoteException) TicketCore(org.opennms.integration.otrs.ticketservice.TicketCore) TicketServiceLocator(org.opennms.integration.otrs.ticketservice.TicketServiceLocator) Credentials(org.opennms.integration.otrs.ticketservice.Credentials) TicketIDAndNumber(org.opennms.integration.otrs.ticketservice.TicketIDAndNumber)

Example 3 with ArticleCore

use of org.opennms.integration.otrs.ticketservice.ArticleCore in project opennms by OpenNMS.

the class OtrsTicketerPlugin method newOTRSArticle.

private void newOTRSArticle(Long otrsTicketNumber, Ticket newTicket, TicketServicePort_PortType port, Credentials creds) throws RemoteException {
    ArticleCore newOtrsArticle = new ArticleCore();
    // All OTRS article fields from ticket
    LOG.debug("Adding a new article to ticket: {}", otrsTicketNumber);
    newOtrsArticle.setBody(newTicket.getDetails());
    newOtrsArticle.setTicketNumber(otrsTicketNumber);
    // TODO: Could remove this once we have the userid reliably in the the ticket
    newOtrsArticle.setFrom(m_configDao.getArticleFrom());
    newOtrsArticle.setUser(m_configDao.getDefaultUser());
    newOtrsArticle.setSubject(newTicket.getSummary().replaceAll("\\<.*?\\>", ""));
    // All OTRS article fields from defaults
    newOtrsArticle.setArticleType(m_configDao.getArticleType());
    newOtrsArticle.setSenderType(m_configDao.getArticleSenderType());
    newOtrsArticle.setContentType(m_configDao.getArticleContentType());
    newOtrsArticle.setHistoryType(m_configDao.getArticleHistoryType());
    newOtrsArticle.setHistoryComment(m_configDao.getArticleHistoryComment());
    port.articleCreate(newOtrsArticle, creds);
}
Also used : ArticleCore(org.opennms.integration.otrs.ticketservice.ArticleCore)

Aggregations

ArticleCore (org.opennms.integration.otrs.ticketservice.ArticleCore)3 RemoteException (java.rmi.RemoteException)1 ServiceException (javax.xml.rpc.ServiceException)1 Credentials (org.opennms.integration.otrs.ticketservice.Credentials)1 TicketCore (org.opennms.integration.otrs.ticketservice.TicketCore)1 TicketIDAndNumber (org.opennms.integration.otrs.ticketservice.TicketIDAndNumber)1 TicketServiceLocator (org.opennms.integration.otrs.ticketservice.TicketServiceLocator)1 TicketServicePort_PortType (org.opennms.integration.otrs.ticketservice.TicketServicePort_PortType)1 DefaultOtrsConfigDao (org.opennms.netmgt.ticketer.otrs.common.DefaultOtrsConfigDao)1