]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/acr/CmsContentTypes.java
Support writing file as XML
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / CmsContentTypes.java
1 package org.argeo.cms.acr;
2
3 import java.net.MalformedURLException;
4 import java.net.URL;
5 import java.util.Objects;
6
7 import org.argeo.api.acr.CrName;
8
9 public enum CmsContentTypes {
10 //
11 // ARGEO
12 //
13 CR_2(CrName.CR_DEFAULT_PREFIX, CrName.CR_NAMESPACE_URI, "cr.xsd", null),
14 //
15 SLC("slc", "http://www.argeo.org/ns/slc", null, null),
16 //
17 ARGEO_LEGACY("argeo", "http://www.argeo.org/ns/argeo", null, null),
18 //
19 // EXTERNAL
20 //
21 XSD_2001("xs", "http://www.w3.org/2001/XMLSchema", "XMLSchema.xsd", "http://www.w3.org/2001/XMLSchema.xsd"),
22 //
23 XML_1998("xml", "http://www.w3.org/XML/1998/namespace", "xml.xsd", "http://www.w3.org/2001/xml.xsd"),
24 //
25 XLINK_1999("xlink", "http://www.w3.org/1999/xlink", "xlink.xsd", "http://www.w3.org/XML/2008/06/xlink.xsd"),
26 //
27 // WEBDAV("dav", "DAV:", "webdav.xsd", "https://raw.githubusercontent.com/lookfirst/sardine/master/webdav.xsd"),
28 //
29 XSLT_2_0("xsl", "http://www.w3.org/1999/XSL/Transform", "schema-for-xslt20.xsd",
30 "https://www.w3.org/2007/schema-for-xslt20.xsd"),
31 //
32 SVG_1_1("svg", "http://www.w3.org/2000/svg", "SVG.xsd",
33 "https://raw.githubusercontent.com/oreillymedia/HTMLBook/master/schema/svg/SVG.xsd"),
34 //
35 DOCBOOK_5_0_1("dbk", "http://docbook.org/ns/docbook", "docbook.xsd",
36 "http://docbook.org/xml/5.0.1/xsd/docbook.xsd"),
37 //
38 XML_EVENTS_2001("ev", "http://www.w3.org/2001/xml-events", "xml-events-attribs-1.xsd",
39 "http://www.w3.org/MarkUp/SCHEMA/xml-events-attribs-1.xsd"),
40 //
41 XFORMS_2002("xforms", "http://www.w3.org/2002/xforms", "XForms-11-Schema.xsd",
42 "https://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd"),
43 //
44 DSML_v2("dsml", "urn:oasis:names:tc:DSML:2:0:core", "DSMLv2.xsd",
45 "https://www.oasis-open.org/committees/dsml/docs/DSMLv2.xsd"),
46 //
47 // JCR (to be moved elsewhere)
48 //
49 JCR("jcr", "http://www.jcp.org/jcr/1.0", null,
50 "https://jackrabbit.apache.org/archive/wiki/JCR/NamespaceRegistry_115513459.html"),
51 //
52 JCR_MIX("mix", "http://www.jcp.org/jcr/mix/1.0", null,
53 "https://jackrabbit.apache.org/archive/wiki/JCR/NamespaceRegistry_115513459.html"),
54 //
55 JCR_NT("nt", "http://www.jcp.org/jcr/nt/1.0", null,
56 "https://jackrabbit.apache.org/archive/wiki/JCR/NamespaceRegistry_115513459.html"),
57 //
58 JACKRABBIT("rep", "internal", null,
59 "https://jackrabbit.apache.org/archive/wiki/JCR/NamespaceRegistry_115513459.html"),
60 //
61 JCRX("jcrx", "http://www.argeo.org/ns/jcrx", null, null),
62 //
63 ;
64
65 private final static String RESOURCE_BASE = "/org/argeo/cms/acr/schemas/";
66
67 private String defaultPrefix;
68 private String namespace;
69 private URL resource;
70 private URL publicUrl;
71
72 CmsContentTypes(String defaultPrefix, String namespace, String resourceFileName, String publicUrl) {
73 Objects.requireNonNull(namespace);
74 this.defaultPrefix = defaultPrefix;
75 Objects.requireNonNull(namespace);
76 this.namespace = namespace;
77 if (resourceFileName != null) {
78 resource = getClass().getResource(RESOURCE_BASE + resourceFileName);
79 Objects.requireNonNull(resource);
80 }
81 if (publicUrl != null)
82 try {
83 this.publicUrl = new URL(publicUrl);
84 } catch (MalformedURLException e) {
85 throw new IllegalArgumentException("Cannot interpret public URL", e);
86 }
87 }
88
89 public String getDefaultPrefix() {
90 return defaultPrefix;
91 }
92
93 public String getNamespace() {
94 return namespace;
95 }
96
97 public URL getResource() {
98 return resource;
99 }
100
101 public URL getPublicUrl() {
102 return publicUrl;
103 }
104
105 }