metadatacenter / cedar-submission-server

CEDAR server to handle submissions to metadata repositories
Other
0 stars 1 forks source link

ImmPort data upload #9

Closed martinjoconnor closed 7 years ago

martinjoconnor commented 7 years ago

Once the upload registration ticket is created (#6, #7), the following steps are performed in the submission server:

a. CEDAR submission server exports form content as ImmPort json templates. b. CEDAR submission server creates a zip file or a directory containing the exported ImmPort json templates and possibly other files with the possibly modified package name returned by the previous API call. c. CEDAR submission server executes the ImmPort script that transfers a file or directory to the Aspera server and provides the ImmPort credentials, and the upload registration ticket and the possibly modified package name returned by the previous API call. d. ImmPort script validates the input parameters by calling the ImmPort Private Data API and if valid, starts the Aspera transfer and returns the appropriate status when complete. e. If the transfer is successful, CEDAR submission server calls the ImmPort Private Data API to change the upload registration ticket status to 'Pending' and provides the ImmPort credentials and upload registration ticket. f. ImmPort Private Data API validates the upload registration ticket, moves the transferred zip file or directory from the Aspera server to the ImmPort Data Upload Server's web upload drop zone, and changes the status of the upload registration ticket to 'Pending'. g. ImmPort Data Upload Server processes the pending upload registration ticket and sends an e-mail to the CEDAR / ImmPort user with the data upload result.

Described instep 10 here:

https://docs.google.com/document/d/1J0j3scmOK8yZQDMH1Te1EiU_epmGCts01dsEHjj--e4/edit

martinjoconnor commented 7 years ago

Above has been simplified considerable. Now simple multi-part upload after workspace retrieval. Will update description when we get final documentation from ImmPort team.

martinjoconnor commented 7 years ago

Email from NG showing curl interaction with API:

#
# The commands below should be executed using the bash shell.
#

#
# Get a new ImmPort access token and get the list of workspaces associated with the CEDAR user
#
token=`curl -X POST https://auth.dev.immport.org/auth/token -d username=cedaruser -d password="REPLACE_WITH_PASSWORD" 2>&1 | fgrep '"token"' | sed -e 's/^.*"token" : "//;s/".*$//'`

curl -H "Authorization: bearer $token" https://api.dev.immport.org/users/cedaruser/workspaces

#
# Get a new ImmPort access token, upload a single ZIP file to ImmPort (replace test.zip with the appropriate file name), and print the upload ticket number
#
token=`curl -X POST https://auth.dev.immport.org/auth/token -d username=cedaruser -d password="REPLACE_WITH_PASSWORD" 2>&1 | fgrep '"token"' | sed -e 's/^.*"token" : "//;s/".*$//'`

curl -H "Authorization: bearer $token" -F 'username=cedaruser' -F 'workspaceId=100001' -F 'file=@test.zip' https://api.dev.immport.org/data/upload 2>&1 | tee output.json
uploadTicketNumber=`cat output.json 2>&1 | fgrep '"uploadTicketNumber"' | sed -e 's/^.*"uploadTicketNumber" : "//;s/".*$//'`
echo $uploadTicketNumber

#
# Get a new ImmPort access token and check the status of the upload
#
token=`curl -X POST https://auth.dev.immport.org/auth/token -d username=cedaruser -d password="REPLACE_WITH_PASSWORD" 2>&1 | fgrep '"token"' | sed -e 's/^.*"token" : "//;s/".*$//'`

curl -H "Authorization: bearer $token" https://api.dev.immport.org/data/upload/registration/$uploadTicketNumber/status

#
# Continue checking the status until it returs "Completed"
#

#
# Get a new ImmPort access token, get the upload report, and save it as file report.html
#
token=`curl -X POST https://auth.dev.immport.org/auth/token -d username=cedaruser -d password="REPLACE_WITH_PASSWORD" 2>&1 | fgrep '"token"' | sed -e 's/^.*"token" : "//;s/".*$//'`

curl -H "Authorization: bearer $token" https://api.dev.immport.org/data/upload/registration/$uploadTicketNumber/report 2>&1 | tee output.json
cat output.json | fgrep '"report"' | sed -e 's/^.*"report" : "//;s/".*$//' | sed -e 's/\\r\\n/<\/br>/g' > report.html

#
# Open file report.html in a web browser
#

####################################################################################################################################

#
# Get a new ImmPort access token, upload multiple files to ImmPort (replace test*.txt with the appropriate file names), and print the upload ticket number
#
token=`curl -X POST https://auth.dev.immport.org/auth/token -d username=cedaruser -d password="REPLACE_WITH_PASSWORD" 2>&1 | fgrep '"token"' | sed -e 's/^.*"token" : "//;s/".*$//'`

curl -H "Authorization: bearer $token" -F 'username=cedaruser' -F 'workspaceId=100001' -F 'file=@test.zip' https://api.dev.immport.org/data/upload 2>&1 | tee output.json
uploadTicketNumber=`cat output.json 2>&1 | fgrep '"uploadTicketNumber"' | sed -e 's/^.*"uploadTicketNumber" : "//;s/".*$//'`
echo $uploadTicketNumber

#
# Get a new ImmPort access token and check the status of the upload
#
token=`curl -X POST https://auth.dev.immport.org/auth/token -d username=cedaruser -d password="REPLACE_WITH_PASSWORD" 2>&1 | fgrep '"token"' | sed -e 's/^.*"token" : "//;s/".*$//'`

curl -H "Authorization: bearer $token" https://api.dev.immport.org/data/upload/registration/$uploadTicketNumber/status

#
# Continue checking the status until it returs "Completed"
#

#
# Get a new ImmPort access token, get the upload report, and save it as file report.html
#
token=`curl -X POST https://auth.dev.immport.org/auth/token -d username=cedaruser -d password="REPLACE_WITH_PASSWORD" 2>&1 | fgrep '"token"' | sed -e 's/^.*"token" : "//;s/".*$//'`

curl -H "Authorization: bearer $token" https://api.dev.immport.org/data/upload/registration/$uploadTicketNumber/report 2>&1 | tee output.json
cat output.json 2>&1 | fgrep '"report"' | sed -e 's/^.*"report" : "//;s/".*$//' | sed -e 's/\\r\\n/<\/br>/g' > report.html

#
# Open file report.html in a web browser
#