]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.app.core/src/org/argeo/app/core/SuiteContentNamespace.java
ec77eda02f8ce7702f0e0952cef6e58d20624e71
[gpl/argeo-suite.git] / org.argeo.app.core / src / org / argeo / app / core / SuiteContentNamespace.java
1 package org.argeo.app.core;
2
3 import java.net.MalformedURLException;
4 import java.net.URI;
5 import java.net.URL;
6 import java.util.Objects;
7
8 import org.argeo.api.acr.spi.ContentNamespace;
9
10 public enum SuiteContentNamespace implements ContentNamespace {
11 //
12 // ARGEO
13 //
14 ENTITY("entity", "http://www.argeo.org/ns/entity",
15 "platform:/plugin/org.argeo.app.api/org/argeo/app/api/entity.xsd", null),
16 //
17 ARGEO_DBK("argeodbk", "http://www.argeo.org/ns/argeodbk", null, null),
18 //
19 // EXTERNAL
20 //
21 DOCBOOK5("dbk", "http://docbook.org/ns/docbook", "docbook.xsd", "http://docbook.org/xml/5.0.1/xsd/docbook.xsd"),
22 //
23 XML_EVENTS("ev", "http://www.w3.org/2001/xml-events", "xml-events-attribs-1.xsd",
24 "http://www.w3.org/MarkUp/SCHEMA/xml-events-attribs-1.xsd"),
25 //
26 XFORMS("xforms", "http://www.w3.org/2002/xforms", "XForms-11-Schema.xsd",
27 "https://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd"),
28 //
29 XCARD("xcard", "urn:ietf:params:xml:ns:vcard-4.0", "xCard-4.0.xsd", null),
30 //
31 XSL_FO("fo", "http://www.w3.org/1999/XSL/Format", "fop.xsd",
32 "https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/fop/src/foschema/fop.xsd"),
33 //
34 // XCAL_2_0("xcal", "urn:ietf:params:xml:ns:icalendar-2.0", "xCal-2.0.xsd", null),
35 //
36 XHTML("h", "http://www.w3.org/1999/xhtml", null, "https://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd"),
37 //
38 // ODK
39 //
40 JR("jr", "http://openrosa.org/javarosa", null, null),
41 //
42 ORX("orx", "http://openrosa.org/xforms", null, null),
43 //
44 ORX_LIST("orxList", "http://openrosa.org/xforms/xformsList", null, null),
45 //
46 ORX_MANIFEST("orxManifest", "http://openrosa.org/xforms/xformsManifest", null, null),
47 //
48 ODK("odk", "http://www.opendatakit.org/xforms", null, null),
49 //
50 WGS84("geo", "http://www.w3.org/2003/01/geo/wgs84_pos#", null, null),
51 // Re-add XML in order to solve import issue with xlink
52 XML("xml", "http://www.w3.org/XML/1998/namespace", "xml.xsd", "http://www.w3.org/2001/xml.xsd"),
53 //
54
55 ;
56
57 private final static String RESOURCE_BASE = "/org/argeo/app/core/schemas/";
58
59 private String defaultPrefix;
60 private String namespace;
61 private URL resource;
62 private URL publicUrl;
63
64 SuiteContentNamespace(String defaultPrefix, String namespace, String resourceFileName, String publicUrl) {
65 Objects.requireNonNull(namespace);
66 this.defaultPrefix = defaultPrefix;
67 Objects.requireNonNull(namespace);
68 this.namespace = namespace;
69 if (resourceFileName != null) {
70 try {
71 // FIXME workaround when in nested OSGi frameworks
72 // we should use class path, as before
73 if (!resourceFileName.startsWith("platform:")) {
74 resource = URI.create("platform:/plugin/org.argeo.app.core" + RESOURCE_BASE + resourceFileName)
75 .toURL();
76 } else {
77 resource = URI.create(resourceFileName).toURL();
78 }
79 } catch (MalformedURLException e) {
80 throw new IllegalArgumentException("Cannot convert " + resourceFileName + " to URL");
81 }
82
83 Objects.requireNonNull(resource);
84 }
85 if (publicUrl != null)
86 try {
87 this.publicUrl = new URL(publicUrl);
88 } catch (MalformedURLException e) {
89 throw new IllegalArgumentException("Cannot interpret public URL", e);
90 }
91 }
92
93 @Override
94 public String getDefaultPrefix() {
95 return defaultPrefix;
96 }
97
98 @Override
99 public String getNamespaceURI() {
100 return namespace;
101 }
102
103 @Override
104 public URL getSchemaResource() {
105 return resource;
106 }
107
108 public URL getPublicUrl() {
109 return publicUrl;
110 }
111
112 }