Skip to content

Latest commit

 

History

History
222 lines (170 loc) · 7.33 KB

README.md

File metadata and controls

222 lines (170 loc) · 7.33 KB

Mod-Wayfinder

Copyright (C) 2016-2019 The Open Library Foundation

This software is distributed under the terms of the Apache License, Version 2.0. See the file "LICENSE" for more information.

Introduction

Mod-Wayfinder is an Okapi module that provides the webservices for a wayfinder.

Configure Mod-Wayfinder

None.

Install Mod-Wayfinder

mvn clean install

Install Mod-Wayfinder Docker Image

docker container prune
docker rmi mod-wayfinder
docker build -t mod-wayfinder .

Deploy as Stand-Alone Application

Java Verticle

cd ~/Desktop/folio/bl/mod-wayfinder
java -jar target/mod-wayfinder-fat.jar embed_postgres=true

Docker Container

cd ~/Desktop/folio/bl/mod-wayfinder
docker run -t -i -p 8081:8081 mod-wayfinder embed_postgres=true

cURL Usage

  1. Create tenant-module databasae (i.e. enable module).

    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
        -H 'X-Okapi-Token: dummyJwt.eyJzdWIiOiJzZWIiLCJ0ZW5hbnQiOm51bGx9.sig' \
        -H 'X-Okapi-Tenant: diku' http://localhost:8081/_/tenant

Deploy as Okapi Module

Full: Postgresql Server, All Modules

  1. Set-up environment (see 0-installation docs).

    sudo ifconfig lo0 alias 10.0.2.15
    brew services restart [email protected]
    open -a Docker
    # wait for Docker to start before running next cmd
    docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:4243:4243 bobrik/socat TCP-LISTEN:4243,fork UNIX-CONNECT:/var/run/docker.sock
  2. Deploy Okapi

    cd ~/Desktop/folio
    java \
        -Dstorage=postgres \
        -Dpostgres_host=localhost \
        -Dpostgres_port=5432 \
        -Dpostgres_user=okapi \
        -Dpostgres_password=okapi25 \
        -Dpostgres_database=okapi \
        -Dhost=10.0.2.15 \
        -Dport=9130 \
        -Dport_start=9131 \
        -Dport_end=9661 \
        -DdockerURL=http://localhost:4243 \
        -Dokapiurl=http://10.0.2.15:9130 \
        -jar bl/okapi/okapi-core/target/okapi-core-fat.jar dev
  3. Only Once: Deploy Okapi modules.

    source activate folio
    python ~/Desktop/folio/bl/dev-ops/deploy_modules.py
    source deactivate folio
  4. Change to mod-wayfinder directory.

    cd ~/Desktop/folio/bl/mod-wayfinder
  5. Only Once: Register mod-wayfinder.

    curl -w '\n' -X POST -D -   \
        -H "Content-type: application/json"   \
        -d @target/ModuleDescriptor.json \
        http://localhost:9130/_/proxy/modules
    curl http://localhost:9130/_/proxy/modules
  6. Only Once: Either deploy mod-wayfinder as a Docker container.

    curl -w '\n' -D - -s \
        -X POST \
        -H "Content-type: application/json" \
        -d @target/DockerDeploymentDescriptor.json  \
        http://localhost:9130/_/discovery/modules
    curl -i -w '\n' -X GET http://localhost:9130/_/discovery/modules
  7. Only Once: Or deploy mod-wayfinder as a Java application.

    curl -w '\n' -D - -s \
        -X POST \
        -H "Content-type: application/json" \
        -d @target/DeploymentDescriptor.json  \
        http://localhost:9130/_/discovery/modules
    curl -i -w '\n' -X GET http://localhost:9130/_/discovery/modules
  8. Only Once: Enable mod-wayfinder for diku tenant.

    curl -w '\n' -X POST -D -   \
        -H "Content-type: application/json"   \
        -d @target/EnableDescriptor.json \
        http://localhost:9130/_/proxy/tenants/diku/modules
    curl http://localhost:9130/_/proxy/tenants/diku/modules
  9. Request wayfinders through mod-wayfinder.

    # LOGIN and get x-okapi-token and use it for the next requests
    curl -i -w '\n' -X POST -H 'X-Okapi-Tenant: diku' \
        -H "Content-type: application/json" \
        -d '{"username": "diku_admin", "password": "admin"}' \
        http://localhost:9130/authn/login
    
    # GET shelves
    curl -i -w '\n' -X GET -H 'X-Okapi-Tenant: diku' \
        -H 'X-Okapi-Token: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJkaWt1X2FkbWluIiwidXNlcl9pZCI6IjM4YmNlODAyLTA3MGItNWExNC1iMGNlLTQzMjgwZjVmNjQyMiIsImlhdCI6MTU1NTQ0MjYzOSwidGVuYW50IjoiZGlrdSJ9.YibK5wWfXgHboeScvUET-vE8Tl9eIKWeH82zUd1ecnU' \
        http://localhost:9130/shelves
    
    # GET shelf that contains book's Library of Congress call number
    # query = (lowerBound <= "TX773 .E334 2004" and upperBound >= "TX773 .E334 2004" and permanentLocationId = fcd64ce1-6995-48f0-840e-89ffa2288371)
    # result should return shelf 52 similar to,
    # https://minrva.library.illinois.edu/index.html#loc/uiu_undergrad/apple/uiu_5999841/Book
    curl -i -w '\n' -X GET -H 'Content-type: application/json' \
        -H 'X-Okapi-Token: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJkaWt1X2FkbWluIiwidXNlcl9pZCI6IjM4YmNlODAyLTA3MGItNWExNC1iMGNlLTQzMjgwZjVmNjQyMiIsImlhdCI6MTU1MzkxNDkyMywidGVuYW50IjoiZGlrdSJ9.GqwGR6ML8nNOrxlQXbBgMpHS8xqz4OgncIIJdOqUfuk' \
        -H 'X-Okapi-Tenant: diku' \
        'http://localhost:9130/shelves?query=%28lowerBound%20%3C%3D%20%22TX773%20.E334%202004%22%20and%20upperBound%20%3E%3D%20%22TX773%20.E334%202004%22%20and%20permanentLocationId%20%3D%20fcd64ce1-6995-48f0-840e-89ffa2288371%29'
    
    # POST shelves (shelf1.json and shelf2.json)
    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
        -H 'X-Okapi-Token: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJkaWt1X2FkbWluIiwidXNlcl9pZCI6IjM4YmNlODAyLTA3MGItNWExNC1iMGNlLTQzMjgwZjVmNjQyMiIsImlhdCI6MTU1MzkxNDkyMywidGVuYW50IjoiZGlrdSJ9.GqwGR6ML8nNOrxlQXbBgMpHS8xqz4OgncIIJdOqUfuk' \
        -H 'X-Okapi-Tenant: diku' \
        -d @ramls/examples/shelf1.json http://localhost:9130/shelves
    
    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
        -H 'X-Okapi-Token: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJkaWt1X2FkbWluIiwidXNlcl9pZCI6IjM4YmNlODAyLTA3MGItNWExNC1iMGNlLTQzMjgwZjVmNjQyMiIsImlhdCI6MTU1MzkxNDkyMywidGVuYW50IjoiZGlrdSJ9.GqwGR6ML8nNOrxlQXbBgMpHS8xqz4OgncIIJdOqUfuk' \
        -H 'X-Okapi-Tenant: diku' \
        -d @ramls/examples/shelf2.json http://localhost:9130/shelves
  10. Optional: Deploy Stripes Platform

    cd ~/Desktop/folio/ui/platform-complete
    yarn start
  11. Tear-down ctrl + c out of okapi and stripes.

    docker kill $(docker ps -q)
    docker container prune
    brew services stop [email protected]
    sudo ifconfig lo0 -alias 10.0.2.15

Note: Launch descriptor has a path relative to the directory that java -jar okapi-core-fat.jar was executed in (likely ~/Desktop/folio).

Reference

  1. Unregister mod-wayfinder from Okapi gateway.

    # undeploy mod-wayfinder
    curl -w '\n' -X DELETE  -D - http://localhost:9130/_/discovery/modules/mod-wayfinder-1.0.0/10.0.2.15-9144
    # disable mod-wayfinder for diku
    curl -w '\n' -X DELETE  -D - http://localhost:9130/_/proxy/tenants/diku/modules/mod-wayfinder-1.0.0
    # unregister mod-wayfinder
    curl -w '\n' -X DELETE  -D - http://localhost:9130/_/proxy/modules/mod-wayfinder-1.0.0
  2. List registered modules.

    # list deployed modules
    curl -i -w '\n' -X GET http://localhost:9130/_/discovery/modules
    # list modules enabled for diku user
    curl -i -w '\n' -X GET http://localhost:9130/_/proxy/tenants/diku/modules
    # list modules registered with okapi
    curl -i -w '\n' -X GET http://localhost:9130/_/proxy/modules