<commit_before>Lisp Client for the URN PID service by the National Library of Norway
=======================================================================


Library
-------
The **nb_urn_client** directory contains the library for communicating with the SOAP API.
To load the library, make sure that the `nb-urn-client`-folder is available to ASDF.
You also need user credentials and endpoint information from NB.

### Usage Example:

```lisp
(asdf:load-system :nb-urn-client)
(in-package :nb-urn-client)

;;; Initialize the client with named arguments:
(defparameter *client*
  (make-instance 'nb-urn-client
                 :username "foo"
                 :password "<PASSWORD>"
                 :endpoint "baz")

;;; Or, initialize the client with information in globals.lisp:
(defparameter *client* (make-instance 'nb-urn-client))

;;; Does not require a valid username or password, only an endpoint:
(find-urn *client* "SOME:URN")
(find-urns-for-url *client* "http://foo.bar.com")

;;; Requires an endpoint and valid username and password
(login *client*)
(register-urn *client* "SOME:URN" "http://foo.bar.com")
(logout *client*)
```

Dependencies
------------

* [drakma](http://www.cliki.net/drakma)
* [cxml](http://www.cliki.net/cxml)
* [lisp-unit](http://www.cliki.net/lisp-unit) (for testing)

All dependencies are available in [quicklisp](http://www.quicklisp.org/).

Testing
-------
To run this test suite you need an appropriate mockservice (not available in the repository yet).

Make sure the `nb-urn-client` and `test` folders are available to ASDF.

```lisp
(asdf:load-system :nb-urn-client-tests)
(in-package :nb-urn-client-tests)
(run-all-tests)

;;; Optionally, if you want more verbose output:
(run-all-tests :verbose t)
```<commit_msg>README update.<commit_after>Lisp Client for the URN PID service by the National Library of Norway
=======================================================================


Library
-------
The **nb_urn_client** directory contains the library for communicating with the SOAP API.
To load the library, make sure that the `nb-urn-client`-folder is available to ASDF.
You also need user credentials and endpoint information from NB.

### Usage Example:

```lisp
(asdf:load-system :nb-urn-client)
(in-package :nb-urn-client)

;;; Initialize the client with named arguments:
(defparameter *client*
  (make-instance 'nb-urn-client
                 :username "foo"
                 :password "<PASSWORD>"
                 :endpoint "baz")

;;; Or, initialize the client with information in globals.lisp:
(defparameter *client* (make-instance 'nb-urn-client))

;;; You need to login first
(login *client*)

;;; Reserve the next available URN in the given series
(defparameter *new-urn* (reserve-next-urn *client* "some:urn:prefix"))

;;; Register some valid URL for the newly created URN
(add-url *client* (urn-info-urn *new-urn*) "http://www.someurl.com/")

;;; Register another URL for the same URN
(add-url *client* (urn-info-urn *new-urn*) "http://www.someotherurl.com/")

;;; Set one of the registered URLs to be the default URL
(set-default-url *client* (urn-info-urn *new-urn*) "http://www.someurl.com/")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ALTERNATIVE: Using create-urn
;;; (defparameter *new-urn* 
;;;               (create-urn *client*
;;;                           "some:urn:prefix" 
;;;                           "http://www.someurl.com"))
;;; (add-url *client* "http://www.someotherurl.com/")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Retrieve the URN you just created and have a look
(find-urn *client* (urn-info-urn *new-urn*))

;;; Retrieve all URNs containing the URL you added. Your URN should be in the list
(find-urns-for-urn *client* "http://www.someurl.com/")

;;; Logout when you're done
(logout *client*)
```

Dependencies
------------

* [drakma](http://www.cliki.net/drakma)
* [cxml](http://www.cliki.net/cxml)
* [lisp-unit](http://www.cliki.net/lisp-unit) (for testing)

All dependencies are available in [quicklisp](http://www.quicklisp.org/).

Testing
-------
To run this test suite you need an appropriate mockservice (not available in the repository yet).

Make sure the `nb-urn-client` and `test` folders are available to ASDF.

```lisp
(asdf:load-system :nb-urn-client-tests)
(in-package :nb-urn-client-tests)
(run-all-tests)

;;; Optionally, if you want more verbose output:
(run-all-tests :verbose t)
```
{'fraction_non_alphanumeric': 0.2068579112505603, 'fraction_numerical': 0.0, 'mean_word_length': 3.851086956521739, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 14, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2575795', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1377, 'n_words': 427}