use of org.opennms.integration.otrs.ticketservice.TicketCore 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;
}
use of org.opennms.integration.otrs.ticketservice.TicketCore in project opennms by OpenNMS.
the class OtrsTicketerPlugin method newOTRSTicket.
private TicketIDAndNumber newOTRSTicket(Ticket newTicket, TicketServicePort_PortType port, Credentials creds) throws RemoteException {
TicketIDAndNumber idAndNumber = null;
TicketCore newOtrsTicket = new TicketCore();
newOtrsTicket.setTitle(newTicket.getSummary().replaceAll("\\<.*?\\>", ""));
newOtrsTicket.setUser(m_configDao.getDefaultUser());
newOtrsTicket.setStateID(openNMSToOTRSState(newTicket.getState()));
// All OTRS ticket fields from defaults
newOtrsTicket.setQueue(m_configDao.getQueue());
newOtrsTicket.setPriority(m_configDao.getPriority());
newOtrsTicket.setLock(m_configDao.getLock());
newOtrsTicket.setOwnerID(m_configDao.getOwnerID());
idAndNumber = port.ticketCreate(newOtrsTicket, creds);
return idAndNumber;
}
Aggregations