Skip to content

Commit 7b58db2

Browse files
authored
LinkedDataHub packages (#259)
* Package model and initial implementation * Removed `PackageManager` * HTTP unit tests for packages * Package implementation and test fixes * Import fix * Ontology import fixes * Package installation fixes * Renamed script * Removed `/transform` from publicly allowed endpoints * Package test fixes * Added getter * Refactored `XSLTMasterUpdater` * Refactored `XSLTMasterUpdater` * Updated SKOS package ontology * Fixed class filename * Added SKOS import to the SKOS package ontology Renamed endpoint classes Removed VIVO ontology * Additional install/uninstall tests * Undo `patch` method changes * Replaced `LinkedDataClient` with `GraphStoreClient` Server and Web-Client bumps `InstallPackage` and `UnistallPackage` use GSP `PATCH` method to add/remove `owl:imports` triple * Core SNAPSHOT bump * Updated POM * `PATCH` update fixes HTTP test fixes * Response closure fixes Use try-with-resources consistently * Package ontology URI fix * Test fix * Varnish ban fix in `ClearOntology` * HTTP test fixes
1 parent 9e6cfb0 commit 7b58db2

67 files changed

Lines changed: 2507 additions & 12834 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env bash
2+
3+
print_usage()
4+
{
5+
printf "Installs a LinkedDataHub package.\n"
6+
printf "\n"
7+
printf "Usage: %s options\n" "$0"
8+
printf "\n"
9+
printf "Options:\n"
10+
printf " -b, --base BASE_URL Base URL of the application\n"
11+
printf " -f, --cert-pem-file CERT_FILE .pem file with the WebID certificate of the agent\n"
12+
printf " -p, --cert-password CERT_PASSWORD Password of the WebID certificate\n"
13+
printf " --proxy PROXY_URL The host this request will be proxied through (optional)\n"
14+
printf " --package PACKAGE_URI URI of the package to install (e.g., https://packages.linkeddatahub.com/skos/#this)\n"
15+
printf "\n"
16+
printf "Example:\n"
17+
printf " %s -b https://localhost:4443/ -f ssl/owner/cert.pem -p Password --package https://packages.linkeddatahub.com/skos/#this\n" "$0"
18+
}
19+
20+
hash curl 2>/dev/null || { echo >&2 "curl not on \$PATH. Aborting."; exit 1; }
21+
22+
unknown=()
23+
while [[ $# -gt 0 ]]
24+
do
25+
key="$1"
26+
27+
case $key in
28+
-b|--base)
29+
base="$2"
30+
shift # past argument
31+
shift # past value
32+
;;
33+
-f|--cert-pem-file)
34+
cert_pem_file="$2"
35+
shift # past argument
36+
shift # past value
37+
;;
38+
-p|--cert-password)
39+
cert_password="$2"
40+
shift # past argument
41+
shift # past value
42+
;;
43+
--proxy)
44+
proxy="$2"
45+
shift # past argument
46+
shift # past value
47+
;;
48+
--package)
49+
package_uri="$2"
50+
shift # past argument
51+
shift # past value
52+
;;
53+
*) # unknown option
54+
unknown+=("$1") # save it in an array for later
55+
shift # past argument
56+
;;
57+
esac
58+
done
59+
set -- "${unknown[@]}" # restore args
60+
61+
if [ -z "$base" ] ; then
62+
print_usage
63+
exit 1
64+
fi
65+
if [ -z "$cert_pem_file" ] ; then
66+
print_usage
67+
exit 1
68+
fi
69+
if [ -z "$cert_password" ] ; then
70+
print_usage
71+
exit 1
72+
fi
73+
if [ -z "$package_uri" ] ; then
74+
print_usage
75+
exit 1
76+
fi
77+
78+
# Convert base URL to admin base URL
79+
admin_uri() {
80+
local uri="$1"
81+
echo "$uri" | sed 's|://|://admin.|'
82+
}
83+
84+
admin_base=$(admin_uri "$base")
85+
target_url="${admin_base}packages/install"
86+
87+
if [ -n "$proxy" ]; then
88+
admin_proxy=$(admin_uri "$proxy")
89+
# rewrite target hostname to proxy hostname
90+
url_host=$(echo "$target_url" | cut -d '/' -f 1,2,3)
91+
proxy_host=$(echo "$admin_proxy" | cut -d '/' -f 1,2,3)
92+
final_url="${target_url/$url_host/$proxy_host}"
93+
else
94+
final_url="$target_url"
95+
fi
96+
97+
# POST to packages/install endpoint
98+
curl -k -w "%{http_code}\n" -E "${cert_pem_file}":"${cert_password}" \
99+
-X POST \
100+
-H "Accept: text/turtle" \
101+
-H "Content-Type: application/x-www-form-urlencoded" \
102+
--data-urlencode "package-uri=${package_uri}" \
103+
"${final_url}"

config/system.trig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
lapp:origin <https://admin.localhost:4443> ;
2222
ldt:ontology <https://w3id.org/atomgraph/linkeddatahub/admin#> ;
2323
ldt:service <urn:linkeddatahub:services/admin> ;
24-
ac:stylesheet <static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/admin/layout.xsl> ;
24+
ac:stylesheet <static/xsl/admin/layout.xsl> ;
2525
lapp:endUserApplication <urn:linkeddatahub:apps/end-user> ;
2626
lapp:frontendProxy <http://varnish-frontend:6060/> .
2727

@@ -41,6 +41,7 @@
4141
lapp:origin <https://localhost:4443> ;
4242
ldt:ontology <https://localhost:4443/ns#> ;
4343
ldt:service <urn:linkeddatahub:services/end-user> ;
44+
ac:stylesheet <static/xsl/layout.xsl> ;
4445
lapp:adminApplication <urn:linkeddatahub:apps/admin> ;
4546
lapp:frontendProxy <http://varnish-frontend:6060/> ;
4647
lapp:public true .
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
initialize_dataset "$END_USER_BASE_URL" "$TMP_END_USER_DATASET" "$END_USER_ENDPOINT_URL"
5+
initialize_dataset "$ADMIN_BASE_URL" "$TMP_ADMIN_DATASET" "$ADMIN_ENDPOINT_URL"
6+
purge_cache "$END_USER_VARNISH_SERVICE"
7+
purge_cache "$ADMIN_VARNISH_SERVICE"
8+
purge_cache "$FRONTEND_VARNISH_SERVICE"
9+
10+
# Missing package-uri parameter should return 400 Bad Request
11+
curl -k -w "%{http_code}\n" -o /dev/null -s \
12+
-E "$OWNER_CERT_FILE":"$OWNER_CERT_PWD" \
13+
-X POST \
14+
-H "Content-Type: application/x-www-form-urlencoded" \
15+
"${ADMIN_BASE_URL}packages/install" \
16+
| grep -q "$STATUS_BAD_REQUEST"

0 commit comments

Comments
 (0)