diff --git a/.travis.yml b/.travis.yml index e177aba8..4bc98b0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ sudo: true language: php php: - - 5.6 - - 7.0 - 7.1 + - 7.2 matrix: fast_finish: true @@ -17,7 +16,6 @@ before_install: install: - git clone https://github.com/Islandora-CLAW/CLAW.git $HOME/CLAW - - $SCRIPT_DIR/travis_setup_php.sh - for D in */; do (cd $D; composer install) done script: diff --git a/Milliner/composer.lock b/Milliner/composer.lock index fe9237b0..56d7aad5 100644 --- a/Milliner/composer.lock +++ b/Milliner/composer.lock @@ -1,7 +1,7 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "97d026ae3ad1a955ac05743a60324ae5", @@ -357,33 +357,33 @@ }, { "name": "doctrine/inflector", - "version": "v1.1.0", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "90b2128806bfde671b6952ab8bea493942c1fdae" + "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", - "reference": "90b2128806bfde671b6952ab8bea493942c1fdae", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/e11d84c6e018beedd929cff5220969a3c6d1d462", + "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "4.*" + "phpunit/phpunit": "^6.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Inflector\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector" } }, "notification-url": "https://packagist.org/downloads/", @@ -420,7 +420,7 @@ "singularize", "string" ], - "time": "2015-11-06T14:35:42+00:00" + "time": "2017-07-22T12:18:28+00:00" }, { "name": "doctrine/lexer", @@ -540,16 +540,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.3.0", + "version": "6.3.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699" + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699", - "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", "shasum": "" }, "require": { @@ -559,7 +559,7 @@ }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "^4.0 || ^5.0", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", "psr/log": "^1.0" }, "suggest": { @@ -568,7 +568,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2-dev" + "dev-master": "6.3-dev" } }, "autoload": { @@ -601,7 +601,7 @@ "rest", "web service" ], - "time": "2017-06-22T18:50:49+00:00" + "time": "2018-04-22T15:46:56+00:00" }, { "name": "guzzlehttp/promises", @@ -781,12 +781,12 @@ "source": { "type": "git", "url": "https://github.com/Islandora-CLAW/Crayfish-Commons.git", - "reference": "38657d33f959b8bdeb59e8f7f4aa6012db2160e7" + "reference": "9434f75659af2abaf433436d1aa847de4416d8ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Islandora-CLAW/Crayfish-Commons/zipball/38657d33f959b8bdeb59e8f7f4aa6012db2160e7", - "reference": "38657d33f959b8bdeb59e8f7f4aa6012db2160e7", + "url": "https://api.github.com/repos/Islandora-CLAW/Crayfish-Commons/zipball/9434f75659af2abaf433436d1aa847de4416d8ae", + "reference": "9434f75659af2abaf433436d1aa847de4416d8ae", "shasum": "" }, "require": { @@ -830,7 +830,7 @@ } ], "description": "Shared code amongst Islandora Crayfish microservices", - "time": "2017-09-21T17:12:48+00:00" + "time": "2017-11-22T19:09:46+00:00" }, { "name": "ml/iri", @@ -881,17 +881,17 @@ }, { "name": "ml/json-ld", - "version": "1.0.7", + "version": "1.0.8", "target-dir": "ML/JsonLD", "source": { "type": "git", "url": "https://github.com/lanthaler/JsonLD.git", - "reference": "f9dfe184f0da9ce0e0ffdddabf6d93d01787ac91" + "reference": "da8efc590273f0420e79cb110778508875690bde" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lanthaler/JsonLD/zipball/f9dfe184f0da9ce0e0ffdddabf6d93d01787ac91", - "reference": "f9dfe184f0da9ce0e0ffdddabf6d93d01787ac91", + "url": "https://api.github.com/repos/lanthaler/JsonLD/zipball/da8efc590273f0420e79cb110778508875690bde", + "reference": "da8efc590273f0420e79cb110778508875690bde", "shasum": "" }, "require": { @@ -900,7 +900,8 @@ "php": ">=5.3.0" }, "require-dev": { - "json-ld/tests": "@dev" + "json-ld/tests": "1.0", + "phpunit/phpunit": "^4" }, "type": "library", "autoload": { @@ -926,7 +927,7 @@ "JSON-LD", "jsonld" ], - "time": "2016-10-10T08:57:56+00:00" + "time": "2018-01-28T12:53:52+00:00" }, { "name": "monolog/monolog", @@ -1071,16 +1072,16 @@ }, { "name": "paragonie/random_compat", - "version": "v2.0.11", + "version": "v2.0.17", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8" + "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/5da4d3c796c275c55f057af5a643ae297d96b4d8", - "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/29af24f25bab834fcbb38ad2a69fa93b867e070d", + "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d", "shasum": "" }, "require": { @@ -1112,23 +1113,24 @@ "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", "keywords": [ "csprng", + "polyfill", "pseudorandom", "random" ], - "time": "2017-09-27T21:40:39+00:00" + "time": "2018-07-04T16:31:37+00:00" }, { "name": "pimple/pimple", - "version": "v3.2.2", + "version": "v3.2.3", "source": { "type": "git", "url": "https://github.com/silexphp/Pimple.git", - "reference": "4d45fb62d96418396ec58ba76e6f065bca16e10a" + "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/4d45fb62d96418396ec58ba76e6f065bca16e10a", - "reference": "4d45fb62d96418396ec58ba76e6f065bca16e10a", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32", + "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32", "shasum": "" }, "require": { @@ -1165,7 +1167,7 @@ "container", "dependency injection" ], - "time": "2017-07-23T07:32:15+00:00" + "time": "2018-01-21T07:42:36+00:00" }, { "name": "psr/container", @@ -1315,16 +1317,16 @@ }, { "name": "silex/silex", - "version": "v2.2.0", + "version": "v2.2.4", "source": { "type": "git", "url": "https://github.com/silexphp/Silex.git", - "reference": "ec7d5b5334465414952d4b2e935e73bd085dbbbb" + "reference": "d2531e5b8099c429b752ad2154e85999c3689057" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/silexphp/Silex/zipball/ec7d5b5334465414952d4b2e935e73bd085dbbbb", - "reference": "ec7d5b5334465414952d4b2e935e73bd085dbbbb", + "url": "https://api.github.com/repos/silexphp/Silex/zipball/d2531e5b8099c429b752ad2154e85999c3689057", + "reference": "d2531e5b8099c429b752ad2154e85999c3689057", "shasum": "" }, "require": { @@ -1400,20 +1402,20 @@ "keywords": [ "microframework" ], - "time": "2017-07-23T07:40:14+00:00" + "time": "2018-03-16T23:34:20+00:00" }, { "name": "symfony/debug", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd" + "reference": "0e3ca9cbde90fffec8038f4d4e16fd4046bbd018" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd", - "reference": "eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd", + "url": "https://api.github.com/repos/symfony/debug/zipball/0e3ca9cbde90fffec8038f4d4e16fd4046bbd018", + "reference": "0e3ca9cbde90fffec8038f4d4e16fd4046bbd018", "shasum": "" }, "require": { @@ -1424,12 +1426,12 @@ "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" }, "require-dev": { - "symfony/http-kernel": "~2.8|~3.0" + "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1456,20 +1458,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2018-06-26T08:45:54+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d7ba037e4b8221956ab1e221c73c9e27e05dd423" + "reference": "fdd5abcebd1061ec647089c6c41a07ed60af09f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d7ba037e4b8221956ab1e221c73c9e27e05dd423", - "reference": "d7ba037e4b8221956ab1e221c73c9e27e05dd423", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/fdd5abcebd1061ec647089c6c41a07ed60af09f8", + "reference": "fdd5abcebd1061ec647089c6c41a07ed60af09f8", "shasum": "" }, "require": { @@ -1480,10 +1482,10 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~3.3", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/dependency-injection": "", @@ -1492,7 +1494,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1519,7 +1521,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2018-04-06T07:35:25+00:00" }, { "name": "symfony/http-foundation", @@ -1576,7 +1578,7 @@ }, { "name": "symfony/http-kernel", - "version": "v3.2.13", + "version": "v3.2.14", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", @@ -1659,25 +1661,26 @@ }, { "name": "symfony/inflector", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/inflector.git", - "reference": "0474dc4d867c7efefd44017f7903465a7f368b6b" + "reference": "bc27e8f793a571313132923b5ad10fdf2843e26c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/inflector/zipball/0474dc4d867c7efefd44017f7903465a7f368b6b", - "reference": "0474dc4d867c7efefd44017f7903465a7f368b6b", + "url": "https://api.github.com/repos/symfony/inflector/zipball/bc27e8f793a571313132923b5ad10fdf2843e26c", + "reference": "bc27e8f793a571313132923b5ad10fdf2843e26c", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1712,20 +1715,75 @@ "symfony", "words" ], - "time": "2017-07-29T21:54:42+00:00" + "time": "2018-05-01T22:53:27+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.8.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-04-30T19:57:29+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.6.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" + "reference": "3296adf6a6454a050679cde90f95350ad604b171" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/3296adf6a6454a050679cde90f95350ad604b171", + "reference": "3296adf6a6454a050679cde90f95350ad604b171", "shasum": "" }, "require": { @@ -1737,7 +1795,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -1771,20 +1829,20 @@ "portable", "shim" ], - "time": "2017-10-11T12:05:26+00:00" + "time": "2018-04-26T10:06:28+00:00" }, { "name": "symfony/polyfill-php56", - "version": "v1.6.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "265fc96795492430762c29be291a371494ba3a5b" + "reference": "af98553c84912459db3f636329567809d639a8f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/265fc96795492430762c29be291a371494ba3a5b", - "reference": "265fc96795492430762c29be291a371494ba3a5b", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/af98553c84912459db3f636329567809d639a8f6", + "reference": "af98553c84912459db3f636329567809d639a8f6", "shasum": "" }, "require": { @@ -1794,7 +1852,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -1827,20 +1885,20 @@ "portable", "shim" ], - "time": "2017-10-11T12:05:26+00:00" + "time": "2018-04-26T10:06:28+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.6.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff" + "reference": "77454693d8f10dd23bb24955cffd2d82db1007a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff", - "reference": "0442b9c0596610bd24ae7b5f0a6cdbbc16d9fcff", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/77454693d8f10dd23bb24955cffd2d82db1007a6", + "reference": "77454693d8f10dd23bb24955cffd2d82db1007a6", "shasum": "" }, "require": { @@ -1850,7 +1908,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -1886,20 +1944,20 @@ "portable", "shim" ], - "time": "2017-10-11T12:05:26+00:00" + "time": "2018-04-26T10:06:28+00:00" }, { "name": "symfony/polyfill-util", - "version": "v1.6.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-util.git", - "reference": "6e719200c8e540e0c0effeb31f96bdb344b94176" + "reference": "1a5ad95d9436cbff3296034fe9f8d586dce3fb3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/6e719200c8e540e0c0effeb31f96bdb344b94176", - "reference": "6e719200c8e540e0c0effeb31f96bdb344b94176", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/1a5ad95d9436cbff3296034fe9f8d586dce3fb3a", + "reference": "1a5ad95d9436cbff3296034fe9f8d586dce3fb3a", "shasum": "" }, "require": { @@ -1908,7 +1966,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -1938,29 +1996,29 @@ "polyfill", "shim" ], - "time": "2017-10-11T12:05:26+00:00" + "time": "2018-04-26T10:06:28+00:00" }, { "name": "symfony/property-access", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/property-access.git", - "reference": "8d975b77d10ad8c24a7b88af1b38b333d2d4fa4b" + "reference": "a6e8c778b220dfd5cd5f5dcb09f87ee232dd608a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-access/zipball/8d975b77d10ad8c24a7b88af1b38b333d2d4fa4b", - "reference": "8d975b77d10ad8c24a7b88af1b38b333d2d4fa4b", + "url": "https://api.github.com/repos/symfony/property-access/zipball/a6e8c778b220dfd5cd5f5dcb09f87ee232dd608a", + "reference": "a6e8c778b220dfd5cd5f5dcb09f87ee232dd608a", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", - "symfony/inflector": "~3.1", + "symfony/inflector": "~3.1|~4.0", "symfony/polyfill-php70": "~1.0" }, "require-dev": { - "symfony/cache": "~3.1" + "symfony/cache": "~3.1|~4.0" }, "suggest": { "psr/cache-implementation": "To cache access methods." @@ -1968,7 +2026,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2006,39 +2064,38 @@ "property path", "reflection" ], - "time": "2017-10-02T06:42:24+00:00" + "time": "2018-01-03T07:37:34+00:00" }, { "name": "symfony/routing", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "2e26fa63da029dab49bf9377b3b4f60a8fecb009" + "reference": "6b9fef5343828e542db17e2519722ef08992f2c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/2e26fa63da029dab49bf9377b3b4f60a8fecb009", - "reference": "2e26fa63da029dab49bf9377b3b4f60a8fecb009", + "url": "https://api.github.com/repos/symfony/routing/zipball/6b9fef5343828e542db17e2519722ef08992f2c1", + "reference": "6b9fef5343828e542db17e2519722ef08992f2c1", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8" }, "conflict": { - "symfony/config": "<2.8", + "symfony/config": "<3.3.1", "symfony/dependency-injection": "<3.3", - "symfony/yaml": "<3.3" + "symfony/yaml": "<3.4" }, "require-dev": { "doctrine/annotations": "~1.0", - "doctrine/common": "~2.2", "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~3.3", - "symfony/expression-language": "~2.8|~3.0", - "symfony/http-foundation": "~2.8|~3.0", - "symfony/yaml": "~3.3" + "symfony/config": "^3.3.1|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/http-foundation": "~2.8|~3.0|~4.0", + "symfony/yaml": "~3.4|~4.0" }, "suggest": { "doctrine/annotations": "For using the annotation loader", @@ -2051,7 +2108,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2084,7 +2141,7 @@ "uri", "url" ], - "time": "2017-10-02T07:25:00+00:00" + "time": "2018-06-19T20:52:10+00:00" }, { "name": "symfony/security", @@ -2166,23 +2223,27 @@ }, { "name": "symfony/yaml", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "8c7bf1e7d5d6b05a690b715729cb4cd0c0a99c46" + "reference": "c5010cc1692ce1fa328b1fb666961eb3d4a85bb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/8c7bf1e7d5d6b05a690b715729cb4cd0c0a99c46", - "reference": "8c7bf1e7d5d6b05a690b715729cb4cd0c0a99c46", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c5010cc1692ce1fa328b1fb666961eb3d4a85bb0", + "reference": "c5010cc1692ce1fa328b1fb666961eb3d4a85bb0", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" }, "require-dev": { - "symfony/console": "~2.8|~3.0" + "symfony/console": "~3.4|~4.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -2190,7 +2251,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -2217,7 +2278,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-10-05T14:43:42+00:00" + "time": "2018-05-03T23:18:14+00:00" } ], "packages-dev": [ @@ -2376,29 +2437,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.2.2", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/4aada1f93c72c35e22fb1383b47fee43b8f1d157", - "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.3.0", + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -2417,20 +2484,20 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-08T06:39:58+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.3.0", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773" + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fb3933512008d8162b3cdf9e18dba9309b7c3773", - "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { @@ -2464,32 +2531,32 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-06-03T08:32:36+00:00" + "time": "2017-07-14T14:27:02+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.7.2", + "version": "1.7.6", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712", + "reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" }, "type": "library", "extra": { @@ -2527,7 +2594,7 @@ "spy", "stub" ], - "time": "2017-09-04T11:05:03+00:00" + "time": "2018-04-18T13:57:24+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2594,16 +2661,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "1.4.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", "shasum": "" }, "require": { @@ -2637,7 +2704,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -2731,29 +2798,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.2.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2776,20 +2843,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.23", + "version": "5.7.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "78532d5269d984660080d8e0f4c99c5c2ea65ffe" + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/78532d5269d984660080d8e0f4c99c5c2ea65ffe", - "reference": "78532d5269d984660080d8e0f4c99c5c2ea65ffe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", "shasum": "" }, "require": { @@ -2813,8 +2880,8 @@ "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", - "symfony/yaml": "~2.1|~3.0" + "sebastian/version": "^1.0.6|^2.0.1", + "symfony/yaml": "~2.1|~3.0|~4.0" }, "conflict": { "phpdocumentor/reflection-docblock": "3.0.2" @@ -2858,7 +2925,7 @@ "testing", "xunit" ], - "time": "2017-10-15T06:13:55+00:00" + "time": "2018-02-01T05:50:59+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -3199,20 +3266,20 @@ }, { "name": "sebastian/finder-facade", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/finder-facade.git", - "reference": "2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9" + "reference": "4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9", - "reference": "2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9", + "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f", + "reference": "4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f", "shasum": "" }, "require": { - "symfony/finder": "~2.3|~3.0", + "symfony/finder": "~2.3|~3.0|~4.0", "theseer/fdomdocument": "~1.3" }, "type": "library", @@ -3234,7 +3301,7 @@ ], "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.", "homepage": "https://github.com/sebastianbergmann/finder-facade", - "time": "2016-02-17T07:02:23+00:00" + "time": "2017-11-18T17:31:49+00:00" }, { "name": "sebastian/global-state", @@ -3335,24 +3402,24 @@ }, { "name": "sebastian/phpcpd", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpcpd.git", - "reference": "d7006078b75a34c9250831c3453a2e256a687615" + "reference": "dfed51c1288790fc957c9433e2f49ab152e8a564" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/d7006078b75a34c9250831c3453a2e256a687615", - "reference": "d7006078b75a34c9250831c3453a2e256a687615", + "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/dfed51c1288790fc957c9433e2f49ab152e8a564", + "reference": "dfed51c1288790fc957c9433e2f49ab152e8a564", "shasum": "" }, "require": { "php": "^5.6|^7.0", "phpunit/php-timer": "^1.0.6", "sebastian/finder-facade": "^1.1", - "sebastian/version": "^2.0", - "symfony/console": "^3.0" + "sebastian/version": "^1.0|^2.0", + "symfony/console": "^2.7|^3.0|^4.0" }, "bin": [ "phpcpd" @@ -3381,7 +3448,7 @@ ], "description": "Copy/Paste Detector (CPD) for PHP code.", "homepage": "https://github.com/sebastianbergmann/phpcpd", - "time": "2017-02-05T07:48:01+00:00" + "time": "2017-11-16T08:49:28+00:00" }, { "name": "sebastian/recursion-context", @@ -3601,25 +3668,25 @@ }, { "name": "symfony/browser-kit", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "317d5bdf0127f06db7ea294186132b4f5b036839" + "reference": "840bb6f0d5b3701fd768b68adf7193c2d0f98f79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/317d5bdf0127f06db7ea294186132b4f5b036839", - "reference": "317d5bdf0127f06db7ea294186132b4f5b036839", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/840bb6f0d5b3701fd768b68adf7193c2d0f98f79", + "reference": "840bb6f0d5b3701fd768b68adf7193c2d0f98f79", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", - "symfony/dom-crawler": "~2.8|~3.0" + "symfony/dom-crawler": "~2.8|~3.0|~4.0" }, "require-dev": { - "symfony/css-selector": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/css-selector": "~2.8|~3.0|~4.0", + "symfony/process": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/process": "" @@ -3627,7 +3694,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3654,48 +3721,49 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2018-03-19T22:32:39+00:00" }, { "name": "symfony/console", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "116bc56e45a8e5572e51eb43ab58c769a352366c" + "reference": "e54f84c50e3b12972e7750edfc5ca84b2284c44e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/116bc56e45a8e5572e51eb43ab58c769a352366c", - "reference": "116bc56e45a8e5572e51eb43ab58c769a352366c", + "url": "https://api.github.com/repos/symfony/console/zipball/e54f84c50e3b12972e7750edfc5ca84b2284c44e", + "reference": "e54f84c50e3b12972e7750edfc5ca84b2284c44e", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0", + "symfony/debug": "~2.8|~3.0|~4.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/dependency-injection": "<3.3" + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3", - "symfony/dependency-injection": "~3.3", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/filesystem": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" }, "suggest": { - "psr/log": "For using the console logger", + "psr/log-implementation": "For using the console logger", "symfony/event-dispatcher": "", - "symfony/filesystem": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3722,20 +3790,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2018-07-10T14:02:11+00:00" }, { "name": "symfony/css-selector", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "07447650225ca9223bd5c97180fe7c8267f7d332" + "reference": "d2ce52290b648ae33b5301d09bc14ee378612914" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/07447650225ca9223bd5c97180fe7c8267f7d332", - "reference": "07447650225ca9223bd5c97180fe7c8267f7d332", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/d2ce52290b648ae33b5301d09bc14ee378612914", + "reference": "d2ce52290b648ae33b5301d09bc14ee378612914", "shasum": "" }, "require": { @@ -3744,7 +3812,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3775,28 +3843,29 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2018-05-16T12:49:49+00:00" }, { "name": "symfony/dom-crawler", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "40dafd42d5dad7fe5ad4e958413d92a207522ac1" + "reference": "54c9e817b74c7be1840344bf4feaa7a7d02abfb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/40dafd42d5dad7fe5ad4e958413d92a207522ac1", - "reference": "40dafd42d5dad7fe5ad4e958413d92a207522ac1", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/54c9e817b74c7be1840344bf4feaa7a7d02abfb8", + "reference": "54c9e817b74c7be1840344bf4feaa7a7d02abfb8", "shasum": "" }, "require": { "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { - "symfony/css-selector": "~2.8|~3.0" + "symfony/css-selector": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/css-selector": "" @@ -3804,7 +3873,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3831,20 +3900,20 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2018-07-05T11:53:23+00:00" }, { "name": "symfony/finder", - "version": "v3.3.10", + "version": "v3.4.13", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "773e19a491d97926f236942484cb541560ce862d" + "reference": "3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/773e19a491d97926f236942484cb541560ce862d", - "reference": "773e19a491d97926f236942484cb541560ce862d", + "url": "https://api.github.com/repos/symfony/finder/zipball/3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394", + "reference": "3a8c3de91d2b2c68cd2d665cf9d00f7ef9eaa394", "shasum": "" }, "require": { @@ -3853,7 +3922,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3880,7 +3949,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2018-06-19T20:52:10+00:00" }, { "name": "theseer/fdomdocument", @@ -3924,16 +3993,16 @@ }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { @@ -3970,7 +4039,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], diff --git a/Milliner/src/Controller/MillinerController.php b/Milliner/src/Controller/MillinerController.php index 95e533c1..74835f9a 100644 --- a/Milliner/src/Controller/MillinerController.php +++ b/Milliner/src/Controller/MillinerController.php @@ -36,40 +36,21 @@ public function __construct(MillinerServiceInterface $milliner, LoggerInterface } /** + * @param string $uuid * @param \Symfony\Component\HttpFoundation\Request $request * @return \Symfony\Component\HttpFoundation\Response */ - public function saveContent(Request $request) + public function saveNode($uuid, Request $request) { - if (0 !== strpos($request->headers->get('Content-Type'), 'application/ld+json')) { - return new Response( - "Expecting 'Content-Type' of 'application/ld+json'", - 400 - ); - } - $token = $request->headers->get("Authorization", null); + $jsonld_url = $request->headers->get("Content-Location"); - $event = json_decode($request->getContent(), true); - - $uuid = $this->parseUuid($event); - if (empty($uuid)) { - return new Response( - "Could not parse UUID from request body", - 400 - ); - } - - $jsonld_url = $this->parseJsonldUrl($event); if (empty($jsonld_url)) { - return new Response( - "Could not parse JSONLD url from request body", - 400 - ); + return new Response("Expected JSONLD url in Content-Location header", 400); } try { - $response = $this->milliner->saveContent( + $response = $this->milliner->saveNode( $uuid, $jsonld_url, $token @@ -85,141 +66,18 @@ public function saveContent(Request $request) } } - protected function parseUuid(array $event) - { - if (!isset($event['object']) || !isset($event['object']['id'])) { - return null; - } - - $urn = $event['object']['id']; - if (preg_match("/urn:uuid:(?.*)/", $urn, $matches)) { - if (!empty($matches['uuid'])) { - return $matches['uuid']; - } - } - - return null; - } - - protected function parseJsonldUrl(array $event) - { - $filtered = array_filter($event['object']['url'], function ($elem) { - return $elem['mediaType'] == 'application/ld+json'; - }); - if ($url = reset($filtered)) { - return $url['href']; - } - return null; - } - - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @return \Symfony\Component\HttpFoundation\Response - */ - public function saveMedia(Request $request) - { - if (0 !== strpos($request->headers->get('Content-Type'), 'application/ld+json')) { - return new Response( - "Expecting 'Content-Type' of 'application/ld+json'", - 400 - ); - } - - $token = $request->headers->get("Authorization", null); - - $event = json_decode($request->getContent(), true); - - $jsonld_url = $this->parseJsonldUrl($event); - if (empty($jsonld_url)) { - return new Response( - "Could not parse JSONLD url from request body", - 400 - ); - } - - $json_url = $this->parseJsonUrl($event); - if (empty($json_url)) { - return new Response( - "Could not parse JSON url from request body", - 400 - ); - } - - try { - $response = $this->milliner->saveMedia( - $json_url, - $jsonld_url, - $token - ); - - return new Response( - $response->getBody(), - $response->getStatusCode() - ); - } catch (\Exception $e) { - $this->log->error("", ['Exception' => $e]); - $code = $e->getCode() == 0 ? 500 : $e->getCode(); - return new Response($e->getMessage(), $code); - } - } - - protected function parseJsonUrl(array $event) - { - $filtered = array_filter($event['object']['url'], function ($elem) { - return $elem['mediaType'] == 'application/json'; - }); - if ($url = reset($filtered)) { - return $url['href']; - } - return null; - } - /** + * @param string $uuid * @param \Symfony\Component\HttpFoundation\Request $request * @return \Symfony\Component\HttpFoundation\Response */ - public function saveFile(Request $request) + public function deleteNode($uuid, Request $request) { - if (0 !== strpos($request->headers->get('Content-Type'), 'application/ld+json')) { - return new Response( - "Expecting 'Content-Type' of 'application/ld+json'", - 400 - ); - } - $token = $request->headers->get("Authorization", null); - $event = json_decode($request->getContent(), true); - - $uuid = $this->parseUuid($event); - if (empty($uuid)) { - return new Response( - "Could not parse UUID from request body", - 400 - ); - } - - $file_url = $this->parseFileUrl($event); - if (empty($file_url)) { - return new Response( - "Could not parse Drupal File URL from request body", - 400 - ); - } - - $checksum_url = $this->parseChecksumUrl($event); - if (empty($checksum_url)) { - return new Response( - "Could not parse Drupal File Checksum URL from request body", - 400 - ); - } - try { - $response = $this->milliner->saveFile( + $response = $this->milliner->deleteNode( $uuid, - $file_url, - $checksum_url, $token ); @@ -234,47 +92,23 @@ public function saveFile(Request $request) } /** - * @param array $event - * @return string|null - */ - protected function parseFileUrl(array $event) - { - $filtered = array_filter($event['object']['url'], function ($elem) { - return $elem['name'] == 'File'; - }); - if ($url = reset($filtered)) { - return $url['href']; - } - return null; - } - - /** - * @param array $event - * @return string|null - */ - protected function parseChecksumUrl(array $event) - { - $filtered = array_filter($event['object']['url'], function ($elem) { - return $elem['name'] == 'Checksum'; - }); - if ($url = reset($filtered)) { - return $url['href']; - } - return null; - } - - /** - * @param string $uuid + * @param string $source_field * @param \Symfony\Component\HttpFoundation\Request $request * @return \Symfony\Component\HttpFoundation\Response */ - public function delete($uuid, Request $request) + public function saveMedia($source_field, Request $request) { $token = $request->headers->get("Authorization", null); + $json_url = $request->headers->get("Content-Location"); + + if (empty($json_url)) { + return new Response("Expected JSON url in Content-Location header", 400); + } try { - $response = $this->milliner->delete( - $uuid, + $response = $this->milliner->saveMedia( + $source_field, + $json_url, $token ); @@ -284,7 +118,8 @@ public function delete($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/src/Service/MillinerService.php b/Milliner/src/Service/MillinerService.php index 6ce996bc..833fc5ef 100644 --- a/Milliner/src/Service/MillinerService.php +++ b/Milliner/src/Service/MillinerService.php @@ -65,7 +65,7 @@ public function __construct( /** * {@inheritDoc} */ - public function saveContent( + public function saveNode( $uuid, $jsonld_url, $token = null @@ -73,13 +73,13 @@ public function saveContent( $urls = $this->gemini->getUrls($uuid, $token); if (empty($urls)) { - return $this->createContent( + return $this->createNode( $uuid, $jsonld_url, $token ); } else { - return $this->updateContent( + return $this->updateNode( $uuid, $jsonld_url, $urls['fedora'], @@ -100,7 +100,7 @@ public function saveContent( * @throws \RuntimeException * @throws \GuzzleHttp\Exception\RequestException */ - protected function createContent( + protected function createNode( $uuid, $jsonld_url, $token = null @@ -170,7 +170,7 @@ protected function createContent( * @throws \RuntimeException * @throws \GuzzleHttp\Exception\RequestException */ - protected function updateContent( + protected function updateNode( $uuid, $jsonld_url, $fedora_url, @@ -347,8 +347,8 @@ protected function getModifiedTimestamp(array $jsonld) * {@inheritDoc} */ public function saveMedia( + $source_field, $json_url, - $jsonld_url, $token = null ) { // First get the media json from Drupal. @@ -358,48 +358,29 @@ public function saveMedia( ['headers' => $headers] ); + $jsonld_url = $this->getLinkHeader($drupal_response, "alternate", "application/ld+json"); $media_json = json_decode( $drupal_response->getBody(), true ); - if (isset($media_json['field_media_image'])) { - $field_name = 'field_media_image'; - } elseif (isset($media_json['field_media_file'])) { - $field_name = 'field_media_file'; - } elseif (isset($media_json['field_media_audio_file'])) { - $field_name = 'field_media_audio_file'; - } elseif (isset($media_json['field_media_video_file'])) { - $field_name = 'field_media_video_file'; - } else { - throw new \RuntimeException( - "Cannot parse file UUID from $json_url. Media must use 'field_media_file', 'field_media_image', " - . "'field_media_audio_file', or 'field_media_video_file'.", - 500 - ); - } - - if (empty($media_json[$field_name])) { + if (!isset($media_json[$source_field]) || empty($media_json[$source_field])) { throw new \RuntimeException( - "Cannot parse file UUID from $json_url. Media must use 'field_media_file', 'field_media_image', " - . "'field_media_audio_file', or 'field_media_video_file'.", + "Cannot parse file UUID from $json_url. Ensure $source_field exists on the media and is populated.", 500 ); } - - $file_uuid = $media_json[$field_name][0]['target_uuid']; + $file_uuid = $media_json[$source_field][0]['target_uuid']; // Get the file's LDP-NR counterpart in Fedora. $urls = $this->gemini->getUrls($file_uuid, $token); - if (empty($urls)) { - $file_url = $media_json[$field_name][0]['url']; + $file_url = $media_json[$source_field][0]['url']; throw new \RuntimeException( "$file_url has not been mapped in Gemini with uuid $file_uuid", 404 ); } - $fedora_file_url = $urls['fedora']; // Now look for the 'describedby' link header on the file in Fedora. @@ -407,7 +388,6 @@ public function saveMedia( $fedora_file_url, $headers ); - $status = $fedora_response->getStatusCode(); if ($status != 200) { $reason = $fedora_response->getReasonPhrase(); @@ -417,9 +397,7 @@ public function saveMedia( $status ); } - $fedora_url = $this->getLinkHeader($fedora_response, "describedby"); - if (empty($fedora_url)) { throw new \RuntimeException( "Cannot parse 'describedby' link header from response to `HEAD $fedora_file_url`", @@ -434,7 +412,6 @@ public function saveMedia( $fedora_url, $headers ); - $status = $fedora_response->getStatusCode(); if ($status != 200) { $reason = $fedora_response->getReasonPhrase(); @@ -448,7 +425,6 @@ public function saveMedia( // 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(), @@ -471,12 +447,10 @@ public function saveMedia( $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. @@ -485,12 +459,10 @@ public function saveMedia( $jsonld_url, $fedora_file_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( @@ -498,7 +470,6 @@ public function saveMedia( 412 ); } - // Conditional save it in Fedora. $headers['Content-Type'] = 'application/ld+json'; $headers['Prefer'] = 'return=minimal; handling=lenient'; @@ -508,84 +479,6 @@ public function saveMedia( json_encode($drupal_jsonld), $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 - ); - } - - // Return the response from Fedora. - return $response; - } - - /** - * {@inheritDoc} - */ - public function saveFile( - $uuid, - $file_url, - $checksum_url, - $token = null - ) { - $urls = $this->gemini->getUrls($uuid, $token); - - if (empty($urls)) { - return $this->createFile( - $uuid, - $file_url, - $token - ); - } else { - return $this->updateFile( - $uuid, - $file_url, - $checksum_url, - $urls['fedora'], - $token - ); - } - } - - /** - * Creates a new LDP-NR in Fedora from a Drupal file. - * - * @param $uuid - * @param $file_url - * @param $token - * - * @return \GuzzleHttp\Psr7\Response - * - * @throws \RuntimeException - * @throws \GuzzleHttp\Exception\RequestException - */ - protected function createFile( - $uuid, - $file_url, - $token = null - ) { - // Mint a new Fedora URL. - $fedora_url = $this->gemini->mintFedoraUrl($uuid, $token); - - // Get the file from Drupal. - $headers = empty($token) ? [] : ['Authorization' => $token]; - $drupal_response = $this->drupal->get( - $file_url, - ['headers' => $headers] - ); - - // Save it in Fedora. - $content_types = $drupal_response->getHeader('Content-Type'); - $headers['Content-Type'] = reset($content_types); - $response = $this->fedora->saveResource( - $fedora_url, - $drupal_response->getBody(), - $headers - ); - $status = $response->getStatusCode(); if (!in_array($status, [201, 204])) { $reason = $response->getReasonPhrase(); @@ -594,150 +487,6 @@ protected function createFile( $status ); } - - // Map the URLS. - $this->gemini->saveUrls( - $uuid, - $file_url, - $fedora_url, - $token - ); - - // Return the response from Fedora. - return $response; - } - - /** - * Updates an existing LDP-NR in Fedora from a Drupal file. - * - * @param $uuid - * @param $file_url - * @param $checksum_url - * @param $fedora_url - * @param $token - * - * @return \GuzzleHttp\Psr7\Response - * - * @throws \RuntimeException - * @throws \GuzzleHttp\Exception\RequestException - */ - protected function updateFile( - $uuid, - $file_url, - $checksum_url, - $fedora_url, - $token = null - ) { - // Get the headers for the file from Fedora. - $headers = empty($token) ? [] : ['Authorization' => $token]; - $fedora_response = $this->fedora->getResourceHeaders( - $fedora_url, - $headers - ); - - $status = $fedora_response->getStatusCode(); - if ($status != 200) { - $reason = $fedora_response->getReasonPhrase(); - throw new \RuntimeException( - "Client error: `HEAD $fedora_url` resulted in a `$status $reason` response: " . - $fedora_response->getBody(), - $status - ); - } - - // Get the ETag. - $etags = $fedora_response->getHeader("ETag"); - $etag = reset($etags); - - // Get the 'describedby' link. - $described_by = $this->getLinkHeader($fedora_response, "describedby"); - if (empty($described_by)) { - throw new \RuntimeException( - "Cannot parse 'describedby' link header from response to `HEAD $fedora_url`", - 500 - ); - } - - // Get the RDF describing the file from Fedora. - $headers['Accept'] = 'application/ld+json'; - $fedora_response = $this->fedora->getResource( - $described_by, - $headers - ); - - $status = $fedora_response->getStatusCode(); - if ($status != 200) { - $reason = $fedora_response->getReasonPhrase(); - throw new \RuntimeException( - "Client error: `GET $described_by` resulted in a `$status $reason` response: " . - $fedora_response->getBody(), - $status - ); - } - - $fedora_jsonld = json_decode( - $fedora_response->getBody(), - true - ); - - // Get the checksum from the RDF. - $fedora_checksum = $this->parseChecksum($fedora_jsonld); - - // Get the checksum from Drupal. - unset($headers['Accept']); - $drupal_response = $this->drupal->get( - $checksum_url, - ['headers' => $headers] - ); - - $checksum_json = json_decode( - $drupal_response->getBody(), - true - ); - - $drupal_checksum = $checksum_json[0]['sha1']; - - // Abort with 412 if the files haven't changed. - if ($fedora_checksum == $drupal_checksum) { - throw new \RuntimeException( - "Not updating $fedora_url because file at $file_url has not changed", - 412 - ); - } - - // Get the file from Drupal. - $drupal_response = $this->drupal->get( - $file_url, - ['headers' => $headers] - ); - - // Save it in Fedora. - $content_types = $drupal_response->getHeader('Content-Type'); - $headers['Content-Type'] = reset($content_types); - $headers['If-Match'] = $etag; - $response = $this->fedora->saveResource( - $fedora_url, - $drupal_response->getBody(), - $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, - $file_url, - $fedora_url, - $token - ); - // Return the response from Fedora. return $response; } @@ -750,47 +499,23 @@ protected function updateFile( * * @return null|string */ - protected function getLinkHeader($response, $rel_name) + protected function getLinkHeader($response, $rel_name, $type = null) { $parsed = Psr7\parse_header($response->getHeader("Link")); foreach ($parsed as $header) { - if (isset($header['rel']) && $header['rel'] == $rel_name) { + $has_relation = isset($header['rel']) && $header['rel'] == $rel_name; + $has_type = $type ? isset($header['type']) && $header['type'] == $type : true; + if ($has_type && $has_relation) { return trim($header[0], '<>'); } } return null; } - /** - * Gets a checksum from Fedora jsonld. - * - * @param array $jsonld - * - * @return string - * - * @throws \RuntimeException - */ - protected function parseChecksum(array $jsonld) - { - $predicate = 'http://www.loc.gov/premis/rdf/v1#hasMessageDigest'; - $urn = $this->getFirstPredicate($jsonld, $predicate, false); - - if (preg_match("/urn:sha1:(?.*)/", $urn, $matches)) { - if (isset($matches['checksum'])) { - return $matches['checksum']; - } - } - - throw new \RuntimeException( - "Could not parse $predicate from " . json_encode($jsonld), - 500 - ); - } - /** * {@inheritDoc} */ - public function delete( + public function deleteNode( $uuid, $token = null ) { diff --git a/Milliner/src/Service/MillinerServiceInterface.php b/Milliner/src/Service/MillinerServiceInterface.php index b27e3c2b..97d2cf8b 100644 --- a/Milliner/src/Service/MillinerServiceInterface.php +++ b/Milliner/src/Service/MillinerServiceInterface.php @@ -17,7 +17,7 @@ interface MillinerServiceInterface * * @return \GuzzleHttp\Psr7\Response */ - public function saveContent( + public function saveNode( $uuid, $jsonld_url, $token = null @@ -33,25 +33,8 @@ public function saveContent( * @return \GuzzleHttp\Psr7\Response */ public function saveMedia( + $source_field, $json_url, - $jsonld_url, - $token = null - ); - - /** - * @param $uuid - * @param $file_url - * @param $checksum_url - * @param $token - * - * @throws \Exception - * - * @return \GuzzleHttp\Psr7\Response - */ - public function saveFile( - $uuid, - $file_url, - $checksum_url, $token = null ); @@ -63,7 +46,7 @@ public function saveFile( * * @return \GuzzleHttp\Psr7\Response|null */ - public function delete( + public function deleteNode( $uuid, $token = null ); diff --git a/Milliner/src/app.php b/Milliner/src/app.php index b050f9fd..dca157eb 100644 --- a/Milliner/src/app.php +++ b/Milliner/src/app.php @@ -34,9 +34,8 @@ ); }; -$app->post('/content', "milliner.controller:saveContent"); -$app->post('/media', "milliner.controller:saveMedia"); -$app->post('/file', "milliner.controller:saveFile"); -$app->delete('/resource/{uuid}', "milliner.controller:delete"); +$app->post('/node/{uuid}', "milliner.controller:saveNode"); +$app->delete('/node/{uuid}', "milliner.controller:deleteNode"); +$app->post('/media/{source_field}', "milliner.controller:saveMedia"); return $app; diff --git a/Milliner/static/Media.json b/Milliner/static/Media.json index 979ceb84..f93e691d 100644 --- a/Milliner/static/Media.json +++ b/Milliner/static/Media.json @@ -90,7 +90,7 @@ "value": 500 } ], - "field_media_image": [ + "field_image": [ { "target_id": 9, "alt": "MEDIUM_SIZE", diff --git a/Milliner/tests/Islandora/Milliner/Tests/DeleteTest.php b/Milliner/tests/Islandora/Milliner/Tests/DeleteTest.php index f8accd50..920484dc 100644 --- a/Milliner/tests/Islandora/Milliner/Tests/DeleteTest.php +++ b/Milliner/tests/Islandora/Milliner/Tests/DeleteTest.php @@ -42,7 +42,7 @@ protected function setUp() } /** - * @covers ::delete + * @covers ::deleteNode * @expectedException \RuntimeException * @expectedExceptionCode 403 */ @@ -68,11 +68,11 @@ public function testDeleteReturnsFedoraError() $this->modifiedDatePredicate ); - $milliner->delete("abc123", "Bearer islandora"); + $milliner->deleteNode("abc123", "Bearer islandora"); } /** - * @covers ::delete + * @covers ::deleteNode */ public function testDeleteReturns204OnGeminiSuccess() { @@ -100,14 +100,14 @@ public function testDeleteReturns204OnGeminiSuccess() $this->modifiedDatePredicate ); - $response = $milliner->delete("first", "Bearer islandora"); + $response = $milliner->deleteNode("first", "Bearer islandora"); $status = $response->getStatusCode(); $this->assertTrue( $status == 204, "Milliner must return 204 when Gemini returns success. Received: $status" ); - $response = $milliner->delete("second", "Bearer islandora"); + $response = $milliner->deleteNode("second", "Bearer islandora"); $status = $response->getStatusCode(); $this->assertTrue( $status == 204, @@ -116,7 +116,7 @@ public function testDeleteReturns204OnGeminiSuccess() } /** - * @covers ::delete + * @covers ::deleteNode */ public function testDeleteReturns404IfNotMappedAndGeminiFails() { @@ -139,7 +139,7 @@ public function testDeleteReturns404IfNotMappedAndGeminiFails() $this->modifiedDatePredicate ); - $response = $milliner->delete("abc123", "Bearer islandora"); + $response = $milliner->deleteNode("abc123", "Bearer islandora"); $status = $response->getStatusCode(); $this->assertTrue( $status == 404, @@ -148,7 +148,7 @@ public function testDeleteReturns404IfNotMappedAndGeminiFails() } /** - * @covers ::delete + * @covers ::deleteNode */ public function testDeleteReturnsFedoraErrorIfMappedButGeminiFails() { @@ -174,7 +174,7 @@ public function testDeleteReturnsFedoraErrorIfMappedButGeminiFails() $this->modifiedDatePredicate ); - $response = $milliner->delete("abc123", "Bearer islandora"); + $response = $milliner->deleteNode("abc123", "Bearer islandora"); $status = $response->getStatusCode(); $this->assertTrue( $status == 410, diff --git a/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php b/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php index ba4c509b..54d40231 100644 --- a/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php +++ b/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php @@ -35,7 +35,7 @@ protected function setUp() } /** - * @covers ::saveContent + * @covers ::saveNode * @covers ::saveMedia * @covers ::saveFile * @covers ::delete @@ -44,63 +44,52 @@ public function testMethodsReturnMillinerErrors() { // Wire up a controller. $milliner = $this->prophesize(MillinerServiceInterface::class); - $milliner->saveContent(Argument::any(), Argument::any(), Argument::any()) + $milliner->saveNode(Argument::any(), Argument::any(), Argument::any()) ->willThrow(new \Exception("Forbidden", 403)); - $milliner->saveFile(Argument::any(), Argument::any(), Argument::any(), Argument::any()) - ->willThrow(new \Exception("Forbidden", 403)); - $milliner->saveMedia(Argument::any(), Argument::any(), Argument::any(), Argument::any()) + $milliner->saveMedia(Argument::any(), Argument::any(), Argument::any()) ->willThrow(new \Exception("Forbidden", 403)); - $milliner->delete(Argument::any(), Argument::any()) + $milliner->deleteNode(Argument::any(), Argument::any()) ->willThrow(new \Exception("Forbidden", 403)); $milliner = $milliner->reveal(); $controller = new MillinerController($milliner, $this->logger); - // Content. - $request = Request::create( - "http://localhost:8000/milliner/content", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/ContentEvent.jsonld') - ); - $response = $controller->saveContent($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 403, - "Response code must be that of thrown exception. Expected 403, received $status" - ); + // Route parameters. + $uuid = 'abc123'; + $source_field = 'field_image'; - // Media. + // Nodes. $request = Request::create( - "http://localhost:8000/milliner/media", + "http://localhost:8000/milliner/node/$uuid", "POST", + ['uuid' => $uuid], [], [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaEvent.jsonld') + [ + 'Authorization' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/node/1?_format=jsonld', + ] ); - $response = $controller->saveMedia($request); + $response = $controller->saveNode($uuid, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 403, "Response code must be that of thrown exception. Expected 403, received $status" ); - // File. + // Media. $request = Request::create( - "http://localhost:8000/milliner/file", + "http://localhost:8000/milliner/media/$source_field", "POST", + ['source_field' => $source_field], [], [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/FileEvent.jsonld') + [ + 'Authorization' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/media/6?_format=json', + ] ); - $response = $controller->saveFile($request); + $response = $controller->saveMedia($source_field, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 403, @@ -108,16 +97,15 @@ public function testMethodsReturnMillinerErrors() ); // Delete. - $uuid = 'abc123'; $request = Request::create( - "http://localhost:8000/milliner/resource/$uuid", + "http://localhost:8000/milliner/node/$uuid", "POST", - ['uuid' => 'abc123'], + ['uuid' => $uuid], [], [], ['Authorization' => 'Bearer islandora'] ); - $response = $controller->delete($uuid, $request); + $response = $controller->deleteNode($uuid, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 403, @@ -126,268 +114,81 @@ public function testMethodsReturnMillinerErrors() } /** - * @covers ::saveContent - * @covers ::saveMedia - * @covers ::saveFile + * @covers ::saveNode */ - public function testMethodsReturn400OnBadContentType() + public function testSaveNodeReturns400WithoutContentLocation() { $milliner = $this->prophesize(MillinerServiceInterface::class)->reveal(); $controller = new MillinerController($milliner, $this->logger); - // Content. - $request = Request::create( - "http://localhost:8000/milliner/content", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/xml'], - file_get_contents(__DIR__ . '/../../../../static/ContentEvent.jsonld') - ); - $response = $controller->saveContent($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 for non application/ld+json Content-Type. Received $status" - ); - - // Media. + $uuid = "abc123"; $request = Request::create( - "http://localhost:8000/milliner/media", + "http://localhost:8000/milliner/node/$uuid", "POST", + ['uuid' => $uuid], [], [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/xml'], - file_get_contents(__DIR__ . '/../../../../static/MediaEvent.jsonld') - ); - $response = $controller->saveMedia($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 for non application/ld+json Content-Type. Received $status" - ); - - // File. - $request = Request::create( - "http://localhost:8000/milliner/file", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/xml'], - file_get_contents(__DIR__ . '/../../../../static/FileEvent.jsonld') - ); - $response = $controller->saveFile($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 for non application/ld+json Content-Type. Received $status" - ); - } - - /** - * @covers ::saveContent - */ - public function testSaveContentReturn400OnMalformedEvents() - { - $milliner = $this->prophesize(MillinerServiceInterface::class)->reveal(); - $controller = new MillinerController($milliner, $this->logger); - - // No uuid in the event. - $request = Request::create( - "http://localhost:8000/milliner/content", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/ContentEventNoUuid.jsonld') - ); - $response = $controller->saveContent($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 when no uuid is present. Received: $status" - ); - - // Malformed uuid in the event. - $request = Request::create( - "http://localhost:8000/milliner/content", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/ContentEventBadUuid.jsonld') - ); - $response = $controller->saveContent($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 when a malformed uuid is present. Received: $status" - ); - - // No JSONLD url in the event. - $request = Request::create( - "http://localhost:8000/milliner/file", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/ContentEventNoJsonldUrl.jsonld') - ); - $response = $controller->saveContent($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 when no JSONLD url is present. Received: $status" - ); - } - - /** - * @covers ::saveFile - */ - public function testSaveFileReturn400OnMalformedEvents() - { - $milliner = $this->prophesize(MillinerServiceInterface::class)->reveal(); - $controller = new MillinerController($milliner, $this->logger); - - // No uuid in the event. - $request = Request::create( - "http://localhost:8000/milliner/file", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/FileEventNoUuid.jsonld') - ); - $response = $controller->saveFile($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 when no uuid is present. Received: $status" - ); - - // Malformed uuid in the event. - $request = Request::create( - "http://localhost:8000/milliner/file", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/FileEventBadUuid.jsonld') - ); - $response = $controller->saveFile($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 when a malformed uuid is present. Received: $status" - ); - - // No file url in the event. - $request = Request::create( - "http://localhost:8000/milliner/file", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/FileEventNoFileUrl.jsonld') - ); - $response = $controller->saveFile($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 when no File url is present. Received: $status" - ); - - // No checksum url in the event. - $request = Request::create( - "http://localhost:8000/milliner/media", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/FileEventNoChecksumUrl.jsonld') + ['Authorization' => 'Bearer islandora'] ); - $response = $controller->saveFile($request); + $response = $controller->saveNode($uuid, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 400, - "Response code must be 400 when no checksum url is present. Received: $status" + "Response code must be 400 when no Content-Location header is present. Received: $status" ); } /** * @covers ::saveMedia */ - public function testSaveMediaReturn400OnMalformedEvents() + public function testSaveMediaReturn400WithoutContentLocation() { $milliner = $this->prophesize(MillinerServiceInterface::class)->reveal(); $controller = new MillinerController($milliner, $this->logger); - // No JSONLD url in the event. - $request = Request::create( - "http://localhost:8000/milliner/media", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaEventNoJsonldUrl.jsonld') - ); - $response = $controller->saveMedia($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 400, - "Response code must be 400 when no JSONLD url is present. Received: $status" - ); - - // No JSON url in the event. + $source_field = "field_image"; + // Media. $request = Request::create( - "http://localhost:8000/milliner/media", + "http://localhost:8000/milliner/media/$source_field", "POST", + ['source_field' => $source_field], [], [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaEventNoJsonUrl.jsonld') + ['Authorization' => 'Bearer islandora'] ); - $response = $controller->saveMedia($request); + $response = $controller->saveMedia($source_field, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 400, - "Response code must be 400 when no JSON url is present. Received: $status" + "Response code must be 400 when no Content-Location header is present. Received: $status" ); } /** - * @covers ::saveContent + * @covers ::saveNode */ - public function testSaveContentReturnsSuccessOnSuccess() + public function testSaveNodeReturnsSuccessOnSuccess() { $milliner = $this->prophesize(MillinerServiceInterface::class); - $milliner->saveContent(Argument::any(), Argument::any(), Argument::any()) + $milliner->saveNode(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/content", + "http://localhost:8000/milliner/node/$uuid", "POST", + ['uuid' => $uuid], [], [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/ContentEvent.jsonld') + [ + 'Authorization' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/node/1?_format=jsonld', + ] ); - $response = $controller->saveContent($request); + $response = $controller->saveNode($uuid, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 201, @@ -395,21 +196,23 @@ public function testSaveContentReturnsSuccessOnSuccess() ); $milliner = $this->prophesize(MillinerServiceInterface::class); - $milliner->saveContent(Argument::any(), Argument::any(), Argument::any()) + $milliner->saveNode(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/content", + "http://localhost:8000/milliner/node/$uuid", "POST", + ['uuid' => $uuid], [], [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/ContentEvent.jsonld') + [ + 'Authorization' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/node/1?_format=jsonld', + ] ); - $response = $controller->saveContent($request); + $response = $controller->saveNode($uuid, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 204, @@ -428,16 +231,19 @@ public function testSaveMediaReturnsSuccessOnSuccess() $milliner = $milliner->reveal(); $controller = new MillinerController($milliner, $this->logger); + $source_field = "field_image"; $request = Request::create( - "http://localhost:8000/milliner/media", + "http://localhost:8000/milliner/media/$source_field", "POST", + ["source_field" => $source_field], [], [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaEvent.jsonld') + [ + 'Authorization' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/media/6?_format=json', + ] ); - $response = $controller->saveMedia($request); + $response = $controller->saveMedia($source_field, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 201, @@ -451,64 +257,17 @@ public function testSaveMediaReturnsSuccessOnSuccess() $controller = new MillinerController($milliner, $this->logger); $request = Request::create( - "http://localhost:8000/milliner/media", + "http://localhost:8000/milliner/media/$source_field", "POST", + ["source_field" => $source_field], [], [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaEvent.jsonld') + [ + 'Authorization' => 'Bearer islandora', + 'HTTP_CONTENT_LOCATION' => 'http://localhost:8000/media/6?_format=json', + ] ); - $response = $controller->saveMedia($request); - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 204, - "Response code must be 204 when milliner returns 204. Received: $status" - ); - } - /** - * @covers ::saveFile - */ - public function testSaveFileReturnsSuccessOnSuccess() - { - $milliner = $this->prophesize(MillinerServiceInterface::class); - $milliner->saveFile(Argument::any(), Argument::any(), Argument::any(), Argument::any()) - ->willReturn(new Response(201)); - $milliner = $milliner->reveal(); - $controller = new MillinerController($milliner, $this->logger); - - $request = Request::create( - "http://localhost:8000/milliner/file", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/FileEvent.jsonld') - ); - $response = $controller->saveFile($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->saveFile(Argument::any(), 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/file", - "POST", - [], - [], - [], - ['Authorization' => 'Bearer islandora', 'CONTENT_TYPE' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/FileEvent.jsonld') - ); - $response = $controller->saveFile($request); + $response = $controller->saveMedia($source_field, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 204, @@ -522,21 +281,22 @@ public function testSaveFileReturnsSuccessOnSuccess() public function testDeleteReturnsSuccessOnSuccess() { $milliner = $this->prophesize(MillinerServiceInterface::class); - $milliner->delete(Argument::any(), Argument::any()) + $milliner->deleteNode(Argument::any(), Argument::any()) ->willReturn(new Response(204)); $milliner = $milliner->reveal(); $controller = new MillinerController($milliner, $this->logger); + $uuid = "abc123"; $request = Request::create( - "http://localhost:8000/milliner/resource/abc-123", + "http://localhost:8000/milliner/resource/$uuid", "DELETE", - [], + ['uuid' => $uuid], [], [], ['Authorization' => 'Bearer islandora'] ); - $response = $controller->delete("abc-123", $request); + $response = $controller->deleteNode($uuid, $request); $status = $response->getStatusCode(); $this->assertTrue( $status == 204, diff --git a/Milliner/tests/Islandora/Milliner/Tests/SaveFileTest.php b/Milliner/tests/Islandora/Milliner/Tests/SaveFileTest.php deleted file mode 100644 index f280eaa1..00000000 --- a/Milliner/tests/Islandora/Milliner/Tests/SaveFileTest.php +++ /dev/null @@ -1,594 +0,0 @@ -logger = new Logger('milliner'); - $this->logger->pushHandler(new NullHandler()); - - $this->modifiedDatePredicate = "http://schema.org/dateModified"; - } - - /** - * @covers ::saveFile - * @expectedException \RuntimeException - * @expectedExceptionCode 403 - */ - public function testCreateFileThrowsFedoraPutError() - { - $url = "http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198"; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn([]); - $gemini->mintFedoraUrl(Argument::any(), Argument::any()) - ->willReturn($url); - $gemini = $gemini->reveal(); - - $drupal_response = new Response( - 200, - ['Content-Type' => 'text/plain'], - "CONTENT" - ); - $drupal = $this->prophesize(Client::class); - $drupal->get(Argument::any(), Argument::any()) - ->willReturn($drupal_response); - $drupal = $drupal->reveal(); - - $fedora_response = new Response(403, [], null, '1.1', 'UNAUTHORIZED'); - $fedora = $this->prophesize(IFedoraClient::class); - $fedora->saveResource(Argument::any(), Argument::any(), Argument::any()) - ->willReturn($fedora_response); - $fedora = $fedora->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - } - - /** - * @covers ::saveFile - */ - public function testCreateFileReturnsFedora201() - { - $url = "http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198"; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn([]); - $gemini->mintFedoraUrl(Argument::any(), Argument::any()) - ->willReturn($url); - $gemini->saveUrls(Argument::any(), Argument::any(), Argument::any(), Argument::any()) - ->willReturn(true); - $gemini = $gemini->reveal(); - - $drupal_response = new Response( - 200, - ['Content-Type' => 'text/plain'], - "CONTENT" - ); - $drupal = $this->prophesize(Client::class); - $drupal->get(Argument::any(), Argument::any()) - ->willReturn($drupal_response); - $drupal = $drupal->reveal(); - - $fedora_response = new Response(201); - $fedora = $this->prophesize(IFedoraClient::class); - $fedora->saveResource(Argument::any(), Argument::any(), Argument::any()) - ->willReturn($fedora_response); - $fedora = $fedora->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $response = $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 201, - "Milliner must return 201 when Fedora returns 201. Received: $status" - ); - } - - /** - * @covers ::saveFile - */ - public function testCreateFileReturnsFedora204() - { - $url = "http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198"; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn([]); - $gemini->mintFedoraUrl(Argument::any(), Argument::any()) - ->willReturn($url); - $gemini->saveUrls(Argument::any(), Argument::any(), Argument::any(), Argument::any()) - ->willReturn(true); - $gemini = $gemini->reveal(); - - $drupal_response = new Response( - 200, - ['Content-Type' => 'text/plain'], - "CONTENT" - ); - $drupal = $this->prophesize(Client::class); - $drupal->get(Argument::any(), Argument::any()) - ->willReturn($drupal_response); - $drupal = $drupal->reveal(); - - $fedora_response = new Response(204); - $fedora = $this->prophesize(IFedoraClient::class); - $fedora->saveResource(Argument::any(), Argument::any(), Argument::any()) - ->willReturn($fedora_response); - $fedora = $fedora->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $response = $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 204, - "Milliner must return 204 when Fedora returns 204. Received: $status" - ); - } - - /** - * @covers ::saveFile - * @expectedException \RuntimeException - * @expectedExceptionCode 404 - */ - public function testUpdateFileThrowsFedoraHeadError() - { - $mapping = [ - 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/fedora_logo.png', - 'fedora' => 'http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198', - ]; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn($mapping); - $gemini = $gemini->reveal(); - - $fedora_response = new Response(404); - $fedora = $this->prophesize(IFedoraClient::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_response); - $fedora = $fedora->reveal(); - - $drupal = $this->prophesize(Client::class)->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - } - - /** - * @covers ::saveFile - * @expectedException \RuntimeException - * @expectedExceptionCode 500 - */ - public function testUpdateFileThrows500WhenNoDescribedby() - { - $mapping = [ - 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/fedora_logo.png', - 'fedora' => 'http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198', - ]; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn($mapping); - $gemini = $gemini->reveal(); - - $fedora_response = new Response( - 200, - ['ETag' => 'abc123'] - ); - $fedora = $this->prophesize(IFedoraClient::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_response); - $fedora = $fedora->reveal(); - - $drupal = $this->prophesize(Client::class)->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - } - - /** - * @covers ::saveFile - * @expectedException \RuntimeException - * @expectedExceptionCode 404 - */ - public function testUpdateFileThrowsFedoraGetError() - { - $fedora_url = 'http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198'; - $mapping = [ - 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/fedora_logo.png', - 'fedora' => $fedora_url, - ]; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn($mapping); - $gemini = $gemini->reveal(); - - $fedora_head_response = new Response( - 200, - ['Link' => "<$fedora_url/fcr:metadata>; rel=\"describedby\"", 'ETag' => 'abc123'] - ); - $fedora_get_response = new Response( - 404 - ); - $fedora = $this->prophesize(IFedoraClient::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_head_response); - $fedora->getResource(Argument::any(), Argument::any()) - ->willReturn($fedora_get_response); - $fedora = $fedora->reveal(); - - $drupal = $this->prophesize(Client::class)->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - } - - /** - * @covers ::saveFile - * @expectedException \RuntimeException - * @expectedExceptionCode 500 - */ - public function testUpdateFileThrows500WhenNoDigest() - { - $fedora_url = 'http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198'; - $mapping = [ - 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/fedora_logo.png', - 'fedora' => $fedora_url, - ]; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn($mapping); - $gemini = $gemini->reveal(); - - $fedora_head_response = new Response( - 200, - ['Link' => "<$fedora_url/fcr:metadata>; rel=\"describedby\"", 'ETag' => 'abc123'] - ); - $fedora_get_response = new Response( - 200, - ['Content-Type' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaLDP-RS-NoDigest.jsonld') - ); - $fedora = $this->prophesize(IFedoraClient::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_head_response); - $fedora->getResource(Argument::any(), Argument::any()) - ->willReturn($fedora_get_response); - $fedora = $fedora->reveal(); - - $drupal = $this->prophesize(Client::class)->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - } - - /** - * @covers ::saveFile - * @expectedException \RuntimeException - * @expectedExceptionCode 412 - */ - public function testUpdateFileThrows412WithChecksumMatch() - { - $fedora_url = 'http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198'; - $mapping = [ - 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/fedora_logo.png', - 'fedora' => $fedora_url, - ]; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn($mapping); - $gemini = $gemini->reveal(); - - $fedora_head_response = new Response( - 200, - ['Link' => "<$fedora_url/fcr:metadata>; rel=\"describedby\"", 'ETag' => 'abc123'] - ); - $fedora_get_response = new Response( - 200, - ['Content-Type' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaLDP-RS.jsonld') - ); - $fedora = $this->prophesize(IFedoraClient::class); - $fedora->getResourceHeaders(Argument::any(), Argument::any()) - ->willReturn($fedora_head_response); - $fedora->getResource(Argument::any(), Argument::any()) - ->willReturn($fedora_get_response); - $fedora = $fedora->reveal(); - - $checksum_response = new Response( - 200, - ['Content-Type' => 'application/json'], - file_get_contents(__DIR__ . '/../../../../static/StaleChecksumResponse.json') - ); - $drupal = $this->prophesize(Client::class); - $drupal->get("http://localhost:8000/checksum/29?_format=json", Argument::any(), Argument::any()) - ->willReturn($checksum_response); - $drupal = $drupal->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - } - - /** - * @covers ::saveFile - * @expectedException \RuntimeException - * @expectedExceptionCode 403 - */ - public function testUpdateFileThrowsFedoraPutError() - { - $fedora_url = 'http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198'; - $mapping = [ - 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/fedora_logo.png', - 'fedora' => $fedora_url, - ]; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn($mapping); - $gemini = $gemini->reveal(); - - $fedora_head_response = new Response( - 200, - ['Link' => "<$fedora_url/fcr:metadata>; rel=\"describedby\"", 'ETag' => 'abc123'] - ); - $fedora_get_response = new Response( - 200, - ['Content-Type' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaLDP-RS.jsonld') - ); - $fedora_put_response = new Response( - 403 - ); - $fedora = $this->prophesize(IFedoraClient::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()) - ->willReturn($fedora_put_response); - $fedora = $fedora->reveal(); - - $checksum_response = new Response( - 200, - ['Content-Type' => 'application/json'], - file_get_contents(__DIR__ . '/../../../../static/ChecksumResponse.json') - ); - $get_response = new Response( - 200, - ['Content-Type' => 'text/plain'], - "CONTENT" - ); - $drupal = $this->prophesize(Client::class); - $drupal->get("http://localhost:8000/checksum/29?_format=json", Argument::any(), Argument::any()) - ->willReturn($checksum_response); - $drupal->get( - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - Argument::any(), - Argument::any() - )->willReturn($get_response); - - $drupal = $drupal->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - } - - /** - * @covers ::saveFile - */ - public function testUpdateFileReturnsFedora204() - { - $fedora_url = 'http://localhost:8080/fcrepo/rest/fc/c3/12/25/fcc31225-51d3-46e8-add3-f4e33b456198'; - $mapping = [ - 'drupal' => 'http://localhost:8000/sites/default/files/2017-07/fedora_logo.png', - 'fedora' => $fedora_url, - ]; - $gemini = $this->prophesize(GeminiClient::class); - $gemini->getUrls(Argument::any(), Argument::any()) - ->willReturn($mapping); - $gemini->saveUrls(Argument::any(), Argument::any(), Argument::any(), Argument::any()) - ->willReturn(true); - $gemini = $gemini->reveal(); - - $fedora_head_response = new Response( - 200, - ['Link' => "<$fedora_url/fcr:metadata>; rel=\"describedby\"", 'ETag' => 'abc123'] - ); - $fedora_get_response = new Response( - 200, - ['Content-Type' => 'application/ld+json'], - file_get_contents(__DIR__ . '/../../../../static/MediaLDP-RS.jsonld') - ); - $fedora_put_response = new Response( - 204 - ); - $fedora = $this->prophesize(IFedoraClient::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()) - ->willReturn($fedora_put_response); - $fedora = $fedora->reveal(); - - $checksum_response = new Response( - 200, - ['Content-Type' => 'application/json'], - file_get_contents(__DIR__ . '/../../../../static/ChecksumResponse.json') - ); - $get_response = new Response( - 200, - ['Content-Type' => 'text/plain'], - "CONTENT" - ); - $drupal = $this->prophesize(Client::class); - $drupal->get("http://localhost:8000/checksum/29?_format=json", Argument::any(), Argument::any()) - ->willReturn($checksum_response); - $drupal->get( - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - Argument::any(), - Argument::any() - )->willReturn($get_response); - - $drupal = $drupal->reveal(); - - $milliner = new MillinerService( - $fedora, - $drupal, - $gemini, - $this->logger, - $this->modifiedDatePredicate - ); - - $response = $milliner->saveFile( - "fcc31225-51d3-46e8-add3-f4e33b456198", - "http://localhost:8000/sites/default/files/2017-07/fedora_logo.png", - "http://localhost:8000/checksum/29?_format=json", - "Bearer islandora" - ); - - $status = $response->getStatusCode(); - $this->assertTrue( - $status == 204, - "Milliner must return 204 when Fedora returns 204. Received: $status" - ); - } -} diff --git a/Milliner/tests/Islandora/Milliner/Tests/SaveMediaTest.php b/Milliner/tests/Islandora/Milliner/Tests/SaveMediaTest.php index f05d5dd2..89a7586e 100644 --- a/Milliner/tests/Islandora/Milliner/Tests/SaveMediaTest.php +++ b/Milliner/tests/Islandora/Milliner/Tests/SaveMediaTest.php @@ -71,8 +71,8 @@ public function testSaveMediaThrows500WithNoFileField() ); $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); } @@ -107,8 +107,8 @@ public function testSaveMediaThrows500WithEmptyFileField() ); $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); } @@ -146,8 +146,8 @@ public function testSaveMediaThrows404WhenFileIsNotInGemini() ); $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); } @@ -193,8 +193,8 @@ public function testSaveMediaThrowsFedoraHeadError() ); $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); } @@ -240,8 +240,8 @@ public function testSaveMediaThrows500WhenNoDescribedbyHeader() ); $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); } @@ -297,8 +297,8 @@ public function testSaveMediaThrowsFedoraGetError() ); $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); } @@ -312,7 +312,10 @@ public function testSaveMediaThrows412OnStaleData() { $drupal_json_response = new Response( 200, - ['Content-Type' => 'application/json'], + [ + 'Content-Type' => 'application/json', + "Link" => '; rel="alternate"; type="application/ld+json"', + ], file_get_contents(__DIR__ . '/../../../../static/Media.json') ); $drupal_jsonld_response = new Response( @@ -363,8 +366,8 @@ public function testSaveMediaThrows412OnStaleData() ); $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); } @@ -378,7 +381,10 @@ public function testSaveMediaThrowsFedoraPutError() { $drupal_json_response = new Response( 200, - ['Content-Type' => 'application/json'], + [ + 'Content-Type' => 'application/json', + "Link" => '; rel="alternate"; type="application/ld+json"', + ], file_get_contents(__DIR__ . '/../../../../static/Media.json') ); $drupal_jsonld_response = new Response( @@ -434,8 +440,8 @@ public function testSaveMediaThrowsFedoraPutError() ); $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); } @@ -447,7 +453,10 @@ public function testSaveMediaReturnsFedoraSuccess() { $drupal_json_response = new Response( 200, - ['Content-Type' => 'application/json'], + [ + 'Content-Type' => 'application/json', + "Link" => '; rel="alternate"; type="application/ld+json"', + ], file_get_contents(__DIR__ . '/../../../../static/Media.json') ); $drupal_jsonld_response = new Response( @@ -503,8 +512,8 @@ public function testSaveMediaReturnsFedoraSuccess() ); $response = $milliner->saveMedia( + "field_image", "http://localhost:8000/media/6?_format=json", - "http://localhost:8000/media/6?_format=jsonld", "Bearer islandora" ); diff --git a/Milliner/tests/Islandora/Milliner/Tests/SaveContentTest.php b/Milliner/tests/Islandora/Milliner/Tests/SaveNodeTest.php similarity index 93% rename from Milliner/tests/Islandora/Milliner/Tests/SaveContentTest.php rename to Milliner/tests/Islandora/Milliner/Tests/SaveNodeTest.php index c4063150..b9c4e839 100644 --- a/Milliner/tests/Islandora/Milliner/Tests/SaveContentTest.php +++ b/Milliner/tests/Islandora/Milliner/Tests/SaveNodeTest.php @@ -16,7 +16,7 @@ * @package Islandora\Milliner\Tests * @coversDefaultClass \Islandora\Milliner\Service\MillinerService */ -class SaveContentTest extends \PHPUnit_Framework_TestCase +class SaveNodeTest extends \PHPUnit_Framework_TestCase { /** * @var LoggerInterface @@ -42,11 +42,11 @@ protected function setUp() } /** - * @covers ::saveContent + * @covers ::saveNode * @expectedException \RuntimeException * @expectedExceptionCode 403 */ - public function testCreateContentThrowsOnFedoraError() + public function testCreateNodeThrowsOnFedoraError() { $url = "http://localhost:8080/fcrepo/rest/95/41/c0/c1/9541c0c1-5bee-4973-a9d0-e55c1658bc8"; $gemini = $this->prophesize(GeminiClient::class); @@ -80,7 +80,7 @@ public function testCreateContentThrowsOnFedoraError() $this->modifiedDatePredicate ); - $milliner->saveContent( + $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora" @@ -88,9 +88,9 @@ public function testCreateContentThrowsOnFedoraError() } /** - * @covers ::saveContent + * @covers ::saveNode */ - public function testCreateContentReturnsFedora201() + public function testCreateNodeReturnsFedora201() { $url = "http://localhost:8080/fcrepo/rest/95/41/c0/c1/9541c0c1-5bee-4973-a9d0-e55c1658bc8"; $gemini = $this->prophesize(GeminiClient::class); @@ -126,7 +126,7 @@ public function testCreateContentReturnsFedora201() $this->modifiedDatePredicate ); - $response = $milliner->saveContent( + $response = $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora" @@ -140,9 +140,9 @@ public function testCreateContentReturnsFedora201() } /** - * @covers ::saveContent + * @covers ::saveNode */ - public function testCreateContentReturnsFedora204() + public function testCreateNodeReturnsFedora204() { $url = "http://localhost:8080/fcrepo/rest/95/41/c0/c1/9541c0c1-5bee-4973-a9d0-e55c1658bc8"; $gemini = $this->prophesize(GeminiClient::class); @@ -178,7 +178,7 @@ public function testCreateContentReturnsFedora204() $this->modifiedDatePredicate ); - $response = $milliner->saveContent( + $response = $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora" @@ -192,11 +192,11 @@ public function testCreateContentReturnsFedora204() } /** - * @covers ::saveContent + * @covers ::saveNode * @expectedException \RuntimeException * @expectedExceptionCode 403 */ - public function testUpdateContentThrowsOnFedoraGetError() + public function testUpdateNodeThrowsOnFedoraGetError() { $mapping = [ 'drupal' => '"http://localhost:8000/node/1?_format=jsonld"', @@ -223,7 +223,7 @@ public function testUpdateContentThrowsOnFedoraGetError() $this->modifiedDatePredicate ); - $milliner->saveContent( + $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora" @@ -231,11 +231,11 @@ public function testUpdateContentThrowsOnFedoraGetError() } /** - * @covers ::saveContent + * @covers ::saveNode * @expectedException \RuntimeException * @expectedExceptionCode 500 */ - public function testUpdateContentThrows500OnBadDatePredicate() + public function testUpdateNodeThrows500OnBadDatePredicate() { $mapping = [ 'drupal' => '"http://localhost:8000/node/1?_format=jsonld"', @@ -274,7 +274,7 @@ public function testUpdateContentThrows500OnBadDatePredicate() "total garbage" ); - $milliner->saveContent( + $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora" @@ -282,11 +282,11 @@ public function testUpdateContentThrows500OnBadDatePredicate() } /** - * @covers ::saveContent + * @covers ::saveNode * @expectedException \RuntimeException * @expectedExceptionCode 412 */ - public function testUpdateContentThrows412OnStaleContent() + public function testUpdateNodeThrows412OnStaleContent() { $mapping = [ 'drupal' => '"http://localhost:8000/node/1?_format=jsonld"', @@ -325,7 +325,7 @@ public function testUpdateContentThrows412OnStaleContent() $this->modifiedDatePredicate ); - $milliner->saveContent( + $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora" @@ -333,11 +333,11 @@ public function testUpdateContentThrows412OnStaleContent() } /** - * @covers ::saveContent + * @covers ::saveNode * @expectedException \RuntimeException * @expectedExceptionCode 403 */ - public function testUpdateContentThrowsOnFedoraSaveError() + public function testUpdateNodeThrowsOnFedoraSaveError() { $mapping = [ 'drupal' => '"http://localhost:8000/node/1?_format=jsonld"', @@ -379,7 +379,7 @@ public function testUpdateContentThrowsOnFedoraSaveError() $this->modifiedDatePredicate ); - $milliner->saveContent( + $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora" @@ -387,9 +387,9 @@ public function testUpdateContentThrowsOnFedoraSaveError() } /** - * @covers ::saveContent + * @covers ::saveNode */ - public function testUpdateContentReturnsFedora201() + public function testUpdateNodeReturnsFedora201() { $mapping = [ 'drupal' => '"http://localhost:8000/node/1?_format=jsonld"', @@ -433,7 +433,7 @@ public function testUpdateContentReturnsFedora201() $this->modifiedDatePredicate ); - $response = $milliner->saveContent( + $response = $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora" @@ -447,9 +447,9 @@ public function testUpdateContentReturnsFedora201() } /** - * @covers ::saveContent + * @covers ::saveNode */ - public function testUpdateContentReturnsFedora204() + public function testUpdateNodeReturnsFedora204() { $mapping = [ 'drupal' => '"http://localhost:8000/node/1?_format=jsonld"', @@ -493,7 +493,7 @@ public function testUpdateContentReturnsFedora204() $this->modifiedDatePredicate ); - $response = $milliner->saveContent( + $response = $milliner->saveNode( "9541c0c1-5bee-4973-a9d0-e55c1658bc81", "http://localhost:8000/node/1?_format=jsonld", "Bearer islandora"