MNT-14316 2013/2014 iWork Transformation Failure

* Support the creation of thumbnails for 2008/9 and 2013/14 iWorks file types.
* Support the preview of 2008/9 and 2013/14 iWorks file types. It should be noted that the
  embedded PDF files from 2008/9 no longer are used for the preview, so the quality is not
  as good as it was in the past. It is however using the embedded JPEG and quality is reasonable.   
* AppleIWorksContentTransformer no longer supports PDF as an target mimetype, as the newer
  iWoks 2013/14 formats no longer includes an embedded PDF file. Having PDF supported by the
  transformer resulted in Share always trying PDF which was one of the reasons that the newer
  formats did not preview. The other reason was that the embedded JPEG filename also changed.
* Added 'quick' files for testing.
* Also modified the exception message thrown when the iWorks file did not contain an embedded
  preview file, which is optional. An example would is "The source numbers file did not contain
  a jpg preview", rather than "Unable to transform numbers file to jpg". This should reduce the
  number of issues raised with support.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@135869 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2017-03-15 13:46:22 +00:00
parent 4fc7f98618
commit 61686ffd6a
7 changed files with 177 additions and 138 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;
import java.io.File;
@@ -256,11 +256,15 @@ public abstract class AbstractContentTransformerTest extends TestCase
// attempt to convert to every other mimetype
for (String targetMimetype : mimetypes)
{
if (sourceMimetype.equals(targetMimetype))
{
// Don't test like-to-like transformations
continue;
}
if (sourceMimetype.equals(targetMimetype))
{
// Don't test like-to-like transformations
continue;
}
if (!doTestTransformation(quickFile, sourceMimetype, targetMimetype))
{
continue;
}
ContentWriter targetWriter = null;
// construct a reader onto the source file
String targetExtension = mimetypeService.getExtension(targetMimetype);
@@ -373,7 +377,19 @@ public abstract class AbstractContentTransformerTest extends TestCase
outputWriter.setEncoding("UTF8");
outputWriter.putContent(sb.toString());
}
/**
* Allows a subclass to skip selected transformations.
* @param quickFile name
* @param sourceMimetype of the quickFile
* @param targetMimetype of the transformation
* @return false to skip the transformation.
*/
protected boolean doTestTransformation(String quickFile, String sourceMimetype, String targetMimetype)
{
return false;
}
/**
* Allows implementations to do some extra checks on the
* results of the content as found by

View File

@@ -1,33 +1,36 @@
/*
* #%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 - 2017 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;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.repository.TransformationOptions;
import java.util.Arrays;
import java.util.List;
/**
* Test case for {@link AppleIWorksContentTransformer} content transformer.
*
@@ -36,7 +39,7 @@ import org.alfresco.service.cmr.repository.TransformationOptions;
*/
public class AppleIWorksContentTransformerTest extends AbstractContentTransformerTest
{
private ContentTransformer transformer;
private AppleIWorksContentTransformer transformer;
@Override
public void setUp() throws Exception
@@ -45,9 +48,9 @@ public class AppleIWorksContentTransformerTest extends AbstractContentTransforme
transformer = new AppleIWorksContentTransformer();
// Ugly cast just to set the MimetypeService
((ContentTransformerHelper)transformer).setMimetypeService(mimetypeService);
((ContentTransformerHelper)transformer).setTransformerConfig(transformerConfig);
transformer.setMimetypeService(mimetypeService);
transformer.setTransformerDebug(transformerDebug);
transformer.setTransformerConfig(transformerConfig);
}
@Override
@@ -55,17 +58,38 @@ public class AppleIWorksContentTransformerTest extends AbstractContentTransforme
{
return transformer;
}
// Commented out rather than removed, in case we can get SHARE to fall back to using JPEG when a PDF is not available
// @Override
// protected String[] getQuickFilenames(String sourceMimetype)
// {
// List<String> filenames = Arrays.asList(super.getQuickFilenames(sourceMimetype));
// filenames.add("quick2009.pages");
// return (String[])filenames.toArray();
// }
//
// @Override
// protected boolean doTestTransformation(String quickFile, String sourceMimetype, String targetMimetype)
// {
// // This transformer can only do transforms to PDF when a iWorks 2008/9 file (rather than 2013/14) file is used.
// return !MimetypeMap.MIMETYPE_PDF.equals(targetMimetype) || !"quick2009.pages".endsWith(quickFile);
// }
//
// @Override
// protected boolean isTransformationExcluded(String sourceExtension, String targetExtension)
// {
// return "pdf".equals(targetExtension); // Our quick files are 2013/14 format so don't include a pdf, only jpgs.
// }
public void testIsTransformable() throws Exception
{
// thumbnails
assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_KEYNOTE, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions()));
assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_NUMBERS, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions()));
assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_PAGES, MimetypeMap.MIMETYPE_IMAGE_JPEG, new TransformationOptions()));
// previews
assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_KEYNOTE, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()));
assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_NUMBERS, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()));
assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_PAGES, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()));
// Commented out rather than removed, in case we can get SHARE to fall back to using JPEG when a PDF is not available
// assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_KEYNOTE, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()));
// assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_NUMBERS, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()));
// assertTrue(transformer.isTransformable(MimetypeMap.MIMETYPE_IWORK_PAGES, MimetypeMap.MIMETYPE_PDF, new TransformationOptions()));
}
}