mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
Batch changes from of review comments - there are more
This commit is contained in:
@@ -30,6 +30,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import org.alfresco.transform.tika.TikaTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.alfresco.transform.base.html.OptionsHelper.getOptionNames;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
@@ -69,6 +70,6 @@ public class AIOTikaTest extends TikaTest
|
||||
"targetEncoding",
|
||||
"thumbnail",
|
||||
"width"),
|
||||
optionLister.getOptionNames(controller.transformConfig(0).getBody().getTransformOptions()));
|
||||
getOptionNames(controller.transformConfig(0).getBody().getTransformOptions()));
|
||||
}
|
||||
}
|
@@ -97,6 +97,12 @@
|
||||
<artifactId>httpmime</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -26,7 +26,6 @@
|
||||
*/
|
||||
package org.alfresco.transform.base;
|
||||
|
||||
import org.alfresco.transform.base.html.OptionLister;
|
||||
import org.alfresco.transform.base.logging.LogEntry;
|
||||
import org.alfresco.transform.base.probes.ProbeTransform;
|
||||
import org.alfresco.transform.base.registry.TransformRegistry;
|
||||
@@ -71,6 +70,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.text.MessageFormat.format;
|
||||
import static org.alfresco.transform.base.html.OptionsHelper.getOptionNames;
|
||||
import static org.alfresco.transform.common.RequestParamMap.CONFIG_VERSION;
|
||||
import static org.alfresco.transform.common.RequestParamMap.CONFIG_VERSION_DEFAULT;
|
||||
import static org.alfresco.transform.common.RequestParamMap.ENDPOINT_ERROR;
|
||||
@@ -112,8 +112,6 @@ public class TransformController
|
||||
TransformHandler transformHandler;
|
||||
@Autowired
|
||||
private String coreVersion;
|
||||
@Autowired
|
||||
private OptionLister optionLister;
|
||||
@Value("${container.behind-ingres}")
|
||||
private boolean behindIngres;
|
||||
|
||||
@@ -181,7 +179,7 @@ public class TransformController
|
||||
model.addAttribute(MODEL_PROXY_PATH_PREFIX, getPathPrefix());
|
||||
TransformConfig transformConfig = ((TransformRegistry) transformRegistry).getTransformConfig();
|
||||
transformConfig = setOrClearCoreVersion(transformConfig, 0);
|
||||
model.addAttribute("transformOptions", optionLister.getOptionNames(transformConfig.getTransformOptions()));
|
||||
model.addAttribute("transformOptions", getOptionNames(transformConfig.getTransformOptions()));
|
||||
return "test"; // display test.html
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@ public interface TransformManager
|
||||
* If possible this method should be avoided as it is better not to leave content on disk.
|
||||
* @throws IllegalStateException if this method has already been called.
|
||||
*/
|
||||
File createSourceFile();
|
||||
File createSourceFile() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Allows a {@link CustomTransformer} to use a local target {@code File} rather than the supplied {@code OutputStream}.
|
||||
@@ -61,7 +61,7 @@ public interface TransformManager
|
||||
* @throws IllegalStateException if this method has already been called. A call to {@link #respondWithFragment(Integer, boolean)}
|
||||
* allows the method to be called again.
|
||||
*/
|
||||
File createTargetFile();
|
||||
File createTargetFile() throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Allows a single transform request to have multiple transform responses. For example, images from a video at
|
||||
|
@@ -57,6 +57,10 @@ public class FileManager
|
||||
public static final String SOURCE_FILE = "sourceFile";
|
||||
public static final String TARGET_FILE = "targetFile";
|
||||
|
||||
private FileManager()
|
||||
{
|
||||
}
|
||||
|
||||
public static File createSourceFile(HttpServletRequest request, InputStream inputStream, String sourceMimetype)
|
||||
{
|
||||
try
|
||||
@@ -185,6 +189,7 @@ public class FileManager
|
||||
public static ResponseEntity<Resource> createAttachment(String targetFilename, File targetFile)
|
||||
{
|
||||
Resource targetResource = load(targetFile);
|
||||
// targetFilename should never be null (will be "transform."+<something>), so we should not worry about encodePath(null)
|
||||
targetFilename = UriUtils.encodePath(getFilename(targetFilename), "UTF-8");
|
||||
return ResponseEntity.ok().header(CONTENT_DISPOSITION,
|
||||
"attachment; filename*=UTF-8''" + targetFilename).body(targetResource);
|
||||
@@ -195,6 +200,10 @@ public class FileManager
|
||||
*/
|
||||
public static class TempFileProvider
|
||||
{
|
||||
private TempFileProvider()
|
||||
{
|
||||
}
|
||||
|
||||
public static File createTempFile(final String prefix, final String suffix)
|
||||
{
|
||||
final File directory = getTempDir();
|
||||
|
@@ -35,36 +35,42 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Used in the html test page, which provides a list of known transform option names.
|
||||
*/
|
||||
@Component
|
||||
public class OptionLister
|
||||
public class OptionsHelper
|
||||
{
|
||||
public Set<String> getOptionNames(Map<String, Set<TransformOption>> transformOptionsByName)
|
||||
private OptionsHelper()
|
||||
{
|
||||
}
|
||||
|
||||
public static Set<String> getOptionNames(Map<String, Set<TransformOption>> transformOptionsByName)
|
||||
{
|
||||
Set<String> set = new TreeSet<>();
|
||||
transformOptionsByName.forEach(((optionName, optionSet) -> {
|
||||
optionSet.stream().forEach(option -> addToList(set, option));
|
||||
}));
|
||||
transformOptionsByName.forEach(((optionName, optionSet) ->
|
||||
optionSet.stream().forEach(option -> addOption(set, option))));
|
||||
return set;
|
||||
}
|
||||
|
||||
private void addToList(Set<String> set, TransformOption option)
|
||||
private static void addOption(Set<String> set, TransformOption option)
|
||||
{
|
||||
if (option instanceof TransformOptionGroup)
|
||||
{
|
||||
addGroupToList(set, (TransformOptionGroup)option);
|
||||
addGroup(set, (TransformOptionGroup)option);
|
||||
}
|
||||
else
|
||||
{
|
||||
addValueToList(set, (TransformOptionValue)option);
|
||||
addValue(set, (TransformOptionValue)option);
|
||||
}
|
||||
}
|
||||
|
||||
private void addGroupToList(Set<String> set, TransformOptionGroup group)
|
||||
private static void addGroup(Set<String> set, TransformOptionGroup group)
|
||||
{
|
||||
group.getTransformOptions().stream().forEach(option -> addToList(set, option));
|
||||
group.getTransformOptions().stream().forEach(option -> addOption(set, option));
|
||||
}
|
||||
|
||||
private void addValueToList(Set<String> set, TransformOptionValue value)
|
||||
private static void addValue(Set<String> set, TransformOptionValue value)
|
||||
{
|
||||
set.add(value.getName());
|
||||
}
|
@@ -33,12 +33,13 @@ import static org.alfresco.transform.base.fs.FileManager.deleteFile;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
/**
|
||||
* Cleans up temporary files in transform requests that upload the content and download the result.
|
||||
*/
|
||||
public class TransformInterceptor extends HandlerInterceptorAdapter
|
||||
public class TransformInterceptor implements AsyncHandlerInterceptor
|
||||
{
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request,
|
||||
|
@@ -26,8 +26,10 @@
|
||||
*/
|
||||
package org.alfresco.transform.base.logging;
|
||||
|
||||
import static java.lang.Math.max;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
@@ -36,9 +38,8 @@ import java.util.Deque;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import static java.lang.Math.max;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
/**
|
||||
* Provides setter and getter methods to allow the current Thread to set various log properties and for these
|
||||
@@ -96,7 +97,7 @@ public final class LogEntry
|
||||
|
||||
private void append(StringBuilder sb, String value)
|
||||
{
|
||||
if (value != null && !value.isEmpty() && !"0bytes".equals(value))
|
||||
if (StringUtils.isNotBlank(value) && !"0bytes".equals(value))
|
||||
{
|
||||
sb.append(value);
|
||||
sb.append(' ');
|
||||
|
@@ -26,14 +26,18 @@
|
||||
*/
|
||||
package org.alfresco.transform.base.logging;
|
||||
|
||||
public interface StandardMessages
|
||||
public final class StandardMessages
|
||||
{
|
||||
String COMMUNITY_LICENCE =
|
||||
private StandardMessages()
|
||||
{
|
||||
}
|
||||
|
||||
public static String COMMUNITY_LICENCE =
|
||||
"If the Alfresco software was purchased under a paid Alfresco license, the terms of the paid license agreement \n" +
|
||||
"will prevail. Otherwise, the software is provided under terms of the GNU LGPL v3 license. \n" +
|
||||
"See the license at http://www.gnu.org/licenses/lgpl-3.0.txt. or in /LICENSE.txt \n\n";
|
||||
|
||||
String ENTERPRISE_LICENCE =
|
||||
public static String ENTERPRISE_LICENCE =
|
||||
"This image is only intended to be used with the Alfresco Enterprise Content Repository which is covered by\n" +
|
||||
"https://www.alfresco.com/legal/agreements and https://www.alfresco.com/terms-use\n" +
|
||||
"\n" +
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2018 Alfresco Software, Ltd. All rights reserved.
|
||||
* Copyright 2015-2022 Alfresco Software, Ltd. All rights reserved.
|
||||
*
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
|
@@ -59,7 +59,6 @@ public class TransformReplySender
|
||||
{
|
||||
try
|
||||
{
|
||||
//jmsTemplate.setSessionTransacted(true); // do we need this?
|
||||
jmsTemplate.convertAndSend(destination, reply, m -> {
|
||||
m.setJMSCorrelationID(correlationId);
|
||||
return m;
|
||||
|
@@ -33,7 +33,6 @@ import org.alfresco.transform.base.CustomTransformer;
|
||||
import org.alfresco.transform.base.TransformManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -127,7 +126,7 @@ public abstract class AbstractMetadataExtractorEmbedder implements CustomTransfo
|
||||
|
||||
private final Type type;
|
||||
|
||||
public AbstractMetadataExtractorEmbedder(Type type, Logger logger)
|
||||
protected AbstractMetadataExtractorEmbedder(Type type, Logger logger)
|
||||
{
|
||||
this.type = type;
|
||||
this.logger = logger;
|
||||
@@ -507,7 +506,7 @@ public abstract class AbstractMetadataExtractorEmbedder implements CustomTransfo
|
||||
}
|
||||
finally
|
||||
{
|
||||
extractMapping.set(null);
|
||||
extractMapping.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -212,7 +212,7 @@ public class ProbeTransform
|
||||
|
||||
File sourceFile = getSourceFile(isLiveProbe);
|
||||
File targetFile = getTargetFile();
|
||||
transformHandler.handleProbRequest(sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile, this);
|
||||
transformHandler.handleProbeRequest(sourceMimetype, targetMimetype, transformOptions, sourceFile, targetFile, this);
|
||||
long time = System.currentTimeMillis() - start;
|
||||
String message = "Transform " + time + "ms";
|
||||
checkTargetFile(targetFile, isLiveProbe, message);
|
||||
|
@@ -32,7 +32,7 @@ public abstract class AbstractTransformConfigSource implements TransformConfigSo
|
||||
private final String readFrom;
|
||||
private final String baseUrl;
|
||||
|
||||
public AbstractTransformConfigSource(String sortOnName, String readFrom, String baseUrl)
|
||||
protected AbstractTransformConfigSource(String sortOnName, String readFrom, String baseUrl)
|
||||
{
|
||||
this.sortOnName = sortOnName;
|
||||
this.readFrom = readFrom;
|
||||
|
@@ -61,7 +61,7 @@ import static org.springframework.http.HttpStatus.OK;
|
||||
* Provides the transform logic common to http (upload/download), message and probe requests. See
|
||||
* {@link TransformHandler#handleHttpRequest(HttpServletRequest, MultipartFile, String, String, Map, ProbeTransform)},
|
||||
* {@link TransformHandler#handleMessageRequest(TransformRequest, Long, Destination, ProbeTransform)} and
|
||||
* {@link TransformHandler#handleProbRequest(String, String, Map, File, File, ProbeTransform)}. Note the handing of transform requests
|
||||
* {@link TransformHandler#handleProbeRequest(String, String, Map, File, File, ProbeTransform)}. Note the handing of transform requests
|
||||
* via a message queue is the same as via the {@link TransformController#transform(TransformRequest, Long, Destination)}.
|
||||
*/
|
||||
abstract class ProcessHandler extends FragmentHandler
|
||||
@@ -151,6 +151,7 @@ abstract class ProcessHandler extends FragmentHandler
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logFragment(Integer index, Long outputLength)
|
||||
{
|
||||
transformerDebug.logFragment(reference, index, outputLength);
|
||||
@@ -200,7 +201,7 @@ abstract class ProcessHandler extends FragmentHandler
|
||||
.collect(Collectors.joining(", ", " ", "")));
|
||||
}
|
||||
return transformerName;
|
||||
}
|
||||
}
|
||||
|
||||
private CustomTransformer getCustomTransformer(String transformName)
|
||||
{
|
||||
|
@@ -85,8 +85,11 @@ import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
@Component
|
||||
public class TransformHandler
|
||||
{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TransformHandler.class);
|
||||
|
||||
private static final String FAILED_WRITING_TO_SFS = "Failed writing to SFS";
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<TransformEngine> transformEngines;
|
||||
@Autowired(required = false)
|
||||
@@ -141,6 +144,7 @@ public class TransformHandler
|
||||
return sourceMultipartFile == null ? -1 : sourceMultipartFile.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendTransformResponse(TransformManagerImpl transformManager)
|
||||
{
|
||||
String extension = ExtensionService.getExtensionForTargetMimetype(targetMimetype, sourceMimetype);
|
||||
@@ -151,7 +155,7 @@ public class TransformHandler
|
||||
return responseEntity.get();
|
||||
}
|
||||
|
||||
public void handleProbRequest(String sourceMimetype, String targetMimetype, Map<String, String> transformOptions,
|
||||
public void handleProbeRequest(String sourceMimetype, String targetMimetype, Map<String, String> transformOptions,
|
||||
File sourceFile, File targetFile, ProbeTransform probeTransform)
|
||||
{
|
||||
new ProcessHandler(sourceMimetype, targetMimetype, transformOptions,
|
||||
@@ -170,7 +174,7 @@ public class TransformHandler
|
||||
@Override
|
||||
protected InputStream getInputStream()
|
||||
{
|
||||
return getInputStreamForHandleProbRequest(sourceFile);
|
||||
return getInputStreamForHandleProbeRequest(sourceFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,6 +232,7 @@ public class TransformHandler
|
||||
return getOutputStreamFromFile(transformManager.getTargetFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendTransformResponse(TransformManagerImpl transformManager)
|
||||
{
|
||||
reply.getInternalContext().setCurrentSourceSize(transformManager.getOutputLength());
|
||||
@@ -345,7 +350,7 @@ public class TransformHandler
|
||||
: getDirectAccessUrlInputStream(directUrl));
|
||||
}
|
||||
|
||||
private InputStream getInputStreamForHandleProbRequest(File sourceFile)
|
||||
private InputStream getInputStreamForHandleProbeRequest(File sourceFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -390,15 +395,15 @@ public class TransformHandler
|
||||
}
|
||||
catch (TransformException e)
|
||||
{
|
||||
throw new TransformException(e.getStatus(), messageWithCause("Failed writing to SFS", e));
|
||||
throw new TransformException(e.getStatus(), messageWithCause(FAILED_WRITING_TO_SFS, e));
|
||||
}
|
||||
catch (HttpClientErrorException e)
|
||||
{
|
||||
throw new TransformException(e.getStatusCode(), messageWithCause("Failed writing to SFS", e));
|
||||
throw new TransformException(e.getStatusCode(), messageWithCause(FAILED_WRITING_TO_SFS, e));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new TransformException(INTERNAL_SERVER_ERROR, messageWithCause("Failed writing to SFS", e));
|
||||
throw new TransformException(INTERNAL_SERVER_ERROR, messageWithCause(FAILED_WRITING_TO_SFS, e));
|
||||
}
|
||||
|
||||
reply.setTargetReference(targetRef.getEntry().getFileRef());
|
||||
|
@@ -49,12 +49,14 @@ public class OutputStreamLengthRecorder extends FilterOutputStream
|
||||
this.byteCount = byteCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException
|
||||
{
|
||||
super.write(b);
|
||||
byteCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte b[], int off, int len) throws IOException
|
||||
{
|
||||
super.write(b, off, len);
|
||||
|
@@ -26,11 +26,12 @@
|
||||
*/
|
||||
package org.alfresco.transform.base.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class Util
|
||||
{
|
||||
private Util()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely converts a {@link String} to an {@link Integer}
|
||||
*
|
||||
|
@@ -106,9 +106,6 @@ public abstract class AbstractBaseTest
|
||||
@SpyBean
|
||||
protected TransformServiceRegistry transformRegistry;
|
||||
|
||||
@Autowired
|
||||
private String coreVersion;
|
||||
|
||||
protected String sourceExtension;
|
||||
protected String targetExtension;
|
||||
protected String sourceMimetype;
|
||||
|
@@ -50,19 +50,6 @@ public class JmsClient
|
||||
return queue;
|
||||
}
|
||||
|
||||
private static void deleteQueues(final ConnectionFactory factory,
|
||||
final ActiveMQQueue... queues) throws Exception
|
||||
{
|
||||
try (final Connection connection = factory.createConnection())
|
||||
{
|
||||
for (ActiveMQQueue q : queues)
|
||||
{
|
||||
// will fail if there are active subscribers
|
||||
((ActiveMQConnection) connection).destroyDestination(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendBytesMessage(final TransformRequest request)
|
||||
throws Exception
|
||||
{
|
||||
|
@@ -1,3 +1,29 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Transform Core
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 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.transform.base.fakes;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -11,13 +37,11 @@ import java.util.Collections;
|
||||
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_JPEG;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_PDF;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_TEXT_PLAIN;
|
||||
|
||||
public class FakeTransformEngineWithFragments extends AbstractFakeTransformEngine
|
||||
{
|
||||
@Override public TransformConfig getTransformConfig()
|
||||
{
|
||||
String imageOptions = "imageOptions";
|
||||
return TransformConfig.builder()
|
||||
.withTransformers(ImmutableList.of(
|
||||
Transformer.builder()
|
||||
|
@@ -29,7 +29,6 @@ package org.alfresco.transform.base.http;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.alfresco.transform.base.html.OptionLister;
|
||||
import org.alfresco.transform.config.TransformOption;
|
||||
import org.alfresco.transform.config.TransformOptionGroup;
|
||||
import org.alfresco.transform.config.TransformOptionValue;
|
||||
@@ -40,21 +39,17 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.alfresco.transform.base.html.OptionsHelper.getOptionNames;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Used in the html test page.
|
||||
*/
|
||||
public class OptionListerTest
|
||||
public class OptionsHelperTest
|
||||
{
|
||||
OptionLister optionLister = new OptionLister();
|
||||
|
||||
@Test
|
||||
public void emptyListTest()
|
||||
public void emptyTest()
|
||||
{
|
||||
Map<String, Set<TransformOption>> transformOptionsByName = Collections.emptyMap();
|
||||
|
||||
assertEquals(Collections.emptySet(), optionLister.getOptionNames(transformOptionsByName));
|
||||
assertEquals(Collections.emptySet(), getOptionNames(transformOptionsByName));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,7 +58,7 @@ public class OptionListerTest
|
||||
Map<String, Set<TransformOption>> transformOptionsByName = ImmutableMap.of("Dummy", ImmutableSet.of(
|
||||
new TransformOptionValue(true, "startPage")));
|
||||
|
||||
assertEquals(ImmutableSet.of("startPage"), optionLister.getOptionNames(transformOptionsByName));
|
||||
assertEquals(ImmutableSet.of("startPage"), getOptionNames(transformOptionsByName));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,7 +67,7 @@ public class OptionListerTest
|
||||
Map<String, Set<TransformOption>> transformOptionsByName = ImmutableMap.of("DummyOptions", ImmutableSet.of(
|
||||
new TransformOptionValue(true, "startPage")));
|
||||
|
||||
assertEquals(ImmutableSet.of("startPage"), optionLister.getOptionNames(transformOptionsByName));
|
||||
assertEquals(ImmutableSet.of("startPage"), getOptionNames(transformOptionsByName));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +76,7 @@ public class OptionListerTest
|
||||
Map<String, Set<TransformOption>> transformOptionsByName = ImmutableMap.of("DummyOptions", ImmutableSet.of(
|
||||
new TransformOptionValue(true, "startPage")));
|
||||
|
||||
assertEquals(ImmutableSet.of("startPage"), optionLister.getOptionNames(transformOptionsByName));
|
||||
assertEquals(ImmutableSet.of("startPage"), getOptionNames(transformOptionsByName));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,7 +86,7 @@ public class OptionListerTest
|
||||
new TransformOptionValue(false, "startPage"),
|
||||
new TransformOptionValue(true, "endPage")));
|
||||
|
||||
assertEquals(ImmutableSet.of("startPage", "endPage"), optionLister.getOptionNames(transformOptionsByName));
|
||||
assertEquals(ImmutableSet.of("startPage", "endPage"), getOptionNames(transformOptionsByName));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,7 +99,7 @@ public class OptionListerTest
|
||||
new TransformOptionValue(false, "f"),
|
||||
new TransformOptionValue(true, "z")));
|
||||
|
||||
assertEquals(ImmutableList.of("a", "f", "k", "n", "z"), new ArrayList<>(optionLister.getOptionNames(transformOptionsByName)));
|
||||
assertEquals(ImmutableList.of("a", "f", "k", "n", "z"), new ArrayList<>(getOptionNames(transformOptionsByName)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,7 +123,7 @@ public class OptionListerTest
|
||||
"x",
|
||||
"y",
|
||||
"ratio"),
|
||||
optionLister.getOptionNames(transformOptionsByName));
|
||||
getOptionNames(transformOptionsByName));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,7 +146,7 @@ public class OptionListerTest
|
||||
"scale",
|
||||
"x",
|
||||
"y"),
|
||||
optionLister.getOptionNames(transformOptionsByName));
|
||||
getOptionNames(transformOptionsByName));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -184,6 +179,6 @@ public class OptionListerTest
|
||||
"4.2.2.1",
|
||||
"4.2.3",
|
||||
"4.3"),
|
||||
optionLister.getOptionNames(transformOptionsByName));
|
||||
getOptionNames(transformOptionsByName));
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Transform Core
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
@@ -32,11 +32,9 @@ import org.alfresco.transform.client.model.TransformReply;
|
||||
import org.alfresco.transform.client.model.TransformRequest;
|
||||
import org.apache.activemq.command.ActiveMQObjectMessage;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jms.support.converter.MessageConversionException;
|
||||
|
||||
@@ -49,7 +47,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
@@ -72,9 +70,9 @@ public class QueueTransformServiceTest
|
||||
{
|
||||
queueTransformService.receive(null);
|
||||
|
||||
verifyNoMoreInteractions(transformController);
|
||||
verifyNoMoreInteractions(transformMessageConverter);
|
||||
verifyNoMoreInteractions(transformReplySender);
|
||||
verifyNoInteractions(transformController);
|
||||
verifyNoInteractions(transformMessageConverter);
|
||||
verifyNoInteractions(transformReplySender);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,9 +80,9 @@ public class QueueTransformServiceTest
|
||||
{
|
||||
queueTransformService.receive(new ActiveMQObjectMessage());
|
||||
|
||||
verifyNoMoreInteractions(transformController);
|
||||
verifyNoMoreInteractions(transformMessageConverter);
|
||||
verifyNoMoreInteractions(transformReplySender);
|
||||
verifyNoInteractions(transformController);
|
||||
verifyNoInteractions(transformMessageConverter);
|
||||
verifyNoInteractions(transformReplySender);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,7 +108,7 @@ public class QueueTransformServiceTest
|
||||
verify(transformMessageConverter).fromMessage(msg);
|
||||
verify(transformReplySender).send(destination, reply, msg.getCorrelationId());
|
||||
|
||||
verifyNoMoreInteractions(transformController);
|
||||
verifyNoInteractions(transformController);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,7 +135,7 @@ public class QueueTransformServiceTest
|
||||
verify(transformMessageConverter).fromMessage(msg);
|
||||
verify(transformReplySender).send(destination, reply, msg.getCorrelationId());
|
||||
|
||||
verifyNoMoreInteractions(transformController);
|
||||
verifyNoInteractions(transformController);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,7 +162,7 @@ public class QueueTransformServiceTest
|
||||
verify(transformMessageConverter).fromMessage(msg);
|
||||
verify(transformReplySender).send(destination, reply, msg.getCorrelationId());
|
||||
|
||||
verifyNoMoreInteractions(transformController);
|
||||
verifyNoInteractions(transformController);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -200,9 +198,9 @@ public class QueueTransformServiceTest
|
||||
|
||||
queueTransformService.receive(msg);
|
||||
|
||||
verifyNoMoreInteractions(transformController);
|
||||
verifyNoMoreInteractions(transformMessageConverter);
|
||||
verifyNoMoreInteractions(transformReplySender);
|
||||
verifyNoInteractions(transformController);
|
||||
verifyNoInteractions(transformMessageConverter);
|
||||
verifyNoInteractions(transformReplySender);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -11,6 +11,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import org.alfresco.transform.base.fakes.FakeTransformEngineWithTwoCustomTransformers;
|
||||
import org.alfresco.transform.base.fakes.FakeTransformerPdf2Png;
|
||||
import org.alfresco.transform.base.fakes.FakeTransformerTxT2Pdf;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
@@ -20,6 +21,9 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -43,7 +47,7 @@ public class TransformRegistryRefreshTest
|
||||
@Test
|
||||
public void checkRegistryRefreshes() throws InterruptedException
|
||||
{
|
||||
waitForRegistryReady(1000);
|
||||
waitForRegistryReady();
|
||||
assertEquals(4, transformRegistry.getTransformConfig().getTransformers().size());
|
||||
verify(transformRegistry, atLeast(1)).retrieveConfig();
|
||||
|
||||
@@ -53,22 +57,18 @@ public class TransformRegistryRefreshTest
|
||||
"foo", "config/addB2C.json"));
|
||||
transformConfigFromFiles.initFileConfig();
|
||||
|
||||
Thread.sleep(3000); // to give it a chance to refresh a few (at least 2 more) times
|
||||
verify(transformRegistry, atLeast(1+2)).retrieveConfig();
|
||||
assertEquals(6, transformRegistry.getTransformConfig().getTransformers().size());
|
||||
Awaitility.await().pollDelay(3, TimeUnit.SECONDS).until( () -> { // i.e. Thread.sleep(3_000) - but keeps sona happy
|
||||
verify(transformRegistry, atLeast(1+2)).retrieveConfig();
|
||||
assertEquals(6, transformRegistry.getTransformConfig().getTransformers().size());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void waitForRegistryReady(int timeout) throws InterruptedException
|
||||
private void waitForRegistryReady() throws InterruptedException
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
while (!transformRegistry.isReadyForTransformRequests())
|
||||
{
|
||||
if (System.currentTimeMillis()-start > timeout)
|
||||
{
|
||||
throw new IllegalStateException("Registry is still not ready after "+timeout+" ms");
|
||||
}
|
||||
Thread.sleep(100);
|
||||
}
|
||||
System.out.println("Registry ready after "+(System.currentTimeMillis()-start)+" ms");
|
||||
Awaitility.await().atMost(1, TimeUnit.SECONDS)
|
||||
.pollInterval(100, TimeUnit.MILLISECONDS)
|
||||
.pollDelay(Duration.ZERO)
|
||||
.until(() -> transformRegistry.isReadyForTransformRequests());
|
||||
}
|
||||
}
|
||||
|
@@ -27,13 +27,13 @@
|
||||
package org.alfresco.transform.base.transform;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.alfresco.transform.base.sfs.SharedFileStoreClient;
|
||||
import org.alfresco.transform.base.fakes.FakeTransformEngineWithFragments;
|
||||
import org.alfresco.transform.base.fakes.FakeTransformerFragments;
|
||||
import org.alfresco.transform.base.messaging.TransformReplySender;
|
||||
import org.alfresco.transform.base.model.FileRefEntity;
|
||||
import org.alfresco.transform.base.model.FileRefResponse;
|
||||
import org.alfresco.transform.base.probes.ProbeTransform;
|
||||
import org.alfresco.transform.base.sfs.SharedFileStoreClient;
|
||||
import org.alfresco.transform.client.model.TransformReply;
|
||||
import org.alfresco.transform.client.model.TransformRequest;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -69,7 +69,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
@@ -238,7 +238,9 @@ public class StreamHandlerTest
|
||||
@Test
|
||||
public void testStartWithOutputStream()
|
||||
{
|
||||
// Do nothing. Same as testUsingInputStream() which just uses the outputStream
|
||||
// This method exists so that we have a test for each input or output type. However, it contains no code
|
||||
// because it would be identical to the testStartWithInputStream method. Testing without both and input
|
||||
// and output would be far more complicated.
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -328,7 +330,8 @@ public class StreamHandlerTest
|
||||
@Test
|
||||
public void testHandleHttpRequestApproachUsingSourceAndTargetStreams()
|
||||
{
|
||||
// Do nothing. Same as testUsingInputStream() which uses inputStream and outputStream
|
||||
// This method exists so that we have a test for each request approach. However, it contains no code
|
||||
// because it would be identical to the testStartWithInputStream method.
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -26,7 +26,6 @@
|
||||
*/
|
||||
package org.alfresco.transform.misc.metadataExtractors;
|
||||
|
||||
import org.alfresco.transform.base.CustomTransformer;
|
||||
import org.alfresco.transform.base.TransformManager;
|
||||
import org.alfresco.transform.base.metadata.AbstractMetadataExtractorEmbedder;
|
||||
import org.slf4j.Logger;
|
||||
|
@@ -26,7 +26,6 @@
|
||||
*/
|
||||
package org.alfresco.transform.misc.metadataExtractors;
|
||||
|
||||
import org.alfresco.transform.base.CustomTransformer;
|
||||
import org.alfresco.transform.base.TransformManager;
|
||||
import org.alfresco.transform.base.metadata.AbstractMetadataExtractorEmbedder;
|
||||
import org.slf4j.Logger;
|
||||
@@ -179,11 +178,10 @@ public class RFC822MetadataExtractor extends AbstractMetadataExtractorEmbedder
|
||||
* Extract values from all header fields, including extension fields "X-"
|
||||
*/
|
||||
Set<String> keys = getExtractMapping().keySet();
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<Header> headers = mimeMessage.getAllHeaders();
|
||||
while (headers.hasMoreElements())
|
||||
{
|
||||
Header header = (Header) headers.nextElement();
|
||||
Header header = headers.nextElement();
|
||||
if (keys.contains(header.getName()))
|
||||
{
|
||||
tmp = header.getValue();
|
||||
|
@@ -28,6 +28,8 @@ package org.alfresco.transform.misc;
|
||||
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_HTML;
|
||||
import static org.alfresco.transform.base.clients.FileInfo.testFile;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_RFC822;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_XHTML;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -56,14 +58,14 @@ public class MiscMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
{
|
||||
return Stream.of(
|
||||
// HtmlMetadataExtractor
|
||||
// testFile(MIMETYPE_HTML, "html", "quick.html"), testFile(MIMETYPE_XHTML, "xhtml", "quick.xhtml.alf"), // avoid the license header check on xhtml
|
||||
//
|
||||
// // RFC822MetadataExtractor
|
||||
// testFile(MIMETYPE_RFC822, "eml", "quick.eml"),
|
||||
//
|
||||
// // Special test cases from the repo tests
|
||||
// // ======================================
|
||||
// testFile(MIMETYPE_RFC822, "eml", "quick.spanish.eml"),
|
||||
testFile(MIMETYPE_HTML, "html", "quick.html"), testFile(MIMETYPE_XHTML, "xhtml", "quick.xhtml.alf"), // avoid the license header check on xhtml
|
||||
|
||||
// RFC822MetadataExtractor
|
||||
testFile(MIMETYPE_RFC822, "eml", "quick.eml"),
|
||||
|
||||
// Special test cases from the repo tests
|
||||
// ======================================
|
||||
testFile(MIMETYPE_RFC822, "eml", "quick.spanish.eml"),
|
||||
testFile(MIMETYPE_HTML, "html", "quick.japanese.html")
|
||||
);
|
||||
}
|
||||
|
@@ -65,8 +65,6 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.alfresco.transform.base.metadata.AbstractMetadataExtractorEmbedder.Type;
|
||||
|
||||
/**
|
||||
* The parent of all Metadata Extractors which use Apache Tika under the hood. This handles all the
|
||||
* common parts of processing the files, and the common mappings.
|
||||
@@ -97,7 +95,7 @@ public abstract class AbstractTikaMetadataExtractorEmbeddor extends AbstractMeta
|
||||
private final DateTimeFormatter tikaUTCDateFormater;
|
||||
private final DateTimeFormatter tikaDateFormater;
|
||||
|
||||
public AbstractTikaMetadataExtractorEmbeddor(Type type, Logger logger)
|
||||
protected AbstractTikaMetadataExtractorEmbeddor(Type type, Logger logger)
|
||||
{
|
||||
super(type, logger);
|
||||
|
||||
|
@@ -35,6 +35,6 @@ public class ArchiveTransformer extends AbstractTikaTransformer
|
||||
@Override
|
||||
protected Parser getParser()
|
||||
{
|
||||
return tika.packageParser;
|
||||
return Tika.packageParser;
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,6 @@ public class OOXMLTransformer extends AbstractTikaTransformer
|
||||
@Override
|
||||
protected Parser getParser()
|
||||
{
|
||||
return tika.ooXmlParser;
|
||||
return Tika.ooXmlParser;
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,6 @@ public class OfficeTransformer extends AbstractTikaTransformer
|
||||
@Override
|
||||
protected Parser getParser()
|
||||
{
|
||||
return tika.officeParser;
|
||||
return Tika.officeParser;
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,6 @@ public class OutlookMsgTransformer extends AbstractTikaTransformer
|
||||
@Override
|
||||
protected Parser getParser()
|
||||
{
|
||||
return tika.officeParser;
|
||||
return Tika.officeParser;
|
||||
}
|
||||
}
|
||||
|
@@ -36,12 +36,12 @@ public class PdfBoxTransformer extends AbstractTikaTransformer
|
||||
@Override
|
||||
protected Parser getParser()
|
||||
{
|
||||
return tika.pdfParser;
|
||||
return Tika.pdfParser;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DocumentSelector getDocumentSelector()
|
||||
{
|
||||
return tika.pdfBoxEmbededDocumentSelector;
|
||||
return Tika.pdfBoxEmbededDocumentSelector;
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,6 @@ public class PoiTransformer extends AbstractTikaTransformer
|
||||
@Override
|
||||
protected Parser getParser()
|
||||
{
|
||||
return tika.tikaOfficeDetectParser;
|
||||
return Tika.tikaOfficeDetectParser;
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,6 @@ public class TextMiningTransformer extends AbstractTikaTransformer
|
||||
@Override
|
||||
protected Parser getParser()
|
||||
{
|
||||
return tika.officeParser;
|
||||
return Tika.officeParser;
|
||||
}
|
||||
}
|
||||
|
@@ -255,6 +255,7 @@ public class Tika
|
||||
}
|
||||
else
|
||||
{
|
||||
javax.xml.transform.TransformerFactory.newInstance();
|
||||
SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
|
||||
TransformerHandler transformerHandler;
|
||||
transformerHandler = factory.newTransformerHandler();
|
||||
|
@@ -26,15 +26,26 @@
|
||||
*/
|
||||
package org.alfresco.transform.tika;
|
||||
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_APP_DWG;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_OUTLOOK_MSG;
|
||||
import org.alfresco.transform.base.clients.FileInfo;
|
||||
import org.alfresco.transform.base.metadata.AbstractMetadataExtractsIT;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.alfresco.transform.base.clients.FileInfo.testFile;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_APP_DWG;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_AUDIO_MP4;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_EXCEL;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_BMP;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_GIF;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_JPEG;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_PNG;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_ARW;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_CR2;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_NEF;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_RAF;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_RW2;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_TIFF;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IWORK_KEYNOTE;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IWORK_NUMBERS;
|
||||
@@ -53,6 +64,7 @@ import static org.alfresco.transform.common.Mimetype.MIMETYPE_OPENOFFICE1_WRITER
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_OPENXML_PRESENTATION;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_OPENXML_SPREADSHEET;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_OPENXML_WORDPROCESSING;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_OUTLOOK_MSG;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_PDF;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_PPT;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_TEXT_PLAIN;
|
||||
@@ -66,18 +78,6 @@ import static org.alfresco.transform.common.Mimetype.MIMETYPE_VORBIS;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_WORD;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_XML;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_ZIP;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_RAF;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_ARW;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_CR2;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_RW2;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_IMAGE_RAW_NEF;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.alfresco.transform.base.metadata.AbstractMetadataExtractsIT;
|
||||
import org.alfresco.transform.base.clients.FileInfo;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/**
|
||||
* Metadata integration tests in the Tika T-Engine.
|
||||
@@ -106,40 +106,40 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
|
||||
return Stream.of(
|
||||
//IPTCMetadataExtractor
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_JPEG, "jpg", "quick.jpg"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_JPEG, "jpg", "quickIPTC-EXT.jpg"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_JPEG, "jpg", "quickIPTC-multi-creator.jpg"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_JPEG, "jpg", "testJPEG_IPTC_EXT.jpg"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_GIF, "gif", "quickIPTC.gif"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_PNG, "png", "quickIPTC.png"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_RAW_ARW, "arw", "20140614_163822_Photogrpahy_Class.ARW"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_RAW_CR2, "cr2", "20141227_134519_Palace.CR2"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_RAW_RW2, "rw2", "20140629_145035_Flower.RW2"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_RAW_NEF, "nef", "20150408_074941_Bush.NEF"),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_RAW_RAF, "raf", "20160502_190928_London_Underground.RAF"),
|
||||
testFile(MIMETYPE_IMAGE_JPEG, "jpg", "quick.jpg"),
|
||||
testFile(MIMETYPE_IMAGE_JPEG, "jpg", "quickIPTC-EXT.jpg"),
|
||||
testFile(MIMETYPE_IMAGE_JPEG, "jpg", "quickIPTC-multi-creator.jpg"),
|
||||
testFile(MIMETYPE_IMAGE_JPEG, "jpg", "testJPEG_IPTC_EXT.jpg"),
|
||||
testFile(MIMETYPE_IMAGE_GIF, "gif", "quickIPTC.gif"),
|
||||
testFile(MIMETYPE_IMAGE_PNG, "png", "quickIPTC.png"),
|
||||
testFile(MIMETYPE_IMAGE_RAW_ARW, "arw", "20140614_163822_Photogrpahy_Class.ARW"),
|
||||
testFile(MIMETYPE_IMAGE_RAW_CR2, "cr2", "20141227_134519_Palace.CR2"),
|
||||
testFile(MIMETYPE_IMAGE_RAW_RW2, "rw2", "20140629_145035_Flower.RW2"),
|
||||
testFile(MIMETYPE_IMAGE_RAW_NEF, "nef", "20150408_074941_Bush.NEF"),
|
||||
testFile(MIMETYPE_IMAGE_RAW_RAF, "raf", "20160502_190928_London_Underground.RAF"),
|
||||
|
||||
// DWGMetadataExtractor
|
||||
FileInfo.testFile(MIMETYPE_APP_DWG, "dwg", "quick2010CustomProps.dwg"),
|
||||
testFile(MIMETYPE_APP_DWG, "dwg", "quick2010CustomProps.dwg"),
|
||||
|
||||
// MailMetadataExtractor
|
||||
FileInfo.testFile(MIMETYPE_OUTLOOK_MSG, "msg", "quick.msg"),
|
||||
testFile(MIMETYPE_OUTLOOK_MSG, "msg", "quick.msg"),
|
||||
|
||||
// MP3MetadataExtractor
|
||||
FileInfo.testFile(MIMETYPE_MP3, "mp3", "quick.mp3"),
|
||||
testFile(MIMETYPE_MP3, "mp3", "quick.mp3"),
|
||||
|
||||
// OfficeMetadataExtractor
|
||||
FileInfo.testFile(MIMETYPE_WORD, "doc", "quick.doc"),
|
||||
testFile(MIMETYPE_WORD, "doc", "quick.doc"),
|
||||
//testFile("application/x-tika-msoffice-embedded; format=ole10_native", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_VISIO, "vsd", "quick.vsd"),
|
||||
testFile(MIMETYPE_VISIO, "vsd", "quick.vsd"),
|
||||
//testFile("application/vnd.ms-project", "mpp", ""),
|
||||
//testFile("application/x-tika-msworks-spreadsheet", "", ""),
|
||||
//testFile("application/x-mspublisher", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_PPT, "ppt", "quick.ppt"),
|
||||
testFile(MIMETYPE_PPT, "ppt", "quick.ppt"),
|
||||
//testFile("application/x-tika-msoffice", "", ""),
|
||||
//testFile(MIMETYPE_VISIO_2013, "vsdx", ""),
|
||||
//testFile("application/sldworks", "", ""),
|
||||
//testFile(MIMETYPE_ENCRYPTED_OFFICE, "", ""),
|
||||
FileInfo.testFile(MIMETYPE_EXCEL, "xls", "quick.xls"),
|
||||
testFile(MIMETYPE_EXCEL, "xls", "quick.xls"),
|
||||
|
||||
// OpenDocumentMetadataExtractor
|
||||
//testFile("application/x-vnd.oasis.opendocument.presentation", "", ""),
|
||||
@@ -147,14 +147,14 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile(MIMETYPE_OPENDOCUMENT_IMAGE_TEMPLATE, "", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.text-web", "", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.image", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS_TEMPLATE, "otg", "quick.otg"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS_TEMPLATE, "otg", "quick.otg"),
|
||||
//testFile(MIMETYPE_OPENDOCUMENT_TEXT_WEB, "oth", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.spreadsheet-template", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_SPREADSHEET_TEMPLATE, "ots", "quick.ots"),
|
||||
FileInfo.testFile(MIMETYPE_OPENOFFICE1_WRITER, "sxw", "quick.sxw"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_SPREADSHEET_TEMPLATE, "ots", "quick.ots"),
|
||||
testFile(MIMETYPE_OPENOFFICE1_WRITER, "sxw", "quick.sxw"),
|
||||
//testFile("application/x-vnd.oasis.opendocument.graphics-template", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS, "odg", "quick.odg"),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_SPREADSHEET, "ods", "quick.ods"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS, "odg", "quick.odg"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_SPREADSHEET, "ods", "quick.ods"),
|
||||
//testFile("application/x-vnd.oasis.opendocument.chart", "", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.spreadsheet", "", ""),
|
||||
//testFile(MIMETYPE_OPENDOCUMENT_IMAGE, "odi", ""),
|
||||
@@ -165,23 +165,23 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("application/vnd.oasis.opendocument.image-template", "", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.image-template", "", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.presentation-template", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_PRESENTATION_TEMPLATE, "otp", "quick.otp"),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_TEXT, "odt", "quick.odt"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_PRESENTATION_TEMPLATE, "otp", "quick.otp"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_TEXT, "odt", "quick.odt"),
|
||||
//testFile(MIMETYPE_OPENDOCUMENT_FORMULA_TEMPLATE, "", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_TEXT_TEMPLATE, "ott", "quick.ott"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_TEXT_TEMPLATE, "ott", "quick.ott"),
|
||||
//testFile("application/vnd.oasis.opendocument.chart-template", "", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.chart-template", "", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.formula-template", "", ""),
|
||||
//testFile(MIMETYPE_OPENDOCUMENT_DATABASE, "odb", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.text-master", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_PRESENTATION, "odp", "quick.odp"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_PRESENTATION, "odp", "quick.odp"),
|
||||
//testFile(MIMETYPE_OPENDOCUMENT_CHART_TEMPLATE, "", ""),
|
||||
//testFile("application/x-vnd.oasis.opendocument.graphics", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_FORMULA, "odf", "quick.odf"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_FORMULA, "odf", "quick.odf"),
|
||||
//testFile(MIMETYPE_OPENDOCUMENT_TEXT_MASTER, "odm", ""),
|
||||
|
||||
// PdfBoxMetadataExtractor
|
||||
FileInfo.testFile(MIMETYPE_PDF, "pdf", "quick.pdf"),
|
||||
testFile(MIMETYPE_PDF, "pdf", "quick.pdf"),
|
||||
//testFile(MIMETYPE_APPLICATION_ILLUSTRATOR, "ai", ""),
|
||||
|
||||
// PoiMetadataExtractor
|
||||
@@ -189,7 +189,7 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile(MIMETYPE_OPENXML_SPREADSHEET_ADDIN_MACRO, "xlam", ""),
|
||||
//testFile(MIMETYPE_OPENXML_WORD_TEMPLATE, "dotx", ""),
|
||||
//testFile(MIMETYPE_OPENXML_SPREADSHEET_BINARY_MACRO, "xlsb", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENXML_WORDPROCESSING, "docx", "quick.docx"),
|
||||
testFile(MIMETYPE_OPENXML_WORDPROCESSING, "docx", "quick.docx"),
|
||||
//testFile(MIMETYPE_OPENXML_PRESENTATION_SLIDE_MACRO, "sldm", ""),
|
||||
//testFile("application/vnd.ms-visio.drawing", "", ""),
|
||||
//testFile(MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW_MACRO, "ppsm", ""),
|
||||
@@ -205,8 +205,8 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("application/vnd.ms-visio.template.macroenabled.12", "", ""),
|
||||
//testFile("model/vnd.dwfx+xps", "", ""),
|
||||
//testFile(MIMETYPE_OPENXML_PRESENTATION_TEMPLATE, "potx", ""),
|
||||
FileInfo.testFile(MIMETYPE_OPENXML_PRESENTATION, "pptx", "quick.pptx"),
|
||||
FileInfo.testFile(MIMETYPE_OPENXML_SPREADSHEET, "xlsx", "quick.xlsx"),
|
||||
testFile(MIMETYPE_OPENXML_PRESENTATION, "pptx", "quick.pptx"),
|
||||
testFile(MIMETYPE_OPENXML_SPREADSHEET, "xlsx", "quick.xlsx"),
|
||||
//testFile("application/vnd.ms-visio.stencil", "", ""),
|
||||
//testFile("application/vnd.ms-visio.template", "", ""),
|
||||
//testFile(MIMETYPE_OPENXML_PRESENTATION_SLIDESHOW, "ppsx", ""),
|
||||
@@ -214,16 +214,16 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile(MIMETYPE_OPENXML_SPREADSHEET_TEMPLATE_MACRO, "xltm", ""),
|
||||
|
||||
// TikaAudioMetadataExtractor
|
||||
FileInfo.testFile("video/x-m4v", "m4v", "quick.m4v"),
|
||||
testFile("video/x-m4v", "m4v", "quick.m4v"),
|
||||
//testFile("audio/x-oggflac", "", ""),
|
||||
//testFile("application/mp4", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_VORBIS, "ogg", "quick.ogg"),
|
||||
FileInfo.testFile(MIMETYPE_VIDEO_3GP, "3gp", "quick.3gp"),
|
||||
testFile(MIMETYPE_VORBIS, "ogg", "quick.ogg"),
|
||||
testFile(MIMETYPE_VIDEO_3GP, "3gp", "quick.3gp"),
|
||||
//testFile(MIMETYPE_FLAC, "flac", ""),
|
||||
FileInfo.testFile(MIMETYPE_VIDEO_3GP2, "3g2", "quick.3g2"),
|
||||
FileInfo.testFile(MIMETYPE_VIDEO_QUICKTIME, "mov", "quick.mov"),
|
||||
FileInfo.testFile(MIMETYPE_AUDIO_MP4, "m4a", "quick.m4a"),
|
||||
FileInfo.testFile(MIMETYPE_VIDEO_MP4, "mp4", "quick.mp4"),
|
||||
testFile(MIMETYPE_VIDEO_3GP2, "3g2", "quick.3g2"),
|
||||
testFile(MIMETYPE_VIDEO_QUICKTIME, "mov", "quick.mov"),
|
||||
testFile(MIMETYPE_AUDIO_MP4, "m4a", "quick.m4a"),
|
||||
testFile(MIMETYPE_VIDEO_MP4, "mp4", "quick.mp4"),
|
||||
|
||||
// TikaAutoMetadataExtractor
|
||||
|
||||
@@ -243,12 +243,12 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("audio/midi", "", ""),
|
||||
//testFile("application/aaigrid", "", ""),
|
||||
//testFile("application/x-bag", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_IWORK_KEYNOTE, "key", "quick.key"),
|
||||
testFile(MIMETYPE_IWORK_KEYNOTE, "key", "quick.key"),
|
||||
//testFile("application/x-quattro-pro; version=9", "", ""),
|
||||
//testFile("application/x-ibooks+zip", "", ""),
|
||||
//testFile("audio/wave", "", ""),
|
||||
//testFile("application/x-midi", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_XML, "xml", "quick.xml"),
|
||||
testFile(MIMETYPE_XML, "xml", "quick.xml"),
|
||||
//testFile(MIMETYPE_RSS, "rss", ""),
|
||||
//testFile("application/x-netcdf", "cdf", ""),
|
||||
//testFile("video/x-daala", "", ""),
|
||||
@@ -276,7 +276,7 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("application/x-rar", "", ""),
|
||||
//testFile("image/sar-ceos", "", ""),
|
||||
//testFile("application/acad", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_ZIP, "zip", "quick.zip"),
|
||||
testFile(MIMETYPE_ZIP, "zip", "quick.zip"),
|
||||
//testFile(MIMETYPE_IMAGE_PSD, "psd", ""),
|
||||
//testFile("application/x-sharedlib", "", ""),
|
||||
//testFile("audio/x-m4a", "", ""),
|
||||
@@ -302,12 +302,12 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("application/x-coredump", "", ""),
|
||||
//testFile("application/x-msaccess", "", ""),
|
||||
//testFile("application/x-dods", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_PNG, "png", "quick.png"),
|
||||
testFile(MIMETYPE_IMAGE_PNG, "png", "quick.png"),
|
||||
//testFile("application/vnd.ms-outlook-pst", "", ""),
|
||||
//testFile("image/bsb", "", ""),
|
||||
//testFile("application/x-cpio", "cpio", ""),
|
||||
//testFile("audio/ogg", "oga", ""),
|
||||
FileInfo.testFile("application/x-tar", "tar", "quick.tar"),
|
||||
testFile("application/x-tar", "tar", "quick.tar"),
|
||||
//testFile("application/x-dbf", "", ""),
|
||||
//testFile("video/x-ogm", "", ""),
|
||||
//testFile("application/x-los-las", "", ""),
|
||||
@@ -327,7 +327,7 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("application/x-hdf", "hdf", ""),
|
||||
//testFile("image/x-mff", "", ""),
|
||||
//testFile("image/x-srp", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_BMP, "bmp", "quick.bmp"),
|
||||
testFile(MIMETYPE_IMAGE_BMP, "bmp", "quick.bmp"),
|
||||
//testFile("video/x-ogguvs", "", ""),
|
||||
//testFile("drawing/dwg", "", ""),
|
||||
//testFile("application/x-doq2", "", ""),
|
||||
@@ -340,7 +340,7 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("application/x-wcs", "", ""),
|
||||
//testFile("text/x-c++src", "", ""),
|
||||
//testFile("application/timestamped-data", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_TIFF, "tiff", "quick.tiff"),
|
||||
testFile(MIMETYPE_IMAGE_TIFF, "tiff", "quick.tiff"),
|
||||
//testFile("application/msexcel", "", ""),
|
||||
//testFile("application/x-asp", "", ""),
|
||||
//testFile("application/x-rar-compressed", "rar", ""),
|
||||
@@ -396,7 +396,7 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("image/vnd.microsoft.icon", "", ""),
|
||||
//testFile("application/x-envi", "", ""),
|
||||
//testFile("application/x-dwg", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_IWORK_NUMBERS, "numbers", "quick.numbers"),
|
||||
testFile(MIMETYPE_IWORK_NUMBERS, "numbers", "quick.numbers"),
|
||||
//testFile("application/vnd.ms-word2006ml", "", ""),
|
||||
//testFile("application/x-bt", "", ""),
|
||||
//testFile("application/x-font-adobe-metric", "", ""),
|
||||
@@ -419,7 +419,7 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("audio/ogg; codecs=opus", "", ""),
|
||||
//testFile("application/fits", "", ""),
|
||||
//testFile("application/x-r", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_IMAGE_GIF, "gif", "quick.gif"),
|
||||
testFile(MIMETYPE_IMAGE_GIF, "gif", "quick.gif"),
|
||||
//testFile("application/java-vm", "", ""),
|
||||
//testFile("application/mspowerpoint", "", ""),
|
||||
//testFile("application/x-http", "", ""),
|
||||
@@ -454,13 +454,13 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("application/x-executable", "", ""),
|
||||
//testFile("application/x-isatab", "", ""),
|
||||
//testFile("application/grass-ascii-grid", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_TEXT_PLAIN, "txt", "quick.txt"),
|
||||
testFile(MIMETYPE_TEXT_PLAIN, "txt", "quick.txt"),
|
||||
//testFile("application/gzipped", "", ""),
|
||||
//testFile("application/x-gxf", "", ""),
|
||||
//testFile("application/x-cpg", "", ""),
|
||||
//testFile("application/x-lan", "", ""),
|
||||
//testFile("application/x-xyz", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_IWORK_PAGES, "pages", "quick.pages"),
|
||||
testFile(MIMETYPE_IWORK_PAGES, "pages", "quick.pages"),
|
||||
//testFile("image/x-jbig2", "", ""),
|
||||
//testFile("image/nitf", "", ""),
|
||||
//testFile("application/mbox", "", ""),
|
||||
@@ -519,7 +519,7 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
//testFile("application/x-emf", "", ""),
|
||||
//testFile("application/x-geo-pdf", "", ""),
|
||||
//testFile("video/x-ogg-uvs", "", ""),
|
||||
FileInfo.testFile(MIMETYPE_VIDEO_FLV, "flv", "quick.flv"),
|
||||
testFile(MIMETYPE_VIDEO_FLV, "flv", "quick.flv"),
|
||||
//testFile("application/x-zip-compressed", "", ""),
|
||||
//testFile("application/gzip", "", ""),
|
||||
//testFile("application/x-tika-unix-dump", "", ""),
|
||||
@@ -546,7 +546,7 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
|
||||
// Test MNT-15219 Excel (.xlsx) containing xmls (shapes/drawings) with multi byte characters may
|
||||
// cause OutOfMemory in Tika Note - doesn't use extractFromMimetype
|
||||
FileInfo.testFile(MIMETYPE_OPENXML_SPREADSHEET, "xlsx", "dmsu1332-reproduced.xlsx")
|
||||
testFile(MIMETYPE_OPENXML_SPREADSHEET, "xlsx", "dmsu1332-reproduced.xlsx")
|
||||
|
||||
);
|
||||
}
|
||||
@@ -565,13 +565,13 @@ public class TikaMetadataExtractsIT extends AbstractMetadataExtractsIT
|
||||
// - the replacement TikaCoreProperties.SUBJECT raw metadata changed into a multi value
|
||||
// The following test files were the ones that failed.
|
||||
return Stream.of(
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS_TEMPLATE, "otg", "quick.otg"),
|
||||
FileInfo.testFile(MIMETYPE_OPENOFFICE1_WRITER, "sxw", "quick.sxw"),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS, "odg", "quick.odg"),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_TEXT, "odt", "quick.odt"),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_TEXT_TEMPLATE, "ott", "quick.ott"),
|
||||
FileInfo.testFile(MIMETYPE_OPENDOCUMENT_FORMULA, "odf", "quick.odf"),
|
||||
FileInfo.testFile(MIMETYPE_PDF, "pdf", "quick.pdf")
|
||||
testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS_TEMPLATE, "otg", "quick.otg"),
|
||||
testFile(MIMETYPE_OPENOFFICE1_WRITER, "sxw", "quick.sxw"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_GRAPHICS, "odg", "quick.odg"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_TEXT, "odt", "quick.odt"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_TEXT_TEMPLATE, "ott", "quick.ott"),
|
||||
testFile(MIMETYPE_OPENDOCUMENT_FORMULA, "odf", "quick.odf"),
|
||||
testFile(MIMETYPE_PDF, "pdf", "quick.pdf")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@ package org.alfresco.transform.tika;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.alfresco.transform.base.AbstractBaseTest;
|
||||
import org.alfresco.transform.base.executors.RuntimeExec;
|
||||
import org.alfresco.transform.base.html.OptionLister;
|
||||
import org.alfresco.transform.base.model.FileRefEntity;
|
||||
import org.alfresco.transform.base.model.FileRefResponse;
|
||||
import org.alfresco.transform.client.model.TransformReply;
|
||||
@@ -39,7 +38,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -54,6 +52,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.alfresco.transform.base.html.OptionsHelper.getOptionNames;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_HTML;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_METADATA_EMBED;
|
||||
import static org.alfresco.transform.common.Mimetype.MIMETYPE_OPENXML_PRESENTATION;
|
||||
@@ -119,8 +118,6 @@ public class TikaTest extends AbstractBaseTest
|
||||
"The quick brown fox jumps over the lazy dogs";
|
||||
private static final String EXPECTED_CSV_CONTENT_CONTAINS = "\"The\",\"quick\",\"brown\",\"fox\"";
|
||||
|
||||
protected @Autowired OptionLister optionLister;
|
||||
|
||||
@Mock
|
||||
private RuntimeExec.ExecutionResult mockExecutionResult;
|
||||
|
||||
@@ -495,6 +492,6 @@ public class TikaTest extends AbstractBaseTest
|
||||
"extractMapping",
|
||||
"notExtractBookmarksText",
|
||||
"metadata"),
|
||||
optionLister.getOptionNames(controller.transformConfig(0).getBody().getTransformOptions()));
|
||||
getOptionNames(controller.transformConfig(0).getBody().getTransformOptions()));
|
||||
}
|
||||
}
|
||||
|
@@ -21,15 +21,6 @@
|
||||
*/
|
||||
package org.alfresco.transform.common;
|
||||
|
||||
import static java.util.Arrays.stream;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Mimetype
|
||||
* <p>
|
||||
|
@@ -197,7 +197,7 @@ public class TransformerDebug
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(getPaddedReference(reference) + " fragment["+index+"] "+fileSize(size));
|
||||
logger.debug("%s fragment[%d]%s", getPaddedReference(reference), index, fileSize(size));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,10 @@ import org.springframework.core.io.Resource;
|
||||
|
||||
public class TransformConfigReaderFactory
|
||||
{
|
||||
private TransformConfigReaderFactory()
|
||||
{
|
||||
}
|
||||
|
||||
public static TransformConfigReader create(final Resource resource)
|
||||
{
|
||||
final String fileName = resource.getFilename();
|
||||
|
@@ -34,10 +34,7 @@ import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
|
||||
/**
|
||||
|
@@ -22,9 +22,9 @@
|
||||
package org.alfresco.transform.registry;
|
||||
|
||||
import org.alfresco.transform.config.AddSupported;
|
||||
import org.alfresco.transform.config.SupportedDefaults;
|
||||
import org.alfresco.transform.config.OverrideSupported;
|
||||
import org.alfresco.transform.config.RemoveSupported;
|
||||
import org.alfresco.transform.config.SupportedDefaults;
|
||||
import org.alfresco.transform.config.SupportedSourceAndTarget;
|
||||
import org.alfresco.transform.config.TransformConfig;
|
||||
import org.alfresco.transform.config.TransformOption;
|
||||
@@ -32,7 +32,6 @@ import org.alfresco.transform.config.TransformStep;
|
||||
import org.alfresco.transform.config.Transformer;
|
||||
import org.alfresco.transform.config.TransformerAndTypes;
|
||||
import org.alfresco.transform.config.Types;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@@ -21,11 +21,6 @@
|
||||
*/
|
||||
package org.alfresco.transform.registry;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Wraps an object so that we know where it was read from. The equals() and hashcode() are that of the wrapped object
|
||||
* so it is still possible do set operations.
|
||||
|
@@ -44,6 +44,10 @@ import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
|
||||
class TransformRegistryHelper
|
||||
{
|
||||
private TransformRegistryHelper()
|
||||
{
|
||||
}
|
||||
|
||||
static Set<TransformOption> lookupTransformOptions(final Set<String> transformOptionNames,
|
||||
final Map<String, Set<TransformOption>> transformOptions, final String readFrom,
|
||||
final Consumer<String> logError)
|
||||
|
@@ -40,6 +40,7 @@ import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.emptySet;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
@@ -255,7 +256,7 @@ public class CombinedTransformConfigTest
|
||||
assertEquals(numberOfTEngineTransformers, transformConfig.getTransformers().size());
|
||||
Transformer actualTransformer = transformConfig.getTransformers().get(numberOfTEngineTransformers - 1);
|
||||
assertEquals(expectedTransformer, actualTransformer);
|
||||
assertTrue(expectedTransformer == actualTransformer);
|
||||
assertSame(expectedTransformer, actualTransformer);
|
||||
|
||||
// Check the baseUrl is that of the original t-engine that will do the work, if the overriding transform
|
||||
// is a single step transform.
|
||||
|
Reference in New Issue
Block a user