diff --git a/source/java/org/alfresco/repo/content/transform/TransformerConfigSupported.java b/source/java/org/alfresco/repo/content/transform/TransformerConfigSupported.java
index 7de77fc9e3..1775faea48 100644
--- a/source/java/org/alfresco/repo/content/transform/TransformerConfigSupported.java
+++ b/source/java/org/alfresco/repo/content/transform/TransformerConfigSupported.java
@@ -23,8 +23,10 @@ import static org.alfresco.repo.content.transform.TransformerConfig.CONTENT;
import static org.alfresco.repo.content.transform.TransformerConfig.MIMETYPES_SEPARATOR;
import static org.alfresco.repo.content.transform.TransformerConfig.SUPPORTED;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -41,6 +43,11 @@ import org.alfresco.util.Triple;
*/
public class TransformerConfigSupported extends TransformerPropertyNameExtractor
{
+ private static final String IS_MIMETYPE_REGEX =
+ "(application|audio|image|message|model|multipart|text|video)/.+";
+ private static final String IS_MIMETYPE_SUBTYPE_WILDCARD_REGEX =
+ "(application|audio|image|message|model|multipart|text|video)/.*\\" + ANY + ".*";
+
// Holds configured (entries only exist if configured rather than for all possible combinations)
// of supported and unsupported mimetypes transformations for a transformer.
// SourceMimetype and targetMimetype may be 'ANY' values to act as wild cards.
@@ -50,6 +57,69 @@ public class TransformerConfigSupported extends TransformerPropertyNameExtractor
{
setSupported(subsystem, mimetypeService);
}
+
+ /**
+ * Determines if the given string is a mime type expression.
+ *
+ * @param extension
+ * @return whether or not the string is a mime type
+ */
+ private boolean isMimetype(String extension)
+ {
+ return (extension != null && extension.matches(IS_MIMETYPE_REGEX));
+ }
+
+ /**
+ * Determines if the given string is a mime type expression containing a wildcard
+ * in the subtype.
+ *
+ * @param mimetype
+ * @return whether or not the mime type contains a wildcard subtype
+ */
+ private boolean isMimetypeSubtypeWildcard(String mimetype)
+ {
+ return (mimetype != null && mimetype.matches(IS_MIMETYPE_SUBTYPE_WILDCARD_REGEX));
+ }
+
+ /**
+ * Gets the mimetypes which match the given configMimetype
from the given
+ * mimetypeService
.
+ *
+ * If the given mime type string contains one or more wildcards (*) in the subtype, the string + * is converted to a regular expression and any mimetypes which match are returned. + *
+ * If the given mime type string has no wildcards a list with only the given
+ * mime type is returned.
+ *
+ * @param configMimetype
+ * @param mimetypeService
+ * @return the list of mime types which match the wildcard, or a list with just the given mimetype
+ */
+ private List