Adding script to close Nexus staging repo

Change-Id: Ibfcbb6b58159393493e1a4be58d2e2360810d0d6
diff --git a/tools/build/onos-release-prerequisites b/tools/build/onos-release-prerequisites
index 9268e50..5880669 100755
--- a/tools/build/onos-release-prerequisites
+++ b/tools/build/onos-release-prerequisites
@@ -107,10 +107,10 @@
 
 # Sonatype account must be created & ~/.m2/settings.xml must be configured
 # Test by "releasing" a fake project setup for that purpose to validate access.
-function testSonatypeAccess {
+function testSonatypeAccessMvn {
     aux=$(mktemp)
     trap "cat $aux; rm -f $aux; echo 'FAILED'" ERR
-    printf "Checking Sonatype access... "
+    printf "Checking Sonatype access via Maven... "
     pushd $ONOS_ROOT/tools/build/release-test >/dev/null
     # TODO: Figure out how to supress the GPG note
     mvn -Prelease clean deploy org.sonatype.plugins:nexus-staging-maven-plugin:drop \
@@ -121,6 +121,31 @@
     echo "OK"
 }
 
+function testSonatypeAccessRest {
+    #FIXME check SONATYPE_USER SONATYPE_PASSWORD
+    export ONOS_VERSION=1.2.3
+    printf "Checking Sonatype access via REST... "
+    pushd $ONOS_ROOT/tools/build/release-test >/dev/null
+    #FIXME this won't work on Linux
+    md5 pom.xml > pom.xml.md5
+    shasum pom.xml > pom.xml.sha1
+    gpg --detach-sign --output pom.xml.asc pom.xml
+    # Upload the files to staging
+    curl -s -u$SONATYPE_USER:$SONATYPE_PASSWORD --upload-file pom.xml \
+    https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-api/$ONOS_VERSION/onos-api-$ONOS_VERSION.pom
+    curl -s -u$SONATYPE_USER:$SONATYPE_PASSWORD --upload-file pom.xml.md5 \
+    https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-api/$ONOS_VERSION/onos-api-$ONOS_VERSION.pom.md5
+    curl -s -u$SONATYPE_USER:$SONATYPE_PASSWORD --upload-file pom.xml.sha1 \
+    https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-api/$ONOS_VERSION/onos-api-$ONOS_VERSION.pom.sha1
+    curl -s -u$SONATYPE_USER:$SONATYPE_PASSWORD --upload-file pom.xml.asc \
+    https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-api/$ONOS_VERSION/onos-api-$ONOS_VERSION.pom.asc
+    rm pom.xml.md5 pom.xml.sha1 pom.xml.asc
+    onos-close-staging -d >/dev/null
+    popd >/dev/null
+    unset ONOS_VERSION
+    echo "OK"
+}
+
 # .buckconfig.local must exist and the sonatype credentials must be set up
 function testBuckconfigLocal() {
     printf "Checking local buck config..."
@@ -153,7 +178,7 @@
 testGerritAccess
 testWikiAccess
 testEC2Access
-testSonatypeAccess
+testSonatypeAccessMvn
+testSonatypeAccessRest
 
 echo "Ready to commence release process!"
-