use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class DomainController method updateBundleDirection.
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/updateBundleDirection", method = RequestMethod.POST)
public ModelAndView updateBundleDirection(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, @RequestParam(required = true) String domainName, @RequestParam(required = true) String bundle, @RequestParam(required = true) String direction, @RequestParam(required = true) String directionValue, HttpSession session, Model model) {
Collection<TrustBundleDomainReltn> bundles = null;
try {
bundles = bundleService.getTrustBundlesByDomain(domainName, false);
} catch (ServiceException ex) {
Logger.getLogger(DomainController.class.getName()).log(Level.SEVERE, null, ex);
}
for (TrustBundleDomainReltn bundleReltn : bundles) {
if (bundleReltn.getId() == Long.parseLong(bundle)) {
if (direction.toLowerCase().equals("incoming")) {
if (Integer.parseInt(directionValue) == 1) {
bundleReltn.setIncoming(true);
} else {
bundleReltn.setIncoming(false);
}
} else {
if (Integer.parseInt(directionValue) == 1) {
bundleReltn.setOutgoing(true);
} else {
bundleReltn.setOutgoing(false);
}
}
}
}
final ModelAndView mav = new ModelAndView();
mav.setViewName("updateBundleDirection");
return mav;
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class UsecuredServiceRequestBase_checkContentTypeTest method testCheckContentType_incompatibleType_assertServiceException.
@Test
public void testCheckContentType_incompatibleType_assertServiceException() throws Exception {
MockServiceRequest req = new MockServiceRequest(null, "http://service/svc", "Test");
Header hdr = mock(Header.class);
when(hdr.getName()).thenReturn("Content-Type");
when(hdr.getValue()).thenReturn("text/xml");
HttpEntity entity = mock(HttpEntity.class);
when(entity.getContentType()).thenReturn(hdr);
boolean exceptionOccured = false;
try {
req.checkContentType("text/plain", entity);
} catch (ServiceException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class UnsecureServiceRequestBase_callTest method testCall_nullRequest_assertServiceException.
@Test
public void testCall_nullRequest_assertServiceException() throws Exception {
HttpClient mockClient = mock(HttpClient.class);
StatusLine statLine = mock(StatusLine.class);
when(statLine.getStatusCode()).thenReturn(204);
HttpResponse resp = mock(HttpResponse.class);
when(resp.getStatusLine()).thenReturn(statLine);
when(mockClient.execute((HttpUriRequest) any())).thenReturn(resp);
MockServiceRequest req = new MockServiceRequest(mockClient, "http://service/svc", "");
boolean exceptionOccured = false;
try {
req.call();
} catch (ServiceException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class NotificationSuppressor method service.
/**
* {@inheritDoc}
*/
@Override
public void service(Mail mail) throws MessagingException {
boolean suppress = false;
final MimeMessage msg = mail.getMessage();
final NHINDAddressCollection recipients = getMailRecipients(mail);
final NHINDAddress sender = getMailSender(mail);
final Tx txToTrack = getTxToTrack(msg, sender, recipients);
if (txToTrack != null) {
try {
// first check if this a MDN processed message and if the consume processed flag is turned on
final TxDetail detail = txToTrack.getDetail(TxDetailType.DISPOSITION);
if (consumeMDNProcessed && txToTrack.getMsgType() == TxMessageType.MDN && detail != null && detail.getDetailValue().contains(MDNStandard.Disposition_Processed))
suppress = true;
else // if the first rule does not apply, then go to the tx Service to see if the message should be suppressed
if (txService != null && txToTrack != null && txService.suppressNotification(txToTrack))
suppress = true;
} catch (ServiceException e) {
// failing to call the txService should not result in an exception being thrown
// from this service.
LOGGER.warn("Failed to get notification suppression status from service. Message will assume to not need supressing.");
}
}
if (suppress)
mail.setState(Mail.GHOST);
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class TrackIncomingNotification method service.
/**
* {@inheritDoc}
*/
@Override
public void service(Mail mail) throws MessagingException {
LOGGER.debug("Calling track incoming notification service");
final MimeMessage msg = mail.getMessage();
final NHINDAddressCollection recipients = getMailRecipients(mail);
final NHINDAddress sender = getMailSender(mail);
final Tx txToMonitor = getTxToTrack(msg, sender, recipients);
// track message
if (txToMonitor != null && (txToMonitor.getMsgType() == TxMessageType.DSN || txToMonitor.getMsgType() == TxMessageType.MDN)) {
try {
txService.trackMessage(txToMonitor);
}///CLOVER:OFF
catch (ServiceException ex) {
LOGGER.warn("Failed to submit message to monitoring service.", ex);
}
///CLOVER:ON
}
LOGGER.debug("Exiting track incoming notification service");
}
Aggregations