This is an example client in Jersey2 that interoperates with Vokter using REST calls. It implements three simple REST methods, a mandatory POST ("/rest/notification") that receives Vokter detected differences for watched pages, and two optional GETs that allow the user to interact with Vokter using the browser's address bar. Notifications are simply printed on the console when received.
If you already have a running Vokter server, skip to step 5.
-
Download and install MongoDB
-
Run MongoDB with
mongod
-
Download the latest release of Vokter core server
-
Run Vokter server with
java -jar vokter-core.jar
(more information on running and using the core service) -
Download the latest war of this Java client
- Download and install Apache Tomcat
- Place the downloaded war file in
tomcat-folder/webapps
- Run Tomcat with
tomcat-folder/bin/startup.sh
- Download and install Jetty
- Place the downloaded war file in
jetty-folder/webapps
- Run Jetty with
java -jar jetty-folder/start.jar
Note that if you change the default host of the deployed web app container or of the deployed Vokter server, you will need to change the first few Strings in the ClientResource.java file and pack a new war.
Load the URL below on your browser or curl, replacing ENCODED_URL with an encoded URL and KEYWORDS with an encoded string including a keyword. You can use 'keywords' query parameter multiple times to add more keywords.
http://localhost:8080/rest/watch?url=ENCODED_URL&keywords=KEYWORDS
For example, the following URL will subscribe the client to receive notifications when changes to the words 'argus' and 'panoptes' are found in the URL bbc.com:
http://localhost:8080/rest/watch?url=http%3A%2F%2Fbbc.com&keywords=argus&keywords=panoptes
Load the URL below on your browser or curl, replacing ENCODED_URL with an encoded URL:
http://localhost:8080/rest/cancel?url=ENCODED_URL
For example, the following URL will cancel the watch job launched by this client for the URL bbc.com:
http://localhost:8080/rest/cancel?url=http%3A%2F%2Fbbc.com
Copyright 2015 Eduardo Duarte
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
http://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.