Commit 0d9c52db authored by Matija Obreza's avatar Matija Obreza
Browse files

Renamed to contentType

parent 2bd8006c
......@@ -97,7 +97,7 @@ public interface BaseMetadata extends Serializable {
String getLicense();
/**
* The MIME type of the resource.
* The content type of the resource.
*
* @return the format
*/
......
......@@ -55,13 +55,13 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
@Column(name = "path", nullable = false)
private String path;
/** The original filename. */
// Original filename
/**
* The original filename as provided by the end user
*/
@Column(name = "originalFilename", nullable = false)
private String originalFilename;
/** The extension. */
// Extension based on mime type
/** Extension based on originalFilename. */
@Column(name = "extension")
private String extension;
......@@ -97,9 +97,9 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
@Column(name = "license")
private String license;
/** The mime type. */
@Column(name = "mimeType")
private String mimeType;
/** The content type. */
@Column(name = "contentType")
private String contentType;
/** The extent. */
@Column(name = "extent")
......@@ -358,25 +358,25 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
*/
@Override
public String getFormat() {
return getMimeType();
return getContentType();
}
/**
* Gets the mime type.
* Gets the content type
*
* @return the mime type
* @return the content type
*/
public String getMimeType() {
return mimeType;
public String getContentType() {
return contentType;
}
/**
* Sets the mime type.
* Sets the content type.
*
* @param mimeType the new mime type
* @param contentType the new content type
*/
public void setMimeType(final String mimeType) {
this.mimeType = mimeType;
public void setContentType(final String contentType) {
this.contentType = contentType;
}
/*
......
......@@ -39,14 +39,14 @@ public interface RepositoryService {
*
* @param repositoryPath the repository path
* @param originalFilename the original filename
* @param mimeType the mime type
* @param contentType the content type
* @param bytes the bytes
* @param metaData the meta data
* @return the repository file
* @throws InvalidRepositoryPathException the invalid repository path exception
* @throws InvalidRepositoryFileDataException the invalid repository file data exception
*/
RepositoryFile addFile(String repositoryPath, String originalFilename, String mimeType, byte[] bytes,
RepositoryFile addFile(String repositoryPath, String originalFilename, String contentType, byte[] bytes,
RepositoryFile metaData) throws InvalidRepositoryPathException, InvalidRepositoryFileDataException;
/**
......@@ -54,14 +54,14 @@ public interface RepositoryService {
*
* @param repositoryPath the repository path
* @param originalFilename the original filename
* @param mimeType the mime type
* @param contentType the content type
* @param bytes the bytes
* @param metaData the meta data
* @return the repository image
* @throws InvalidRepositoryPathException the invalid repository path exception
* @throws InvalidRepositoryFileDataException the invalid repository file data exception
*/
RepositoryImage addImage(String repositoryPath, String originalFilename, String mimeType, byte[] bytes,
RepositoryImage addImage(String repositoryPath, String originalFilename, String contentType, byte[] bytes,
RepositoryImage metaData) throws InvalidRepositoryPathException, InvalidRepositoryFileDataException;
/**
......@@ -104,26 +104,26 @@ public interface RepositoryService {
* Update file bytes.
*
* @param fileData the file data
* @param mimeType the mime type
* @param contentType the content type
* @param data the data
* @return the repository file
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
RepositoryFile updateBytes(RepositoryFile fileData, String mimeType, byte[] data)
RepositoryFile updateBytes(RepositoryFile fileData, String contentType, byte[] data)
throws NoSuchRepositoryFileException, IOException;
/**
* Load image to validate data and mimeType, update image bytes and generate updated {@link ImageMetadata}.
* Load image to validate data and contentType, update image bytes and generate updated {@link ImageMetadata}.
*
* @param imageData the image data
* @param mimeType the mime type
* @param contentType the content type
* @param data the data
* @return the repository image
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
RepositoryImage updateBytes(RepositoryImage imageData, String mimeType, byte[] data)
RepositoryImage updateBytes(RepositoryImage imageData, String contentType, byte[] data)
throws NoSuchRepositoryFileException, IOException;
/**
......
......@@ -20,6 +20,7 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
......@@ -73,13 +74,13 @@ public class RepositoryServiceImpl implements RepositoryService {
*/
@Override
@Transactional
public RepositoryFile addFile(final String repositoryPath, final String originalFilename, final String mimeType,
public RepositoryFile addFile(final String repositoryPath, final String originalFilename, final String contentType,
final byte[] bytes, final RepositoryFile metaData) throws InvalidRepositoryPathException,
InvalidRepositoryFileDataException {
if (!isValidPath(repositoryPath))
throw new InvalidRepositoryPathException();
if (originalFilename == null || mimeType == null || bytes == null)
if (originalFilename == null || contentType == null || bytes == null)
throw new InvalidRepositoryFileDataException();
RepositoryFile file = new RepositoryFile();
......@@ -89,7 +90,7 @@ public class RepositoryServiceImpl implements RepositoryService {
}
file.setOriginalFilename(originalFilename);
file.setMimeType(mimeType);
file.setContentType(contentType);
file.setPath(repositoryPath);
file = repositoryFilePersistence.save(file);
......@@ -111,13 +112,13 @@ public class RepositoryServiceImpl implements RepositoryService {
*/
@Override
@Transactional
public RepositoryImage addImage(final String repositoryPath, final String originalFilename, final String mimeType,
final byte[] bytes, final RepositoryImage metaData) throws InvalidRepositoryPathException,
InvalidRepositoryFileDataException {
public RepositoryImage addImage(final String repositoryPath, final String originalFilename,
final String contentType, final byte[] bytes, final RepositoryImage metaData)
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException {
if (!isValidPath(repositoryPath))
throw new InvalidRepositoryPathException();
if (originalFilename == null || mimeType == null || bytes == null)
if (originalFilename == null || contentType == null || bytes == null)
throw new InvalidRepositoryFileDataException();
RepositoryImage image = new RepositoryImage();
......@@ -128,11 +129,19 @@ public class RepositoryServiceImpl implements RepositoryService {
image.setPath(repositoryPath);
image.setOriginalFilename(originalFilename);
image.setMimeType(mimeType);
image.setContentType(contentType);
try (final InputStream in = new ByteArrayInputStream(bytes)) {
final BufferedImage imageData = ImageIO.read(in);
in.mark(0);
String detectedContentType = URLConnection.guessContentTypeFromStream(in);
if (detectedContentType != null && !detectedContentType.equals(contentType)) {
// overwrite contentType
LOG.warn("Replacing content type; provided={} detected={}", contentType, detectedContentType);
image.setContentType(detectedContentType);
}
in.reset();
final BufferedImage imageData = ImageIO.read(in);
if (imageData != null) {
image.setWidth(imageData.getWidth());
image.setHeight(imageData.getHeight());
......@@ -215,7 +224,7 @@ public class RepositoryServiceImpl implements RepositoryService {
throw new NoSuchRepositoryFileException();
RepositoryFile repositoryFile;
if (fileData.getMimeType().startsWith("image")) {
if (fileData.getContentType().startsWith("image")) {
repositoryFile = repositoryImagePersistence.save((RepositoryImage) fileData);
} else {
repositoryFile = repositoryFilePersistence.save(fileData);
......@@ -245,12 +254,12 @@ public class RepositoryServiceImpl implements RepositoryService {
*/
@Override
@Transactional
public RepositoryFile updateBytes(final RepositoryFile fileData, final String mimeType, final byte[] data)
public RepositoryFile updateBytes(final RepositoryFile fileData, final String contentType, final byte[] data)
throws NoSuchRepositoryFileException, IOException {
if (fileData == null)
throw new NoSuchRepositoryFileException();
fileData.setMimeType(mimeType);
fileData.setContentType(contentType);
bytesStorageService.upsert(fileData.getPath(), fileData.getFilename(), data);
return repositoryFilePersistence.save(fileData);
......@@ -264,12 +273,12 @@ public class RepositoryServiceImpl implements RepositoryService {
*/
@Override
@Transactional
public RepositoryImage updateBytes(final RepositoryImage imageData, final String mimeType, final byte[] data)
public RepositoryImage updateBytes(final RepositoryImage imageData, final String contentType, final byte[] data)
throws NoSuchRepositoryFileException, IOException {
if (imageData == null)
throw new NoSuchRepositoryFileException();
imageData.setMimeType(mimeType);
imageData.setContentType(contentType);
final InputStream in = new ByteArrayInputStream(data);
final BufferedImage image = ImageIO.read(in);
......@@ -299,7 +308,7 @@ public class RepositoryServiceImpl implements RepositoryService {
bytesStorageService.remove(repositoryFile.getPath(), repositoryFile.getFilename());
if (repositoryFile.getMimeType().startsWith("image")) {
if (repositoryFile.getContentType().startsWith("image")) {
repositoryImagePersistence.delete((RepositoryImage) repositoryFile);
} else {
repositoryFilePersistence.delete(repositoryFile);
......@@ -327,7 +336,7 @@ public class RepositoryServiceImpl implements RepositoryService {
repositoryFile.setPath(newPath);
RepositoryFile file;
if (repositoryFile.getMimeType().startsWith("image")) {
if (repositoryFile.getContentType().startsWith("image")) {
file = repositoryImagePersistence.save((RepositoryImage) repositoryFile);
} else {
file = repositoryFilePersistence.save(repositoryFile);
......@@ -343,7 +352,7 @@ public class RepositoryServiceImpl implements RepositoryService {
* @param resultFile the result file
*/
private void copyMetaData(final RepositoryFile sourceFile, final RepositoryFile resultFile) {
resultFile.setMimeType(sourceFile.getMimeType());
resultFile.setContentType(sourceFile.getContentType());
resultFile.setDescription(sourceFile.getDescription());
resultFile.setOriginalFilename(sourceFile.getOriginalFilename());
resultFile.setAccessRights(sourceFile.getAccessRights());
......
......@@ -58,13 +58,13 @@ public class FileRepositoryAddTest {
@Test
public void addFile() throws InvalidRepositoryPathException, InvalidRepositoryFileDataException {
final String path = "/test1/test2/";
final String mimeType = "text/plain;charset=UTF-8";
final String contentType = "text/plain;charset=UTF-8";
final String extension = ".txt";
final String originalFilename = "requirements" + extension;
final RepositoryFile repoFile = fileRepoService.addFile(path, originalFilename, mimeType, SOME_BYTES, null);
final RepositoryFile repoFile = fileRepoService.addFile(path, originalFilename, contentType, SOME_BYTES, null);
FileRepositoryTestUtil.checkFile(repoFile, path, originalFilename, extension, mimeType);
FileRepositoryTestUtil.checkFile(repoFile, path, originalFilename, extension, contentType);
}
/**
......@@ -76,7 +76,7 @@ public class FileRepositoryAddTest {
@Test
public void addFileWithMetadata() throws InvalidRepositoryPathException, InvalidRepositoryFileDataException {
final String path = "/test1/test2/";
final String mimeType = "text/plain;charset=UTF-8";
final String contentType = "text/plain;charset=UTF-8";
final String extension = ".txt";
final String originalFilename = "requirements" + extension;
......@@ -90,14 +90,14 @@ public class FileRepositoryAddTest {
final String extension2 = ".extension2";
final String extent = "extent";
final String license = "license";
final String mimeType2 = "mimeType2";
final String contentType2 = "contentType2";
final String originalFilename2 = "originalFilename2";
final String rightsHolder = "rightsHolder";
final String subject = "subject";
final String title = "File Repository Requirements";
// This test is to ensure they get overwritten in the service
assertThat("mimeType2 must not match", mimeType2, not(equalTo(mimeType)));
assertThat("contentType2 must not match", contentType2, not(equalTo(contentType)));
assertThat("originalFilename2 must not match", originalFilename2, not(equalTo(originalFilename)));
assertThat("extension2 must not match", extension2, not(equalTo(extension)));
......@@ -108,15 +108,15 @@ public class FileRepositoryAddTest {
fileData.setDescription(description);
fileData.setExtent(extent);
fileData.setLicense(license);
fileData.setMimeType(mimeType2);
fileData.setContentType(contentType2);
fileData.setOriginalFilename(originalFilename2);
fileData.setRightsHolder(rightsHolder);
fileData.setSubject(subject);
fileData.setTitle(title);
final RepositoryFile repoFile = fileRepoService.addFile(path, originalFilename, mimeType, SOME_BYTES, fileData);
final RepositoryFile repoFile = fileRepoService.addFile(path, originalFilename, contentType, SOME_BYTES, fileData);
FileRepositoryTestUtil.checkFile(repoFile, path, originalFilename, extension, mimeType);
FileRepositoryTestUtil.checkFile(repoFile, path, originalFilename, extension, contentType);
FileRepositoryTestUtil.checkMetadata(repoFile, bibliographicCitation, accessRights, created, creator,
description, extent, license, rightsHolder, subject, title);
}
......@@ -130,17 +130,17 @@ public class FileRepositoryAddTest {
@Test(expected = InvalidRepositoryFileDataException.class)
public void invalidMissingOriginalFilename()
throws InvalidRepositoryFileDataException, InvalidRepositoryPathException {
fileRepoService.addFile("/valid/path/", null, "mimeType", FileRepositoryAddTest.EMPTY_BYTES, null);
fileRepoService.addFile("/valid/path/", null, "contentType", FileRepositoryAddTest.EMPTY_BYTES, null);
}
/**
* Base data missing mimeType.
* Base data missing contentType.
*
* @throws InvalidRepositoryFileDataException the invalid repository file data exception
* @throws InvalidRepositoryPathException the invalid repository path exception
*/
@Test(expected = InvalidRepositoryFileDataException.class)
public void invalidMissingMimeType() throws InvalidRepositoryFileDataException, InvalidRepositoryPathException {
public void invalidMissingContentType() throws InvalidRepositoryFileDataException, InvalidRepositoryPathException {
fileRepoService.addFile("/valid/path/", "orignalFilename.txt", null, FileRepositoryAddTest.EMPTY_BYTES, null);
}
......@@ -152,7 +152,7 @@ public class FileRepositoryAddTest {
*/
@Test(expected = InvalidRepositoryFileDataException.class)
public void invalidMissingBytes() throws InvalidRepositoryFileDataException, InvalidRepositoryPathException {
fileRepoService.addFile("/valid/path/", "orignalFilename.txt", "mimeType", null, null);
fileRepoService.addFile("/valid/path/", "orignalFilename.txt", "contentType", null, null);
}
/**
......@@ -165,7 +165,7 @@ public class FileRepositoryAddTest {
@Test(expected = InvalidRepositoryPathException.class)
public void invalidAddNullPath()
throws NoSuchRepositoryFileException, InvalidRepositoryPathException, InvalidRepositoryFileDataException {
fileRepoService.addFile(null, "originalFilename.txt", "mimeType", FileRepositoryAddTest.EMPTY_BYTES, null);
fileRepoService.addFile(null, "originalFilename.txt", "contentType", FileRepositoryAddTest.EMPTY_BYTES, null);
}
/**
......@@ -178,7 +178,7 @@ public class FileRepositoryAddTest {
@Test(expected = InvalidRepositoryPathException.class)
public void invalidAddBlankPath()
throws NoSuchRepositoryFileException, InvalidRepositoryPathException, InvalidRepositoryFileDataException {
fileRepoService.addFile(" ", "originalFilename.txt", "mimeType", FileRepositoryAddTest.EMPTY_BYTES, null);
fileRepoService.addFile(" ", "originalFilename.txt", "contentType", FileRepositoryAddTest.EMPTY_BYTES, null);
}
/**
......@@ -191,7 +191,7 @@ public class FileRepositoryAddTest {
@Test(expected = InvalidRepositoryPathException.class)
public void invalidAddDoubleSlashPath()
throws NoSuchRepositoryFileException, InvalidRepositoryPathException, InvalidRepositoryFileDataException {
fileRepoService.addFile("/double//slash/", "originalFilename.txt", "mimeType",
fileRepoService.addFile("/double//slash/", "originalFilename.txt", "contentType",
FileRepositoryAddTest.EMPTY_BYTES, null);
}
......@@ -204,7 +204,7 @@ public class FileRepositoryAddTest {
@Test(expected = InvalidRepositoryPathException.class)
public void invalidAddMissingStartSlash()
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException {
fileRepoService.addFile("invalidpath/here/", "originalFilename.txt", "mimeType",
fileRepoService.addFile("invalidpath/here/", "originalFilename.txt", "contentType",
FileRepositoryAddTest.EMPTY_BYTES, null);
}
......@@ -218,7 +218,7 @@ public class FileRepositoryAddTest {
@Test(expected = InvalidRepositoryPathException.class)
public void invalidAddMissingEndSlash()
throws NoSuchRepositoryFileException, InvalidRepositoryPathException, InvalidRepositoryFileDataException {
fileRepoService.addFile("/invalidpath/here", "originalFilename.txt", "mimeType",
fileRepoService.addFile("/invalidpath/here", "originalFilename.txt", "contentType",
FileRepositoryAddTest.EMPTY_BYTES, null);
}
......
......@@ -67,32 +67,32 @@ public class FileRepositoryDirectoryTest {
@Test
public void testPathList() throws InvalidRepositoryPathException, InvalidRepositoryFileDataException,
NoSuchRepositoryFileException, IOException {
final String mimeType = "text/plain;charset=UTF-8";
final String contentType = "text/plain;charset=UTF-8";
final String extension = ".txt";
final String originalFilename = "folderfile" + extension;
List<RepositoryFile> repoFiles = new ArrayList<RepositoryFile>(20);
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/ee/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/ee/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/ee/gg/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/ee/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/ee/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/ee/ff/", originalFilename, mimeType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/ee/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/ee/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/dd/ee/gg/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/ee/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/ee/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "bb/cc/ee/ff/", originalFilename, contentType, SOME_BYTES, null));
List<String> paths = fileRepoService.listPaths(PATH + "aa/", new PageRequest(0, 10));
assertThat("Paths definitely exist", paths, notNullValue());
......
......@@ -38,8 +38,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration(classes = { ServiceBeanConfig.class, DatabaseConfig.class })
public class FileRepositoryExtensionTest {
/** The initial mime type. */
private final String initialMimeType = "text/plain";
/** The initial content type. */
private final String initialContentType = "text/plain";
/** The initial path. */
private final String initialPath = "/initial/" + System.currentTimeMillis() + "/";
......@@ -68,11 +68,11 @@ public class FileRepositoryExtensionTest {
@Test
public void extensionIsAssigned() throws NoSuchRepositoryFileException, InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException {
RepositoryFile repoFile = fileRepoService.addFile(initialPath, initialOriginalFilename, initialMimeType,
RepositoryFile repoFile = fileRepoService.addFile(initialPath, initialOriginalFilename, initialContentType,
EMPTY_BYTES, null);
FileRepositoryTestUtil.checkFile(repoFile, initialPath, initialOriginalFilename, initialExtension,
initialMimeType);
initialContentType);
final String extension = ".extension2";
final String originalFilename = "originalFilename2" + extension;
......@@ -92,9 +92,9 @@ public class FileRepositoryExtensionTest {
@Test
public void extensionIsNullOnAdd() throws NoSuchRepositoryFileException, InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException {
final RepositoryFile repoFile = fileRepoService.addFile(initialPath, "no extension in file", initialMimeType,
final RepositoryFile repoFile = fileRepoService.addFile(initialPath, "no extension in file", initialContentType,
EMPTY_BYTES, null);
FileRepositoryTestUtil.checkFile(repoFile, initialPath, "no extension in file", null, initialMimeType);
FileRepositoryTestUtil.checkFile(repoFile, initialPath, "no extension in file", null, initialContentType);
fileRepoService.removeFile(repoFile);
}
......@@ -110,7 +110,7 @@ public class FileRepositoryExtensionTest {
public void extensionIsNullOnUpdate() throws NoSuchRepositoryFileException, InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException {
RepositoryFile repoFile = fileRepoService.addFile(initialPath, initialOriginalFilename, initialMimeType,
RepositoryFile repoFile = fileRepoService.addFile(initialPath, initialOriginalFilename, initialContentType,
EMPTY_BYTES, null);
repoFile = updateAndCheck(repoFile, "no extension here", null);
......@@ -128,9 +128,9 @@ public class FileRepositoryExtensionTest {
@Test
public void extensionDotFileIsNullOnAdd() throws NoSuchRepositoryFileException, InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException {
final RepositoryFile repoFile = fileRepoService.addFile(initialPath, ".gitignore", initialMimeType, EMPTY_BYTES,
final RepositoryFile repoFile = fileRepoService.addFile(initialPath, ".gitignore", initialContentType, EMPTY_BYTES,
null);
FileRepositoryTestUtil.checkFile(repoFile, initialPath, ".gitignore", null, initialMimeType);
FileRepositoryTestUtil.checkFile(repoFile, initialPath, ".gitignore", null, initialContentType);
fileRepoService.removeFile(repoFile);
}
......@@ -146,7 +146,7 @@ public class FileRepositoryExtensionTest {
public void extensionDotFileIsNullOnUpdate() throws NoSuchRepositoryFileException, InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException {
RepositoryFile repoFile = fileRepoService.addFile(initialPath, initialOriginalFilename, initialMimeType,
RepositoryFile repoFile = fileRepoService.addFile(initialPath, initialOriginalFilename, initialContentType,
EMPTY_BYTES, null);
repoFile = updateAndCheck(repoFile, ".gitignore", null);
fileRepoService.removeFile(repoFile);
......@@ -165,13 +165,13 @@ public class FileRepositoryExtensionTest {
final String expectedExtension) throws NoSuchRepositoryFileException {
FileRepositoryTestUtil.checkFile(repoFile, initialPath, initialOriginalFilename, initialExtension,
initialMimeType);
initialContentType);
repoFile.setOriginalFilename(originalFilename);
repoFile = fileRepoService.updateMetadata(repoFile);
return FileRepositoryTestUtil.checkFile(repoFile, initialPath, originalFilename, expectedExtension,
initialMimeType);
initialContentType);
}
......@@ -187,9 +187,9 @@ public class FileRepositoryExtensionTest {
public void extensionIsAfterLastDot() throws NoSuchRepositoryFileException, InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException {
final String originalFilename = "Screen Shot 2016-03-14 at 10.44.17.png";
final RepositoryFile repoFile = fileRepoService.addFile(initialPath, originalFilename, initialMimeType,
final RepositoryFile repoFile = fileRepoService.addFile(initialPath, originalFilename, initialContentType,
EMPTY_BYTES, null);
FileRepositoryTestUtil.checkFile(repoFile, initialPath, originalFilename, ".png", initialMimeType);
FileRepositoryTestUtil.checkFile(repoFile, initialPath, originalFilename, ".png", initialContentType);
fileRepoService.removeFile(repoFile);
}
......