From bf88bfb6ffec88907960adc80ca18fe482a43025 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Tue, 16 Apr 2019 13:25:53 +0000 Subject: [PATCH 1/6] Fixing media indexing in Fedora with 5.0 --- Milliner/src/Service/MillinerService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Milliner/src/Service/MillinerService.php b/Milliner/src/Service/MillinerService.php index 889ec26d..dc187843 100644 --- a/Milliner/src/Service/MillinerService.php +++ b/Milliner/src/Service/MillinerService.php @@ -457,7 +457,7 @@ public function saveMedia( $drupal_jsonld = $this->processJsonld( $drupal_jsonld, $jsonld_url, - $fedora_file_url + $fedora_url ); // Get the modified date from the RDF. $drupal_modified = $this->getModifiedTimestamp( From b34cf4934f7abee8b164ddc1dbf7f39432388f14 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Tue, 23 Apr 2019 17:01:13 +0000 Subject: [PATCH 2/6] Using external content for non-fedora binaries --- Milliner/composer.lock | 739 +++++++----------- .../src/Controller/MillinerController.php | 31 + Milliner/src/Service/MillinerService.php | 162 ++-- .../src/Service/MillinerServiceInterface.php | 15 + Milliner/src/app.php | 1 + 5 files changed, 403 insertions(+), 545 deletions(-) diff --git a/Milliner/composer.lock b/Milliner/composer.lock index 5756642a..d703c8ae 100644 --- a/Milliner/composer.lock +++ b/Milliner/composer.lock @@ -6,103 +6,40 @@ ], "content-hash": "97d026ae3ad1a955ac05743a60324ae5", "packages": [ - { - "name": "doctrine/annotations", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", - "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", - "shasum": "" - }, - "require": { - "doctrine/lexer": "1.*", - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "doctrine/cache": "1.*", - "phpunit/phpunit": "^5.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "time": "2017-02-24T16:22:25+00:00" - }, { "name": "doctrine/cache", - "version": "v1.6.2", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b" + "reference": "d768d58baee9a4862ca783840eca1b9add7a7f57" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b", - "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b", + "url": "https://api.github.com/repos/doctrine/cache/zipball/d768d58baee9a4862ca783840eca1b9add7a7f57", + "reference": "d768d58baee9a4862ca783840eca1b9add7a7f57", "shasum": "" }, "require": { - "php": "~5.5|~7.0" + "php": "~7.1" }, "conflict": { "doctrine/common": ">2.2,<2.4" }, "require-dev": { - "phpunit/phpunit": "~4.8|~5.0", - "predis/predis": "~1.0", - "satooshi/php-coveralls": "~0.6" + "alcaeus/mongo-php-adapter": "^1.1", + "doctrine/coding-standard": "^4.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -137,174 +74,40 @@ } ], "description": "Caching library offering an object-oriented API for many cache backends", - "homepage": "http://www.doctrine-project.org", + "homepage": "https://www.doctrine-project.org", "keywords": [ "cache", "caching" ], - "time": "2017-07-22T12:49:21+00:00" - }, - { - "name": "doctrine/collections", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/collections.git", - "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/1a4fb7e902202c33cce8c55989b945612943c2ba", - "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "doctrine/coding-standard": "~0.1@dev", - "phpunit/phpunit": "^5.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Collections\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Collections Abstraction library", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "array", - "collections", - "iterator" - ], - "time": "2017-01-03T10:49:41+00:00" - }, - { - "name": "doctrine/common", - "version": "v2.7.3", - "source": { - "type": "git", - "url": "https://github.com/doctrine/common.git", - "reference": "4acb8f89626baafede6ee5475bc5844096eba8a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/4acb8f89626baafede6ee5475bc5844096eba8a9", - "reference": "4acb8f89626baafede6ee5475bc5844096eba8a9", - "shasum": "" - }, - "require": { - "doctrine/annotations": "1.*", - "doctrine/cache": "1.*", - "doctrine/collections": "1.*", - "doctrine/inflector": "1.*", - "doctrine/lexer": "1.*", - "php": "~5.6|~7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.4.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\": "lib/Doctrine/Common" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Common Library for Doctrine projects", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "collections", - "eventmanager", - "persistence", - "spl" - ], - "time": "2017-07-22T08:35:12+00:00" + "time": "2018-08-21T18:01:43+00:00" }, { "name": "doctrine/dbal", - "version": "v2.5.13", + "version": "v2.9.2", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "729340d8d1eec8f01bff708e12e449a3415af873" + "reference": "22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/729340d8d1eec8f01bff708e12e449a3415af873", - "reference": "729340d8d1eec8f01bff708e12e449a3415af873", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9", + "reference": "22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9", "shasum": "" }, "require": { - "doctrine/common": ">=2.4,<2.8-dev", - "php": ">=5.3.2" + "doctrine/cache": "^1.0", + "doctrine/event-manager": "^1.0", + "ext-pdo": "*", + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "4.*", - "symfony/console": "2.*||^3.0" + "doctrine/coding-standard": "^5.0", + "jetbrains/phpstorm-stubs": "^2018.1.2", + "phpstan/phpstan": "^0.10.1", + "phpunit/phpunit": "^7.4", + "symfony/console": "^2.0.5|^3.0|^4.0", + "symfony/phpunit-bridge": "^3.4.5|^4.0.5" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -315,12 +118,13 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5.x-dev" + "dev-master": "2.9.x-dev", + "dev-develop": "3.0.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\DBAL\\": "lib/" + "psr-4": { + "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" } }, "notification-url": "https://packagist.org/downloads/", @@ -345,45 +149,53 @@ "email": "jonwage@gmail.com" } ], - "description": "Database Abstraction Layer", - "homepage": "http://www.doctrine-project.org", + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", "keywords": [ + "abstraction", "database", "dbal", + "mysql", "persistence", + "pgsql", + "php", "queryobject" ], - "time": "2017-07-22T20:44:48+00:00" + "time": "2018-12-31T03:27:51+00:00" }, { - "name": "doctrine/inflector", - "version": "v1.2.0", + "name": "doctrine/event-manager", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/doctrine/inflector.git", - "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462" + "url": "https://github.com/doctrine/event-manager.git", + "reference": "a520bc093a0170feeb6b14e9d83f3a14452e64b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/e11d84c6e018beedd929cff5220969a3c6d1d462", - "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/a520bc093a0170feeb6b14e9d83f3a14452e64b3", + "reference": "a520bc093a0170feeb6b14e9d83f3a14452e64b3", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.1" + }, + "conflict": { + "doctrine/common": "<2.9@dev" }, "require-dev": { - "phpunit/phpunit": "^6.2" + "doctrine/coding-standard": "^4.0", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { - "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" + "Doctrine\\Common\\": "lib/Doctrine/Common" } }, "notification-url": "https://packagist.org/downloads/", @@ -410,71 +222,20 @@ { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com" - } - ], - "description": "Common String Manipulations with regard to casing and singular/plural rules.", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "inflection", - "pluralize", - "singularize", - "string" - ], - "time": "2017-07-22T12:18:28+00:00" - }, - { - "name": "doctrine/lexer", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Lexer\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" }, { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" } ], - "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "http://www.doctrine-project.org", + "description": "Doctrine Event Manager component", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", "keywords": [ - "lexer", - "parser" + "event", + "eventdispatcher", + "eventmanager" ], - "time": "2014-09-09T13:34:57+00:00" + "time": "2018-06-11T11:59:03+00:00" }, { "name": "easyrdf/easyrdf", @@ -723,16 +484,16 @@ }, { "name": "islandora/chullo", - "version": "0.1.1", + "version": "0.2.0", "source": { "type": "git", "url": "https://github.com/Islandora-CLAW/chullo.git", - "reference": "c90c9f1670617b1be939709c2d72c74d2e589d8c" + "reference": "7dcef926a8500548f68e2302fff6b070f82c250d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Islandora-CLAW/chullo/zipball/c90c9f1670617b1be939709c2d72c74d2e589d8c", - "reference": "c90c9f1670617b1be939709c2d72c74d2e589d8c", + "url": "https://api.github.com/repos/Islandora-CLAW/chullo/zipball/7dcef926a8500548f68e2302fff6b070f82c250d", + "reference": "7dcef926a8500548f68e2302fff6b070f82c250d", "shasum": "" }, "require": { @@ -743,8 +504,9 @@ }, "require-dev": { "mockery/mockery": "^0.9", - "phpunit/phpunit": "^4.8", - "squizlabs/php_codesniffer": "^2.0@dev" + "phpunit/phpunit": "^5.0", + "sebastian/phpcpd": "^3.0", + "squizlabs/php_codesniffer": "^2.0" }, "type": "library", "autoload": { @@ -775,7 +537,7 @@ ], "description": "A PHP client for interacting with a Fedora 4 server.", "homepage": "https://github.com/islandora-claw/chullo", - "time": "2017-04-12T20:14:38+00:00" + "time": "2017-04-21T20:53:16+00:00" }, { "name": "islandora/crayfish-commons", @@ -783,17 +545,17 @@ "source": { "type": "git", "url": "https://github.com/Islandora-CLAW/Crayfish-Commons.git", - "reference": "6e361bd180e9b62ef343ead5344677d9f0d1c897" + "reference": "19a03ebb4401d23ec5a15090dafea6066d6085e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Islandora-CLAW/Crayfish-Commons/zipball/6e361bd180e9b62ef343ead5344677d9f0d1c897", - "reference": "6e361bd180e9b62ef343ead5344677d9f0d1c897", + "url": "https://api.github.com/repos/Islandora-CLAW/Crayfish-Commons/zipball/19a03ebb4401d23ec5a15090dafea6066d6085e8", + "reference": "19a03ebb4401d23ec5a15090dafea6066d6085e8", "shasum": "" }, "require": { "doctrine/dbal": "~2.2", - "islandora/chullo": "^0.1.1", + "islandora/chullo": "^0.2", "monolog/monolog": "^1.22", "namshi/jose": "^7.2", "pimple/pimple": "~3.0", @@ -832,7 +594,7 @@ } ], "description": "Shared code amongst Islandora Crayfish microservices", - "time": "2019-02-04T14:57:25+00:00" + "time": "2019-04-12T20:13:55+00:00" }, { "name": "ml/iri", @@ -1444,32 +1206,32 @@ }, { "name": "symfony/debug", - "version": "v3.4.22", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "667a26c4dd6bc75c67f06bc9bcd015bdecc7cbb8" + "reference": "2d279b6bb1d582dd5740d4d3251ae8c18812ed37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/667a26c4dd6bc75c67f06bc9bcd015bdecc7cbb8", - "reference": "667a26c4dd6bc75c67f06bc9bcd015bdecc7cbb8", + "url": "https://api.github.com/repos/symfony/debug/zipball/2d279b6bb1d582dd5740d4d3251ae8c18812ed37", + "reference": "2d279b6bb1d582dd5740d4d3251ae8c18812ed37", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", + "php": "^7.1.3", "psr/log": "~1.0" }, "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + "symfony/http-kernel": "<3.4" }, "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" + "symfony/http-kernel": "~3.4|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -1496,20 +1258,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2019-01-25T10:19:25+00:00" + "time": "2019-04-11T11:27:41+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.4.22", + "version": "v3.4.26", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "ed5be1663fa66623b3a7004d5d51a14c4045399b" + "reference": "a088aafcefb4eef2520a290ed82e4374092a6dff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ed5be1663fa66623b3a7004d5d51a14c4045399b", - "reference": "ed5be1663fa66623b3a7004d5d51a14c4045399b", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a088aafcefb4eef2520a290ed82e4374092a6dff", + "reference": "a088aafcefb4eef2520a290ed82e4374092a6dff", "shasum": "" }, "require": { @@ -1559,20 +1321,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-01-16T13:27:11+00:00" + "time": "2019-04-02T08:51:52+00:00" }, { "name": "symfony/http-foundation", - "version": "v3.4.22", + "version": "v3.4.26", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "9a81d2330ea255ded06a69b4f7fb7804836e7a05" + "reference": "90454ad44c95d75faf3507d56388056001b74baf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/9a81d2330ea255ded06a69b4f7fb7804836e7a05", - "reference": "9a81d2330ea255ded06a69b4f7fb7804836e7a05", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/90454ad44c95d75faf3507d56388056001b74baf", + "reference": "90454ad44c95d75faf3507d56388056001b74baf", "shasum": "" }, "require": { @@ -1613,20 +1375,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-01-27T09:04:14+00:00" + "time": "2019-04-17T14:51:18+00:00" }, { "name": "symfony/http-kernel", - "version": "v3.4.22", + "version": "v3.4.26", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "dc6bf17684b7120f7bf74fae85c9155506041002" + "reference": "14fa41ccd38570b5e3120a3754bbaa144a15f311" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/dc6bf17684b7120f7bf74fae85c9155506041002", - "reference": "dc6bf17684b7120f7bf74fae85c9155506041002", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/14fa41ccd38570b5e3120a3754bbaa144a15f311", + "reference": "14fa41ccd38570b5e3120a3754bbaa144a15f311", "shasum": "" }, "require": { @@ -1702,30 +1464,30 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2019-02-03T12:22:50+00:00" + "time": "2019-04-17T15:57:07+00:00" }, { "name": "symfony/inflector", - "version": "v3.4.22", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/inflector.git", - "reference": "4a7d5c4ad3edeba3fe4a27d26ece6a012eee46b1" + "reference": "275e54941a4f17a471c68d2a00e2513fc1fd4a78" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/inflector/zipball/4a7d5c4ad3edeba3fe4a27d26ece6a012eee46b1", - "reference": "4a7d5c4ad3edeba3fe4a27d26ece6a012eee46b1", + "url": "https://api.github.com/repos/symfony/inflector/zipball/275e54941a4f17a471c68d2a00e2513fc1fd4a78", + "reference": "275e54941a4f17a471c68d2a00e2513fc1fd4a78", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", + "php": "^7.1.3", "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -1760,20 +1522,20 @@ "symfony", "words" ], - "time": "2019-01-16T13:27:11+00:00" + "time": "2019-01-16T20:31:39+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + "reference": "82ebae02209c21113908c229e9883c419720738a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", "shasum": "" }, "require": { @@ -1785,7 +1547,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -1807,7 +1569,7 @@ }, { "name": "Gert de Pagter", - "email": "backendtea@gmail.com" + "email": "BackEndTea@gmail.com" } ], "description": "Symfony polyfill for ctype functions", @@ -1818,20 +1580,20 @@ "polyfill", "portable" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", - "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", "shasum": "" }, "require": { @@ -1843,7 +1605,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -1877,20 +1639,20 @@ "portable", "shim" ], - "time": "2018-09-21T13:07:52+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-php56", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "ff208829fe1aa48ab9af356992bb7199fed551af" + "reference": "f4dddbc5c3471e1b700a147a20ae17cdb72dbe42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ff208829fe1aa48ab9af356992bb7199fed551af", - "reference": "ff208829fe1aa48ab9af356992bb7199fed551af", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/f4dddbc5c3471e1b700a147a20ae17cdb72dbe42", + "reference": "f4dddbc5c3471e1b700a147a20ae17cdb72dbe42", "shasum": "" }, "require": { @@ -1900,7 +1662,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -1933,20 +1695,20 @@ "portable", "shim" ], - "time": "2018-09-21T06:26:08+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224" + "reference": "bc4858fb611bda58719124ca079baff854149c89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/6b88000cdd431cd2e940caa2cb569201f3f84224", - "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/bc4858fb611bda58719124ca079baff854149c89", + "reference": "bc4858fb611bda58719124ca079baff854149c89", "shasum": "" }, "require": { @@ -1956,7 +1718,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -1992,20 +1754,20 @@ "portable", "shim" ], - "time": "2018-09-21T06:26:08+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-util", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-util.git", - "reference": "3b58903eae668d348a7126f999b0da0f2f93611c" + "reference": "b46c6cae28a3106735323f00a0c38eccf2328897" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/3b58903eae668d348a7126f999b0da0f2f93611c", - "reference": "3b58903eae668d348a7126f999b0da0f2f93611c", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/b46c6cae28a3106735323f00a0c38eccf2328897", + "reference": "b46c6cae28a3106735323f00a0c38eccf2328897", "shasum": "" }, "require": { @@ -2014,7 +1776,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -2044,29 +1806,28 @@ "polyfill", "shim" ], - "time": "2018-09-30T16:36:12+00:00" + "time": "2019-02-08T14:16:39+00:00" }, { "name": "symfony/property-access", - "version": "v3.4.22", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/property-access.git", - "reference": "dedc7c1b52e1d0cd5069da0b4c727b3087897f90" + "reference": "5440dd2b5373073beee051bd978b58a0f543b192" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-access/zipball/dedc7c1b52e1d0cd5069da0b4c727b3087897f90", - "reference": "dedc7c1b52e1d0cd5069da0b4c727b3087897f90", + "url": "https://api.github.com/repos/symfony/property-access/zipball/5440dd2b5373073beee051bd978b58a0f543b192", + "reference": "5440dd2b5373073beee051bd978b58a0f543b192", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/inflector": "~3.1|~4.0", - "symfony/polyfill-php70": "~1.0" + "php": "^7.1.3", + "symfony/inflector": "~3.4|~4.0" }, "require-dev": { - "symfony/cache": "~3.1|~4.0" + "symfony/cache": "~3.4|~4.0" }, "suggest": { "psr/cache-implementation": "To cache access methods." @@ -2074,7 +1835,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -2112,20 +1873,20 @@ "property path", "reflection" ], - "time": "2019-01-16T09:39:14+00:00" + "time": "2019-03-04T09:16:25+00:00" }, { "name": "symfony/routing", - "version": "v3.4.22", + "version": "v3.4.26", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "62f0b8d8cd2cd359c3caa5a9f5253a4a6d480646" + "reference": "ff11aac46d6cb8a65f2855687bb9a1ac9d860eec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/62f0b8d8cd2cd359c3caa5a9f5253a4a6d480646", - "reference": "62f0b8d8cd2cd359c3caa5a9f5253a4a6d480646", + "url": "https://api.github.com/repos/symfony/routing/zipball/ff11aac46d6cb8a65f2855687bb9a1ac9d860eec", + "reference": "ff11aac46d6cb8a65f2855687bb9a1ac9d860eec", "shasum": "" }, "require": { @@ -2148,7 +1909,6 @@ "suggest": { "doctrine/annotations": "For using the annotation loader", "symfony/config": "For using the all-in-one router or any loader", - "symfony/dependency-injection": "For loading routes from a service", "symfony/expression-language": "For using expression matching", "symfony/http-foundation": "For using a Symfony Request object", "symfony/yaml": "For using the YAML loader" @@ -2189,20 +1949,20 @@ "uri", "url" ], - "time": "2019-01-29T08:47:12+00:00" + "time": "2019-03-29T21:58:42+00:00" }, { "name": "symfony/security", - "version": "v3.4.22", + "version": "v3.4.26", "source": { "type": "git", "url": "https://github.com/symfony/security.git", - "reference": "25c0590cd98d651caa560a80bde01fe8df5ed74e" + "reference": "fdbff3de6a0486aa10fcc3f0cbfe336d46534f27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security/zipball/25c0590cd98d651caa560a80bde01fe8df5ed74e", - "reference": "25c0590cd98d651caa560a80bde01fe8df5ed74e", + "url": "https://api.github.com/repos/symfony/security/zipball/fdbff3de6a0486aa10fcc3f0cbfe336d46534f27", + "reference": "fdbff3de6a0486aa10fcc3f0cbfe336d46534f27", "shasum": "" }, "require": { @@ -2226,6 +1986,7 @@ "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/finder": "~2.8|~3.0|~4.0", "symfony/ldap": "~3.1|~4.0", + "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-icu": "~1.0", "symfony/routing": "~2.8|~3.0|~4.0", "symfony/validator": "^3.2.5|~4.0" @@ -2271,20 +2032,20 @@ ], "description": "Symfony Security Component", "homepage": "https://symfony.com", - "time": "2019-01-31T10:03:47+00:00" + "time": "2019-04-17T14:49:35+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.22", + "version": "v3.4.26", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d" + "reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/ba11776e9e6c15ad5759a07bffb15899bac75c2d", - "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d", + "url": "https://api.github.com/repos/symfony/yaml/zipball/212a27b731e5bfb735679d1ffaac82bd6a1dc996", + "reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996", "shasum": "" }, "require": { @@ -2330,38 +2091,40 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2019-01-16T10:59:17+00:00" + "time": "2019-03-25T07:48:46+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "a2c590166b2133a4633738648b6b064edae0814a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -2381,34 +2144,37 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2019-03-17T17:37:11+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.7.0", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" + "phpunit/phpunit": "^7.1" }, "type": "library", "autoload": { @@ -2431,7 +2197,7 @@ "object", "object graph" ], - "time": "2017-10-19T19:58:43+00:00" + "time": "2019-04-07T13:18:21+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -3036,6 +2802,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2017-06-30T09:13:00+00:00" }, { @@ -3720,16 +3487,16 @@ }, { "name": "symfony/browser-kit", - "version": "v3.4.22", + "version": "v3.4.26", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "884689e5d29fc3c48498a0038e96d60e4f91b471" + "reference": "7f2b0843d5045468225f9a9b27a0cb171ae81828" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/884689e5d29fc3c48498a0038e96d60e4f91b471", - "reference": "884689e5d29fc3c48498a0038e96d60e4f91b471", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/7f2b0843d5045468225f9a9b27a0cb171ae81828", + "reference": "7f2b0843d5045468225f9a9b27a0cb171ae81828", "shasum": "" }, "require": { @@ -3773,25 +3540,25 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2019-01-16T09:39:14+00:00" + "time": "2019-04-06T19:33:58+00:00" }, { "name": "symfony/console", - "version": "v3.4.22", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "069bf3f0e8f871a2169a06e43d9f3f03f355e9be" + "reference": "e2840bb38bddad7a0feaf85931e38fdcffdb2f81" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/069bf3f0e8f871a2169a06e43d9f3f03f355e9be", - "reference": "069bf3f0e8f871a2169a06e43d9f3f03f355e9be", + "url": "https://api.github.com/repos/symfony/console/zipball/e2840bb38bddad7a0feaf85931e38fdcffdb2f81", + "reference": "e2840bb38bddad7a0feaf85931e38fdcffdb2f81", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0|~4.0", + "php": "^7.1.3", + "symfony/contracts": "^1.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { @@ -3803,11 +3570,11 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3|~4.0", + "symfony/config": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.3|~4.0" + "symfony/process": "~3.4|~4.0" }, "suggest": { "psr/log": "For using the console logger", @@ -3818,7 +3585,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -3845,11 +3612,79 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-01-25T10:42:12+00:00" + "time": "2019-04-08T14:23:48+00:00" + }, + { + "name": "symfony/contracts", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/contracts.git", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "require-dev": { + "psr/cache": "^1.0", + "psr/container": "^1.0" + }, + "suggest": { + "psr/cache": "When using the Cache contracts", + "psr/container": "When using the Service contracts", + "symfony/cache-contracts-implementation": "", + "symfony/service-contracts-implementation": "", + "symfony/translation-contracts-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\": "" + }, + "exclude-from-classmap": [ + "**/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A set of abstractions extracted out of the Symfony components", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2018-12-05T08:06:11+00:00" }, { "name": "symfony/css-selector", - "version": "v3.4.22", + "version": "v3.4.26", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -3902,25 +3737,25 @@ }, { "name": "symfony/dom-crawler", - "version": "v3.4.22", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "32cb577c07bd900ee883a9d4b55d4098aa02e422" + "reference": "53c97769814c80a84a8403efcf3ae7ae966d53bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/32cb577c07bd900ee883a9d4b55d4098aa02e422", - "reference": "32cb577c07bd900ee883a9d4b55d4098aa02e422", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/53c97769814c80a84a8403efcf3ae7ae966d53bb", + "reference": "53c97769814c80a84a8403efcf3ae7ae966d53bb", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", + "php": "^7.1.3", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { - "symfony/css-selector": "~2.8|~3.0|~4.0" + "symfony/css-selector": "~3.4|~4.0" }, "suggest": { "symfony/css-selector": "" @@ -3928,7 +3763,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -3955,29 +3790,29 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2019-01-16T13:27:11+00:00" + "time": "2019-02-23T15:17:42+00:00" }, { "name": "symfony/finder", - "version": "v3.4.22", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "7c0c627220308928e958a87c293108e5891cde1d" + "reference": "e45135658bd6c14b61850bf131c4f09a55133f69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/7c0c627220308928e958a87c293108e5891cde1d", - "reference": "7c0c627220308928e958a87c293108e5891cde1d", + "url": "https://api.github.com/repos/symfony/finder/zipball/e45135658bd6c14b61850bf131c4f09a55133f69", + "reference": "e45135658bd6c14b61850bf131c4f09a55133f69", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -4004,7 +3839,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-01-16T13:43:35+00:00" + "time": "2019-04-06T13:51:08+00:00" }, { "name": "theseer/fdomdocument", diff --git a/Milliner/src/Controller/MillinerController.php b/Milliner/src/Controller/MillinerController.php index 74835f9a..64dfacc9 100644 --- a/Milliner/src/Controller/MillinerController.php +++ b/Milliner/src/Controller/MillinerController.php @@ -122,4 +122,35 @@ public function saveMedia($source_field, Request $request) return new Response($e->getMessage(), $code); } } + + /** + * @param string $uuid + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Symfony\Component\HttpFoundation\Response + */ + public function saveExternal($uuid, Request $request) + { + $token = $request->headers->get("Authorization", null); + $external_url = $request->headers->get("Content-Location"); + + if (empty($external_url)) { + return new Response("Expected external url in Content-Location header", 400); + } + + try { + $response = $this->milliner->saveExternal( + $uuid, + $external_url, + $token + ); + + return new Response( + $response->getBody(), + $response->getStatusCode() + ); + } catch (\Exception $e) { + $this->log->error("", ['Exception' => $e]); + return new Response($e->getMessage(), $e->getCode()); + } + } } diff --git a/Milliner/src/Service/MillinerService.php b/Milliner/src/Service/MillinerService.php index dc187843..84b4d46f 100644 --- a/Milliner/src/Service/MillinerService.php +++ b/Milliner/src/Service/MillinerService.php @@ -80,7 +80,6 @@ public function saveNode( ); } else { return $this->updateNode( - $uuid, $jsonld_url, $urls['fedora'], $token @@ -171,12 +170,11 @@ protected function createNode( * @throws \GuzzleHttp\Exception\RequestException */ protected function updateNode( - $uuid, $jsonld_url, $fedora_url, $token = null ) { - // Get the jsonld from Fedora. + // Get the RDF from Fedora. $headers = empty($token) ? [] : ['Authorization' => $token]; $headers['Accept'] = 'application/ld+json'; $fedora_response = $this->fedora->getResource( @@ -189,7 +187,7 @@ protected function updateNode( $reason = $fedora_response->getReasonPhrase(); throw new \RuntimeException( "Client error: `GET $fedora_url` resulted in a `$status $reason` response: " . - $fedora_response->getBody(), + $fedora_response->getBody(), $status ); } @@ -204,9 +202,15 @@ protected function updateNode( true ); - $fedora_modified = $this->getModifiedTimestamp( - $fedora_jsonld - ); + // Account for the fact that new media haven't got a modified date + // pushed to it from Drupal yet. + try { + $fedora_modified = $this->getModifiedTimestamp( + $fedora_jsonld + ); + } catch (\RuntimeException $e) { + $fedora_modified = 0; + } // Get the jsonld from Drupal. $headers = empty($token) ? [] : ['Authorization' => $token]; @@ -214,7 +218,6 @@ protected function updateNode( $jsonld_url, ['headers' => $headers] ); - $drupal_jsonld = json_decode( $drupal_response->getBody(), true @@ -240,7 +243,7 @@ protected function updateNode( ); } - // Conditional save it in Fedora. + // Conditionally save it in Fedora. $headers['Content-Type'] = 'application/ld+json'; $headers['Prefer'] = 'return=minimal; handling=lenient'; $headers['If-Match'] = $etag; @@ -384,12 +387,15 @@ public function saveMedia( $fedora_file_url = $urls['fedora']; // Now look for the 'describedby' link header on the file in Fedora. - $fedora_response = $this->fedora->getResourceHeaders( + // I'm using the drupal http client because I have the full + // URI and need to squash redirects in case of external content. + $fedora_response = $this->drupal->head( $fedora_file_url, - $headers + ['allow_redirects' => false, 'headers' => $headers] ); $status = $fedora_response->getStatusCode(); - if ($status != 200) { + + if ($status != 200 && $status != 307) { $reason = $fedora_response->getReasonPhrase(); throw new \RuntimeException( "Client error: `HEAD $fedora_file_url` resulted in a `$status $reason` response: " . @@ -397,6 +403,7 @@ public function saveMedia( $status ); } + $fedora_url = $this->getLinkHeader($fedora_response, "describedby"); if (empty($fedora_url)) { throw new \RuntimeException( @@ -405,90 +412,11 @@ public function saveMedia( ); } - // Get the RDF from Fedora. - $headers = empty($token) ? [] : ['Authorization' => $token]; - $headers['Accept'] = 'application/ld+json'; - $fedora_response = $this->fedora->getResource( - $fedora_url, - $headers - ); - $status = $fedora_response->getStatusCode(); - if ($status != 200) { - $reason = $fedora_response->getReasonPhrase(); - throw new \RuntimeException( - "Client error: `GET $fedora_url` resulted in a `$status $reason` response: " . - $fedora_response->getBody(), - $status - ); - } - - // Strip off the W/ prefix to make the ETag strong. - $etags = $fedora_response->getHeader("ETag"); - $etag = ltrim(reset($etags), "W/"); - // Get the modified date from the RDF. - $fedora_jsonld = json_decode( - $fedora_response->getBody(), - true - ); - - // Account for the fact that new media haven't got a modified date - // pushed to it from Drupal yet. - try { - $fedora_modified = $this->getModifiedTimestamp( - $fedora_jsonld - ); - } catch (\RuntimeException $e) { - $fedora_modified = 0; - } - - // Get the jsonld from Drupal. - $headers = empty($token) ? [] : ['Authorization' => $token]; - $drupal_response = $this->drupal->get( + return $this->updateNode( $jsonld_url, - ['headers' => $headers] - ); - $drupal_jsonld = json_decode( - $drupal_response->getBody(), - true - ); - // Mash it into the shape Fedora accepts. - // Be sure to give it the URL of the file being described, not that of - // the RDF itself. - $drupal_jsonld = $this->processJsonld( - $drupal_jsonld, - $jsonld_url, - $fedora_url - ); - // Get the modified date from the RDF. - $drupal_modified = $this->getModifiedTimestamp( - $drupal_jsonld - ); - // Abort with 412 if the Drupal RDF is stale. - if ($drupal_modified <= $fedora_modified) { - throw new \RuntimeException( - "Not updating $fedora_url because RDF at $jsonld_url is not newer", - 412 - ); - } - // Conditional save it in Fedora. - $headers['Content-Type'] = 'application/ld+json'; - $headers['Prefer'] = 'return=minimal; handling=lenient'; - $headers['If-Match'] = $etag; - $response = $this->fedora->saveResource( $fedora_url, - json_encode($drupal_jsonld), - $headers + $token ); - $status = $response->getStatusCode(); - if (!in_array($status, [201, 204])) { - $reason = $response->getReasonPhrase(); - throw new \RuntimeException( - "Client error: `PUT $fedora_url` resulted in a `$status $reason` response: " . $response->getBody(), - $status - ); - } - // Return the response from Fedora. - return $response; } /** @@ -548,4 +476,52 @@ public function deleteNode( return new Response(isset($status) ? $status : 404); } + + /** + * {@inheritDoc} + */ + public function saveExternal( + $uuid, + $external_url, + $token = null + ) { + // Mint a new Fedora URL. + $fedora_url = $this->gemini->mintFedoraUrl($uuid, $token); + + $headers = empty($token) ? [] : ['Authorization' => $token]; + $mimetype = $this->drupal->head( + $external_url, + ['headers' => $headers] + )->getHeader('Content-Type')[0]; + + // Save it in Fedora as external content. + $external_rel = "http://fedora.info/definitions/fcrepo#ExternalContent"; + $link = '<' . $external_url . '>; rel="' . $external_rel . '"; handling="redirect"; type="' . $mimetype . '"'; + $headers['Link'] = $link; + $response = $this->fedora->saveResource( + $fedora_url, + null, + $headers + ); + + $status = $response->getStatusCode(); + if (!in_array($status, [201, 204])) { + $reason = $response->getReasonPhrase(); + throw new \RuntimeException( + "Client error: `PUT $fedora_url` resulted in a `$status $reason` response: " . $response->getBody(), + $status + ); + } + + // Map the URLS. + $this->gemini->saveUrls( + $uuid, + $external_url, + $fedora_url, + $token + ); + + // Return the response from Fedora. + return $response; + } } diff --git a/Milliner/src/Service/MillinerServiceInterface.php b/Milliner/src/Service/MillinerServiceInterface.php index 97d2cf8b..cf1ec8dd 100644 --- a/Milliner/src/Service/MillinerServiceInterface.php +++ b/Milliner/src/Service/MillinerServiceInterface.php @@ -50,4 +50,19 @@ public function deleteNode( $uuid, $token = null ); + + /** + * @param $uuid + * @param $external_url + * @param $token + * + * @throws \Exception + * + * @return \GuzzleHttp\Psr7\Response|null + */ + public function saveExternal( + $uuid, + $external_url, + $token = null + ); } diff --git a/Milliner/src/app.php b/Milliner/src/app.php index ccd76beb..1594bf80 100644 --- a/Milliner/src/app.php +++ b/Milliner/src/app.php @@ -37,5 +37,6 @@ $app->post('/node/{uuid}', "milliner.controller:saveNode"); $app->delete('/node/{uuid}', "milliner.controller:deleteNode"); $app->post('/media/{source_field}', "milliner.controller:saveMedia"); +$app->post('/external/{uuid}', "milliner.controller:saveExternal"); return $app; From 5bf22ef910822fc098aa9e009ccaba1c9a2aa67f Mon Sep 17 00:00:00 2001 From: dannylamb Date: Tue, 23 Apr 2019 18:42:20 +0000 Subject: [PATCH 3/6] Coding standards --- Milliner/src/Service/MillinerService.php | 6 +++--- Milliner/src/Service/MillinerServiceInterface.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Milliner/src/Service/MillinerService.php b/Milliner/src/Service/MillinerService.php index bd495c62..77101c97 100644 --- a/Milliner/src/Service/MillinerService.php +++ b/Milliner/src/Service/MillinerService.php @@ -481,9 +481,9 @@ public function deleteNode( * {@inheritDoc} */ public function saveExternal( - $uuid, - $external_url, - $token = null + $uuid, + $external_url, + $token = null ) { // Mint a new Fedora URL. $fedora_url = $this->gemini->mintFedoraUrl($uuid, $token); diff --git a/Milliner/src/Service/MillinerServiceInterface.php b/Milliner/src/Service/MillinerServiceInterface.php index cf1ec8dd..2c76373c 100644 --- a/Milliner/src/Service/MillinerServiceInterface.php +++ b/Milliner/src/Service/MillinerServiceInterface.php @@ -61,8 +61,8 @@ public function deleteNode( * @return \GuzzleHttp\Psr7\Response|null */ public function saveExternal( - $uuid, - $external_url, - $token = null + $uuid, + $external_url, + $token = null ); } From 94cf96adafe9c9c1ce129a34781b1a39f6986684 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Tue, 23 Apr 2019 19:37:44 +0000 Subject: [PATCH 4/6] Patching existing tests --- .../Milliner/Tests/SaveMediaTest.php | 74 ++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/Milliner/tests/Islandora/Milliner/Tests/SaveMediaTest.php b/Milliner/tests/Islandora/Milliner/Tests/SaveMediaTest.php index 924ff2b2..9c8b4fa4 100644 --- a/Milliner/tests/Islandora/Milliner/Tests/SaveMediaTest.php +++ b/Milliner/tests/Islandora/Milliner/Tests/SaveMediaTest.php @@ -187,16 +187,17 @@ public function testSaveMediaThrowsFedoraHeadError() $drupal = $this->prophesize(Client::class); $drupal->get(Argument::any(), Argument::any()) ->willReturn($drupal_response); + + $head_response = new Response(404); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn($head_response); $drupal = $drupal->reveal(); - $fedora_response = new Response(404); $fedora = $this->prophesize(IFedoraApi::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_response); $fedora = $fedora->reveal(); $mapping = [ - 'drupal' => 'http://localhost:8000/media/6?_format=jsonld', + 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', 'fedora' => 'http://localhost:8080/fcrepo/rest/ff/b1/5b/4f/ffb15b4f-54db-44ce-ad0b-3588889a3c9b', ]; $gemini = $this->prophesize(GeminiClient::class); @@ -239,16 +240,17 @@ public function testSaveMediaThrows500WhenNoDescribedbyHeader() $drupal = $this->prophesize(Client::class); $drupal->get(Argument::any(), Argument::any()) ->willReturn($drupal_response); + + $head_response = new Response(200); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn($head_response); $drupal = $drupal->reveal(); - $fedora_response = new Response(200); $fedora = $this->prophesize(IFedoraApi::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_response); $fedora = $fedora->reveal(); $mapping = [ - 'drupal' => 'http://localhost:8000/media/6?_format=jsonld', + 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', 'fedora' => 'http://localhost:8080/fcrepo/rest/ff/b1/5b/4f/ffb15b4f-54db-44ce-ad0b-3588889a3c9b', ]; $gemini = $this->prophesize(GeminiClient::class); @@ -291,26 +293,27 @@ public function testSaveMediaThrowsFedoraGetError() $drupal = $this->prophesize(Client::class); $drupal->get(Argument::any(), Argument::any()) ->willReturn($drupal_response); - $drupal = $drupal->reveal(); $link = ''; $link .= ';rel="describedby"'; - $fedora_head_response = new Response( + $head_response = new Response( 200, ['Link' => $link] ); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn($head_response); + $drupal = $drupal->reveal(); + $fedora_get_response = new Response( 404 ); $fedora = $this->prophesize(IFedoraApi::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_head_response); $fedora->getResource(Argument::any(), Argument::any()) ->willReturn($fedora_get_response); $fedora = $fedora->reveal(); $mapping = [ - 'drupal' => 'http://localhost:8000/media/6?_format=jsonld', + 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', 'fedora' => 'http://localhost:8080/fcrepo/rest/ff/b1/5b/4f/ffb15b4f-54db-44ce-ad0b-3588889a3c9b', ]; $gemini = $this->prophesize(GeminiClient::class); @@ -363,28 +366,29 @@ public function testSaveMediaThrows412OnStaleData() ->willReturn($drupal_json_response); $drupal->get('http://localhost:8000/media/6?_format=jsonld', Argument::any()) ->willReturn($drupal_jsonld_response); - $drupal = $drupal->reveal(); $link = ''; $link .= '; rel="describedby"'; - $fedora_head_response = new Response( + $head_response = new Response( 200, ['Link' => $link] ); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn($head_response); + $drupal = $drupal->reveal(); + $fedora_get_response = new Response( 200, ['Content-Type' => 'application/ld+json', 'ETag' => 'W\abc123'], file_get_contents(__DIR__ . '/../../../../static/MediaLDP-RS.jsonld') ); $fedora = $this->prophesize(IFedoraApi::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_head_response); $fedora->getResource(Argument::any(), Argument::any()) ->willReturn($fedora_get_response); $fedora = $fedora->reveal(); $mapping = [ - 'drupal' => 'http://localhost:8000/media/6?_format=jsonld', + 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', 'fedora' => 'http://localhost:8080/fcrepo/rest/ff/b1/5b/4f/ffb15b4f-54db-44ce-ad0b-3588889a3c9b', ]; $gemini = $this->prophesize(GeminiClient::class); @@ -437,14 +441,17 @@ public function testSaveMediaThrowsFedoraPutError() ->willReturn($drupal_json_response); $drupal->get('http://localhost:8000/media/6?_format=jsonld', Argument::any()) ->willReturn($drupal_jsonld_response); - $drupal = $drupal->reveal(); $link = ''; $link .= '; rel="describedby"'; - $fedora_head_response = new Response( + $head_response = new Response( 200, ['Link' => $link] ); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn($head_response); + $drupal = $drupal->reveal(); + $fedora_get_response = new Response( 200, ['Content-Type' => 'application/ld+json', 'ETag' => 'W\abc123'], @@ -454,8 +461,6 @@ public function testSaveMediaThrowsFedoraPutError() 403 ); $fedora = $this->prophesize(IFedoraApi::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_head_response); $fedora->getResource(Argument::any(), Argument::any()) ->willReturn($fedora_get_response); $fedora->saveResource(Argument::any(), Argument::any(), Argument::any()) @@ -463,7 +468,7 @@ public function testSaveMediaThrowsFedoraPutError() $fedora = $fedora->reveal(); $mapping = [ - 'drupal' => 'http://localhost:8000/media/6?_format=jsonld', + 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', 'fedora' => 'http://localhost:8080/fcrepo/rest/ff/b1/5b/4f/ffb15b4f-54db-44ce-ad0b-3588889a3c9b', ]; $gemini = $this->prophesize(GeminiClient::class); @@ -514,14 +519,17 @@ public function testSaveMediaReturnsFedoraSuccess() ->willReturn($drupal_json_response); $drupal->get('http://localhost:8000/media/6?_format=jsonld', Argument::any()) ->willReturn($drupal_jsonld_response); - $drupal = $drupal->reveal(); $link = ''; $link .= '; rel="describedby"'; - $fedora_head_response = new Response( + $head_response = new Response( 200, ['Link' => $link] ); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn($head_response); + $drupal = $drupal->reveal(); + $fedora_get_response = new Response( 200, ['Content-Type' => 'application/ld+json', 'ETag' => 'W\abc123'], @@ -531,8 +539,6 @@ public function testSaveMediaReturnsFedoraSuccess() 204 ); $fedora = $this->prophesize(IFedoraApi::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_head_response); $fedora->getResource(Argument::any(), Argument::any()) ->willReturn($fedora_get_response); $fedora->saveResource(Argument::any(), Argument::any(), Argument::any()) @@ -540,7 +546,7 @@ public function testSaveMediaReturnsFedoraSuccess() $fedora = $fedora->reveal(); $mapping = [ - 'drupal' => 'http://localhost:8000/media/6?_format=jsonld', + 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', 'fedora' => 'http://localhost:8080/fcrepo/rest/ff/b1/5b/4f/ffb15b4f-54db-44ce-ad0b-3588889a3c9b', ]; $gemini = $this->prophesize(GeminiClient::class); @@ -597,14 +603,18 @@ public function testSaveMediaReturnsNoModifiedDate() ->willReturn($drupal_json_response); $drupal->get('http://localhost:8000/media/6?_format=jsonld', Argument::any()) ->willReturn($drupal_jsonld_response); - $drupal = $drupal->reveal(); $link = ''; $link .= '; rel="describedby"'; - $fedora_head_response = new Response( + $head_response = new Response( 200, ['Link' => $link] ); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn($head_response); + + $drupal = $drupal->reveal(); + $fedora_get_response = new Response( 200, ['Content-Type' => 'application/ld+json', 'ETag' => 'W\abc123'], @@ -614,8 +624,6 @@ public function testSaveMediaReturnsNoModifiedDate() 204 ); $fedora = $this->prophesize(IFedoraApi::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_head_response); $fedora->getResource(Argument::any(), Argument::any()) ->willReturn($fedora_get_response); $fedora->saveResource(Argument::any(), Argument::any(), Argument::any()) @@ -623,7 +631,7 @@ public function testSaveMediaReturnsNoModifiedDate() $fedora = $fedora->reveal(); $mapping = [ - 'drupal' => 'http://localhost:8000/media/6?_format=jsonld', + 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', 'fedora' => 'http://localhost:8080/fcrepo/rest/ff/b1/5b/4f/ffb15b4f-54db-44ce-ad0b-3588889a3c9b', ]; $gemini = $this->prophesize(GeminiClient::class); From 8bd55fb0c3d5a14c04957c5d651af20064779886 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Thu, 25 Apr 2019 13:59:00 +0000 Subject: [PATCH 5/6] Updating tests --- .../Milliner/Tests/SaveExternalTest.php | 215 ++++++++++++++++++ .../Islandora/Milliner/Tests/SaveNodeTest.php | 44 ++++ 2 files changed, 259 insertions(+) create mode 100644 Milliner/tests/Islandora/Milliner/Tests/SaveExternalTest.php diff --git a/Milliner/tests/Islandora/Milliner/Tests/SaveExternalTest.php b/Milliner/tests/Islandora/Milliner/Tests/SaveExternalTest.php new file mode 100644 index 00000000..7cee8391 --- /dev/null +++ b/Milliner/tests/Islandora/Milliner/Tests/SaveExternalTest.php @@ -0,0 +1,215 @@ +logger = new Logger('milliner'); + $this->logger->pushHandler(new NullHandler()); + + $this->modifiedDatePredicate = "http://schema.org/dateModified"; + } + + /** + * @covers ::__construct + * @covers ::saveExternal + * @expectedException \GuzzleHttp\Exception\RequestException + * @expectedExceptionCode 403 + */ + public function testSaveExternalThrowsOnMintError() + { + $gemini = $this->prophesize(GeminiClient::class); + $gemini->mintFedoraUrl(Argument::any(), Argument::any()) + ->willThrow( + new RequestException( + "Unauthorized", + new Request('POST', 'http://localhost:8000/gemini'), + new Response(403, [], "Unauthorized") + ) + ); + $gemini = $gemini->reveal(); + + $drupal = $this->prophesize(Client::class); + $drupal = $drupal->reveal(); + + $fedora = $this->prophesize(IFedoraApi::class); + $fedora = $fedora->reveal(); + + $milliner = new MillinerService( + $fedora, + $drupal, + $gemini, + $this->logger, + $this->modifiedDatePredicate + ); + + $milliner->saveExternal( + "9541c0c1-5bee-4973-a9d0-e55c1658bc81", + 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', + "Bearer islandora" + ); + } + + /** + * @covers ::__construct + * @covers ::saveExternal + * @expectedException \GuzzleHttp\Exception\RequestException + * @expectedExceptionCode 403 + */ + public function testSaveExternalThrowsOnHeadError() + { + $url = "http://localhost:8080/95/41/c0/c1/9541c0c1-5bee-4973-a9d0-e55c1658bc81"; + $gemini = $this->prophesize(GeminiClient::class); + $gemini->mintFedoraUrl(Argument::any(), Argument::any()) + ->willReturn($url); + $gemini = $gemini->reveal(); + + $drupal = $this->prophesize(Client::class); + $drupal->head(Argument::any(), Argument::any()) + ->willThrow( + new RequestException( + "Unauthorized", + new Request('HEAD', 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg'), + new Response(403, [], null, "1.1", "UNAUTHORIZED") + ) + ); + $drupal = $drupal->reveal(); + + $fedora = $this->prophesize(IFedoraApi::class); + $fedora = $fedora->reveal(); + + $milliner = new MillinerService( + $fedora, + $drupal, + $gemini, + $this->logger, + $this->modifiedDatePredicate + ); + + $milliner->saveExternal( + "9541c0c1-5bee-4973-a9d0-e55c1658bc81", + 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', + "Bearer islandora" + ); + } + + /** + * @covers ::__construct + * @covers ::saveExternal + * @expectedException \RuntimeException + * @expectedExceptionCode 403 + */ + public function testSaveExternalThrowsOnPutError() + { + $url = "http://localhost:8080/95/41/c0/c1/9541c0c1-5bee-4973-a9d0-e55c1658bc81"; + $gemini = $this->prophesize(GeminiClient::class); + $gemini->mintFedoraUrl(Argument::any(), Argument::any()) + ->willReturn($url); + $gemini = $gemini->reveal(); + + $drupal = $this->prophesize(Client::class); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn(new Response(200, ['Content-Type' => 'image/jpeg'])); + $drupal = $drupal->reveal(); + + $fedora = $this->prophesize(IFedoraApi::class); + $fedora->saveResource(Argument::any(), Argument::any(), Argument::any()) + ->willReturn(new Response(403, [], null, "1.1", "UNAUTHORIZED")); + $fedora = $fedora->reveal(); + + $milliner = new MillinerService( + $fedora, + $drupal, + $gemini, + $this->logger, + $this->modifiedDatePredicate + ); + + $milliner->saveExternal( + "9541c0c1-5bee-4973-a9d0-e55c1658bc81", + 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', + "Bearer islandora" + ); + } + + /** + * @covers ::__construct + * @covers ::saveExternal + * @expectedException \GuzzleHttp\Exception\RequestException + * @expectedExceptionCode 403 + */ + public function testSaveExternalThrowsOnGeminiError() + { + $url = "http://localhost:8080/95/41/c0/c1/9541c0c1-5bee-4973-a9d0-e55c1658bc81"; + $gemini = $this->prophesize(GeminiClient::class); + $gemini->mintFedoraUrl(Argument::any(), Argument::any()) + ->willReturn($url); + $gemini->saveUrls(Argument::any(), Argument::any(), Argument::any(), Argument::any()) + ->willThrow( + new RequestException( + "Unauthorized", + new Request('PUT', 'http://localhost:8000/gemini/9541c0c1-5bee-4973-a9d0-e55c1658bc81'), + new Response(403, [], "Unauthorized") + ) + ); + $gemini = $gemini->reveal(); + + $drupal = $this->prophesize(Client::class); + $drupal->head(Argument::any(), Argument::any()) + ->willReturn(new Response(200, ['Content-Type' => 'image/jpeg'])); + $drupal = $drupal->reveal(); + + $fedora = $this->prophesize(IFedoraApi::class); + $fedora->saveResource(Argument::any(), Argument::any(), Argument::any()) + ->willReturn(new Response(201)); + $fedora = $fedora->reveal(); + + $milliner = new MillinerService( + $fedora, + $drupal, + $gemini, + $this->logger, + $this->modifiedDatePredicate + ); + + $milliner->saveExternal( + "9541c0c1-5bee-4973-a9d0-e55c1658bc81", + 'http://localhost:8000/sites/default/files/2017-07/sample_0.jpeg', + "Bearer islandora" + ); + } +} diff --git a/Milliner/tests/Islandora/Milliner/Tests/SaveNodeTest.php b/Milliner/tests/Islandora/Milliner/Tests/SaveNodeTest.php index 8e49d0d5..66cd3918 100644 --- a/Milliner/tests/Islandora/Milliner/Tests/SaveNodeTest.php +++ b/Milliner/tests/Islandora/Milliner/Tests/SaveNodeTest.php @@ -4,6 +4,8 @@ use GuzzleHttp\Client; use GuzzleHttp\Psr7\Response; +use GuzzleHttp\Psr7\Request; +use GuzzleHttp\Exception\RequestException; use Islandora\Chullo\IFedoraApi; use Islandora\Crayfish\Commons\Client\GeminiClient; use Islandora\Milliner\Service\MillinerService; @@ -42,6 +44,48 @@ protected function setUp() $this->modifiedDatePredicate = "http://schema.org/dateModified"; } + /** + * @covers ::__construct + * @covers ::saveNode + * @expectedException \GuzzleHttp\Exception\RequestException + * @expectedExceptionCode 403 + */ + public function testCreateNodeThrowsOnMintError() + { + $gemini = $this->prophesize(GeminiClient::class); + $gemini->getUrls(Argument::any(), Argument::any()) + ->willReturn([]); + $gemini->mintFedoraUrl(Argument::any(), Argument::any()) + ->willThrow( + new RequestException( + "Unauthorized", + new Request('POST', 'http://localhost:8000/gemini'), + new Response(403, [], "Unauthorized") + ) + ); + $gemini = $gemini->reveal(); + + $drupal = $this->prophesize(Client::class); + $drupal = $drupal->reveal(); + + $fedora = $this->prophesize(IFedoraApi::class); + $fedora = $fedora->reveal(); + + $milliner = new MillinerService( + $fedora, + $drupal, + $gemini, + $this->logger, + $this->modifiedDatePredicate + ); + + $milliner->saveNode( + "9541c0c1-5bee-4973-a9d0-e55c1658bc81", + "http://localhost:8000/node/1?_format=jsonld", + "Bearer islandora" + ); + } + /** * @covers ::__construct * @covers ::saveNode From 4132791206d5d18174fba34c3bb3b62fca7c79b8 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Thu, 25 Apr 2019 14:45:23 +0000 Subject: [PATCH 6/6] Controller tests --- .../src/Controller/MillinerController.php | 9 +- .../Milliner/Tests/MillinerControllerTest.php | 124 ++++++++++++++++-- 2 files changed, 120 insertions(+), 13 deletions(-) diff --git a/Milliner/src/Controller/MillinerController.php b/Milliner/src/Controller/MillinerController.php index 64dfacc9..35fba721 100644 --- a/Milliner/src/Controller/MillinerController.php +++ b/Milliner/src/Controller/MillinerController.php @@ -62,7 +62,8 @@ public function saveNode($uuid, Request $request) ); } catch (\Exception $e) { $this->log->error("", ['Exception' => $e]); - return new Response($e->getMessage(), $e->getCode()); + $code = $e->getCode() == 0 ? 500 : $e->getCode(); + return new Response($e->getMessage(), $code); } } @@ -87,7 +88,8 @@ public function deleteNode($uuid, Request $request) ); } catch (\Exception $e) { $this->log->error("", ['Exception' => $e]); - return new Response($e->getMessage(), $e->getCode()); + $code = $e->getCode() == 0 ? 500 : $e->getCode(); + return new Response($e->getMessage(), $code); } } @@ -150,7 +152,8 @@ public function saveExternal($uuid, Request $request) ); } catch (\Exception $e) { $this->log->error("", ['Exception' => $e]); - return new Response($e->getMessage(), $e->getCode()); + $code = $e->getCode() == 0 ? 500 : $e->getCode(); + return new Response($e->getMessage(), $code); } } } diff --git a/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php b/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php index ab590edc..ec1f6e9a 100644 --- a/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php +++ b/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php @@ -50,6 +50,8 @@ public function testMethodsReturnMillinerErrors() ->willThrow(new \Exception("Forbidden", 403)); $milliner->deleteNode(Argument::any(), Argument::any()) ->willThrow(new \Exception("Forbidden", 403)); + $milliner->saveExternal(Argument::any(), Argument::any(), Argument::any()) + ->willThrow(new \Exception("Forbidden", 403)); $milliner = $milliner->reveal(); $controller = new MillinerController($milliner, $this->logger); @@ -66,7 +68,7 @@ public function testMethodsReturnMillinerErrors() [], [], [ - 'Authorization' => 'Bearer islandora', + 'HTTP_AUTHORIZATION' => 'Bearer islandora', 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/node/1?_format=jsonld', ] ); @@ -85,7 +87,7 @@ public function testMethodsReturnMillinerErrors() [], [], [ - 'Authorization' => 'Bearer islandora', + 'HTTP_AUTHORIZATION' => 'Bearer islandora', 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/media/6?_format=json', ] ); @@ -103,7 +105,7 @@ public function testMethodsReturnMillinerErrors() ['uuid' => $uuid], [], [], - ['Authorization' => 'Bearer islandora'] + ['HTTP_AUTHORIZATION' => 'Bearer islandora'] ); $response = $controller->deleteNode($uuid, $request); $status = $response->getStatusCode(); @@ -111,6 +113,25 @@ public function testMethodsReturnMillinerErrors() $status == 403, "Response code must be that of thrown exception. Expected 403, received $status" ); + + // External. + $request = Request::create( + "http://localhost:8000/milliner/external/$uuid", + "POST", + ['uuid' => $uuid], + [], + [], + [ + 'HTTP_AUTHORIZATION' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/sites/default/files/1.jpg', + ] + ); + $response = $controller->saveExternal($uuid, $request); + $status = $response->getStatusCode(); + $this->assertTrue( + $status == 403, + "Response code must be that of thrown exception. Expected 403, received $status" + ); } /** @@ -129,7 +150,7 @@ public function testSaveNodeReturns400WithoutContentLocation() ['uuid' => $uuid], [], [], - ['Authorization' => 'Bearer islandora'] + ['HTTP_AUTHORIZATION' => 'Bearer islandora'] ); $response = $controller->saveNode($uuid, $request); $status = $response->getStatusCode(); @@ -156,7 +177,7 @@ public function testSaveMediaReturn400WithoutContentLocation() ['source_field' => $source_field], [], [], - ['Authorization' => 'Bearer islandora'] + ['HTTP_AUTHORIZATION' => 'Bearer islandora'] ); $response = $controller->saveMedia($source_field, $request); $status = $response->getStatusCode(); @@ -166,6 +187,32 @@ public function testSaveMediaReturn400WithoutContentLocation() ); } + /** + * @covers ::__construct + * @covers ::saveExternal + */ + public function testSaveExternalReturns400WithoutContentLocation() + { + $milliner = $this->prophesize(MillinerServiceInterface::class)->reveal(); + $controller = new MillinerController($milliner, $this->logger); + + $uuid = "abc123"; + $request = Request::create( + "http://localhost:8000/milliner/external/$uuid", + "POST", + ['uuid' => $uuid], + [], + [], + ['HTTP_AUTHORIZATION' => 'Bearer islandora'] + ); + $response = $controller->saveExternal($uuid, $request); + $status = $response->getStatusCode(); + $this->assertTrue( + $status == 400, + "Response code must be 400 when no Content-Location header is present. Received: $status" + ); + } + /** * @covers ::__construct * @covers ::saveNode @@ -187,7 +234,7 @@ public function testSaveNodeReturnsSuccessOnSuccess() [], [], [ - 'Authorization' => 'Bearer islandora', + 'HTTP_AUTHORIZATION' => 'Bearer islandora', 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/node/1?_format=jsonld', ] ); @@ -211,7 +258,7 @@ public function testSaveNodeReturnsSuccessOnSuccess() [], [], [ - 'Authorization' => 'Bearer islandora', + 'HTTP_AUTHORIZATION' => 'Bearer islandora', 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/node/1?_format=jsonld', ] ); @@ -243,7 +290,7 @@ public function testSaveMediaReturnsSuccessOnSuccess() [], [], [ - 'Authorization' => 'Bearer islandora', + 'HTTP_AUTHORIZATION' => 'Bearer islandora', 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/media/6?_format=json', ] ); @@ -267,7 +314,7 @@ public function testSaveMediaReturnsSuccessOnSuccess() [], [], [ - 'Authorization' => 'Bearer islandora', + 'HTTP_AUTHORIZATION' => 'Bearer islandora', 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/media/6?_format=json', ] ); @@ -279,6 +326,63 @@ public function testSaveMediaReturnsSuccessOnSuccess() ); } + /** + * @covers ::__construct + * @covers ::saveExternal + */ + public function testSaveExternalReturnsSuccessOnSuccess() + { + $milliner = $this->prophesize(MillinerServiceInterface::class); + $milliner->saveExternal(Argument::any(), Argument::any(), Argument::any()) + ->willReturn(new Response(201)); + $milliner = $milliner->reveal(); + $controller = new MillinerController($milliner, $this->logger); + + // Nodes. + $uuid = "abc123"; + $request = Request::create( + "http://localhost:8000/milliner/external/$uuid", + "POST", + ['uuid' => $uuid], + [], + [], + [ + 'HTTP_AUTHORIZATION' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/sites/default/files/1.jpeg', + ] + ); + $response = $controller->saveExternal($uuid, $request); + $status = $response->getStatusCode(); + $this->assertTrue( + $status == 201, + "Response code must be 201 when milliner returns 201. Received: $status" + ); + + $milliner = $this->prophesize(MillinerServiceInterface::class); + $milliner->saveExternal(Argument::any(), Argument::any(), Argument::any()) + ->willReturn(new Response(204)); + $milliner = $milliner->reveal(); + $controller = new MillinerController($milliner, $this->logger); + + $request = Request::create( + "http://localhost:8000/milliner/external/$uuid", + "POST", + ['uuid' => $uuid], + [], + [], + [ + 'HTTP_AUTHORIZATION' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/sites/default/files/1.jpeg', + ] + ); + $response = $controller->saveExternal($uuid, $request); + $status = $response->getStatusCode(); + $this->assertTrue( + $status == 204, + "Response code must be 204 when milliner returns 204. Received: $status" + ); + } + /** * @covers ::__construct * @covers ::deleteNode @@ -298,7 +402,7 @@ public function testDeleteReturnsSuccessOnSuccess() ['uuid' => $uuid], [], [], - ['Authorization' => 'Bearer islandora'] + ['HTTP_AUTHORIZATION' => 'Bearer islandora'] ); $response = $controller->deleteNode($uuid, $request);