-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d0f971
commit 4533783
Showing
9 changed files
with
192 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package play.modules.morphia; | ||
|
||
import javassist.CtClass; | ||
import javassist.CtField; | ||
import javassist.bytecode.AnnotationsAttribute; | ||
import javassist.bytecode.annotation.Annotation; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: luog | ||
* Date: 16/10/13 | ||
* Time: 9:07 PM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
public class CRUDFieldEnhancer implements MorphiaEnhancer.FieldEnhancer { | ||
@Override | ||
public void enhance(CtField field, CtClass clz) { | ||
AnnotationsAttribute aa = (AnnotationsAttribute)field.getFieldInfo().getAttribute(AnnotationsAttribute.visibleTag); | ||
if (null == aa) { | ||
aa = new AnnotationsAttribute(clz.getClassFile().getConstPool(), | ||
AnnotationsAttribute.visibleTag); | ||
field.getFieldInfo().addAttribute(aa); | ||
} | ||
Annotation ann = new Annotation("controllers.CRUD$Hidden", clz.getClassFile().getConstPool()); | ||
aa.addAnnotation(ann); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package play.modules.morphia.utils; | ||
|
||
import org.osgl.util.S; | ||
|
||
import java.io.File; | ||
import java.net.URLConnection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: luog | ||
* Date: 16/11/13 | ||
* Time: 8:33 PM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
public enum MimeTypes { | ||
_; | ||
|
||
private Map<String, String> m = new HashMap<String, String>(); | ||
|
||
private MimeTypes() { | ||
p(".doc:application/msword"); | ||
p(".dot:application/msword"); | ||
p(".docx:application/vnd.openxmlformats-officedocument.wordprocessingml.document"); | ||
p(".dotx:application/vnd.openxmlformats-officedocument.wordprocessingml.template"); | ||
p(".docm:application/vnd.ms-word.document.macroEnabled.12"); | ||
p(".dotm:application/vnd.ms-word.template.macroEnabled.12"); | ||
p(".ppt:application/vnd.ms-powerpoint"); | ||
p(".pot:application/vnd.ms-powerpoint"); | ||
p(".pps:application/vnd.ms-powerpoint"); | ||
p(".ppa:application/vnd.ms-powerpoint"); | ||
p(".potx:application/vnd.openxmlformats-officedocument.presentationml.template"); | ||
p(".ppsx:application/vnd.openxmlformats-officedocument.presentationml.slideshow"); | ||
p(".pptx:application/vnd.openxmlformats-officedocument.presentationml.presentation"); | ||
p(".sldx:application/vnd.openxmlformats-officedocument.presentationml.slide"); | ||
p(".ppam:application/vnd.ms-powerpoint.addin.macroEnabled.12"); | ||
p(".pptm:application/vnd.ms-powerpoint.presentation.macroEnabled.12"); | ||
p(".potm:application/vnd.ms-powerpoint.template.macroEnabled.12"); | ||
p(".ppsm:application/vnd.ms-powerpoint.slideshow.macroEnabled.12"); | ||
p(".xla:application/vnd.ms-excel"); | ||
p(".xls:application/vnd.ms-excel"); | ||
p(".xlt:application/vnd.ms-excel"); | ||
p(".xlam:application/vnd.ms-excel.addin.macroEnabled.12"); | ||
p(".xlsb:application/vnd.ms-excel.sheet.binary.macroEnabled.12"); | ||
p(".xlsm:application/vnd.ms-excel.sheet.macroEnabled.12"); | ||
p(".xltm:application/vnd.ms-excel.template.macroEnabled.12"); | ||
p(".xlsx:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); | ||
p(".xltx:application/vnd.openxmlformats-officedocument.spreadsheetml.template"); | ||
} | ||
|
||
private void p(String s) { | ||
String[] sa = s.split(":"); | ||
m.put(sa[0], sa[1]); | ||
} | ||
|
||
private String get(String k) { | ||
return m.get(k); | ||
} | ||
|
||
public static String probe(File file) { | ||
return probe(file.getName()); | ||
} | ||
|
||
public static String probe(String fileName) { | ||
// try JDK util first | ||
String type = URLConnection.guessContentTypeFromName(fileName); | ||
if (null == type) { | ||
String suffix = "." + S.str(fileName).afterLast(".").get(); | ||
type = _.get(suffix); | ||
} | ||
return type; | ||
} | ||
} |