Progress on noark5-parser tool for importing XML into Nikita Noark 5 Core server

Ole Aamot oka at oka.no
Thu Jun 8 17:26:27 CEST 2017


I am still working on the free tool noark5-parser for importing Noark
5 XML archives into the Nikita Noark 5 Core.

git https://github.com/oleaamot/noark5-parser.git
cd noark5-parser/
./runparser

The noark5-parser tool now does HTTP Basic Authentication with curl in
PHP and takes 4 command line interface arguments (filename of XML
archive file such as <URL:
https://raw.githubusercontent.com/KDRS-SA/noark5-validator/master/src/resources/test-uttrekk/uttrekk1/n5uttrekk/arkivstruktur.xml>,
the URL of the Nikita Noark 5 Core server instance such as
"http://nikita.hioa.no:8092/noark5v4/", username such as "admin" and
password such as "password").  You can see the command line interface
arguments if you run the file noark5-parser.php without any command
line interface arguments on Unix:

$ ./noark5-parser.php
noark5-parser.php FILE BASEURL USER PASS

The noark5-parser is at the moment able to parse arkiv, arkivskaper
and arkivdel from the arkivstruktur.xml XML file and to upload
well-formed JSON data to the correct Noark 5 endpoints with HTTP Basic
Authentication on a Nikita Noark 5 Core server instance.

Below is the current code that uploads the JSON structure to a Nikita
Noark 5 Core server:

$arkiv = "{ \"tittel\": \"" . $node->tittel . "\", \"beskrivelse\":\""
.$node->beskrivelse . "\", \"arkivstatus\":\"" . $node->arkivstatus .
"\", \"dokumentmedium\":\"" . $node->dokumentmedium . "\",
\"opprettetAv\":\"" . $node->opprettetAv . "\", \"opprettetDato\":\""
. $node->opprettetDato . "\", \"avsluttetDato\":\"" .
$node->avsluttetDato . "\"}";
upload($baseurl, $token, $arkiv, "hateoas-api/arkivstruktur/ny-arkiv");
$arkivskaper = "{ \"arkivskaperID\": \"" .
$node->arkivskaper->arkivskaperID . "\", \"arkivskaperNavn\": \"" .
$node->arkivskaper->arkivskaperNavn . "\", \"beskrivelse\": \"" .
$node->arkivskaper->beskrivelse . "\"}";
upload($baseurl, $token, $arkivskaper,
"hateoas-api/arkivstruktur/ny-arkivskaper");
$arkivdel = "{ \"systemID\": \"" . $node->arkivdel->systemID . "\",
\"tittel\": \"" . $node->arkivdel->tittel . "\", \"beskrivelse\": \""
. $node->arkivdel->beskrivelse . "\", \"arkivdelstatus\": \"" .
$node->arkivdel->arkivdelstatus . "\", \"dokumentmedium\": \"" .
$node->arkivdel->dokumentmedium. "\", \"opprettetDato\": \"" .
$node->arkivdel->opprettetDato . "\", \"avsluttetAv\": \"" .
$node->arkivdel->avsluttetAv . "\"}";
upload($baseurl, $token, $arkivdel, "hateoas-api/arkivstruktur/ny-arkivdel");

You can view the full source code for the free noark5-parser tool
available under MIT license on
https://github.com/oleaamot/noark5-parser/blob/master/noark5-parser.php

Lots of work remains on noark5-parser as it does not yet completely
upload the data.

Happy hacking,
Ole Aamot


More information about the nikita-noark mailing list