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

Commit

Permalink
make FileService.parsePotFile static (mikado method)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Jul 16, 2013
1 parent de288bf commit b985a92
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions zanata-war/src/main/java/org/zanata/rest/service/FileService.java
Expand Up @@ -218,7 +218,8 @@ private Response tryUploadSourceFile(String projectSlug, String iterationSlug, S
if (uploadForm.getFileType().equals(".pot"))
{
InputStream potStream = getInputStream(tempFile, uploadForm);
parsePotFile(potStream, projectSlug, iterationSlug, docId, uploadForm);
parsePotFile(potStream, projectSlug, iterationSlug, docId, uploadForm,
translationFileServiceImpl, documentServiceImpl, documentDAO);
}
else
{
Expand Down Expand Up @@ -431,11 +432,6 @@ private static boolean isSinglePart(DocumentFileUploadForm uploadForm)
return uploadForm.getFirst() && uploadForm.getLast();
}

private boolean useOfflinePo(String projectSlug, String iterationSlug, String docId)
{
return !isNewDocument(projectSlug, iterationSlug, docId, documentDAO) && !translationFileServiceImpl.isPoDocument(projectSlug, iterationSlug, docId);
}

private static boolean isNewDocument(String projectSlug, String iterationSlug, String docId, DocumentDAO dao)
{
return dao.getByProjectIterationAndDocId(projectSlug, iterationSlug, docId) == null;
Expand Down Expand Up @@ -587,20 +583,26 @@ private static void checkUploadPreconditions(String projectSlug, String iteratio
}
}

private void parsePotFile(InputStream potStream, String projectSlug, String iterationSlug, String docId, DocumentFileUploadForm uploadForm)
{
parsePotFile(potStream, docId, uploadForm.getFileType(), projectSlug, iterationSlug, useOfflinePo(projectSlug, iterationSlug, docId));
}

private void parsePotFile(InputStream documentStream, String docId, String fileType, String projectSlug, String iterationSlug, boolean asOfflinePo)
private static void parsePotFile(InputStream potStream, String projectSlug, String iterationSlug,
String docId, DocumentFileUploadForm uploadForm,
TranslationFileService translationFileServiceImpl,
DocumentService documentServiceImpl,
DocumentDAO documentDAO)
{
Resource doc;
doc = translationFileServiceImpl.parseUpdatedPotFile(documentStream, docId, fileType, asOfflinePo);
doc = translationFileServiceImpl.parseUpdatedPotFile(potStream, docId, uploadForm.getFileType(),
useOfflinePo(projectSlug, iterationSlug, docId, documentDAO, translationFileServiceImpl));
doc.setLang( new LocaleId("en-US") );
// TODO Copy Trans values
documentServiceImpl.saveDocument(projectSlug, iterationSlug, doc, new StringSet(ExtensionType.GetText.toString()), false);
}

private static boolean useOfflinePo(String projectSlug, String iterationSlug, String docId,
DocumentDAO documentDAO, TranslationFileService translationFileServiceImpl)
{
return !isNewDocument(projectSlug, iterationSlug, docId, documentDAO) && !translationFileServiceImpl.isPoDocument(projectSlug, iterationSlug, docId);
}

private static Response sourceUploadSuccessResponse(boolean isNewDocument, int acceptedChunks)
{
Response response;
Expand Down

0 comments on commit b985a92

Please sign in to comment.