Skip to content

Commit

Permalink
Merged in feature/shibui-2341 (pull request #616)
Browse files Browse the repository at this point in the history
Feature/shibui 2341

Approved-by: Bill Smith
  • Loading branch information
chasegawa committed Sep 12, 2022
2 parents fadd43e + 0e8e038 commit 1e8d1a4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions backend/src/main/resources/db/changelog/changelog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ 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
-- preconditions onFail:MARK_RAN
-- 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
2 changes: 1 addition & 1 deletion bulk-upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path to upload.conf> -m <path to metadata location> -e (enable metadata source after upload)`

2 changes: 1 addition & 1 deletion bulk-upload/docker-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions bulk-upload/docker-build/shibui-md-upload.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use XML::LibXML::XPathContext;
use Encode;
use JSON;
use URI::Encode;

##process arguments
our ($opt_e,$opt_m,$opt_c);
Expand Down Expand Up @@ -41,6 +42,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);
##
Expand Down Expand Up @@ -196,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'");
Expand All @@ -221,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 {
Expand Down

0 comments on commit 1e8d1a4

Please sign in to comment.