Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
make FileService.persistTempFileFromUpload static (mikado method)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Jul 16, 2013
1 parent a1f58b7 commit 44cebb1
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -221,7 +221,7 @@ private Response tryUploadSourceFile(String projectSlug, String iterationSlug, S
{
if (!tempFile.isPresent())
{
tempFile = Optional.of(persistTempFileFromUpload(uploadForm));
tempFile = Optional.of(persistTempFileFromUpload(uploadForm, translationFileServiceImpl));
}
processAdapterFile(tempFile.get(), projectSlug, iterationSlug, docId, uploadForm);
}
Expand Down Expand Up @@ -292,14 +292,14 @@ private void checkValidSourceUploadType(DocumentFileUploadForm uploadForm)
}
}

private File persistTempFileFromUpload(DocumentFileUploadForm uploadForm)
private static File persistTempFileFromUpload(DocumentFileUploadForm uploadForm, TranslationFileService transFileService)
{
File tempFile;
try
{
MessageDigest md = MessageDigest.getInstance("MD5");
InputStream fileContents = new DigestInputStream(uploadForm.getFileStream(), md);
tempFile = translationFileServiceImpl.persistToTempFile(fileContents);
tempFile = transFileService.persistToTempFile(fileContents);
String md5hash = new String(Hex.encodeHex(md.digest()));
if (!md5hash.equals(uploadForm.getHash()))
{
Expand Down Expand Up @@ -679,7 +679,7 @@ private Response tryUploadTranslationFile(String projectSlug, String iterationSl
{
if (!tempFile.isPresent())
{
tempFile = Optional.of(persistTempFileFromUpload(uploadForm));
tempFile = Optional.of(persistTempFileFromUpload(uploadForm, translationFileServiceImpl));
}
// FIXME this is misusing the 'filename' field. the method should probably take a
// type anyway
Expand Down

0 comments on commit 44cebb1

Please sign in to comment.