Skip to content

Latest commit

 

History

History
161 lines (144 loc) · 5.58 KB

README.md

File metadata and controls

161 lines (144 loc) · 5.58 KB

Mod-Elf

Copyright (C) 2017 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-Elf is an Okapi module that provides the webservices for a electronic loanable form.

Configure Mod-Elf

In order for mod-elf to send e-mails, you will need to configure smtp settings.

  1. Open EmailComposer.java
    code ~/Desktop/folio/bl/mod-elf/src/main/java/org/folio/rest/utils/EmailComposer.java
  2. Provide your smtp username, password, host, and port.
    private final String SMTP_USERNAME = "username";
    private final String SMTP_PASSWORD = "password";
    private final String SMTP_HOST = "smtp.gmail.com";
    private final String SMTP_PORT = "587";
  3. Customize the checkin and checkout e-mail confirmations by changing the variables in the e-mail settings section.
    /** e-mail settings */
    private final String LIBRARY_NAME = "Datalogisk Institut";
    private final String LIBRARY_PHONE = "29979812";
    private final String HOME_PAGE = "http://diku.dk";
    private final String BANNER = "http://diku.dk/english/about/topgrafik/AboutDIKU_Top_505px.jpg?size=700x267";
    private final String FB_ICON = "https://images2.imgbox.com/dd/7b/dERSD77S_o.png";
    private final String FB_LINK = "https://www.facebook.com/universitet";
    private final String TWITTER_ICON = "https://images2.imgbox.com/17/29/H9U3G6if_o.png";
    private final String TWITTER_LINK = "https://twitter.com/uni_copenhagen";

Install Mod-Elf

mvn clean install

Install Mod-Elf Docker Image

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

Deploy as Okapi Module: 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=9151 \
          -DdockerURL=http://localhost:4243 \
          -Dokapiurl=http://10.0.2.15:9130 \
          -jar bl/okapi/okapi-core/target/okapi-core-fat.jar dev
  3. Deploy Okapi modules (necessary for permissions-module-4.0.4).
    source activate folio
    python ~/Desktop/folio/bl/dev-ops/deploy_modules.py
    source deactivate folio
  4. Change to mod-elf directory.
    cd ~/Desktop/folio/bl/mod-elf
  5. Only Once: Register mod-elf.
    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. Deploy mod-elf 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: Enable mod-elf 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
  8. Request itemInfo through mod-elf.
    # 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 elf info
    curl -i -w '\n' -X GET \
        -H 'Content-type: application/json' \
        -H 'X-Okapi-Token: [Replace_With_Token]' \
        -H 'X-Okapi-Tenant: diku' 'http://localhost:9130/iteminfo?limit=30&query=itemid%3D%22459afaba-5b39-468d-9072-eb1685e0ddf4%22'
  9. 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-elf from Okapi gateway.
    # undeploy mod-elf
    curl -w '\n' -X DELETE  -D - http://localhost:9130/_/discovery/modules/mod-elf-1.0.0/10.0.2.15-9143
    # disable mod-elf for diku
    curl -w '\n' -X DELETE  -D - http://localhost:9130/_/proxy/tenants/diku/modules/mod-elf-1.0.0
    # unregister mod-elf
    curl -w '\n' -X DELETE  -D - http://localhost:9130/_/proxy/modules/mod-elf-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