You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2011/04/14 17:58:59 UTC
svn commit: r1092364 - in /chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/
chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apach...
Author: fmui
Date: Thu Apr 14 15:58:59 2011
New Revision: 1092364
URL: http://svn.apache.org/viewvc?rev=1092364&view=rev
Log:
moved MimeTypes class to a central place and removed copies
Added:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeTypes.java (with props)
Removed:
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/MIMETypes.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/MIMETypes.java
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java?rev=1092364&r1=1092363&r2=1092364&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java Thu Apr 14 15:58:59 2011
@@ -252,6 +252,10 @@ public class SessionImpl implements Sess
}
public ItemIterable<Document> getCheckedOutDocs(OperationContext context) {
+ if (context == null) {
+ throw new IllegalArgumentException("Operation context must be set!");
+ }
+
final NavigationService navigationService = getBinding().getNavigationService();
final ObjectFactory objectFactory = getObjectFactory();
final OperationContext ctxt = new OperationContextImpl(context);
@@ -293,6 +297,10 @@ public class SessionImpl implements Sess
public ChangeEvents getContentChanges(String changeLogToken, boolean includeProperties, long maxNumItems,
OperationContext context) {
+ if (context == null) {
+ throw new IllegalArgumentException("Operation context must be set!");
+ }
+
lock.readLock().lock();
try {
Holder<String> changeLogTokenHolder = new Holder<String>(changeLogToken);
@@ -530,6 +538,9 @@ public class SessionImpl implements Sess
public ItemIterable<QueryResult> query(final String statement, final boolean searchAllVersions,
OperationContext context) {
+ if (context == null) {
+ throw new IllegalArgumentException("Operation context must be set!");
+ }
final DiscoveryService discoveryService = getBinding().getDiscoveryService();
final ObjectFactory objectFactory = this.getObjectFactory();
@@ -763,6 +774,9 @@ public class SessionImpl implements Sess
if ((objectId == null) || (objectId.getId() == null)) {
throw new IllegalArgumentException("Invalid object id!");
}
+ if (context == null) {
+ throw new IllegalArgumentException("Operation context must be set!");
+ }
final String id = objectId.getId();
final String typeId = (type == null ? null : type.getId());
Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeTypes.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeTypes.java?rev=1092364&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeTypes.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeTypes.java Thu Apr 14 15:58:59 2011
@@ -0,0 +1,394 @@
+/*
+ * 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.chemistry.opencmis.commons.impl;
+
+import java.io.File;
+import java.net.URLConnection;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MimeTypes {
+
+ private static Map<String, String> EXT2MIME = new HashMap<String, String>();
+ private static Map<String, String> MIME2EXT = new HashMap<String, String>();
+
+ static {
+ // extension to MIME type
+ EXT2MIME.put("", "application/octet-stream");
+ EXT2MIME.put("ai", "application/postscript");
+ EXT2MIME.put("aif", "audio/x-aiff");
+ EXT2MIME.put("aifc", "audio/x-aiff");
+ EXT2MIME.put("aiff", "audio/x-aiff");
+ EXT2MIME.put("asf", "video/x-ms-asf");
+ EXT2MIME.put("asr", "video/x-ms-asf");
+ EXT2MIME.put("asx", "video/x-ms-asf");
+ EXT2MIME.put("au", "audio/basic");
+ EXT2MIME.put("avi", "video/x-msvideo");
+ EXT2MIME.put("axs", "application/olescript");
+ EXT2MIME.put("bas", "text/plain");
+ EXT2MIME.put("bmp", "image/bmp");
+ EXT2MIME.put("c", "text/plain");
+ EXT2MIME.put("cat", "application/vnd.ms-pkiseccat");
+ EXT2MIME.put("cdf", "application/x-cdf");
+ EXT2MIME.put("cer", "application/x-x509-ca-cert");
+ EXT2MIME.put("clp", "application/x-msclip");
+ EXT2MIME.put("cmx", "image/x-cmx");
+ EXT2MIME.put("cod", "image/cis-cod");
+ EXT2MIME.put("cpio", "application/x-cpio");
+ EXT2MIME.put("crd", "application/x-mscardfile");
+ EXT2MIME.put("crl", "application/pkix-crl");
+ EXT2MIME.put("crt", "application/x-x509-ca-cert");
+ EXT2MIME.put("csh", "application/x-csh");
+ EXT2MIME.put("css", "text/css");
+ EXT2MIME.put("dll", "application/x-msdownload");
+ EXT2MIME.put("doc", "application/msword");
+ EXT2MIME.put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+ EXT2MIME.put("doct", "application/vnd.openxmlformats-officedocument.wordprocessingml.template");
+ EXT2MIME.put("dot", "application/msword");
+ EXT2MIME.put("dvi", "application/x-dvi");
+ EXT2MIME.put("dxr", "application/x-director");
+ EXT2MIME.put("eps", "application/postscript");
+ EXT2MIME.put("etx", "text/x-setext");
+ EXT2MIME.put("evy", "application/envoy");
+ EXT2MIME.put("fif", "application/fractals");
+ EXT2MIME.put("flr", "x-world/x-vrml");
+ EXT2MIME.put("gif", "image/gif");
+ EXT2MIME.put("gtar", "application/x-gtar");
+ EXT2MIME.put("gz", "application/x-gzip");
+ EXT2MIME.put("h", "text/plain");
+ EXT2MIME.put("hdf", "application/x-hdf");
+ EXT2MIME.put("hlp", "application/winhlp");
+ EXT2MIME.put("hqx", "application/mac-binhex40");
+ EXT2MIME.put("hta", "application/hta");
+ EXT2MIME.put("htc", "text/x-component");
+ EXT2MIME.put("htm", "text/html");
+ EXT2MIME.put("html", "text/html");
+ EXT2MIME.put("htt", "text/webviewhtml");
+ EXT2MIME.put("ico", "image/x-icon");
+ EXT2MIME.put("ief", "image/ief");
+ EXT2MIME.put("iii", "application/x-iphone");
+ EXT2MIME.put("isp", "application/x-internet-signup");
+ EXT2MIME.put("jfif", "image/pipeg");
+ EXT2MIME.put("jpe", "image/jpeg");
+ EXT2MIME.put("jpeg", "image/jpeg");
+ EXT2MIME.put("jpg", "image/jpeg");
+ EXT2MIME.put("js", "application/x-javascript");
+ EXT2MIME.put("latex", "application/x-latex");
+ EXT2MIME.put("lsf", "video/x-la-asf");
+ EXT2MIME.put("lsx", "video/x-la-asf");
+ EXT2MIME.put("m3u", "audio/x-mpegurl");
+ EXT2MIME.put("man", "application/x-troff-man");
+ EXT2MIME.put("mdb", "application/x-msaccess");
+ EXT2MIME.put("me", "application/x-troff-me");
+ EXT2MIME.put("mhtv", "message/rfc822");
+ EXT2MIME.put("mhtml", "message/rfc822");
+ EXT2MIME.put("mid", "audio/mid");
+ EXT2MIME.put("mov", "video/quicktime");
+ EXT2MIME.put("movie", "video/x-sgi-movie");
+ EXT2MIME.put("mp2", "video/mpeg");
+ EXT2MIME.put("mp3", "audio/mpeg");
+ EXT2MIME.put("mpa", "video/mpeg");
+ EXT2MIME.put("mpe", "video/mpegv");
+ EXT2MIME.put("mpeg", "video/mpeg");
+ EXT2MIME.put("mpg", "video/mpegv");
+ EXT2MIME.put("mpp", "application/vnd.ms-project");
+ EXT2MIME.put("mpv2", "video/mpeg");
+ EXT2MIME.put("ms", "application/x-troff-ms");
+ EXT2MIME.put("mvb", "application/x-msmediaview");
+ EXT2MIME.put("nws", "message/rfc822");
+ EXT2MIME.put("oda", "application/oda");
+ EXT2MIME.put("p10", "application/pkcs10");
+ EXT2MIME.put("p12", "application/x-pkcs12v");
+ EXT2MIME.put("p7b", "application/x-pkcs7-certificates");
+ EXT2MIME.put("p7c", "application/x-pkcs7-mime");
+ EXT2MIME.put("p7m", "application/x-pkcs7-mime");
+ EXT2MIME.put("p7r", "application/x-pkcs7-certreqresp");
+ EXT2MIME.put("p7s", "application/x-pkcs7-signature");
+ EXT2MIME.put("pbm", "image/x-portable-bitmap");
+ EXT2MIME.put("pdf", "application/pdf");
+ EXT2MIME.put("pfx", "application/x-pkcs12");
+ EXT2MIME.put("pgm", "image/x-portable-graymap");
+ EXT2MIME.put("vpko", "application/ynd.ms-pkipko");
+ EXT2MIME.put("pma", "application/x-perfmon");
+ EXT2MIME.put("pmc", "application/x-perfmon");
+ EXT2MIME.put("pml", "application/x-perfmon");
+ EXT2MIME.put("pmr", "application/x-perfmon");
+ EXT2MIME.put("pmw", "application/x-perfmon");
+ EXT2MIME.put("png", "image/png");
+ EXT2MIME.put("pnm", "image/x-portable-anymap");
+ EXT2MIME.put("pot", "application/vnd.ms-powerpoint");
+ EXT2MIME.put("ppm", "image/x-portable-pixmap");
+ EXT2MIME.put("pps", "application/vnd.ms-powerpoint");
+ EXT2MIME.put("ppt", "application/vnd.ms-powerpoint");
+ EXT2MIME.put("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
+ EXT2MIME.put("ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow");
+ EXT2MIME.put("potx", "application/vnd.openxmlformats-officedocument.presentationml.template");
+ EXT2MIME.put("prf", "application/pics-rules");
+ EXT2MIME.put("ps", "application/postscript");
+ EXT2MIME.put("pub", "application/x-mspublisher");
+ EXT2MIME.put("qt", "video/quicktime");
+ EXT2MIME.put("ra", "audio/x-pn-realaudio");
+ EXT2MIME.put("ram", "audio/x-pn-realaudio");
+ EXT2MIME.put("ras", "image/x-cmu-raster");
+ EXT2MIME.put("rgb", "image/x-rgb");
+ EXT2MIME.put("rmi", "audio/mid");
+ EXT2MIME.put("roff", "application/x-troff");
+ EXT2MIME.put("rtf", "application/rtf");
+ EXT2MIME.put("rtx", "text/richtext");
+ EXT2MIME.put("scd", "application/x-msschedule");
+ EXT2MIME.put("sct", "text/scriptlet");
+ EXT2MIME.put("sh", "application/x-sh");
+ EXT2MIME.put("shar", "application/x-shar");
+ EXT2MIME.put("sit", "application/x-stuffit");
+ EXT2MIME.put("snd", "audio/basic");
+ EXT2MIME.put("spc", "application/x-pkcs7-certificates");
+ EXT2MIME.put("spl", "application/futuresplash");
+ EXT2MIME.put("src", "application/x-wais-source");
+ EXT2MIME.put("sst", "application/vnd.ms-pkicertstore");
+ EXT2MIME.put("stl", "application/vnd.ms-pkistl");
+ EXT2MIME.put("stm", "text/html");
+ EXT2MIME.put("svg", "image/svg+xml");
+ EXT2MIME.put("swf", "application/x-shockwave-flash");
+ EXT2MIME.put("t", "application/x-troff");
+ EXT2MIME.put("tar", "application/x-tar");
+ EXT2MIME.put("tcl", "application/x-tcl");
+ EXT2MIME.put("tex", "application/x-tex");
+ EXT2MIME.put("texi", "application/x-texinfo");
+ EXT2MIME.put("texinfo", "application/x-texinfo");
+ EXT2MIME.put("tgz", "application/x-compressed");
+ EXT2MIME.put("tif", "image/tiff");
+ EXT2MIME.put("tiff", "image/tiff");
+ EXT2MIME.put("tr", "application/x-troff");
+ EXT2MIME.put("trm", "application/x-msterminal");
+ EXT2MIME.put("tsv", "text/tab-separated-values");
+ EXT2MIME.put("txt", "text/plain");
+ EXT2MIME.put("uls", "text/iuls");
+ EXT2MIME.put("ustar", "application/x-ustar");
+ EXT2MIME.put("vcf", "text/x-vcard");
+ EXT2MIME.put("vrml", "x-world/x-vrml");
+ EXT2MIME.put("wav", "audio/x-wav");
+ EXT2MIME.put("wcm", "application/vnd.ms-works");
+ EXT2MIME.put("wdb", "application/vnd.ms-works");
+ EXT2MIME.put("wmf", "application/x-msmetafile");
+ EXT2MIME.put("wps", "application/vnd.ms-works");
+ EXT2MIME.put("wri", "application/x-mswrite");
+ EXT2MIME.put("wrl", "x-world/x-vrml");
+ EXT2MIME.put("wrz", "x-world/x-vrml");
+ EXT2MIME.put("xaf", "x-world/x-vrml");
+ EXT2MIME.put("xbm", "image/x-xbitmap");
+ EXT2MIME.put("xla", "application/vnd.ms-excel");
+ EXT2MIME.put("xlc", "application/vnd.ms-excel");
+ EXT2MIME.put("xlm", "application/vnd.ms-excel");
+ EXT2MIME.put("xls", "application/vnd.ms-excel");
+ EXT2MIME.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ EXT2MIME.put("xlt", "application/vnd.ms-excel");
+ EXT2MIME.put("xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template");
+ EXT2MIME.put("xlw", "application/vnd.ms-excel");
+ EXT2MIME.put("xml", "text/xml");
+ EXT2MIME.put("xof", "x-world/x-vrml");
+ EXT2MIME.put("xpm", "image/x-xpixmap");
+ EXT2MIME.put("xwd", "image/x-xwindowdump");
+ EXT2MIME.put("z", "application/x-compress");
+ EXT2MIME.put("zip", "application/zip");
+
+ // MIME type to extension
+ MIME2EXT.put("application/octet-stream", "");
+ MIME2EXT.put("application/envoy", "evy");
+ MIME2EXT.put("application/fractals", "fif");
+ MIME2EXT.put("application/futuresplash", "spl");
+ MIME2EXT.put("application/hta", "hta");
+ MIME2EXT.put("application/mac-binhex40", "hqx");
+ MIME2EXT.put("application/msword", "doc");
+ MIME2EXT.put("application/oda", "oda");
+ MIME2EXT.put("application/olescript", "axs");
+ MIME2EXT.put("application/pdf", "pdf");
+ MIME2EXT.put("application/pics-rules", "prf");
+ MIME2EXT.put("application/pkcs10", "p10");
+ MIME2EXT.put("application/pkix-crl", "crl");
+ MIME2EXT.put("application/postscript", "ps");
+ MIME2EXT.put("application/rtf", "rtf");
+ MIME2EXT.put("application/vnd.ms-excel", "xls");
+ MIME2EXT.put("application/vnd.ms-pkicertstore", "sst");
+ MIME2EXT.put("application/vnd.ms-pkiseccat", "cat");
+ MIME2EXT.put("application/vnd.ms-pkistl", "stl");
+ MIME2EXT.put("application/vnd.ms-powerpoint", "ppt");
+ MIME2EXT.put("application/vnd.ms-project", "mpp");
+ MIME2EXT.put("application/vnd.ms-works", "wps");
+ MIME2EXT.put("application/vnd.openxmlformats-officedocument.presentationml.presentation", "pptx");
+ MIME2EXT.put("application/vnd.openxmlformats-officedocument.presentationml.slideshow", "ppsx");
+ MIME2EXT.put("application/vnd.openxmlformats-officedocument.presentationml.template", "potx");
+ MIME2EXT.put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx");
+ MIME2EXT.put("application/vnd.openxmlformats-officedocument.spreadsheetml.template", "xltx");
+ MIME2EXT.put("application/winhlp", "hlp");
+ MIME2EXT.put("application/x-cdf", "cdf");
+ MIME2EXT.put("application/x-compress", "z");
+ MIME2EXT.put("application/x-compressed", "tgz");
+ MIME2EXT.put("application/x-cpio", "cpio");
+ MIME2EXT.put("application/x-csh", "csh");
+ MIME2EXT.put("application/x-director", "dxr");
+ MIME2EXT.put("application/x-dvi", "dvi");
+ MIME2EXT.put("application/x-gtar", "gtar");
+ MIME2EXT.put("application/x-gzip", "gz");
+ MIME2EXT.put("application/x-hdf", "hdf");
+ MIME2EXT.put("application/x-internet-signup", "isp");
+ MIME2EXT.put("application/x-iphone", "iii");
+ MIME2EXT.put("application/x-javascript", "js");
+ MIME2EXT.put("application/x-latex", "latex");
+ MIME2EXT.put("application/x-msaccess", "mdb");
+ MIME2EXT.put("application/x-mscardfile", "crd");
+ MIME2EXT.put("application/x-msclip", "clp");
+ MIME2EXT.put("application/x-msdownload", "dll");
+ MIME2EXT.put("application/x-msmediaview", "mvb");
+ MIME2EXT.put("application/x-msmetafile", "wmf");
+ MIME2EXT.put("application/x-mspublisher", "pub");
+ MIME2EXT.put("application/x-msschedule", "scd");
+ MIME2EXT.put("application/x-msterminal", "trm");
+ MIME2EXT.put("application/x-mswrite", "wri");
+ MIME2EXT.put("application/x-perfmon", "pmw");
+ MIME2EXT.put("application/x-pkcs12", "pfx");
+ MIME2EXT.put("application/x-pkcs12v", "p12");
+ MIME2EXT.put("application/x-pkcs7-certificates", "p7b");
+ MIME2EXT.put("application/x-pkcs7-certificates", "spc");
+ MIME2EXT.put("application/x-pkcs7-certreqresp", "p7r");
+ MIME2EXT.put("application/x-pkcs7-mime", "p7m");
+ MIME2EXT.put("application/x-pkcs7-signature", "p7s");
+ MIME2EXT.put("application/x-sh", "sh");
+ MIME2EXT.put("application/x-shar", "shar");
+ MIME2EXT.put("application/x-shockwave-flash", "swf");
+ MIME2EXT.put("application/x-stuffit", "sit");
+ MIME2EXT.put("application/x-tar", "tar");
+ MIME2EXT.put("application/x-tcl", "tcl");
+ MIME2EXT.put("application/x-tex", "tex");
+ MIME2EXT.put("application/x-texinfo", "texinfo");
+ MIME2EXT.put("application/x-troff-man", "man");
+ MIME2EXT.put("application/x-troff-me", "me");
+ MIME2EXT.put("application/x-troff-ms", "ms");
+ MIME2EXT.put("application/x-troff", "tr");
+ MIME2EXT.put("application/x-ustar", "ustar");
+ MIME2EXT.put("application/x-wais-source", "src");
+ MIME2EXT.put("application/x-x509-ca-cert", "cer");
+ MIME2EXT.put("application/ynd.ms-pkipko", "vpko");
+ MIME2EXT.put("application/zip", "zip");
+ MIME2EXT.put("audio/basic", "snd");
+ MIME2EXT.put("audio/mid", "mid");
+ MIME2EXT.put("audio/mpeg", "mp3");
+ MIME2EXT.put("audio/x-aiff", "aif");
+ MIME2EXT.put("audio/x-mpegurl", "m3u");
+ MIME2EXT.put("audio/x-pn-realaudio", "ram");
+ MIME2EXT.put("audio/x-wav", "wav");
+ MIME2EXT.put("doct", "application/vnd.openxmlformats-officedocument.wordprocessingml.template");
+ MIME2EXT.put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+ MIME2EXT.put("image/bmp", "bmp");
+ MIME2EXT.put("image/cis-cod", "cod");
+ MIME2EXT.put("image/gif", "gif");
+ MIME2EXT.put("image/ief", "ief");
+ MIME2EXT.put("image/jpeg", "jpeg");
+ MIME2EXT.put("image/pipeg", "jfif");
+ MIME2EXT.put("image/png", "png");
+ MIME2EXT.put("image/svg+xml", "svg");
+ MIME2EXT.put("image/tiff", "tiff");
+ MIME2EXT.put("image/x-cmu-raster", "ras");
+ MIME2EXT.put("image/x-cmx", "cmx");
+ MIME2EXT.put("image/x-icon", "ico");
+ MIME2EXT.put("image/x-portable-anymap", "pnm");
+ MIME2EXT.put("image/x-portable-bitmap", "pbm");
+ MIME2EXT.put("image/x-portable-graymap", "pgm");
+ MIME2EXT.put("image/x-portable-pixmap", "ppm");
+ MIME2EXT.put("image/x-rgb", "rgb");
+ MIME2EXT.put("image/x-xbitmap", "xbm");
+ MIME2EXT.put("image/x-xpixmap", "xpm");
+ MIME2EXT.put("image/x-xwindowdump", "xwd");
+ MIME2EXT.put("message/rfc822", "mhtml");
+ MIME2EXT.put("text/css", "css");
+ MIME2EXT.put("text/html", "html");
+ MIME2EXT.put("text/iuls", "uls");
+ MIME2EXT.put("text/plain", "txt");
+ MIME2EXT.put("text/richtext", "rtx");
+ MIME2EXT.put("text/scriptlet", "sct");
+ MIME2EXT.put("text/tab-separated-values", "tsv");
+ MIME2EXT.put("text/webviewhtml", "htt");
+ MIME2EXT.put("text/x-component", "htc");
+ MIME2EXT.put("text/x-setext", "etx");
+ MIME2EXT.put("text/x-vcard", "vcf");
+ MIME2EXT.put("text/xml", "xml");
+ MIME2EXT.put("video/mpeg", "mpeg");
+ MIME2EXT.put("video/mpegv", "mpe");
+ MIME2EXT.put("video/quicktime", "mov");
+ MIME2EXT.put("video/quicktime", "qt");
+ MIME2EXT.put("video/x-la-asf", "lsf");
+ MIME2EXT.put("video/x-la-asf", "lsx");
+ MIME2EXT.put("video/x-ms-asf", "asf");
+ MIME2EXT.put("video/x-msvideo", "avi");
+ MIME2EXT.put("video/x-sgi-movie", "movie");
+ MIME2EXT.put("x-world/x-vrml", "vrml");
+ }
+
+ /**
+ * Returns the MIME type for file extension.
+ */
+ public static String getMIMEType(String ext) {
+ if (ext == null) {
+ return EXT2MIME.get("");
+ }
+
+ int x = ext.lastIndexOf('.');
+ if (x > -1) {
+ ext = ext.substring(x + 1);
+ }
+
+ String mime = EXT2MIME.get(ext.toLowerCase());
+ if (mime == null) {
+ mime = URLConnection.getFileNameMap().getContentTypeFor("x." + ext);
+ }
+ if (mime == null) {
+ mime = EXT2MIME.get("");
+ }
+
+ return mime;
+ }
+
+ /**
+ * Returns the MIME type for a file.
+ */
+ public static String getMIMEType(File file) {
+ if (file == null) {
+ return getMIMEType("");
+ }
+
+ return getMIMEType(file.getName());
+ }
+
+ /**
+ * Guesses a extension from a MIME type.
+ */
+ public static String getExtension(String mimeType) {
+ if (mimeType == null) {
+ return "";
+ }
+
+ int x = mimeType.indexOf(';');
+ if (x > -1) {
+ mimeType = mimeType.substring(0, x);
+ }
+ mimeType = mimeType.trim().toLowerCase();
+
+ String extension = MIME2EXT.get(mimeType);
+ return ((extension == null || extension.length() == 0) ? "" : "." + extension);
+ }
+}
Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeTypes.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java?rev=1092364&r1=1092363&r2=1092364&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java Thu Apr 14 15:58:59 2011
@@ -92,6 +92,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.apache.chemistry.opencmis.commons.impl.Converter;
import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
+import org.apache.chemistry.opencmis.commons.impl.MimeTypes;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
@@ -540,8 +541,8 @@ public class FileShareRepository {
addPropertyId(newProperties, typeId, null, PropertyIds.OBJECT_TYPE_ID, typeId);
addPropertyString(newProperties, typeId, null, PropertyIds.CREATED_BY, context.getUsername());
- addPropertyDateTime(newProperties, typeId, null, PropertyIds.CREATION_DATE, millisToCalendar(System
- .currentTimeMillis()));
+ addPropertyDateTime(newProperties, typeId, null, PropertyIds.CREATION_DATE,
+ millisToCalendar(System.currentTimeMillis()));
addPropertyString(newProperties, typeId, null, PropertyIds.LAST_MODIFIED_BY, context.getUsername());
// check the file
@@ -941,7 +942,7 @@ public class FileShareRepository {
ContentStreamImpl result = new ContentStreamImpl();
result.setFileName(file.getName());
result.setLength(BigInteger.valueOf(file.length()));
- result.setMimeType(MIMETypes.getMIMEType(file));
+ result.setMimeType(MimeTypes.getMIMEType(file));
result.setStream(stream);
return result;
@@ -1420,11 +1421,11 @@ public class FileShareRepository {
addPropertyId(result, typeId, filter, PropertyIds.VERSION_SERIES_ID, fileToId(file));
addPropertyString(result, typeId, filter, PropertyIds.CHECKIN_COMMENT, "");
addPropertyInteger(result, typeId, filter, PropertyIds.CONTENT_STREAM_LENGTH, file.length());
- addPropertyString(result, typeId, filter, PropertyIds.CONTENT_STREAM_MIME_TYPE, MIMETypes
- .getMIMEType(file));
+ addPropertyString(result, typeId, filter, PropertyIds.CONTENT_STREAM_MIME_TYPE,
+ MimeTypes.getMIMEType(file));
addPropertyString(result, typeId, filter, PropertyIds.CONTENT_STREAM_FILE_NAME, file.getName());
- objectInfo.setContentType(MIMETypes.getMIMEType(file));
+ objectInfo.setContentType(MimeTypes.getMIMEType(file));
objectInfo.setFileName(file.getName());
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java?rev=1092364&r1=1092363&r2=1092364&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java Thu Apr 14 15:58:59 2011
@@ -47,7 +47,7 @@ import org.apache.chemistry.opencmis.cli
import org.apache.chemistry.opencmis.commons.data.ContentStream;
import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
-import org.apache.chemistry.opencmis.workbench.model.MIMETypes;
+import org.apache.chemistry.opencmis.commons.impl.MimeTypes;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -203,7 +203,7 @@ public class ClientHelper {
}
if (filename.indexOf('.') == -1) {
- filename = filename + MIMETypes.getExtension(content.getMimeType());
+ filename = filename + MimeTypes.getExtension(content.getMimeType());
}
File tempFile = ClientHelper.createTempFile(filename);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java?rev=1092364&r1=1092363&r2=1092364&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java Thu Apr 14 15:58:59 2011
@@ -47,6 +47,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.impl.MimeTypes;
public class ClientModel {
@@ -212,7 +213,7 @@ public class ClientModel {
InputStream stream = new FileInputStream(file);
content = clientSession.getSession().getObjectFactory()
- .createContentStream(file.getName(), file.length(), MIMETypes.getMIMEType(file), stream);
+ .createContentStream(file.getName(), file.length(), MimeTypes.getMIMEType(file), stream);
}
return content;