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

Handle missing gndIdentifier in search result and JSON link #386

Merged
merged 3 commits into from
Apr 11, 2024
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
11 changes: 7 additions & 4 deletions app/controllers/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ public Result authority(String id, String format) {
if (responseFormat == null || responseFormat == Accept.Format.JSON_LINES
|| format != null && format.contains(":")) {
return unsupportedMediaType(views.html.error.render(id, String.format(
"Unsupported for single resource: format=%s, accept=%s", format, request().acceptedTypes())));
"Unsupported for single resource: format=%s, accept=%s", format,
request().acceptedTypes()), allHits()));
}
String jsonLd = getAuthorityResource(id);
if (jsonLd == null) {
Expand Down Expand Up @@ -372,7 +373,7 @@ public Result authority(String id, String format) {
}
} catch (Exception e) {
Logger.error("Could not create response", e);
return internalServerError(views.html.error.render(id, e.getMessage()));
return internalServerError(views.html.error.render(id, e.getMessage(), allHits()));
}
}

Expand Down Expand Up @@ -476,7 +477,9 @@ public Result search(String q, String name, String place, String subject, String
if (responseFormat == null || Stream.of(RdfFormat.values()).map(RdfFormat::getParam)
.anyMatch(f -> f.equals(responseFormat.queryParamString))) {
return unsupportedMediaType(views.html.error.render(q,
String.format("Unsupported for search: format=%s, accept=%s", format, request().acceptedTypes())));
String.format("Unsupported for search: format=%s, accept=%s", format,
request().acceptedTypes()),
allHits()));
}
String queryString = buildQueryString(q, name, place, subject, publication, date);
queryString = (queryString == null || queryString.isEmpty()) ? "*" : queryString;
Expand Down Expand Up @@ -507,7 +510,7 @@ public Result search(String q, String name, String place, String subject, String
} catch (Throwable t) {
String message = t.getMessage() + (t.getCause() != null ? ", cause: " + t.getCause().getMessage() : "");
Logger.error("Error: {}", message);
return internalServerError(views.html.error.render(q, "Error: " + message));
return internalServerError(views.html.error.render(q, "Error: " + message, allHits()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/models/AuthorityResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private <T> List<T> get(String field) {
}

public String getId() {
return id.substring(id.startsWith(GND_PREFIX) ? GND_PREFIX.length() : RPPD_PREFIX.length());
return id.replace(GND_PREFIX, "").replace(RPPD_PREFIX, "");
}

public String getFullId() {
Expand Down
4 changes: 2 additions & 2 deletions app/views/error.scala.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@* Copyright 2015-2018 Fabian Steeg, hbz. Licensed under the EPL 2.0 *@

@(q: String, message: String)
@(q: String, message: String, allHits: Long)

@main(q, "Error") {
@main(q, "Error", allHits) {
<div class="panel panel-danger footer">
<div class='panel-heading'>Fehler</div>
<div class='panel-body'>@message</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ <h5>@models.GndOntology.label("type")</h5>
</div>
<table class="table table-striped table-condensed">
<tr><th /><th /><th /><th /><th /></tr>
@for((doc,i) <- hits; gndId = (doc\"gndIdentifier").as[String]; id = if (gndId.contains("Keine")) (doc\"rppdId").as[String] else gndId) {
@for((doc,i) <- hits; gndId = (doc\"gndIdentifier").asOpt[String].getOrElse("Keine"); id = if (gndId.contains("Keine")) (doc\"rppdId").as[String] else gndId) {
@result_short(id,doc,i-1)
}
</table>
Expand Down
Loading