use of org.alfresco.service.cmr.repository.PagedSourceOptions in project alfresco-repository by Alfresco.
the class AlfrescoPdfRendererContentTransformerWorker method getSourcePageRange.
/**
* Gets the page range from the source to use in the command line.
*
* @param options the transformation options
* @param sourceMimetype the source mimetype
* @param targetMimetype the target mimetype
* @return the source page range for the command line
*/
private String getSourcePageRange(TransformationOptions options, String sourceMimetype, String targetMimetype) {
if (options instanceof ImageTransformationOptions) {
ImageTransformationOptions imageOptions = (ImageTransformationOptions) options;
PagedSourceOptions pagedSourceOptions = imageOptions.getSourceOptions(PagedSourceOptions.class);
if (pagedSourceOptions != null) {
if (pagedSourceOptions.getStartPageNumber() != null && pagedSourceOptions.getEndPageNumber() != null) {
if (pagedSourceOptions.getStartPageNumber().equals(pagedSourceOptions.getEndPageNumber())) {
return "" + (pagedSourceOptions.getStartPageNumber() - 1);
} else {
throw new AlfrescoRuntimeException("The alfresco-pdf-renderer can only convert single pages, no page ranges.");
}
} else {
throw new AlfrescoRuntimeException("The alfresco-pdf-renderer can only convert single pages, no page ranges.");
}
}
}
return "0";
}
use of org.alfresco.service.cmr.repository.PagedSourceOptions in project alfresco-repository by Alfresco.
the class TransformationOptionsConverterTest method testSWFTransformationOptionsPage.
@Test
public // is no longer used as there are o transformers for it.
void testSWFTransformationOptionsPage() {
SWFTransformationOptions oldOptions = new SWFTransformationOptions();
PagedSourceOptions pagedSourceOptions = new PagedSourceOptions();
pagedSourceOptions.setStartPageNumber(1);
pagedSourceOptions.setEndPageNumber(1);
oldOptions.addSourceOptions(pagedSourceOptions);
assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "{maxSourceSizeKBytes=-1, use=null, contentReaderNodeRef=null, readLimitKBytes=-1, " + "contentWriterNodeRef=null, pageLimit=-1, flashVersion=9, timeoutMs=-1, maxPages=-1, " + "sourceContentProperty=null, targetContentProperty=null, includeEmbedded=null, readLimitTimeMs=-1}", "flashVersion=9 " + "timeout=-1 ", // SWFTransformationOptions are not used by ImageMagickContentTransformerWorker
false);
}
use of org.alfresco.service.cmr.repository.PagedSourceOptions in project alfresco-repository by Alfresco.
the class TransformationOptionsConverterTest method testCompositeReformatAndResizeRendition.
@Test
public void testCompositeReformatAndResizeRendition() {
ImageTransformationOptions oldOptions = new ImageTransformationOptions();
ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
imageResizeOptions.setHeight(30);
imageResizeOptions.setWidth(20);
oldOptions.setResizeOptions(imageResizeOptions);
PagedSourceOptions pagedSourceOptions = new PagedSourceOptions();
pagedSourceOptions.setStartPageNumber(1);
pagedSourceOptions.setEndPageNumber(1);
oldOptions.addSourceOptions(pagedSourceOptions);
assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_JPEG, "ImageTransformationOptions [commandOptions=, resizeOptions=" + "ImageResizeOptions [width=20, height=30, maintainAspectRatio=true, percentResize=false, " + "resizeToThumbnail=false, allowEnlargement=true], autoOrient=true], " + "sourceOptions={ PagedSourceOptionsPagedSourceOptions {1, 1}} ]", "alphaRemove=true " + "autoOrient=true " + "endPage=0 " + "resizeHeight=30 " + "resizeWidth=20 " + "startPage=0 " + "timeout=-1 ", true);
}
use of org.alfresco.service.cmr.repository.PagedSourceOptions in project alfresco-repository by Alfresco.
the class TransformationOptionsConverterTest method testImageTransformationOptionsPage.
@Test
public // Checks we do what was in the legacy ImageMagickContentTransformerWorker
void testImageTransformationOptionsPage() {
ImageTransformationOptions oldOptions = new ImageTransformationOptions();
oldOptions.setAutoOrient(false);
PagedSourceOptions pagedSourceOptions = new PagedSourceOptions();
pagedSourceOptions.setStartPageNumber(1);
pagedSourceOptions.setEndPageNumber(1);
oldOptions.addSourceOptions(pagedSourceOptions);
assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG, "ImageTransformationOptions [commandOptions=, " + "resizeOptions=null, autoOrient=false], " + "sourceOptions={ PagedSourceOptionsPagedSourceOptions {1, 1}} ]", "endPage=0 startPage=0 " + "timeout=-1 ", true);
}
use of org.alfresco.service.cmr.repository.PagedSourceOptions in project alfresco-repository by Alfresco.
the class ImageMagickContentTransformerTest method ignoreTestPageSourceOptions.
// This fails with remote transformers
// The thumbnails actually have parameters in real life
public void ignoreTestPageSourceOptions() throws Exception {
// Test empty source options
ImageTransformationOptions options = new ImageTransformationOptions();
this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options);
// Test first page
options = new ImageTransformationOptions();
List<TransformationSourceOptions> sourceOptionsList = new ArrayList<TransformationSourceOptions>();
sourceOptionsList.add(PagedSourceOptions.getPage1Instance());
options.setSourceOptionsList(sourceOptionsList);
this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options);
// Test second page
options = new ImageTransformationOptions();
sourceOptionsList = new ArrayList<TransformationSourceOptions>();
PagedSourceOptions sourceOptions = new PagedSourceOptions();
sourceOptions.setStartPageNumber(2);
sourceOptions.setEndPageNumber(2);
sourceOptionsList.add(sourceOptions);
options.setSourceOptionsList(sourceOptionsList);
this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options);
// Test page range invalid for target type
options = new ImageTransformationOptions();
sourceOptionsList = new ArrayList<TransformationSourceOptions>();
sourceOptions = new PagedSourceOptions();
sourceOptions.setStartPageNumber(1);
sourceOptions.setEndPageNumber(2);
sourceOptionsList.add(sourceOptions);
options.setSourceOptionsList(sourceOptionsList);
try {
this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options);
fail("An exception regarding an invalid page range should have been thrown");
} catch (Exception e) {
// failure expected
}
// Test page out of range
options = new ImageTransformationOptions();
sourceOptionsList = new ArrayList<TransformationSourceOptions>();
sourceOptions = new PagedSourceOptions();
sourceOptions.setStartPageNumber(3);
sourceOptions.setEndPageNumber(3);
sourceOptionsList.add(sourceOptions);
options.setSourceOptionsList(sourceOptionsList);
try {
this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options);
fail("An exception regarding an invalid page range should have been thrown");
} catch (Exception e) {
// failure expected
}
}
Aggregations