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

Fixing media indexing in Fedora with 5.0 #62

Merged
merged 9 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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