Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media versioning #96

Merged
merged 28 commits into from
Sep 11, 2020
Merged

Media versioning #96

merged 28 commits into from
Sep 11, 2020

Conversation

elizoller
Copy link
Member

@elizoller elizoller commented Feb 21, 2020

GitHub Issue: (Islandora/documentation#740)

What does this Pull Request do?

Allows Milliner to fire requests to Fedora to create versions of Media objects

What's new?

  • Separates the routes for node versioning and media versioning - because they rely on different data
  • Abstracts shared code with the saveMedia method where possible to reduce duplication
  • Creates a Fedora version for a Media object

How should this be tested?

Additional Notes:

This PR depends on an Alpaca PR or it will break versioning for nodes (media versioning didn't work before this point). Islandora/Alpaca#70

Interested parties

@Islandora/8-x-committers

dependabot bot and others added 6 commits March 26, 2020 14:56
…andora#92)

Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 3.4.30 to 3.4.36.
- [Release notes](https://github.com/symfony/http-foundation/releases)
- [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md)
- [Commits](symfony/http-foundation@v3.4.30...v3.4.36)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ndora#94)

Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 3.4.30 to 3.4.36.
- [Release notes](https://github.com/symfony/http-foundation/releases)
- [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md)
- [Commits](symfony/http-foundation@v3.4.30...v3.4.36)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ora#91)

Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 3.4.30 to 3.4.36.
- [Release notes](https://github.com/symfony/http-foundation/releases)
- [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md)
- [Commits](symfony/http-foundation@v3.4.30...v3.4.36)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ora#101)

Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 3.4.30 to 3.4.38.
- [Release notes](https://github.com/symfony/http-foundation/releases)
- [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md)
- [Commits](symfony/http-foundation@v3.4.30...v3.4.38)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…dora#98)

Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 3.4.30 to 3.4.38.
- [Release notes](https://github.com/symfony/http-foundation/releases)
- [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md)
- [Commits](symfony/http-foundation@v3.4.30...v3.4.38)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Copy link
Contributor

@dannylamb dannylamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than some small things, this looks like a good little refactor. We'll have to sort out what's up with tests, too, but I'm 👍 to this.

{
$token = $request->headers->get("Authorization", null);
try {
$this->log->info("in create Node version with " . $uuid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would delete this or set the level to debug.

{
$token = $request->headers->get("Authorization", null);
try {
$this->log->info("in create Node version with " . $uuid);
$urls = $this->milliner->getGeminiUrls($uuid, $token);
$this->log->info($urls);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would delete these two lines or set the levels to debug.

$json_url = $request->headers->get("Content-Location");

if (empty($json_url)) {
$this->log->info("json url is EMPTY");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use error instead of info here

$this->log->info("json url is EMPTY");
return new Response("Expected JSON url in Content-Location header", 400);
} else {
$this->log->info("json url is" . $json_url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make this debug or delete it

$timestamp,
null,
$headers
$this->log->error("the fedora url in service is " . $fedora_url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make this debug or delete it.

404
);
}
return array('fedora'=>$urls['fedora'], 'jsonld' =>$jsonld_url, 'drupal'=>$urls['drupal']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate myself for nitpicking on this, but you should use [] instead of array here

@dannylamb
Copy link
Contributor

Hrm... Chullo is out of date at 30f13e7 according to the composer install output from Travis, but it is recent enough to contain versioning. It's not a bad idea to run composer update and commit the updated lockfile just in case.

@elizoller
Copy link
Member Author

I might need some help with the tests here: https://travis-ci.com/github/Islandora/Crayfish/jobs/382853022

@dannylamb
Copy link
Contributor

Because you refactored and added the getGeminiUrls and getFileFromMedia functions, you need to wire up your mocks to return values for them or throw exceptions. Here's a diff of what I had to do to get them working.

diff --git a/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php b/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php
index 09b9e74..e28e5f9 100644
--- a/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php
+++ b/Milliner/tests/Islandora/Milliner/Tests/MillinerControllerTest.php
@@ -48,12 +48,16 @@ class MillinerControllerTest extends TestCase
         $milliner = $this->prophesize(MillinerServiceInterface::class);
         $milliner->saveNode(Argument::any(), Argument::any(), Argument::any(), Argument::any())
             ->willThrow(new \Exception("Forbidden", 403));
+        $milliner->getFileFromMedia(Argument::any(), Argument::any(), Argument::any())
+            ->willThrow(new \Exception("Forbidden", 403));
         $milliner->saveMedia(Argument::any(), Argument::any(), Argument::any())
             ->willThrow(new \Exception("Forbidden", 403));
         $milliner->deleteNode(Argument::any(), Argument::any())
             ->willThrow(new \Exception("Forbidden", 403));
         $milliner->saveExternal(Argument::any(), Argument::any(), Argument::any(), Argument::any())
             ->willThrow(new \Exception("Forbidden", 403));
+        $milliner->getGeminiUrls(Argument::any(), Argument::any())
+            ->willThrow(new \Exception("Forbidden", 403));
         $milliner->createVersion(Argument::any(), Argument::any())
             ->willThrow(new \Exception("Forbidden", 403));
         $milliner = $milliner->reveal();
@@ -473,7 +477,9 @@ class MillinerControllerTest extends TestCase
     public function testCreateNodeVersionReturnsSuccessOnSuccess()
     {
         $milliner = $this->prophesize(MillinerServiceInterface::class);
-        $milliner->createVersion(Argument::any(), Argument::any(), Argument::any(), Argument::any())
+        $milliner->getGeminiUrls(Argument::any(), Argument::any())
+            ->willReturn(['fedora' => "http://example.org/fcrepo/abc123", "drupal" => "http://example.org/node/1"]);
+        $milliner->createVersion(Argument::any(), Argument::any())
             ->willReturn(new Response(201));
         $milliner = $milliner->reveal();
         $controller = new MillinerController($milliner, $this->logger);
@@ -499,7 +505,9 @@ class MillinerControllerTest extends TestCase
         );
 
         $milliner = $this->prophesize(MillinerServiceInterface::class);
-        $milliner->createVersion(Argument::any(), Argument::any(), Argument::any(), Argument::any())
+        $milliner->getGeminiUrls(Argument::any(), Argument::any())
+            ->willReturn(['fedora' => "http://example.org/fcrepo/abc123", "drupal" => "http://example.org/node/1"]);
+        $milliner->createVersion(Argument::any(), Argument::any())
             ->willReturn(new Response(204));
         $milliner = $milliner->reveal();
         $controller = new MillinerController($milliner, $this->logger);

@elizoller
Copy link
Member Author

my hero!!!

@codecov
Copy link

codecov bot commented Sep 10, 2020

Codecov Report

Merging #96 into dev will decrease coverage by 2.98%.
The diff coverage is 58.82%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev      #96      +/-   ##
============================================
- Coverage     94.85%   91.87%   -2.99%     
- Complexity      168      175       +7     
============================================
  Files             9        9              
  Lines           700      726      +26     
============================================
+ Hits            664      667       +3     
- Misses           36       59      +23     
Impacted Files Coverage Δ Complexity Δ
Milliner/src/Service/MillinerService.php 89.84% <43.18%> (-9.37%) 56.00 <6.00> (+2.00) ⬇️
Milliner/src/Controller/MillinerController.php 97.02% <87.50%> (+2.09%) 24.00 <8.00> (+5.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 463aa7e...291ebe0. Read the comment docs.

@dannylamb dannylamb merged commit de6c968 into Islandora:dev Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants