Commit 473b6668 authored by Stefan Funk's avatar Stefan Funk 🐧
Browse files

Merge branch 'release/10.3.0.46-DH' into main

parents 9da00e07 23aa7385
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>crud-base</artifactId>
<name>DARIAHDE :: CrudService :: Base</name>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud-common</artifactId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>crudclient-online</artifactId>
<name>DARIAHDE :: CrudClient :: Online Tests</name>
......
......@@ -33,6 +33,10 @@ BUG25068_SUFFIX_EXP_MIME=text/xml
BUG32946_SUFFIX=0000-000C-D90D-2
BUG32946_SUFFIX_EXP_MIME=text/xml
# BUG#35556 (dc:format: application/vnd.openxmlformats-officedocument.wordprocessingml.document)
BUG35556_SUFFIX=0000-000E-556E-8
BUG35556_SUFFIX_EXP_MIME=application/rtf
# DELETED OBJECT
DELETED_OBJECT=0000-001B-41BD-5
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>dhcrud-api</artifactId>
<name>DARIAHDE :: DHCrudService :: API</name>
......
......@@ -174,7 +174,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.WILDCARD)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/data")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/data")
public Response read(final @PathParam(PARAM_PID) URI pid,
final @QueryParam(PARAM_OFFSET) long offset, final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -189,7 +189,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/metadata")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/metadata")
public Response readMetadata(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -204,7 +204,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_XML)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/metadata/xml")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/metadata/xml")
public Response readMetadataRDF(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -219,7 +219,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/metadata/ttl")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/metadata/ttl")
public Response readMetadataTTL(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -234,7 +234,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/metadata/ntriples")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/metadata/ntriples")
public Response readMetadataNTRIPLES(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -249,7 +249,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/metadata/json")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/metadata/json")
public Response readMetadataJSON(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -264,7 +264,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/metadata/jsonld")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/metadata/jsonld")
public Response readMetadataJSONLD(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -279,7 +279,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_XML)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/adm")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/adm")
public Response readAdmMD(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -294,7 +294,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/adm/ttl")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/adm/ttl")
public Response readAdmMDTTL(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -309,7 +309,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_XML)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/adm/xml")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/adm/xml")
public Response readAdmMDRDF(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -324,7 +324,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/adm/json")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/adm/json")
public Response readAdmMDJSON(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -339,7 +339,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/adm/ntriples")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/adm/ntriples")
public Response readAdmMDNTRIPLES(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -354,7 +354,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/adm/jsonld")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/adm/jsonld")
public Response readAdmMDJSONLD(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -369,7 +369,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_XML)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/tech")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/tech")
public Response readTechMD(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -384,7 +384,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_XML)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/prov")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/prov")
public Response readProvMD(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -399,7 +399,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_HTML)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/index")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/index")
public Response readIndex(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -414,7 +414,7 @@ public interface DHCrudService {
*/
@GET
@Produces(MediaType.TEXT_HTML)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/landing")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/landing")
public Response readLanding(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -429,7 +429,7 @@ public interface DHCrudService {
*/
@GET
@Produces(APPLICATION_ZIP)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/bag")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/bag")
public Response readBag(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -444,7 +444,7 @@ public interface DHCrudService {
*/
@GET
@Produces(APPLICATION_ZIP)
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/bag/pack")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/bag/pack")
public Response readBagPack(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -462,7 +462,7 @@ public interface DHCrudService {
* @return HTTP response with the object as Bagit Bag ZIP.
*/
@GET
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}")
public Response readRoot(final @PathParam(PARAM_PID) URI pid,
final @HeaderParam("Accept") String accept, final @HeaderParam(TRANSACTION_ID) String logID);
......@@ -489,7 +489,7 @@ public interface DHCrudService {
* @return HTTP response of the update message sending call.
*/
@GET
@Path("/{pid: " + PID_AND_DOI_REGEXP + "}/recache")
@Path("/{" + PARAM_PID + ": " + PID_AND_DOI_REGEXP + "}/recache")
public Response recache(@PathParam(PARAM_PID) URI pid,
final @HeaderParam(TRANSACTION_ID) String logID);
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>dhcrud-base</artifactId>
<name>DARIAHDE :: DHCrudService :: Base</name>
......
......@@ -68,11 +68,14 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
/**
* TODOLOG
*
* 2018-05-04 - FIXME Check mimetype of ADM entries! In all methods!
* 2018-05-04 - FIXME Check mimetype of ADM entries! In all methods! (see #35617)
*
**
* CHANGELOG
*
* 2021-06-29 - Funk - Always use mimetype extracted from tika (could also put into ADMMD right from
* the start? (fixes #35556)
*
* 2021-05-04 - Funk - Add correct error handling for HTTP responses.
*
* 2021-04-19 - Funk - Refactor citation for tombstone page to get from handle metadata.
......@@ -973,7 +976,7 @@ public class DHCrudServiceImpl extends CrudService implements DHCrudService {
try {
init(methodInfo);
result = readAdmMD(thePID, RDFConstants.JSON_LD, MediaType.TEXT_PLAIN,
result = readAdmMD(thePID, RDFConstants.JSON_LD, MediaType.APPLICATION_JSON,
RDFConstants.JSONLD_FILE_SUFFIX, theLogID, methodInfo);
} catch (IOException | ParseException | IoFault e) {
......@@ -2374,9 +2377,12 @@ public class DHCrudServiceImpl extends CrudService implements DHCrudService {
/**
* <p>
* Tries to determine the correct Mimetype to return in HTTP response. Takes mimetype from ADMMD
* first, if not valid or existing, looks into Tika extraction, and lastly takes the default type
* OCTET_STREAM.
* Always returns Tika mimetype to be independent of the dc:format in DMD, because this value/s
* is/are served by the operating system of the user's machine and only seldom trustworthy. For
* returning mimetype and file extension in HTTP responses we MUST HAVE correct data.must have and
* file extensionTries to determine the correct Mimetype to return in HTTP response. Finally use
* the default type OCTET_STREAM.
* </p>
*
* @param theBag
* @param theTempData
......@@ -2390,32 +2396,20 @@ public class DHCrudServiceImpl extends CrudService implements DHCrudService {
final File theTempData, final CrudServiceMethodInfo theMethodInfo, final String theLogID)
throws TikaException, IOException {
// Get and test mimetype from ADMMD.
String mimetype = theBag.getMimetype();
String result = LTPUtils.extractMimetype(theTempData);
log(DEBUG, theMethodInfo, "Mimetype from ADMMD: " + mimetype, theLogID);
log(DEBUG, theMethodInfo, "Mimetype from ADMMD: " + theBag.getMimetype(), theLogID);
log(DEBUG, theMethodInfo, "Mimetype from TIKA: " + result, theLogID);
// If empty or not valid or default mimetype (from import fallback), try getting mimetype from
// temp file using Tika.
if (mimetype.isEmpty() || !MimeType.isValid(mimetype)
|| mimetype.equals(MediaType.APPLICATION_OCTET_STREAM)) {
mimetype = LTPUtils.extractMimetype(theTempData);
// If Tika mimetype is empty or not valid, use default mimetype (was: workaround for #25068).
if (result.isEmpty() || !MimeType.isValid(result)) {
result = MediaType.APPLICATION_OCTET_STREAM;
log(DEBUG, theMethodInfo,
"Mimetype from ADMMD empty or invalid or import fallback, try getting mimetype from data: "
+ mimetype,
theLogID);
}
// Use default mimetype if still empty (workaround for #25068).
if (mimetype.isEmpty()) {
mimetype = MediaType.APPLICATION_OCTET_STREAM;
log(DEBUG, theMethodInfo, "Mimetype still empty! Using fallback mimetype: " + mimetype,
theLogID);
"Mimetype extracted from Tika is empty or invalid, using default mimetype: " + result);
}
return mimetype;
return result;
}
/**
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>dhcrud-webapp-public</artifactId>
<name>DARIAHDE :: DHCrudService :: Public Web Application</name>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>dhcrud-webapp</artifactId>
<name>DARIAHDE :: DHCrudService :: Web Application</name>
......
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
<packaging>pom</packaging>
<name>DARIAHDE :: CrudService</name>
<properties>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>tgcrud-adaptormanager</artifactId>
<name>DARIAHDE :: TGCrudService :: AdaptorManager</name>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>tgcrud-api</artifactId>
<name>DARIAHDE :: TGCrudService :: API</name>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>tgcrud-client</artifactId>
<name>DARIAHDE :: TGCrudService :: Client</name>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>tgcrud-webapp-public</artifactId>
<name>DARIAHDE :: TGCrudService :: Public Web Application</name>
......
......@@ -38,7 +38,7 @@ This page is valid for TG-crud Service Version
::
crud-base-10.3.0.43-TG
crud-base-10.3.0.46-DH
To check the current productive TG-crud version simply try:
......@@ -571,7 +571,7 @@ A simple way to work with the TG-crud service is to just include the tgcrud-clie
<dependency>
<groupId>info.textgrid.middleware</groupId>
<artifactId>tgcrud-client</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</dependency>
You could then use the method TGCrudClientUtilities.getTgcrud(), provide a TG-crud service endpoint and simply call this tgcrud client's methods. For example:
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud</artifactId>
<version>10.3.0.43-TG</version>
<version>10.3.0.46-DH</version>
</parent>
<artifactId>tgcrud-webapp</artifactId>
<name>DARIAHDE :: TGCrudService :: Web Application</name>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment