MNT-16448 / REPO-928: Fix "Alfresco OOTB install doesn't show preview for .EML files"

- add back Rfc822ToPdf to replace removal of Rfc822ToSwf (removed for BDE-443)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@128822 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2016-07-20 08:16:00 +00:00
parent b3ea9e4549
commit 011323f178
2 changed files with 63 additions and 25 deletions

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.content.transform;
@@ -59,6 +59,8 @@ public class EMLTransformerTest extends AbstractContentTransformerTest
private EMLTransformer transformer;
private ContentTransformerRegistry registry;
@Override
public void setUp() throws Exception
{
@@ -68,6 +70,8 @@ public class EMLTransformerTest extends AbstractContentTransformerTest
transformer.setMimetypeService(mimetypeService);
transformer.setTransformerDebug(transformerDebug);
transformer.setTransformerConfig(transformerConfig);
registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry");
}
@Override
@@ -103,6 +107,37 @@ public class EMLTransformerTest extends AbstractContentTransformerTest
assertTrue(reader2.getContentString().contains(QUICK_EML_CONTENT));
}
/**
* Test transforming a valid eml file to pdf using complex transformer ("Rfc822ToPdf") - eg. for HTML5 preview
*/
public void testRFC822ToPdf() throws Exception
{
String sourceMimetype = MimetypeMap.MIMETYPE_RFC822;
String targetMimetype = MimetypeMap.MIMETYPE_PDF;
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
String targetExtension = mimetypeService.getExtension(targetMimetype);
File emlSourceFile = loadQuickTestFile("eml");
ContentReader sourceReader = new FileContentReader(emlSourceFile);
ContentTransformer transformer = registry.getTransformer(sourceMimetype, -1, targetMimetype, null);
assertNotNull(transformer);
// make a writer for the target file
File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_"
+ getName() + "_" + sourceExtension + "_", "." + targetExtension);
ContentWriter targetWriter = new FileContentWriter(targetFile);
// do the transformation
sourceReader.setMimetype(sourceMimetype);
targetWriter.setMimetype(targetMimetype);
transformer.transform(sourceReader.getReader(), targetWriter);
ContentReader targetReader = new FileContentReader(targetFile);
assertTrue(targetReader.getSize() > 0);
}
/**
* Test transforming a non-ascii eml file to text
*/