You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/01/15 15:57:24 UTC

[isis] branch master updated: ISIS-2158: removes BlobClobFactory in favor of new Blob/Clob.of(...)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new 65a73a7  ISIS-2158: removes BlobClobFactory in favor of new Blob/Clob.of(...)
65a73a7 is described below

commit 65a73a7bcbfd54e8ae18f25debd6805ceee747e9
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jan 15 16:57:11 2020 +0100

    ISIS-2158: removes BlobClobFactory in favor of new Blob/Clob.of(...)
---
 .../isis/applib/mixins/dto/Dto_downloadXml.java    |   5 +-
 .../isis/applib/mixins/dto/Dto_downloadXsd.java    |   8 +-
 .../mixins/layout/Object_downloadLayoutXml.java    |   5 +-
 .../metamodel/Object_downloadMetaModelXml.java     |   6 +-
 .../java/org/apache/isis/applib/value/Blob.java    |  48 ++++---
 .../apache/isis/applib/value/BlobClobFactory.java  | 151 ---------------------
 .../java/org/apache/isis/applib/value/Clob.java    |  49 ++++---
 .../isis/applib/value/NamedWithMimeType.java       | 147 ++++++++++++++++++++
 8 files changed, 220 insertions(+), 199 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/mixins/dto/Dto_downloadXml.java b/api/applib/src/main/java/org/apache/isis/applib/mixins/dto/Dto_downloadXml.java
index 95f0026..b20828f 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/mixins/dto/Dto_downloadXml.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/mixins/dto/Dto_downloadXml.java
@@ -30,7 +30,8 @@ import org.apache.isis.applib.annotation.RestrictTo;
 import org.apache.isis.applib.annotation.SemanticsOf;
 import org.apache.isis.applib.mixins.MixinConstants;
 import org.apache.isis.applib.services.jaxb.JaxbService;
-import org.apache.isis.applib.value.BlobClobFactory;
+import org.apache.isis.applib.value.Clob;
+import org.apache.isis.applib.value.NamedWithMimeType.CommonMimeType;
 
 import lombok.RequiredArgsConstructor;
 import lombok.val;
@@ -63,7 +64,7 @@ public class Dto_downloadXml {
             final String fileName) {
 
         val xmlString = jaxbService.toXml(holder);
-        return BlobClobFactory.clobXml(fileName, xmlString);
+        return Clob.of(fileName, CommonMimeType.XML, xmlString);
     }
 
     // -- PARAM 0
diff --git a/api/applib/src/main/java/org/apache/isis/applib/mixins/dto/Dto_downloadXsd.java b/api/applib/src/main/java/org/apache/isis/applib/mixins/dto/Dto_downloadXsd.java
index e724daf..4a18777 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/mixins/dto/Dto_downloadXsd.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/mixins/dto/Dto_downloadXsd.java
@@ -34,7 +34,9 @@ import org.apache.isis.applib.mixins.MixinConstants;
 import org.apache.isis.applib.services.jaxb.JaxbService;
 import org.apache.isis.applib.services.message.MessageService;
 import org.apache.isis.applib.util.ZipWriter;
-import org.apache.isis.applib.value.BlobClobFactory;
+import org.apache.isis.applib.value.Blob;
+import org.apache.isis.applib.value.Clob;
+import org.apache.isis.applib.value.NamedWithMimeType.CommonMimeType;
 
 import lombok.RequiredArgsConstructor;
 import lombok.val;
@@ -81,7 +83,7 @@ public class Dto_downloadXsd {
 
         if(schemaMap.size() == 1) {
             val xmlString = schemaMap.values().iterator().next();
-            return BlobClobFactory.clob(BlobClobFactory.Type.xml, fileName, "xsd", xmlString);
+            return Clob.of(fileName, CommonMimeType.XSD, xmlString);
         }
 
         val zipWriter = ZipWriter.newInstance();
@@ -94,7 +96,7 @@ public class Dto_downloadXsd {
             });
         }
 
-        return BlobClobFactory.blobZip(fileName, zipWriter.toBytes());
+        return Blob.of(fileName, CommonMimeType.ZIP, zipWriter.toBytes());
 
     }
 
diff --git a/api/applib/src/main/java/org/apache/isis/applib/mixins/layout/Object_downloadLayoutXml.java b/api/applib/src/main/java/org/apache/isis/applib/mixins/layout/Object_downloadLayoutXml.java
index 48a618f..7a44227 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/mixins/layout/Object_downloadLayoutXml.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/mixins/layout/Object_downloadLayoutXml.java
@@ -30,7 +30,8 @@ import org.apache.isis.applib.annotation.RestrictTo;
 import org.apache.isis.applib.annotation.SemanticsOf;
 import org.apache.isis.applib.mixins.MixinConstants;
 import org.apache.isis.applib.services.layout.LayoutService;
-import org.apache.isis.applib.value.BlobClobFactory;
+import org.apache.isis.applib.value.Clob;
+import org.apache.isis.applib.value.NamedWithMimeType.CommonMimeType;
 
 import lombok.RequiredArgsConstructor;
 import lombok.val;
@@ -67,7 +68,7 @@ public class Object_downloadLayoutXml {
             final LayoutService.Style style) {
 
         val xmlString = layoutService.toXml(holder.getClass(), style);
-        return BlobClobFactory.clobXml(fileName, xmlString);
+        return  Clob.of(fileName, CommonMimeType.XML, xmlString);
     }
 
     // -- PARAM 0 (fileName)
diff --git a/api/applib/src/main/java/org/apache/isis/applib/mixins/metamodel/Object_downloadMetaModelXml.java b/api/applib/src/main/java/org/apache/isis/applib/mixins/metamodel/Object_downloadMetaModelXml.java
index 3d94c23..c7d59f5 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/mixins/metamodel/Object_downloadMetaModelXml.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/mixins/metamodel/Object_downloadMetaModelXml.java
@@ -34,7 +34,8 @@ import org.apache.isis.applib.mixins.MixinConstants;
 import org.apache.isis.applib.services.jaxb.JaxbService;
 import org.apache.isis.applib.services.metamodel.MetaModelService;
 import org.apache.isis.applib.services.metamodel.MetaModelServicesMenu;
-import org.apache.isis.applib.value.BlobClobFactory;
+import org.apache.isis.applib.value.Clob;
+import org.apache.isis.applib.value.NamedWithMimeType.CommonMimeType;
 
 import lombok.RequiredArgsConstructor;
 import lombok.val;
@@ -86,8 +87,7 @@ public class Object_downloadMetaModelXml {
 
         val xmlString = jaxbService.toXml(metamodelDto);
 
-        return BlobClobFactory.clobXml(fileName, xmlString);
-
+        return Clob.of(fileName, CommonMimeType.XML, xmlString);
     }
 
     // -- PARAM 0
diff --git a/api/applib/src/main/java/org/apache/isis/applib/value/Blob.java b/api/applib/src/main/java/org/apache/isis/applib/value/Blob.java
index 79f0b48..2d925e5 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/value/Blob.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/value/Blob.java
@@ -25,7 +25,10 @@ import java.util.Arrays;
 import java.util.Objects;
 
 import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
+
+import org.apache.isis.core.commons.internal.base._Strings;
+
+import lombok.val;
 
 public final class Blob implements NamedWithMimeType {
 
@@ -38,17 +41,40 @@ public final class Blob implements NamedWithMimeType {
      * </pre>
      */
     private static final long serialVersionUID = 5659679806709601263L;
+    
+    // -- FACTORIES
+    
+    /**
+     * Returns a new {@link Blob} of given {@code name}, {@code mimeType} and {@code content}.
+     * <p>
+     * {@code name} may or may not include the desired filename extension, anyway it 
+     * is guaranteed, that the resulting Blob has the appropriate extension as constraint by 
+     * the given {@code mimeType}.
+     * <p>
+     * For more fine-grained control use one of the {@link Blob} constructors directly. 
+     * @param name - may or may not include the desired filename extension
+     * @param mimeType
+     * @param content - bytes
+     * @return new {@link Blob}
+     */
+    public static Blob of(String name, CommonMimeType mimeType, byte[] content) {
+        val proposedFileExtension = mimeType.getProposedFileExtensions().getFirst().orElse("");
+        val fileName = _Strings.asFileNameWithExtension(name, proposedFileExtension);
+        return new Blob(fileName, mimeType.getMimeType(), content);
+    }
+    
+     // -- 
 
     private final MimeType mimeType;
     private final byte[] bytes;
     private final String name;
 
     public Blob(String name, String primaryType, String subtype, byte[] bytes) {
-        this(name, newMimeType(primaryType, subtype), bytes);
+        this(name, CommonMimeType.newMimeType(primaryType, subtype), bytes);
     }
 
     public Blob(String name, String mimeTypeBase, byte[] bytes) {
-        this(name, newMimeType(mimeTypeBase), bytes);
+        this(name, CommonMimeType.newMimeType(mimeTypeBase), bytes);
     }
 
     public Blob(String name, MimeType mimeType, byte[] bytes) {
@@ -69,22 +95,6 @@ public final class Blob implements NamedWithMimeType {
         this.bytes = bytes;
     }
 
-    private static MimeType newMimeType(String primaryType, String subtype) {
-        try {
-            return new MimeType(primaryType, subtype);
-        } catch (MimeTypeParseException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    private static MimeType newMimeType(String baseType) {
-        try {
-            return new MimeType(baseType);
-        } catch (MimeTypeParseException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
     @Override
     public String getName() {
         return name;
diff --git a/api/applib/src/main/java/org/apache/isis/applib/value/BlobClobFactory.java b/api/applib/src/main/java/org/apache/isis/applib/value/BlobClobFactory.java
deleted file mode 100644
index 1c031c2..0000000
--- a/api/applib/src/main/java/org/apache/isis/applib/value/BlobClobFactory.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.apache.isis.applib.value;
-
-import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
-
-import static org.apache.isis.core.commons.internal.base._Strings.asFileNameWithExtension;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * @since 2.0
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class BlobClobFactory {
-
-    /**
-     * see https://stackoverflow.com/questions/4212861/what-is-a-correct-mime-type-for-docx-pptx-etc
-     */
-    public static enum Type {
-        txt("text/plain"),
-        xml("xml/plain"),
-        zip("application/zip"),
-        json("application/json"), 
-        xlsx("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
-        ;
-        final String base;
-        final MimeType mimeType;
-
-        private Type(String baseType) {
-            this.base = baseType;
-            try {
-                this.mimeType = new MimeType(baseType);
-            } catch (MimeTypeParseException e) {
-                throw new IllegalArgumentException(e);
-            }
-        }
-
-        public String getFileNameWithExtension(String fileName) {
-            return asFileNameWithExtension(fileName, name());
-        }
-    }
-
-    /**
-     * Returns a new {@link Blob} of given {@code type}, {@code fileName} and {@code content}.
-     * <p>
-     * {@code fileName} may or may not include the desired filename extension, anyway it 
-     * is guaranteed, that the resulting Blob has the appropriate extension as dictated by 
-     * the given {@code Type}'s name.
-     * <p>
-     * For more fine-grained control use one of the {@link Blob} constructors directly. 
-     * @param type
-     * @param fileName - may or may not include the desired filename extension
-     * @param content
-     * @return new {@link Blob}
-     */
-    public static Blob blob(Type type, String fileName, byte[] content){
-        return blob(type, fileName, type.name(), content);
-    }
-
-    /** To explicitly specify the fileNameExtension, otherwise use {@link #blob(Type, String, byte[])} */
-    public static Blob blob(Type type, String fileName, String fileNameExtension, byte[] content){
-        return new Blob(asFileNameWithExtension(fileName, fileNameExtension), type.mimeType, content);
-    }
-
-    /**
-     * Returns a new {@link Clob} of given {@code type}, {@code fileName} and {@code content}.
-     * <p>
-     * {@code fileName} may or may not include the desired filename extension, anyway it 
-     * is guaranteed, that the resulting Blob has the appropriate extension as dictated by 
-     * the given {@code Type}'s name.
-     * <p>
-     * For more fine-grained control use one of the {@link Clob} constructors directly. 
-     * @param type
-     * @param fileName - may or may not include the desired filename extension
-     * @param content
-     * @return new {@link Clob}
-     */
-    public static Clob clob(Type type, String fileName, CharSequence content){
-        return clob(type, fileName, type.name(), content);
-    }
-
-    /** To explicitly specify the fileNameExtension, otherwise use {@link #clob(Type, String, String)} */
-    public static Clob clob(Type type, String fileName, String fileNameExtension, CharSequence content){
-        return new Clob(asFileNameWithExtension(fileName, fileNameExtension), type.mimeType, content);
-    }
-
-    // -- SHORTCUTS - BLOB
-
-    /** A shortcut, see {@link #blob(Type, String, byte[])} */
-    public static Blob blobTxt(String fileName, byte[] content) {
-        return blob(Type.txt, fileName, content);
-    }
-
-    /** A shortcut, see {@link #blob(Type, String, byte[])} */
-    public static Blob blobXml(String fileName, byte[] content) {
-        return blob(Type.xml, fileName, content);
-    }
-
-    /** A shortcut, see {@link #blob(Type, String, byte[])} */
-    public static Blob blobZip(String fileName, byte[] content) {
-        return blob(Type.zip, fileName, content);
-    }
-
-    /** A shortcut, see {@link #blob(Type, String, byte[])} */
-    public static Blob blobJson(String fileName, byte[] content) {
-        return blob(Type.json, fileName, content);
-    }
-
-    /** A shortcut, see {@link #blob(Type, String, byte[])} */
-    public static Blob blobXlsx(String fileName, byte[] content) {
-        return blob(Type.xlsx, fileName, content);
-    }
-
-    // -- SHORTCUTS - CLOB
-
-    /** A shortcut, see {@link #clob(Type, String, String)} */
-    public static Clob clobTxt(String fileName, CharSequence content) {
-        return clob(Type.txt, fileName, content);
-    }
-
-    /** A shortcut, see {@link #clob(Type, String, String)} */
-    public static Clob clobXml(String fileName, CharSequence content) {
-        return clob(Type.xml, fileName, content);
-    }
-
-    /** A shortcut, see {@link #clob(Type, String, String)} */
-    public static Clob clobJson(String fileName, CharSequence content) {
-        return clob(Type.json, fileName, content);
-    }
-
-
-}
diff --git a/api/applib/src/main/java/org/apache/isis/applib/value/Clob.java b/api/applib/src/main/java/org/apache/isis/applib/value/Clob.java
index b326950..9c59e29 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/value/Clob.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/value/Clob.java
@@ -24,7 +24,10 @@ import java.io.Writer;
 import java.util.Objects;
 
 import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
+
+import org.apache.isis.core.commons.internal.base._Strings;
+
+import lombok.val;
 
 public final class Clob implements NamedWithMimeType {
 
@@ -33,6 +36,30 @@ public final class Clob implements NamedWithMimeType {
     private final String name;
     private final MimeType mimeType;
     private final CharSequence chars;
+    
+    
+    // -- FACTORIES
+    
+    /**
+     * Returns a new {@link Clob} of given {@code name}, {@code mimeType} and {@code content}.
+     * <p>
+     * {@code name} may or may not include the desired filename extension, anyway it 
+     * is guaranteed, that the resulting Blob has the appropriate extension as constraint by 
+     * the given {@code mimeType}.
+     * <p>
+     * For more fine-grained control use one of the {@link Clob} constructors directly. 
+     * @param name - may or may not include the desired filename extension
+     * @param mimeType
+     * @param content - chars
+     * @return new {@link Clob}
+     */
+    public static Clob of(String name, CommonMimeType mimeType, CharSequence content) {
+        val proposedFileExtension = mimeType.getProposedFileExtensions().getFirst().orElse("");
+        val fileName = _Strings.asFileNameWithExtension(name, proposedFileExtension);
+        return new Clob(fileName, mimeType.getMimeType(), content);
+    }
+    
+    // --
 
     public Clob(String name, String primaryType, String subType, char[] chars) {
         this(name, primaryType, subType, new String(chars));
@@ -47,11 +74,11 @@ public final class Clob implements NamedWithMimeType {
     }
 
     public Clob(String name, String primaryType, String subType, CharSequence chars) {
-        this(name, newMimeType(primaryType, subType), chars);
+        this(name, CommonMimeType.newMimeType(primaryType, subType), chars);
     }
 
     public Clob(String name, String mimeTypeBase, CharSequence chars) {
-        this(name, newMimeType(mimeTypeBase), chars);
+        this(name, CommonMimeType.newMimeType(mimeTypeBase), chars);
     }
 
     public Clob(String name, MimeType mimeType, CharSequence chars) {
@@ -72,22 +99,6 @@ public final class Clob implements NamedWithMimeType {
         this.chars = chars;
     }
 
-    private static MimeType newMimeType(String baseType) {
-        try {
-            return new MimeType(baseType);
-        } catch (MimeTypeParseException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    private static MimeType newMimeType(String primaryType, String subType) {
-        try {
-            return new MimeType(primaryType, subType);
-        } catch (MimeTypeParseException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
     @Override
     public String getName() {
         return name;
diff --git a/api/applib/src/main/java/org/apache/isis/applib/value/NamedWithMimeType.java b/api/applib/src/main/java/org/apache/isis/applib/value/NamedWithMimeType.java
index 8910174..35ab297 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/value/NamedWithMimeType.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/value/NamedWithMimeType.java
@@ -22,6 +22,11 @@ package org.apache.isis.applib.value;
 import java.io.Serializable;
 
 import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+
+import org.apache.isis.core.commons.collections.Can;
+
+import lombok.Getter;
 
 public interface NamedWithMimeType extends Serializable {
 
@@ -29,4 +34,146 @@ public interface NamedWithMimeType extends Serializable {
 
     public MimeType getMimeType();
 
+    /**
+     * Subset of MimeTypes most commonly used.
+     * 
+     * @since 2.0
+     */
+    public static enum CommonMimeType {
+
+        // see
+        // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types
+
+        AAC("audio/aac"),
+        ABW("application/x-abiword"),
+        ARC("application/x-freearc"),
+        AVI("video/x-msvideo"),
+        AZW("application/vnd.amazon.ebook"),
+        BIN("application/octet-stream"),
+        BMP("image/bmp"),
+        BZ("application/x-bzip"),
+        BZ2("application/x-bzip2"),
+        CSH("application/x-csh"),
+        CSS("text/css"),
+        CSV("text/csv"),
+        EOT("application/vnd.ms-fontobject"),
+        EPUB("application/epub+zip"),
+        GZ("application/gzip"),
+        GIF("image/gif"),
+        HTML("text/html", "htm"),
+        ICO("image/vnd.microsoft.icon"),
+        ICS("text/calendar"),
+        JAR("application/java-archive"),
+        JPEG("image/jpeg", "jpg"),
+        JS("text/javascript"),
+        JSON("application/json"),
+        JSONLD("application/ld+json"),
+        MIDI("audio/midi", "mid"),
+        MJS("text/javascript"),
+        MP3("audio/mpeg"),
+        MPEG("video/mpeg"),
+        MPKG("application/vnd.apple.installer+xml"),
+        ODP("application/vnd.oasis.opendocument.presentation"),
+        ODS("application/vnd.oasis.opendocument.spreadsheet"),
+        ODT("application/vnd.oasis.opendocument.text"),
+        OGA("audio/ogg"),
+        OGV("video/ogg"),
+        OGX("application/ogg"),
+        OPUS("audio/opus"),
+        OTF("font/otf"),
+        PNG("image/png"),
+        PDF("application/pdf"),
+        PHP("application/php"),
+        RAR("application/x-rar-compressed"),
+        RTF("application/rtf"),
+        SH("application/x-sh"),
+        SVG("image/svg+xml"),
+        SWF("application/x-shockwave-flash"),
+        TAR("application/x-tar"),
+        TIFF("image/tiff", "tif"),
+        TS("video/mp2t"),
+        TTF("font/ttf"),
+        TXT("text/plain"),
+        VSD("application/vnd.visio"),
+        WAV("audio/wav"),
+        WEBA("audio/webm"),
+        WEBM("video/webm"),
+        WEBP("image/webp"),
+        WOFF("font/woff"),
+        WOFF2("font/woff2"),
+        XHTML("application/xhtml+xml"),
+        XML("application/xml"), /*alias*/ XSD("application/xml"),
+        
+        XUL("application/vnd.mozilla.xul+xml"),
+        ZIP("application/zip"),
+        _7Z("application/x-7z-compressed"),
+
+        // see
+        // https://stackoverflow.com/questions/4212861/what-is-a-correct-mime-type-for-docx-pptx-etc
+
+        DOC("application/msword"), 
+        DOT("application/msword"),
+
+        DOCX("application/vnd.openxmlformats-officedocument.wordprocessingml.document"),
+        DOTX("application/vnd.openxmlformats-officedocument.wordprocessingml.template"),
+        DOCM("application/vnd.ms-word.document.macroEnabled.12"),
+        DOTM("application/vnd.ms-word.template.macroEnabled.12"),
+
+        XLS("application/vnd.ms-excel"), 
+        XLT("application/vnd.ms-excel"),
+        XLA("application/vnd.ms-excel"),
+
+        XLSX("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
+        XLTX("application/vnd.openxmlformats-officedocument.spreadsheetml.template"),
+        XLSM("application/vnd.ms-excel.sheet.macroEnabled.12"),
+        XLTM("application/vnd.ms-excel.template.macroEnabled.12"),
+        XLAM("application/vnd.ms-excel.addin.macroEnabled.12"),
+        XLSB("application/vnd.ms-excel.sheet.binary.macroEnabled.12"),
+
+        PPT("application/vnd.ms-powerpoint"), 
+        POT("application/vnd.ms-powerpoint"),
+        PPS("application/vnd.ms-powerpoint"), 
+        PPA("application/vnd.ms-powerpoint"),
+
+        PPTX("application/vnd.openxmlformats-officedocument.presentationml.presentation"),
+        POTX("application/vnd.openxmlformats-officedocument.presentationml.template"),
+        PPSX("application/vnd.openxmlformats-officedocument.presentationml.slideshow"),
+        PPAM("application/vnd.ms-powerpoint.addin.macroEnabled.12"),
+        PPTM("application/vnd.ms-powerpoint.presentation.macroEnabled.12"),
+        POTM("application/vnd.ms-powerpoint.template.macroEnabled.12"),
+        PPSM("application/vnd.ms-powerpoint.slideshow.macroEnabled.12"),
+
+        MDB("application/vnd.ms-access"), 
+
+        ;
+
+        private CommonMimeType(String primaryType, String ... additionalProposedFileExtension) {
+            this.mimeType = newMimeType(primaryType);
+            this.proposedFileExtensions = Can.ofSingleton(name().toLowerCase())
+                    .addAll(Can.ofArray(additionalProposedFileExtension));
+        }
+
+        @Getter
+        final MimeType mimeType;
+        @Getter
+        final Can<String> proposedFileExtensions;
+
+        static MimeType newMimeType(String primaryType, String subtype) {
+            try {
+                return new MimeType(primaryType, subtype);
+            } catch (MimeTypeParseException e) {
+                throw new IllegalArgumentException(e);
+            }
+        }
+
+        static MimeType newMimeType(String baseType) {
+            try {
+                return new MimeType(baseType);
+            } catch (MimeTypeParseException e) {
+                throw new IllegalArgumentException(e);
+            }
+        }
+
+    }
+
 }