null
if the parameter value is null
- *
- * @param paramName the name of the parameter being checked.
- * @param clazz the expected {@link Class} of the parameter value.
- * @return the parameter value or null
.
- */
public defaultValue
and
- * throws a {@link RenditionServiceException} if it isn't. Returns
- * defaultValue
if the parameter value is null
- *
- * @param TransformationSourceOptions
object from this
+ * one, merging any non-null overriding fields in the given
+ * overridingOptions
+ *
+ * @param overridingOptions
+ * @return a merged TransformationSourceOptions
object
+ */
+ public TransformationSourceOptions mergedOptions(TransformationSourceOptions overridingOptions)
+ {
+ try
+ {
+ AbstractTransformationSourceOptions mergedOptions = this.clone();
+ mergedOptions.setApplicableMimetypes(this.getApplicabledMimetypes());
+
+ return mergedOptions;
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // Not thrown
+ }
+ return null;
+ }
+
+ /**
+ * Adds the given paramValue to the given params if it's not null.
+ *
+ * @param paramName
+ * @param paramValue
+ * @param params
+ */
+ protected void putParameterIfNotNull(String paramName, Serializable paramValue, Map+ * The page numbering index starts with 1. + *
+ * If only the start page number is specified transformers should attempt + * a page range from that page number to the end if possible. + *
+ * If only an end page number is specified transformers should attempt
+ * a page range from the start to that page if possible.
+ *
+ * @author Ray Gauss II
+ */
+public class PagedSourceOptions extends AbstractTransformationSourceOptions
+{
+ public static final Integer PAGE_1 = new Integer(1);
+
+ /** The start of the page range in the source document */
+ private Integer startPageNumber;
+
+ /** The end of the page range in the source document */
+ private Integer endPageNumber;
+
+ protected static List
+ * If only the offset is specified transformers should attempt
+ * a transform from that offset to the end if possible.
+ *
+ * If only a duration is specified transformers should attempt
+ * a transform from the start until that duration is reached if possible.
+ *
+ * @author Ray Gauss II
+ */
+public class TemporalSourceOptions extends AbstractTransformationSourceOptions
+{
+
+ /** The offset time code from which to start the transformation */
+ private String offset;
+
+ /** The duration of the target video after the transformation */
+ private String duration;
+
+ public boolean isApplicableForMimetype(String sourceMimetype)
+ {
+ return ((sourceMimetype != null &&
+ sourceMimetype.startsWith(MIMETYPE_VIDEO_PREFIX) ||
+ sourceMimetype.startsWith(MIMETYPE_AUDIO_PREFIX)) ||
+ super.isApplicableForMimetype(sourceMimetype));
+ }
+
+ /**
+ * Gets the offset time code from which to start the transformation
+ * with a format of hh:mm:ss[.xxx]
+ *
+ * @return the offset
+ */
+ public String getOffset()
+ {
+ return offset;
+ }
+
+ /**
+ * Sets the offset time code from which to start the transformation
+ * with a format of hh:mm:ss[.xxx]
+ *
+ * @param offset
+ */
+ public void setOffset(String offset)
+ {
+ this.offset = offset;
+ }
+
+ /**
+ * Gets the duration of the source to read
+ * with a format of hh:mm:ss[.xxx]
+ *
+ * @return
+ */
+ public String getDuration()
+ {
+ return duration;
+ }
+
+ /**
+ * Sets the duration of the source to read
+ * with a format of hh:mm:ss[.xxx]
+ *
+ * @param duration
+ */
+ public void setDuration(String duration)
+ {
+ this.duration = duration;
+ }
+
+ @Override
+ public TransformationSourceOptions mergedOptions(TransformationSourceOptions overridingOptions)
+ {
+ if (overridingOptions instanceof TemporalSourceOptions)
+ {
+ TemporalSourceOptions mergedOptions = (TemporalSourceOptions) super.mergedOptions(overridingOptions);
+
+ if (((TemporalSourceOptions) overridingOptions).getOffset() != null)
+ {
+ mergedOptions.setOffset(((TemporalSourceOptions) overridingOptions).getOffset());
+ }
+ if (((TemporalSourceOptions) overridingOptions).getDuration() != null)
+ {
+ mergedOptions.setDuration(((TemporalSourceOptions) overridingOptions).getDuration());
+ }
+ return mergedOptions;
+ }
+ return null;
+ }
+
+ @Override
+ public TransformationSourceOptionsSerializer getSerializer()
+ {
+ return TemporalSourceOptions.createSerializerInstance();
+ }
+
+ /**
+ * Creates an instance of the options serializer
+ *
+ * @return the options serializer
+ */
+ public static TransformationSourceOptionsSerializer createSerializerInstance()
+ {
+ return (new TemporalSourceOptions()).new TemporalSourceOptionsSerializer();
+ }
+
+ /**
+ * Serializer for temporal source options
+ */
+ public class TemporalSourceOptionsSerializer implements TransformationSourceOptionsSerializer
+ {
+ public static final String PARAM_SOURCE_TIME_OFFSET = "source_time_offset";
+ public static final String PARAM_SOURCE_TIME_DURATION = "source_time_duration";
+
+ @Override
+ public TransformationSourceOptions deserialize(SerializedTransformationOptionsAccessor serializedOptions)
+ {
+ String offset = serializedOptions.getCheckedParam(PARAM_SOURCE_TIME_OFFSET, String.class);
+ String duration = serializedOptions.getCheckedParam(PARAM_SOURCE_TIME_DURATION, String.class);
+
+ if (offset == null && duration == null)
+ {
+ return null;
+ }
+
+ TemporalSourceOptions sourceOptions = new TemporalSourceOptions();
+ sourceOptions.setOffset(offset);
+ sourceOptions.setDuration(duration);
+ return sourceOptions;
+ }
+
+ @Override
+ public void serialize(TransformationSourceOptions sourceOptions,
+ Map
+ * Note that if source options of the same class already exists a new
+ * merged source options object is added.
+ *
+ * @param sourceOptions
+ */
+ public void addSourceOptions(TransformationSourceOptions sourceOptions)
+ {
+ if (sourceOptionsMap == null)
+ {
+ sourceOptionsMap = new HashMap
diff --git a/source/java/org/alfresco/service/cmr/repository/TransformationSourceOptions.java b/source/java/org/alfresco/service/cmr/repository/TransformationSourceOptions.java
new file mode 100644
index 0000000000..40f4e3af05
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/repository/TransformationSourceOptions.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2005-2013 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * 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
+ * See {@link PagedSourceOptions} for an example implementation that
+ * describes the page number that should be used from the source content.
+ *
+ * @author Ray Gauss II
+ */
+public interface TransformationSourceOptions
+{
+
+ /**
+ * Gets the list of applicable mimetypes
+ *
+ * @return the applicable mimetypes
+ */
+ public List
+ * This is primarily used when interacting with the {@link RenditionService}
+ * with {@link AbstractRenderingEngine}'s RenderContext being an implementer
+ * of this interface.
+ */
+ public interface TransformationSourceOptionsSerializer
+ {
+
+ /**
+ * Serializes the given transformation source options into the given parameter map.
+ *
+ * @param transformationSourceOptions
+ * @param parameters
+ */
+ public void serialize(TransformationSourceOptions transformationSourceOptions, Mapnull
if the parameter value is null
+ *
+ * @param paramName the name of the parameter being checked.
+ * @param clazz the expected {@link Class} of the parameter value.
+ * @return the parameter value or null
.
+ */
+ public defaultValue
and
+ * throws a {@link RenditionServiceException} if it isn't. Returns
+ * defaultValue
if the parameter value is null
+ *
+ * @param defaultValue
if the parameter value is null
.
+ *
+ * @param key
+ * @param defaultValue
+ * @return
+ */
+ public int getIntegerParam(String key, int defaultValue);
+
+}
diff --git a/source/java/org/alfresco/service/cmr/repository/TemporalSourceOptions.java b/source/java/org/alfresco/service/cmr/repository/TemporalSourceOptions.java
new file mode 100644
index 0000000000..2a419ae185
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/repository/TemporalSourceOptions.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2005-2013 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * 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 TransformationSourceOptions
object from this
+ * one, merging any non-null overriding fields in the given
+ * overridingOptions
+ *
+ * @param overridingOptions
+ * @return a merged TransformationSourceOptions
object
+ */
+ public TransformationSourceOptions mergedOptions(TransformationSourceOptions overridingOptions);
+
+ /**
+ * Gets the serializer for the source options.
+ *
+ * @return the serializer
+ */
+ public TransformationSourceOptionsSerializer getSerializer();
+
+ /**
+ * Defines methods for serializing the source options into a parameter map and
+ * deserializing from a serialized options accessor.
+ *