mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-07-31 17:38:33 +00:00
ATS-675 - Move static strings to util class
This commit is contained in:
@@ -32,6 +32,12 @@ import static org.alfresco.transformer.fs.FileManager.createAttachment;
|
||||
import static org.alfresco.transformer.fs.FileManager.createSourceFile;
|
||||
import static org.alfresco.transformer.fs.FileManager.createTargetFile;
|
||||
import static org.alfresco.transformer.fs.FileManager.createTargetFileName;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_ENCODING;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_EXTENSION;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_MIMETYPE;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.TARGET_EXTENSION;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.TARGET_MIMETYPE;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.TEST_DELAY;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
@@ -64,13 +70,6 @@ public class AIOController extends AbstractTransformerController
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(AIOController.class);
|
||||
|
||||
private static final String SOURCE_ENCODING = "sourceEncoding";
|
||||
private static final String SOURCE_EXTENSION = "sourceExtension";
|
||||
private static final String TARGET_EXTENSION = "targetExtension";
|
||||
private static final String TARGET_MIMETYPE = "targetMimetype";
|
||||
private static final String SOURCE_MIMETYPE = "sourceMimetype";
|
||||
private static final String TEST_DELAY = "testDelay";
|
||||
|
||||
@Autowired
|
||||
private AllInOneTransformer transformer;
|
||||
|
||||
|
@@ -26,6 +26,24 @@
|
||||
*/
|
||||
package org.alfresco.transformer.transformers;
|
||||
|
||||
import static org.alfresco.transformer.util.RequestParamMap.ALLOW_ENLARGEMENT;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.ALPHA_REMOVE;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.AUTO_ORIENT;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.COMMAND_OPTIONS;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.CROP_GRAVITY;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.CROP_HEIGHT;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.CROP_PERCENTAGE;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.CROP_WIDTH;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.CROP_X_OFFSET;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.CROP_Y_OFFSET;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.END_PAGE;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.MAINTAIN_ASPECT_RATIO;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.RESIZE_HEIGHT;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.RESIZE_PERCENTAGE;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.RESIZE_WIDTH;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.START_PAGE;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.THUMBNAIL;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.TIMEOUT;
|
||||
import static org.alfresco.transformer.util.Util.stringToInteger;
|
||||
import static org.alfresco.transformer.util.Util.stringToLong;
|
||||
|
||||
@@ -41,27 +59,6 @@ public class ImageMagickAdapter extends AbstractTransformer
|
||||
private static String CONFIG_PREFIX = "imagemagick";
|
||||
private ImageMagickCommandExecutor commandExecutor;
|
||||
|
||||
//TODO move key strings to a central class
|
||||
private static final String START_PAGE = "startPage";
|
||||
private static final String END_PAGE = "endPage";
|
||||
private static final String ALPHA_REMOVE = "alphaRemove";
|
||||
private static final String AUTO_ORIENT = "autoOrient";
|
||||
private static final String CROP_GRAVITY = "cropGravity";
|
||||
private static final String CROP_WIDTH = "cropWidth";
|
||||
private static final String CROP_HEIGHT = "cropHeight";
|
||||
private static final String CROP_PERCENTAGE = "cropPercentage";
|
||||
private static final String CROP_X_OFFSET = "cropXOffset";
|
||||
private static final String CROP_Y_OFFSET = "cropYOffset";
|
||||
private static final String THUMBNAIL = "thumbnail";
|
||||
private static final String RESIZE_WIDTH = "resizeWidth";
|
||||
private static final String RESIZE_HEIGHT = "resizeHeight";
|
||||
private static final String RESIZE_PERCENTAGE = "resizePercentage";
|
||||
private static final String ALLOW_ENLARGEMENT = "allowEnlargement";
|
||||
private static final String MAINTAIN_ASPECT_RATIO = "maintainAspectRatio";
|
||||
private static final String COMMAND_OPTIONS = "commandOptions";
|
||||
private static final String TIMEOUT_REQUEST_PARAM = "timeOut";
|
||||
|
||||
|
||||
public ImageMagickAdapter() throws Exception
|
||||
{
|
||||
super();
|
||||
@@ -105,7 +102,7 @@ public class ImageMagickAdapter extends AbstractTransformer
|
||||
stringToInteger(transformOptions.get(END_PAGE))
|
||||
);
|
||||
|
||||
Long timeout = stringToLong(transformOptions.get(TIMEOUT_REQUEST_PARAM));
|
||||
Long timeout = stringToLong(transformOptions.get(TIMEOUT));
|
||||
|
||||
commandExecutor.run(options, sourceFile, pageRange, targetFile, timeout);
|
||||
}
|
||||
|
@@ -26,6 +26,12 @@
|
||||
*/
|
||||
package org.alfresco.transformer.transformers;
|
||||
|
||||
import static org.alfresco.transformer.util.RequestParamMap.ALLOW_PDF_ENLARGEMENT;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.HEIGHT_REQUEST_PARAM;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.MAINTAIN_PDF_ASPECT_RATIO;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.PAGE_REQUEST_PARAM;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.TIMEOUT;
|
||||
import static org.alfresco.transformer.util.RequestParamMap.WIDTH_REQUEST_PARAM;
|
||||
import static org.alfresco.transformer.util.Util.stringToLong;
|
||||
|
||||
import java.io.File;
|
||||
@@ -40,15 +46,6 @@ public class PdfRendererAdapter extends AbstractTransformer
|
||||
private static String CONFIG_PREFIX = "pdfrenderer";
|
||||
private PdfRendererCommandExecutor pdfExecutor;
|
||||
|
||||
//TODO move key strings to a central class
|
||||
private final static String PAGE_REQUEST_PARAM = "page";
|
||||
private final static String WIDTH_REQUEST_PARAM = "width";
|
||||
private final static String HEIGHT_REQUEST_PARAM = "height";
|
||||
private final static String ALLOW_PDF_ENLARGEMENT = "allowPdfEnlargement";
|
||||
private final static String MAINTAIN_PDF_ASPECT_RATIO = "maintainPdfAspectRatio";
|
||||
private final static String TIMEOUT_REQUEST_PARAM = "timeout";
|
||||
|
||||
|
||||
public PdfRendererAdapter() throws Exception
|
||||
{
|
||||
super();
|
||||
@@ -75,7 +72,7 @@ public class PdfRendererAdapter extends AbstractTransformer
|
||||
.withMaintainPdfAspectRatio(transformOptions.get(MAINTAIN_PDF_ASPECT_RATIO))
|
||||
.build();
|
||||
|
||||
Long timeout = stringToLong(transformOptions.get(TIMEOUT_REQUEST_PARAM));
|
||||
Long timeout = stringToLong(transformOptions.get(TIMEOUT));
|
||||
|
||||
pdfExecutor.run(options, sourceFile, targetFile, timeout);
|
||||
}
|
||||
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Transform Core
|
||||
* %%
|
||||
* Copyright (C) 2005 - 200 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.transformer.util;
|
||||
|
||||
public interface RequestParamMap
|
||||
{
|
||||
String SOURCE_ENCODING = "sourceEncoding";
|
||||
String SOURCE_EXTENSION = "sourceExtension";
|
||||
String SOURCE_MIMETYPE = "sourceMimetype";
|
||||
String TARGET_EXTENSION = "targetExtension";
|
||||
String TARGET_MIMETYPE = "targetMimetype";
|
||||
String TEST_DELAY = "testDelay";
|
||||
String PAGE_REQUEST_PARAM = "page";
|
||||
String WIDTH_REQUEST_PARAM = "width";
|
||||
String HEIGHT_REQUEST_PARAM = "height";
|
||||
String ALLOW_PDF_ENLARGEMENT = "allowPdfEnlargement";
|
||||
String MAINTAIN_PDF_ASPECT_RATIO = "maintainPdfAspectRatio";
|
||||
String START_PAGE = "startPage";
|
||||
String END_PAGE = "endPage";
|
||||
String ALPHA_REMOVE = "alphaRemove";
|
||||
String AUTO_ORIENT = "autoOrient";
|
||||
String CROP_GRAVITY = "cropGravity";
|
||||
String CROP_WIDTH = "cropWidth";
|
||||
String CROP_HEIGHT = "cropHeight";
|
||||
String CROP_PERCENTAGE = "cropPercentage";
|
||||
String CROP_X_OFFSET = "cropXOffset";
|
||||
String CROP_Y_OFFSET = "cropYOffset";
|
||||
String THUMBNAIL = "thumbnail";
|
||||
String RESIZE_WIDTH = "resizeWidth";
|
||||
String RESIZE_HEIGHT = "resizeHeight";
|
||||
String RESIZE_PERCENTAGE = "resizePercentage";
|
||||
String ALLOW_ENLARGEMENT = "allowEnlargement";
|
||||
String MAINTAIN_ASPECT_RATIO = "maintainAspectRatio";
|
||||
String COMMAND_OPTIONS = "commandOptions";
|
||||
String TIMEOUT = "timeOut";
|
||||
}
|
Reference in New Issue
Block a user