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