mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-07 17:48:35 +00:00
Revert "Revert "ATS-702/ATS-675 Change exception thrown by tranformers to TransformException""
This reverts commit ab0ab14956
.
This commit is contained in:
@@ -174,18 +174,7 @@ public class AIOController extends AbstractTransformerController
|
|||||||
debugLogTransform("Performing transform with parameters: ", sourceMimetype, targetMimetype,
|
debugLogTransform("Performing transform with parameters: ", sourceMimetype, targetMimetype,
|
||||||
targetExtension, requestParameters);
|
targetExtension, requestParameters);
|
||||||
|
|
||||||
try
|
transformer.transform(sourceFile, targetFile, sourceMimetype, targetMimetype, transformOptions);
|
||||||
{
|
|
||||||
transformer.transform(sourceFile, targetFile, sourceMimetype, targetMimetype, transformOptions);
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
throw new TransformException(BAD_REQUEST.value(), e.getMessage(), e);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new TransformException(INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
final ResponseEntity<Resource> body = createAttachment(targetFilename, targetFile);
|
final ResponseEntity<Resource> body = createAttachment(targetFilename, targetFile);
|
||||||
LogEntry.setTargetSize(targetFile.length());
|
LogEntry.setTargetSize(targetFile.length());
|
||||||
|
@@ -26,8 +26,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.transformer.transformers;
|
package org.alfresco.transformer.transformers;
|
||||||
|
|
||||||
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
|
||||||
import org.alfresco.transform.client.model.config.TransformConfig;
|
import org.alfresco.transform.client.model.config.TransformConfig;
|
||||||
import org.alfresco.transform.client.model.config.TransformOption;
|
import org.alfresco.transform.client.model.config.TransformOption;
|
||||||
|
import org.alfresco.transform.exceptions.TransformException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -80,14 +83,14 @@ public class AllInOneTransformer implements Transformer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
||||||
Map<String, String> transformOptions) throws Exception
|
Map<String, String> transformOptions) throws TransformException
|
||||||
{
|
{
|
||||||
String transformName = transformOptions.get(TRANSFORM_NAME_PARAMETER);
|
String transformName = transformOptions.get(TRANSFORM_NAME_PARAMETER);
|
||||||
Transformer transformer = transformerTransformMapping.get(transformName);
|
Transformer transformer = transformerTransformMapping.get(transformName);
|
||||||
|
|
||||||
if (transformer == null)
|
if (transformer == null)
|
||||||
{
|
{
|
||||||
throw new Exception("No transformer mapping for : transform:" + transformName + " sourceMimetype:"
|
throw new TransformException(BAD_REQUEST.value(),"No transformer mapping for : transform:" + transformName + " sourceMimetype:"
|
||||||
+ sourceMimetype + " targetMimetype:" + targetMimetype);
|
+ sourceMimetype + " targetMimetype:" + targetMimetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,6 +50,7 @@ import static org.alfresco.transformer.util.Util.stringToLong;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.transform.exceptions.TransformException;
|
||||||
import org.alfresco.transformer.ImageMagickOptionsBuilder;
|
import org.alfresco.transformer.ImageMagickOptionsBuilder;
|
||||||
import org.alfresco.transformer.executors.ImageMagickCommandExecutor;
|
import org.alfresco.transformer.executors.ImageMagickCommandExecutor;
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ public class ImageMagickAdapter extends AbstractTransformer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
||||||
Map<String, String> transformOptions) throws Exception
|
Map<String, String> transformOptions) throws TransformException
|
||||||
{
|
{
|
||||||
|
|
||||||
final String options = ImageMagickOptionsBuilder
|
final String options = ImageMagickOptionsBuilder
|
||||||
|
@@ -29,6 +29,7 @@ package org.alfresco.transformer.transformers;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.transform.exceptions.TransformException;
|
||||||
import org.alfresco.transformer.executors.LibreOfficeJavaExecutor;
|
import org.alfresco.transformer.executors.LibreOfficeJavaExecutor;
|
||||||
|
|
||||||
public class LibreOfficeAdapter extends AbstractTransformer
|
public class LibreOfficeAdapter extends AbstractTransformer
|
||||||
@@ -50,7 +51,7 @@ public class LibreOfficeAdapter extends AbstractTransformer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
||||||
Map<String, String> transformOptions) throws Exception
|
Map<String, String> transformOptions) throws TransformException
|
||||||
{
|
{
|
||||||
javaExecutor.call(sourceFile, targetFile);
|
javaExecutor.call(sourceFile, targetFile);
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,8 @@ package org.alfresco.transformer.transformers;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.transform.exceptions.TransformException;
|
||||||
|
|
||||||
public class MiscAdapter extends AbstractTransformer
|
public class MiscAdapter extends AbstractTransformer
|
||||||
{
|
{
|
||||||
private static final String CONFIG_PREFIX = "misc";
|
private static final String CONFIG_PREFIX = "misc";
|
||||||
@@ -48,8 +50,8 @@ public class MiscAdapter extends AbstractTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype, Map<String,
|
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
||||||
String> transformOptions) throws Exception
|
Map<String,String> transformOptions) throws TransformException
|
||||||
{
|
{
|
||||||
String transformerName = transformOptions.get(TRANSFORM_NAME_PARAMETER);
|
String transformerName = transformOptions.get(TRANSFORM_NAME_PARAMETER);
|
||||||
miscSelectingTransformer.transform(transformerName, sourceFile, targetFile,
|
miscSelectingTransformer.transform(transformerName, sourceFile, targetFile,
|
||||||
|
@@ -38,6 +38,7 @@ import java.io.File;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.transformer.executors.PdfRendererCommandExecutor;
|
import org.alfresco.transformer.executors.PdfRendererCommandExecutor;
|
||||||
|
import org.alfresco.transform.exceptions.TransformException;
|
||||||
import org.alfresco.transformer.PdfRendererOptionsBuilder;
|
import org.alfresco.transformer.PdfRendererOptionsBuilder;
|
||||||
|
|
||||||
|
|
||||||
@@ -59,8 +60,8 @@ public class PdfRendererAdapter extends AbstractTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
||||||
Map<String, String> transformOptions) throws Exception
|
Map<String, String> transformOptions) throws TransformException
|
||||||
{
|
{
|
||||||
|
|
||||||
final String options = PdfRendererOptionsBuilder
|
final String options = PdfRendererOptionsBuilder
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.transformer.transformers;
|
package org.alfresco.transformer.transformers;
|
||||||
|
|
||||||
|
import org.alfresco.transform.exceptions.TransformException;
|
||||||
import org.alfresco.transformer.executors.TikaJavaExecutor;
|
import org.alfresco.transformer.executors.TikaJavaExecutor;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -55,7 +56,8 @@ public class TikaAdapter extends AbstractTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype, Map<String, String> transformOptions) throws Exception
|
public void transform(File sourceFile, File targetFile, String sourceMimetype, String targetMimetype,
|
||||||
|
Map<String, String> transformOptions) throws TransformException
|
||||||
{
|
{
|
||||||
final String transform = transformOptions.get(TRANSFORM_NAME_PARAMETER);
|
final String transform = transformOptions.get(TRANSFORM_NAME_PARAMETER);
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ package org.alfresco.transformer.transformers;
|
|||||||
|
|
||||||
|
|
||||||
import org.alfresco.transform.client.model.config.TransformConfig;
|
import org.alfresco.transform.client.model.config.TransformConfig;
|
||||||
|
import org.alfresco.transform.exceptions.TransformException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -49,10 +50,10 @@ public interface Transformer
|
|||||||
* @param sourceFile
|
* @param sourceFile
|
||||||
* @param targetFile
|
* @param targetFile
|
||||||
* @param transformOptions
|
* @param transformOptions
|
||||||
* @throws Exception
|
* @throws TransformException - if there was a problem internally
|
||||||
*/
|
*/
|
||||||
void transform(File sourceFile, File targetFile, String sourceMimetype,
|
void transform(File sourceFile, File targetFile, String sourceMimetype,
|
||||||
String targetMimetype, Map<String, String> transformOptions) throws Exception;
|
String targetMimetype, Map<String, String> transformOptions) throws TransformException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user