Skip to content

DataONEorg/notification-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notification Service

Notification Service provides a notification system for datasets and portals, to notify both portal owners/editors and the community about events such as downloads, views, citations, derived products, new datasets added to a portal, reminders to update a portal, etc.

DataONE in general, and notification-service in particular, are open source, community projects. We welcome contributions in many forms, including code, graphics, documentation, bug reports, testing, etc.

Use the DataONE discussions to discuss these contributions with us.

Documentation

Documentation is a work in progress, and can be found here in the README

Jakarta EE

Jakarta EE is the latest version of what was formerly Oracle's Java Enterprise Edition (originally J2EE). It has now been moved to the Eclipse Foundation, where it is maintained as open source software.

Here are some useful links for those unfamiliar with Jakarta EE:

Development build

This is a java application, built using the Maven build tool.

$ mvn clean package  [ -DskipTests ]

Building the Docker Image

(Temporary manual step -- This is a workaround until we start pulling config from environment variables.): Edit src/main/resources/properties.yaml and change localhost to host.docker.internal in the database.jdbcUrl property:

database:
  jdbcUrl: jdbc:postgresql://host.docker.internal:5432/notifications
# TAG: the docker image tag string; use a version # for releases, or "DEVELOP" for dev
# NS_VERSION: the notification-service war version to use; defaults to ${TAG} if
#             "--build-arg NS_VERSION=..." is omitted

$ docker image build -t ghcr.io/dataoneorg/notification-service:${TAG} \
                     -f docker/Dockerfile  \
                     --build-arg NS_VERSION=${NS_VERSION}  .

# Don't forget the trailing dot!

For build-debugging purposes, you can also add --progress=plain and/or --no-cache.

Running in Docker

Use docker compose, which will start all the required components (Tomcat container & PostgreSQL database container)

$ docker compose up

To attach to the running container:

docker container exec  --interactive --tty notification-service-webapp-1 bash

Building and Running on a Localhost Webapp Server

NOTE: Jakarta EE 10 is supported only by compliant web application servers. Tomcat version 10 is NOT yet fully compliant with Jakarta EE 10, so for the time being, it is recommended to use Apache TomEE, which is an Apache-maintained combination of Tomcat and the additional libraries needed to support Jakarta EE.

TomEE can be downloaded from https://tomee.apache.org:

  • Version 9.1 (Webprofile) is a Final Release that is only Jakarta 9 EE compliant, but seems to work OK with the current v10 codebase
  • Version 10.0.0-M2 (Webprofile) is a Milestone Release that is Jakarta EE 10 compliant.

Build with maven and copy the war file to your TomEE webapps directory

$ mvn clean package -DskipTests

$ cp ./target/notification-service-${NS_VERSION}.war $TOMEE_HOME/webapps

...and (re)start TomEE.

API Usage Examples

Example API interactions, using curl:

# Subscribe user authenticated with jwt $TOKEN, to update-notifications for
# the dataset identified by {pid}
#
$ curl --request POST "http://localhost:8080/notifications/datasets/{pid}" \
       --header "Authorization: Bearer $TOKEN"  |  jq

# Get a list of subscriptions for user authenticated with jwt $TOKEN:
#
$ curl --request GET "http://localhost:8080/notifications/datasets" \
       --header "Authorization: Bearer $TOKEN"  |  jq

# Unsubscribe user authenticated with jwt $TOKEN, from notifications for the
# dataset identified by {pid}
#
$ curl --request DELETE "http://localhost:8080/notifications/datasets/{pid}" \
       --header "Authorization: Bearer $TOKEN"  |  jq

License

Copyright [2024] [Regents of the University of California]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Acknowledgements

Work on this package was supported by:

  • DataONE Network
  • Arctic Data Center: NSF-PLR grant #2042102 to M. B. Jones, A. Budden, M. Schildhauer, and J. Dozier

Additional support was provided for collaboration by the National Center for Ecological Analysis and Synthesis, a Center funded by the University of California, Santa Barbara, and the State of California.

DataONE_footer NCEAS_footer