diff --git a/bin/Makefile b/bin/Makefile index 03834dc2..7a8898ff 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -1,45 +1,45 @@ DEPOSIT_ID=1 ARCHIVE=../../swh-deposit.zip ARCHIVE2=../../swh-model.zip -STATUS=false -PARTIAL_STATUS=true +STATUS=--no-partial +PARTIAL_STATUS=--partial UPDATE_STATUS='done' ATOM_ENTRY=../../atom-entry.xml EXTERNAL_ID='external-id' create-archives: 7z a $(ARCHIVE) $(FOLDER) 7z a $(ARCHIVE2) $(FOLDER2) new: ./create_deposit.sh $(ARCHIVE) $(STATUS) new-complete: ./create_deposit_with_metadata.sh $(ARCHIVE) $(ATOM_ENTRY) $(STATUS) $(EXTERNAL_ID) new-partial: make new STATUS=$(PARTIAL_STATUS) ARCHIVE=$(ARCHIVE) update: ./update-deposit-with-another-archive.sh $(DEPOSIT_ID) $(ARCHIVE2) $(STATUS) update-partial: make update DEPOSIT_ID=$(DEPOSIT_ID) ARCHIVE2=$(ARCHIVE2) STATUS=$(PARTIAL_STATUS) replace: ./replace-deposit-archive.sh $(ARCHIVE2) $(DEPOSIT_ID) download: ./download-deposit-archive.sh $(DEPOSIT_ID) status: ./status.sh $(DEPOSIT_ID) service-document: ./service-document.sh home: ./home.sh update-status: ./update-status.sh $(DEPOSIT_ID) $(UPDATE_STATUS) diff --git a/bin/create_deposit.sh b/bin/create_deposit.sh index 183f114a..41e4010b 100755 --- a/bin/create_deposit.sh +++ b/bin/create_deposit.sh @@ -1,21 +1,16 @@ #!/usr/bin/env bash . ./default-setup ARCHIVE=${1-'../../deposit.zip'} -NAME=$(basename ${ARCHIVE}) -MD5=$(md5sum ${ARCHIVE} | cut -f 1 -d' ') +STATUS=${2-'--no-partial'} -PROGRESS=${2-'false'} -TYPE=${3-'application/zip'} - -curl -i -u "$CREDS" \ - -X POST \ - --data-binary @${ARCHIVE} \ - -H "In-Progress: ${PROGRESS}" \ - -H "Content-MD5: ${MD5}" \ - -H "Content-Disposition: attachment; filename=${NAME}" \ - -H 'Slug: external-id' \ - -H "Content-type: ${TYPE}" \ - ${SERVER}/1/${COLLECTION}/ +./swh-deposit \ + --username ${USER} \ + --password ${PASSWORD} \ + --collection ${COLLECTION} \ + --archive-deposit \ + --archive ${ARCHIVE} \ + ${STATUS} \ + --url ${SERVER}/1 diff --git a/bin/create_deposit_with_metadata.sh b/bin/create_deposit_with_metadata.sh index 92034750..d93a85bc 100755 --- a/bin/create_deposit_with_metadata.sh +++ b/bin/create_deposit_with_metadata.sh @@ -1,20 +1,21 @@ #!/usr/bin/env bash . ./default-setup ARCHIVE=${1-'../../swh-deposit.zip'} ATOM_ENTRY=${2-'../../atom-entry.xml'} -NAME=$(basename $ARCHIVE) -MD5=$(md5sum $ARCHIVE | cut -f 1 -d' ') - -PROGRESS=${3-'false'} +STATUS=${3-'--no-partial'} EXTERNAL_ID=${4-'external-id'} -set -x -curl -i --user "${CREDS}" \ - -H "In-Progress: ${PROGRESS}" \ - -H "Slug: ${EXTERNAL_ID}" \ - -F "file=@${ARCHIVE};type=application/zip" \ - -F "atom=@${ATOM_ENTRY};type=application/atom+xml;type=entry" \ - -XPOST ${SERVER}/1/${COLLECTION}/ +./swh-deposit \ + --username ${USER} \ + --password ${PASSWORD} \ + --collection ${COLLECTION} \ + --archive-deposit \ + --archive ${ARCHIVE} \ + --metadata-deposit \ + --metadata ${ATOM_ENTRY} \ + --slug ${EXTERNAL_ID} \ + ${STATUS} \ + --url ${SERVER}/1 diff --git a/bin/default-setup b/bin/default-setup index a8fccdca..c27054f9 100644 --- a/bin/default-setup +++ b/bin/default-setup @@ -1,3 +1,5 @@ SERVER=http://127.0.0.1:5006 -CREDS='hal:hal' +USER='hal' +PASSWORD='hal' COLLECTION=hal +CREDS="$USER:$PASSWORD" diff --git a/bin/status.sh b/bin/status.sh index 80687885..6d3662d1 100755 --- a/bin/status.sh +++ b/bin/status.sh @@ -1,7 +1,13 @@ #!/usr/bin/env bash . ./default-setup DEPOSIT_ID=${1-1} -curl -i -u "${CREDS}" ${SERVER}/1/${COLLECTION}/${DEPOSIT_ID}/status/ +./swh-deposit \ + --username ${USER} \ + --password ${PASSWORD} \ + --collection ${COLLECTION} \ + --status \ + --deposit-id ${DEPOSIT_ID} \ + --url ${SERVER}/1