Skip to content

Commit

Permalink
Fixing media indexing in Fedora with 5.0 (#62)
Browse files Browse the repository at this point in the history
* Fixing media indexing in Fedora with 5.0
* Using external content for non-fedora binaries
* Controller tests
  • Loading branch information
dannylamb authored and seth-shaw-unlv committed Apr 30, 2019
1 parent 0b49f10 commit 0663c54
Show file tree
Hide file tree
Showing 9 changed files with 579 additions and 182 deletions.
88 changes: 44 additions & 44 deletions Milliner/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 36 additions & 2 deletions Milliner/src/Controller/MillinerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function saveNode($uuid, Request $request)
);
} catch (\Exception $e) {
$this->log->error("", ['Exception' => $e]);
return new Response($e->getMessage(), $e->getCode());
$code = $e->getCode() == 0 ? 500 : $e->getCode();
return new Response($e->getMessage(), $code);
}
}

Expand All @@ -87,7 +88,8 @@ public function deleteNode($uuid, Request $request)
);
} catch (\Exception $e) {
$this->log->error("", ['Exception' => $e]);
return new Response($e->getMessage(), $e->getCode());
$code = $e->getCode() == 0 ? 500 : $e->getCode();
return new Response($e->getMessage(), $code);
}
}

Expand Down Expand Up @@ -122,4 +124,36 @@ public function saveMedia($source_field, Request $request)
return new Response($e->getMessage(), $code);
}
}

/**
* @param string $uuid
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function saveExternal($uuid, Request $request)
{
$token = $request->headers->get("Authorization", null);
$external_url = $request->headers->get("Content-Location");

if (empty($external_url)) {
return new Response("Expected external url in Content-Location header", 400);
}

try {
$response = $this->milliner->saveExternal(
$uuid,
$external_url,
$token
);

return new Response(
$response->getBody(),
$response->getStatusCode()
);
} catch (\Exception $e) {
$this->log->error("", ['Exception' => $e]);
$code = $e->getCode() == 0 ? 500 : $e->getCode();
return new Response($e->getMessage(), $code);
}
}
}
Loading

0 comments on commit 0663c54

Please sign in to comment.