LoginSignup
0
0

More than 3 years have passed since last update.

【Folio LSP】チュートリアル③VMを触ってみる

Last updated at Posted at 2020-07-03

この記事では、Library Service PlatformのOpen Sourceプロジェクトである、Folioのチュートリアルを解説します。

前記事:チュートリアル②VM概要

前提

チュートリアル①ワークスペースを作ってVMを立ち上げるを参考に、Vagrantが立ち上がった状態にする。

ブラウザから

  1. ブラウザから、Folioを開きます。http://localhost:3000
  2. ユーザ/PWにdiku_admin/adminを入力し、ログインします。
  3. image.pngをクリックすると、システム情報やソフトウェアバージョンなどが確認できます。
  4. image.pngimage.png を見てみてください。

開発用の設定情報

  1. http://localhost:3000/settings/developer/にアクセスします。 image.png

curlを利用する

C:\vm-snapshot-core>vagrant ssh

デフォルトパスワードはvagrant。
run-basic.shを実行する⇒"Finished"が表示されたらおしまい。

vagrant@vagrant:~$ touch run-basic.sh
vagrant@vagrant:~$ vim run-basic.sh
vagrant@vagrant:~$ chmod +x run-basic.sh
vagrant@vagrant:~$ ./run-basic.sh

run-basic.shの内容は以下をコピペしてください。
(curlで9130ポートのOkapiと通信します。)

run-basic.sh
#!/usr/bin/env bash

OKAPIURL="http://localhost:9130"
CURL="curl -w\n -D - "
PATH_TMP="/tmp/folio-tutorial"

H_TENANT="-HX-Okapi-Tenant:diku"
H_JSON="-HContent-type:application/json"

echo "Ensure that Okapi can be reached ..."
STATUS=$(curl -s -S -w "%{http_code}" $OKAPIURL/_/proxy/tenants -o /dev/null)
if [ "$STATUS" != "200" ]; then
  echo "Cannot contact okapi: $STATUS"
  exit
fi
VERSION_OKAPI=$(curl -s -S "$OKAPIURL/_/version")
echo "Using version ${VERSION_OKAPI}"
echo

echo "Do login and obtain our token ..."
cat >$PATH_TMP-login-credentials.json << END
{
  "username": "diku_admin",
  "password": "admin"
}
END

$CURL $H_TENANT $H_JSON --progress-bar \
  -X POST \
  -d@$PATH_TMP-login-credentials.json \
  $OKAPIURL/authn/login > $PATH_TMP-login-response.json

echo "Extract the token header from the response ..."
H_TOKEN=-H$(grep -i x-okapi-token "$PATH_TMP-login-response.json" | sed 's/ //')
echo
#echo Received a token: $H_TOKEN

echo "Test 1: Find some users"
$CURL $H_TENANT $H_TOKEN \
  "$OKAPIURL/users?query=personal.lastName==a*+sortBy+username"
echo

echo "Finished."

Stripes-CLIを利用する

これは別の記事にします。

補足

:sparkles:curlのオプション

オプション 名称 説明
-s --show-error エラーを表示する。-sと一緒に使う。
-S --silent サイレントモード(何も出力しない)
-w --write-out フォーマット

変更履歴

2020年7月3日 新規作成

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0