From 7d8b1d879f03bf40d1c8cb4f8624b9d8c9722e78 Mon Sep 17 00:00:00 2001 From: Sean Porth Date: Fri, 9 Sep 2022 11:56:09 -0400 Subject: [PATCH 1/3] shibui-2341 fix SQL --- backend/src/main/resources/db/changelog/changelog.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/resources/db/changelog/changelog.sql b/backend/src/main/resources/db/changelog/changelog.sql index f1494b2ca..af15ca6b8 100644 --- a/backend/src/main/resources/db/changelog/changelog.sql +++ b/backend/src/main/resources/db/changelog/changelog.sql @@ -184,7 +184,7 @@ update resource_backed_metadata_resolver_aud set max_refresh_delay ='PT4H'; ALTER TABLE description ALTER COLUMN descriptionValue LONGTEXT; GO -ALTER TABLE description)aud ALTER COLUMN descriptionValue LONGTEXT; +ALTER TABLE description_aud ALTER COLUMN descriptionValue LONGTEXT; GO -- changeset liquibase:1.13.0.2 dbms:postgresql,mssql @@ -192,7 +192,7 @@ GO -- precondition-sql-check expectedResult:1 SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'users' -- comment: /* we don't need to run this if the system is new */ -ALTER TABLE description ALTER COLUMN descriptionValue TEXT; +ALTER TABLE description ALTER COLUMN descriptionValue TYPE TEXT; GO -ALTER TABLE description_aud ALTER COLUMN descriptionValue TEXT; +ALTER TABLE description_aud ALTER COLUMN descriptionValue TYPE TEXT; GO \ No newline at end of file From bfeda4f3b5863a5007dda37c67b126bcc037fc66 Mon Sep 17 00:00:00 2001 From: Sean Porth Date: Fri, 9 Sep 2022 12:16:51 -0400 Subject: [PATCH 2/3] shibui-2341 exit upload if api is inaccessible --- bulk-upload/docker-build/shibui-md-upload.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bulk-upload/docker-build/shibui-md-upload.pl b/bulk-upload/docker-build/shibui-md-upload.pl index 3aae45aa8..160559c6d 100755 --- a/bulk-upload/docker-build/shibui-md-upload.pl +++ b/bulk-upload/docker-build/shibui-md-upload.pl @@ -41,6 +41,11 @@ #create auth token $client->HEAD('/'); + +my $code = $client->responseCode(); +my $res = $client->responseContent(); +die "$res\n" if ($code != 302 && $code != 200); + my $token = &get_cookie_value($cookies, 'XSRF-TOKEN'); $client->addHeader('X-XSRF-TOKEN', $token); ## From 1f7a8ff6b116e8c72b5bd6b0b28c873f1cfc5a9c Mon Sep 17 00:00:00 2001 From: Sean Porth Date: Mon, 12 Sep 2022 13:38:40 -0400 Subject: [PATCH 3/3] shibui-2341 better url encoding, utf8 encoding of names --- bulk-upload/README.md | 2 +- bulk-upload/docker-build/Dockerfile | 2 +- bulk-upload/docker-build/shibui-md-upload.pl | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bulk-upload/README.md b/bulk-upload/README.md index 23462d5ca..02196fba9 100644 --- a/bulk-upload/README.md +++ b/bulk-upload/README.md @@ -42,6 +42,6 @@ If you prefer to build the image yourself, `cd docker-build;docker build -t unic ### running without docker ### The docker-build/shibui-md-upload.pl script can be run manually. -Depending on OS you may need to install some additional non dist Perl modules. REST::Client , XML::LibXML , JSON , Config::File +Depending on OS you may need to install some additional non dist Perl modules. REST::Client , XML::LibXML , JSON , Config::File , URI::Encode `perl shibui-md-upload.pl -c -m -e (enable metadata source after upload)` diff --git a/bulk-upload/docker-build/Dockerfile b/bulk-upload/docker-build/Dockerfile index dd7384667..8c1efcba9 100644 --- a/bulk-upload/docker-build/Dockerfile +++ b/bulk-upload/docker-build/Dockerfile @@ -3,7 +3,7 @@ MAINTAINER sporth@unicon.net RUN apt-get clean \ && apt-get -y update \ - && apt-get install -y librest-client-perl libconfig-file-perl jq libxml-libxml-perl libjson-perl + && apt-get install -y librest-client-perl libconfig-file-perl jq libxml-libxml-perl libjson-perl liburi-encode-perl WORKDIR /opt COPY shibui-md-upload.pl /opt/shibui-md-upload.pl diff --git a/bulk-upload/docker-build/shibui-md-upload.pl b/bulk-upload/docker-build/shibui-md-upload.pl index 160559c6d..4f24334e3 100755 --- a/bulk-upload/docker-build/shibui-md-upload.pl +++ b/bulk-upload/docker-build/shibui-md-upload.pl @@ -12,6 +12,7 @@ use XML::LibXML::XPathContext; use Encode; use JSON; +use URI::Encode; ##process arguments our ($opt_e,$opt_m,$opt_c); @@ -201,10 +202,13 @@ sub call_api { my $xml = shift; my $enable = shift; my ($params,$code,$result); + my $encoder = URI::Encode->new({encode_reserved => 1}); my $utf8 = encode_utf8($xml); + my $utf8_name = encode_utf8($name); + my $ename = $encoder->encode($name); - $params = "?spName=$name"; + $params = "?spName=$ename"; $params .= "&enableService=true" if ($enable); $client->addHeader('Content-Type', "application/xml; charset='utf8'"); @@ -226,18 +230,18 @@ sub call_api { my $eresult = $client->responseContent(); if ($ecode == 200 || $ecode == 201) { - print "$ecode: entity $name uploaded sucessfully and enabled\n"; + print "$ecode: entity $utf8_name uploaded sucessfully and enabled\n"; } else { - print "$ecode: entity $name uploaded sucessfully but enabling failed:\n"; + print "$ecode: entity $utf8_name uploaded sucessfully but enabling failed:\n"; open(my $pipe, '|-', "jq ."); print $pipe $eresult; } } else { - print "$code: entity $name uploaded sucessfully\n"; + print "$code: entity $utf8_name uploaded sucessfully\n"; } } elsif ($code == 409) { - print "$code: entity $name already exists\n"; + print "$code: entity $utf8_name already exists\n"; } elsif ($code == 500) { print "$code: $result\n"; } else {