Coder Social home page Coder Social logo

alphagov / notifications-java-client Goto Github PK

View Code? Open in Web Editor NEW
8.0 18.0 30.0 962 KB

Java client for the GOV.UK Notify API

Home Page: https://central.sonatype.com/artifact/uk.gov.service.notify/notifications-java-client

License: MIT License

Java 98.96% Makefile 0.49% Shell 0.47% Dockerfile 0.08%
govuk-notify government-as-a-platform

notifications-java-client's Introduction

notifications-java-client's People

Contributors

bandesz avatar benthorner avatar blesseddev avatar catherineheywood avatar crystalpea avatar davidillsley avatar dependabot[bot] avatar grantforrester-nes avatar gurps-singh avatar idavidmcdonald avatar imdadahad avatar jonathanglassman avatar karlchillmaid avatar klssmith avatar leohemsted avatar minglis avatar petergphillips avatar przemos avatar quis avatar rhowe-gds avatar richardc0 avatar robyoung avatar saimaghafoor avatar samuelhwilliams avatar servingupaces avatar tamasperger avatar timja avatar wardt7 avatar willp-bl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notifications-java-client's Issues

Provide an API endpoint to update programatically an email template

Currently, as far as I know, we can only update an email template using the User Interface within a web browser. So when we deploy new code to production that requires an email update, we need to remind ourselves to update the email template on Gov Notify. Exposing an endpoint to do that email update, would allow to script that change and to trigger the change as the new code goes live.

NotificationClient.sendSms can't get notification Id

We experienced a lot of failures from the notification client while sending notifications. The sms/notification gets sent but unable to retrieve the notification id from the response object.
See jira
https://payments-platform.atlassian.net/browse/PP-2168
see stack trace below

pay-adminusers[13856]: Caused by: java.lang.RuntimeException: error sending user notification
pay-adminusers[13856]: #011at uk.gov.pay.adminusers.service.AdminUsersExceptions.userNotificationError(AdminUsersExceptions.java:96)
pay-adminusers[13856]: #011at uk.gov.pay.adminusers.service.NotificationService.lambda$sendSecondFactorPasscodeSms$0(NotificationService.java:58)
pay-adminusers[13856]: #011at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
pay-adminusers[13856]: #011... 3 common frames omitted
pay-adminusers[13856]: Caused by: org.json.JSONException: JSONObject["id"] not a string.
pay-adminusers[13856]: #011at org.json.JSONObject.getString(JSONObject.java:721)
pay-adminusers[13856]: #011at uk.gov.service.notify.SendSmsResponse.<init>(SendSmsResponse.java:20)
pay-adminusers[13856]: #011at uk.gov.service.notify.NotificationClient.sendSms(NotificationClient.java:162)
pay-adminusers[13856]: #011at uk.gov.pay.adminusers.service.NotificationService.lambda$sendSecondFactorPasscodeSms$0(NotificationService.java:54)

NullPointerException on reading the error stream

We occasionally hit a NPE when using the Java Gov Notify client.

It happens on conn.getErrorStream() when the HTTP response code is not as expected. We don't know the underlying cause of why the stream is not available, perhaps a socket error.

It would helpful to have a little more protection around lines 322-329 of uk.gov.service.notify.NotificationClient.

Here is the stack trace:

java.lang.NullPointerException: null
	at java.io.Reader.<init>(Reader.java:78)
	at java.io.InputStreamReader.<init>(InputStreamReader.java:113)
	at uk.gov.service.notify.NotificationClient.performPostRequest(NotificationClient.java:327)
	at uk.gov.service.notify.NotificationClient.sendSms(NotificationClient.java:192)
	at uk.gov.service.notify.NotificationClient.sendSms(NotificationClient.java:171)
	at uk.nhs.nhsbsa.covid19.faster.testing.service.GovNotifyService.sendSms(GovNotifyService.java:110)
	at uk.nhs.nhsbsa.covid19.faster.testing.service.GovNotifyService.send(GovNotifyService.java:62)
	at uk.nhs.nhsbsa.covid19.faster.testing.listener.FasterTestingQueueListener.lambda$listen$0(FasterTestingQueueListener.java:47)
	at java.util.Optional.map(Optional.java:215)
	at uk.nhs.nhsbsa.covid19.faster.testing.listener.FasterTestingQueueListener.listen(FasterTestingQueueListener.java:47)
	at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:171)
	at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:120)
	at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMatch(AbstractMethodMessageHandler.java:565)
	at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMessageInternal(AbstractMethodMessageHandler.java:520)
	at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMessage(AbstractMethodMessageHandler.java:454)
	at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer.executeMessage(SimpleMessageListenerContainer.java:227)
	at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer$MessageExecutor.run(SimpleMessageListenerContainer.java:417)
	at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer$SignalExecutingRunnable.run(SimpleMessageListenerContainer.java:309)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Support Java 8 Datetime API

The Java client is already packed up for Java 8, so would you consider supporting the Java 8 Datetime API instead of or in addition to Joda Time?

Deploy to maven central

Can this be deployed to maven central?

What's the reasoning behind not using the standard repository?

don't always use ssl context

in their development environment, pay want to be able to stub out notify - the easiest way is to have a mock notify service. but they can't give a http URL - because we set up a default ssl context, it won't work or something. They'd have to set up their stub service with https which is a bit extreme. If someone passes in an HTTP url, we shouldn't set up the ssl context I guess. I'm not too sure how java works.

@mrlumbu or @simad can probably provide more details

Allow several recipients for email notification

Currently the API for email only allow to specify one recipient:

SendEmailResponse response = client.sendEmail(templateId, emailAddress, personalisation, "yourReferenceString", emailReplyToId);

Could we add / extend this method to support several recipients:

List<String> emailAddresses = ...

SendEmailResponse response = client.sendEmail(templateId, emailAddresses, personalisation, "yourReferenceString", emailReplyToId);

Where emailAddresses is a list of strings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.