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

ufal/be-cannot-download-and-preview-files-after-migration #454

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
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,10 @@ public BitstreamRest importBitstreamForExistingFile(HttpServletRequest request)
log.info("SequenceId is null. Bitstream UUID: " + bitstream.getID());
}
//add bitstream format
String bitstreamFormatIdString = request.getParameter("bitstreamFormat");
Integer bitstreamFormatId = getIntegerFromString(bitstreamFormatIdString);
String bitstreamFormatMimeType = request.getParameter("bitstreamFormat");
BitstreamFormat bitstreamFormat = null;
if (!Objects.isNull(bitstreamFormatId)) {
bitstreamFormat = bitstreamFormatService.find(context, bitstreamFormatId);
if (StringUtils.isNotBlank(bitstreamFormatMimeType)) {
bitstreamFormat = bitstreamFormatService.findByMIMEType(context, bitstreamFormatMimeType);
}
bitstream.setFormat(context, bitstreamFormat);
String deletedString = request.getParameter("deleted");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void setup() throws Exception {
.withName("TESTINGBUNDLE")
.build();
token = getAuthToken(admin.getEmail(), password);
bitstreamFormat = BitstreamFormatBuilder.createBitstreamFormat(context).build();
bitstreamFormat = BitstreamFormatBuilder.createBitstreamFormat(context).withMimeType("application/pdf").build();
String input = "Hello, World!";
MockMultipartFile file = new MockMultipartFile("file", "hello.txt",
MediaType.TEXT_PLAIN_VALUE,
Expand Down Expand Up @@ -147,7 +147,7 @@ public void importBitstreamForExistingFileWithBundleTest() throws Exception {
.contentType(contentType)
.param("internal_id", internalId)
.param("storeNumber", Integer.toString(storeNumber))
.param("bitstreamFormat", Integer.toString(bitstreamFormat.getID()))
.param("bitstreamFormat", bitstreamFormat.getMIMEType())
.param("deleted", Boolean.toString(deleted))
.param("sequenceId", Integer.toString(sequence))
.param("primaryBundle_id", "")
Expand All @@ -156,8 +156,8 @@ public void importBitstreamForExistingFileWithBundleTest() throws Exception {
.andReturn().getResponse().getContentAsString(),
"$.id"));

checkCreatedBitstream(uuid, internalId, storeNumber, bitstreamFormat.getID(), sequence, deleted, sizeBytes,
checkSum);
checkCreatedBitstream(uuid, internalId, storeNumber, bitstreamFormat.getMIMEType(), sequence, deleted,
sizeBytes, checkSum);

//clean all
context.turnOffAuthorisationSystem();
Expand All @@ -182,7 +182,7 @@ public void importBitstreamForExistingFileWithoutBundleTest() throws Exception {
.contentType(contentType)
.param("internal_id", internalId)
.param("storeNumber", Integer.toString(storeNumber))
.param("bitstreamFormat", Integer.toString(bitstreamFormat.getID()))
.param("bitstreamFormat", bitstreamFormat.getMIMEType())
.param("deleted", Boolean.toString(deleted))
.param("sequenceId", Integer.toString(sequence))
.param("primaryBundle_id", "")
Expand All @@ -191,8 +191,8 @@ public void importBitstreamForExistingFileWithoutBundleTest() throws Exception {
.andReturn().getResponse().getContentAsString(),
"$.id"));

checkCreatedBitstream(uuid, internalId, storeNumber, bitstreamFormat.getID(), sequence, deleted, sizeBytes,
checkSum);
checkCreatedBitstream(uuid, internalId, storeNumber, bitstreamFormat.getMIMEType(), sequence, deleted,
sizeBytes, checkSum);

//clean all
context.turnOffAuthorisationSystem();
Expand All @@ -217,7 +217,7 @@ public void importBitstreamForExistingFileAsPrimaryBitstreamOfBundleTest() throw
.contentType(contentType)
.param("internal_id", internalId)
.param("storeNumber", Integer.toString(storeNumber))
.param("bitstreamFormat", Integer.toString(bitstreamFormat.getID()))
.param("bitstreamFormat", bitstreamFormat.getMIMEType())
.param("deleted", Boolean.toString(deleted))
.param("sequenceId", Integer.toString(sequence))
.param("primaryBundle_id", bundle.getID().toString())
Expand All @@ -226,8 +226,8 @@ public void importBitstreamForExistingFileAsPrimaryBitstreamOfBundleTest() throw
.andReturn().getResponse().getContentAsString(),
"$.id"));

checkCreatedBitstream(uuid, internalId, storeNumber, bitstreamFormat.getID(), sequence, deleted, sizeBytes,
checkSum);
checkCreatedBitstream(uuid, internalId, storeNumber, bitstreamFormat.getMIMEType(), sequence, deleted,
sizeBytes, checkSum);
bundle = bundleService.find(context, bundle.getID());
assertEquals(bundle.getPrimaryBitstream().getID(), bitstream.getID());

Expand Down Expand Up @@ -257,7 +257,7 @@ public void importBitstreamForExistingFileValidationErrorTest() throws Exception
.contentType(contentType)
.param("internal_id", internalId)
.param("storeNumber", Integer.toString(storeNumber))
.param("bitstreamFormat", Integer.toString(bitstreamFormat.getID()))
.param("bitstreamFormat", bitstreamFormat.getMIMEType())
.param("deleted", Boolean.toString(deleted))
.param("sequenceId", Integer.toString(sequence))
.param("primaryBundle_id", "")
Expand All @@ -271,12 +271,12 @@ public void importBitstreamForExistingFileValidationErrorTest() throws Exception
}

private void checkCreatedBitstream(UUID uuid, String internalId, int storeNumber,
Integer bitstreamFormat, int sequence, boolean deleted, long sizeBytes,
String bitstreamFormat, int sequence, boolean deleted, long sizeBytes,
String checkSum) throws SQLException {
bitstream = bitstreamService.find(context, uuid);
assertEquals(bitstream.getChecksum(), checkSum);
assertEquals(bitstream.getSizeBytes(), sizeBytes);
assertEquals(bitstream.getFormat(context).getID(), bitstreamFormat);
assertEquals(bitstream.getFormat(context).getMIMEType(), bitstreamFormat);
assertEquals(bitstream.getInternalId(), internalId);
assertEquals(bitstream.getStoreNumber(), storeNumber);
assertEquals(bitstream.getSequenceID(), sequence);
Expand Down
Loading