DNA SVN: r904 - trunk/dna-jcr-tck.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-05-15 09:17:40 -0400 (Fri, 15 May 2009)
New Revision: 904
Modified:
trunk/dna-jcr-tck/pom.xml
Log:
DNA-408 DNA JCR TCK Tests for Nightly JCR TCK Compatibility Build Fail
Propagated IDTrust dependencies from dna-jcr POM to dna-jcr-tck POM.
Modified: trunk/dna-jcr-tck/pom.xml
===================================================================
--- trunk/dna-jcr-tck/pom.xml 2009-05-14 14:48:09 UTC (rev 903)
+++ trunk/dna-jcr-tck/pom.xml 2009-05-15 13:17:40 UTC (rev 904)
@@ -102,5 +102,40 @@
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-tests</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.code.google-collections</groupId>
+ <artifactId>google-collect</artifactId>
+ <version>snapshot-20080530</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-idtrust</artifactId>
+ <version>2.0.2.CR1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-security-spi-bare</artifactId>
+ <version>2.0.2.SP6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx-bare</artifactId>
+ <version>2.0.2.SP6</version>
+ <exclusions>
+ <exclusion>
+ <groupId>apache-xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>apache-xalan</groupId>
+ <artifactId>serializer</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
15 years, 1 month
DNA SVN: r903 - in trunk/dna-graph/src: test/java/org/jboss/dna/graph/request and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-14 10:48:09 -0400 (Thu, 14 May 2009)
New Revision: 903
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBranchRequest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/request/AbstractRequestTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/request/ReadBranchRequestTest.java
Log:
DNA-407 ReadBranchRequest.iterator() returns too many nodes
Verified the behavior with additional unit tests, and then corrected the iterator to not include children that are not actually part of the branch.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBranchRequest.java 2009-05-13 16:36:56 UTC (rev 902)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ReadBranchRequest.java 2009-05-14 14:48:09 UTC (rev 903)
@@ -337,7 +337,11 @@
Location next = queue.poll();
if (next == null) throw new NoSuchElementException();
List<Location> children = getChildren(next);
- if (children != null && children.size() > 0) queue.addAll(0, children);
+ if (children != null && children.size() > 0) {
+ // We should only add the children if they are nodes in the branch, so check the first one...
+ Location firstChild = children.get(0);
+ if (includes(firstChild)) queue.addAll(0, children);
+ }
return next;
}
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/request/AbstractRequestTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/request/AbstractRequestTest.java 2009-05-13 16:36:56 UTC (rev 902)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/request/AbstractRequestTest.java 2009-05-14 14:48:09 UTC (rev 903)
@@ -93,6 +93,10 @@
return context.getValueFactories().getNameFactory().create(name);
}
+ protected Location location( String path ) {
+ return Location.create(createPath(path));
+ }
+
protected abstract Request createRequest();
@Test
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/request/ReadBranchRequestTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/request/ReadBranchRequestTest.java 2009-05-13 16:36:56 UTC (rev 902)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/request/ReadBranchRequestTest.java 2009-05-14 14:48:09 UTC (rev 903)
@@ -27,6 +27,8 @@
import static org.hamcrest.core.IsNull.nullValue;
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
+import java.util.Iterator;
+import org.jboss.dna.graph.Location;
import org.junit.Before;
import org.junit.Test;
@@ -104,4 +106,67 @@
ReadBranchRequest request2 = new ReadBranchRequest(validPathLocation1, workspace1, 2);
assertThat(request.equals(request2), is(false));
}
+
+ @Test
+ public void shouldIterateOverNodesInBranchOfDepthOne() {
+ request = new ReadBranchRequest(location("/a"), workspace1, 1);
+ request.setActualLocationOfNode(request.at());
+ request.setChildren(location("/a"), location("/a/b"), location("/a/c"));
+ Iterator<Location> actual = request.iterator();
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a")));
+ assertThat(actual.hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldIterateOverNodesInBranchOfDepthTwo() {
+ request = new ReadBranchRequest(location("/a"), workspace1, 2);
+ request.setActualLocationOfNode(request.at());
+ request.setChildren(location("/a"), location("/a/b"), location("/a/c"), location("/a/d"));
+ request.setChildren(location("/a/b"), location("/a/b/j"), location("/a/b/k"));
+ request.setChildren(location("/a/c"), location("/a/c/j"), location("/a/c/k"));
+ request.setChildren(location("/a/d"));
+ Iterator<Location> actual = request.iterator();
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/b")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/c")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/d")));
+ assertThat(actual.hasNext(), is(false));
+ }
+
+ @Test
+ public void shouldIterateOverNodesInBranchOfDepthThree() {
+ request = new ReadBranchRequest(location("/a"), workspace1, 3);
+ request.setActualLocationOfNode(request.at());
+ request.setChildren(location("/a"), location("/a/b"), location("/a/c"), location("/a/d"));
+ request.setChildren(location("/a/b"), location("/a/b/j"), location("/a/b/k"));
+ request.setChildren(location("/a/c"), location("/a/c/j"), location("/a/c/k"));
+ request.setChildren(location("/a/c/j"), location("/a/c/j/j1"), location("/a/c/j/j2"));
+ request.setChildren(location("/a/c/k"), location("/a/c/k/k1"), location("/a/c/k/k2"));
+ request.setChildren(location("/a/b/j"), location("/a/b/j/m"), location("/a/b/j/n"));
+ request.setChildren(location("/a/b/k"));
+ request.setChildren(location("/a/d"));
+ Iterator<Location> actual = request.iterator();
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/b")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/b/j")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/b/k")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/c")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/c/j")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/c/k")));
+ assertThat(actual.hasNext(), is(true));
+ assertThat(actual.next(), is(location("/a/d")));
+ assertThat(actual.hasNext(), is(false));
+ }
}
15 years, 1 month
DNA SVN: r902 - in trunk/dna-graph/src/main: resources/org/jboss/dna/graph and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-13 12:36:56 -0400 (Wed, 13 May 2009)
New Revision: 902
Added:
trunk/dna-graph/src/main/resources/org/jboss/dna/graph/mime.types
Removed:
trunk/dna-graph/src/main/resources/org/jboss/dna/graph/MimeTypes.properties
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/ExtensionBasedMimeTypeDetector.java
Log:
DNA-402 Update MIME type based on file extensions
The previous mechanism for specifying the extensions for MIME types was a property file. This format is not the conventional way systems typically have this information formatted; usually it is a *nix-style tab-delimited file with the mime type followed by whitespace (usually tab) followed by any applicable extensions. Therefore, the property-file approach was changed to support these *nix-style files directly, though property file formats are still allowed (delimited by '=' rather than whitespace). A regular expression is used to process each line, so the code works with both file formats. Changed the name of the resource/classpath file used for the defaults from MimeTypes.properties to mime.types, and changed this file accordingly.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/ExtensionBasedMimeTypeDetector.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/ExtensionBasedMimeTypeDetector.java 2009-05-11 18:39:47 UTC (rev 901)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/ExtensionBasedMimeTypeDetector.java 2009-05-13 16:36:56 UTC (rev 902)
@@ -27,11 +27,18 @@
import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
-import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.IoUtil;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.common.util.StringUtil;
import org.jboss.dna.graph.GraphI18n;
/**
@@ -43,9 +50,10 @@
public class ExtensionBasedMimeTypeDetector implements MimeTypeDetector {
/**
- * The default location of the properties file containing the extension patterns to MIME types.
+ * The default location of the properties file containing the extension patterns to MIME types. Value is "{@value} ".
*/
- public static final String MIME_TYPE_EXTENSIONS_RESOURCE_PATH = "/org/jboss/dna/graph/MimeTypes.properties";
+ public static final String MIME_TYPE_EXTENSIONS_RESOURCE_PATH = "/org/jboss/dna/graph/mime.types";
+ // public static final String MIME_TYPE_EXTENSIONS_RESOURCE_PATH = "/org/jboss/dna/graph/MimeTypes.properties";
/**
* The mapping of extension (which includes the leading '.') to MIME type.
@@ -54,7 +62,7 @@
/**
* Create a default instance of the extension-based MIME type detector. The set of extension patterns to MIME-types is loaded
- * from "org.jboss.dna.graph.MimeTypes.properties".
+ * from the "org/jboss/dna/graph/mime.types" classpath resource.
*/
public ExtensionBasedMimeTypeDetector() {
this(null, true);
@@ -62,8 +70,8 @@
/**
* Create an instance of the extension-based MIME type detector by using the supplied mappings. The set of extension patterns
- * to MIME-types is loaded from "org.jboss.dna.graph.MimeTypes.properties", but the supplied extension mappings override any
- * default mappings.
+ * to MIME-types is loaded from the "org/jboss/dna/graph/mime.types" classpath resource, but the supplied extension mappings
+ * override any default mappings.
*
* @param extensionsToMimeTypes the mapping of extension patterns to MIME types, which will override the default mappings; may
* be null if the default mappings are to be used
@@ -74,8 +82,8 @@
/**
* Create an instance of the extension-based MIME type detector by using the supplied mappings. If requested, the set of
- * extension patterns to MIME-types is loaded from "org.jboss.dna.graph.MimeTypes.properties" and any supplied extension
- * mappings override any default mappings.
+ * extension patterns to MIME-types is loaded from the "org/jboss/dna/graph/mime.types" classpath resource and any supplied
+ * extension mappings override any default mappings.
*
* @param extensionsToMimeTypes the mapping of extension patterns to MIME types, which will override the default mappings; may
* be null if the default mappings are to be used
@@ -114,21 +122,78 @@
mimeTypesByExtension = Collections.unmodifiableMap(mappingsByAnyCharExtension);
}
+ /**
+ * Load the default extensions from {@link #MIME_TYPE_EXTENSIONS_RESOURCE_PATH}, which can either be a property file or a
+ * tab-delimited *nix-style MIME types file (common in web servers and libraries). If an extension applies to more than one
+ * MIME type, the first one in the file wins.
+ *
+ * @return the default mappings; never null
+ */
protected static Map<String, String> getDefaultMappings() {
- Properties extensionsToMimeTypes = new Properties();
+ Map<String, Set<String>> duplicates = new HashMap<String, Set<String>>();
+ return load(ExtensionBasedMimeTypeDetector.class.getResourceAsStream(MIME_TYPE_EXTENSIONS_RESOURCE_PATH), duplicates);
+ }
+
+ /**
+ * Load the default extensions from the supplied stream, which may provide the contents in the format of property file or a
+ * tab-delimited *nix-style MIME types file (common in web servers and libraries). If an extension applies to more than one
+ * MIME type, the first one in the file wins.
+ *
+ * @param stream the stream containing the content; may not be null
+ * @param duplicateMimeTypesByExtension a map into which any extension should be placed if there are multiple MIME types that
+ * apply; may be null if this information is not required
+ * @return the default mappings; never null
+ */
+ protected static Map<String, String> load( InputStream stream,
+ Map<String, Set<String>> duplicateMimeTypesByExtension ) {
+ CheckArg.isNotNull(stream, "stream");
+ // Create a Regex pattern that can be used for each line. This pattern looks for a mime type
+ // (which may contain no whitespace or '=') followed by an optional whitespace, an optional equals sign,
+ // optionally more whitespace, and finally by a string of one or more extensions.
+ Pattern linePattern = Pattern.compile("\\s*([^\\s=]+)\\s*=?\\s*(.*)");
+ List<String> lines = null;
try {
- extensionsToMimeTypes.load(ExtensionBasedMimeTypeDetector.class.getResourceAsStream(MIME_TYPE_EXTENSIONS_RESOURCE_PATH));
+ String content = IoUtil.read(stream);
+ lines = StringUtil.splitLines(content);
} catch (IOException e) {
I18n msg = GraphI18n.unableToAccessResourceFileFromClassLoader;
Logger.getLogger(ExtensionBasedMimeTypeDetector.class).warn(e, msg, MIME_TYPE_EXTENSIONS_RESOURCE_PATH);
}
Map<String, String> mimeTypesByExtension = new HashMap<String, String>();
- for (Map.Entry<Object, Object> entry : extensionsToMimeTypes.entrySet()) {
- String mimeType = entry.getKey().toString().trim();
- String extensionStrings = entry.getValue().toString().toLowerCase().trim();
- for (String extensionString : extensionStrings.split("\\s+")) {
- extensionString = extensionString.trim();
- if (extensionString.length() != 0) mimeTypesByExtension.put(extensionString, mimeType);
+ if (lines != null) {
+ for (String line : lines) {
+ line = line.trim();
+ if (line.length() == 0 || line.startsWith("#")) continue;
+ // Apply the pattern to each line ...
+ Matcher matcher = linePattern.matcher(line);
+ if (matcher.matches()) {
+ String mimeType = matcher.group(1).trim().toLowerCase();
+ String extensions = matcher.group(2).trim().toLowerCase();
+ if (extensions.length() != 0) {
+ // A valid mime type with at least one extension was found, so for each extension ...
+ for (String extensionString : extensions.split("\\s+")) {
+ extensionString = extensionString.trim();
+ if (extensionString.length() != 0) {
+ // Register the extension with the MIME type ...
+ String existingMimeType = mimeTypesByExtension.put(extensionString, mimeType);
+ if (existingMimeType != null) {
+ // A MIME type already had this extension, so use the first one ...
+ mimeTypesByExtension.put(extensionString, existingMimeType);
+ if (duplicateMimeTypesByExtension != null) {
+ // And record the duplicate ...
+ Set<String> dups = duplicateMimeTypesByExtension.get(extensionString);
+ if (dups == null) {
+ dups = new HashSet<String>();
+ duplicateMimeTypesByExtension.put(extensionString, dups);
+ }
+ dups.add(existingMimeType);
+ dups.add(mimeType);
+ }
+ }
+ }
+ }
+ }
+ }
}
}
return mimeTypesByExtension;
Deleted: trunk/dna-graph/src/main/resources/org/jboss/dna/graph/MimeTypes.properties
===================================================================
--- trunk/dna-graph/src/main/resources/org/jboss/dna/graph/MimeTypes.properties 2009-05-11 18:39:47 UTC (rev 901)
+++ trunk/dna-graph/src/main/resources/org/jboss/dna/graph/MimeTypes.properties 2009-05-13 16:36:56 UTC (rev 902)
@@ -1,168 +0,0 @@
-# This file contains the mapping of filename extensions to MIME types.
-#
-# The format is simply a line for each MIME type. If multiple extensions map to the same MIME type, simply
-# put them all on the right-hand side of the '=' and separated by spaces. For example:
-#
-# text/plain = txt
-# text/html = html htm
-#
-# If the same extension applies to multiple MIME types, then the last MIME type wins.
-#
-# MIME type = Extension
-application/andrew-inset = ez
-application/acad = dwg
-application/arj = arj
-application/astound = asd asn
-application/clariscad = ccad
-application/drafting = drw
-application/dxf = dxf
-application/fractals = fif
-application/finale = mus etf fxt ftm
-application/i-deas = unv
-application/iges = iges, igs
-application/java-archive = jar
-application/json = json
-application/mac-binhex40 = hqx
-application/mac-compactpro = cpt
-application/octet-stream = bin dms lha lzh exe class w02 w03 w04 cab jar dzl
-application/oda = oda
-application/pdf = pdf
-application/postscript = ai eps ps
-application/rtf = rtf
-application/smil = smi smil
-application/pro_eng = part prt
-application/set = set
-application/sla = stl
-application/solids = sol
-application/STEP = st step stp
-application/vda = vda
-application/vnd.mif = mif
-application/vnd.mozilla.xul+xml = xul
-application/vnd.ms-excel = xls csv
-application/vnd.ms-powerpoint = ppt ppz pps pot
-application/vnd.ms-powerpoint.template = potm potx
-application/vnd.ms-access = mdb
-application/vnd.oasis.opendocument.text = odt
-application/vnd.oasis.opendocument.formula = odf
-application/vnd.oasis.opendocument.chart = odc
-application/vnd.oasis.opendocument.graphics = odg
-application/vnd.oasis.opendocument.presentation = odp
-application/vnd.oasis.opendocument.spreadsheet = ods
-application/vnd.oasis.opendocument.presentation-template = otp
-application/vnd.oasis.opendocument.formula-template = ott
-application/vnd.openxmlformats = docx docm dotm xslm xslx
-application/vnd.stardivision.impress = sdd
-application/vnd.stardivision.math = smf
-application/vnd.wap.wbxml = wbxml
-application/vnd.wap.wmlc = wmlc
-application/vnd.wap.wmlscriptc = wmlsc
-application/x-bcpio = bcpio
-application/x-cpio = cpio
-application/x-cdlink = vcd
-application/x-chess-pgn = pgn
-application/x-compress = Z
-application/x-cpio = cpio
-application/x-csh = csh
-application/x-director = dcr dir dxr
-application/x-dvi = dvi
-application/x-dwf = dwf
-application/x-futuresplash = spl
-application/x-gtar = gtar
-application/x-gzip = gz
-application/x-hdf = hdf
-application/x-javascript = js mocha
-application/x-koan = skp skd skt skm
-application/x-latex = latex
-application/x-midi = mid
-application/x-mif = mif
-# various Micro$oft extensions
-application/x-ms-wmz = wmz
-application/x-ms-wmd = wmd
-#
-application/x-netcdf = nc cdf
-application/x-sdp = sdp
-application/x-sh = sh
-application/x-shar = shar
-application/x-shockwave-flash = swf
-application/x-stuffit = sit
-application/x-sv4cpio = sv4cpio
-application/x-sv4crc = sv4crc
-application/x-tar = tar
-application/x-tcl = tcl
-application/x-tex = tex
-application/x-texinfo = texinfo texi
-application/x-troff = t tr roff
-application/x-troff-man = man
-application/x-troff-me = me
-application/x-troff-ms = ms
-application/x-ustar = ustar
-application/x-wais-source = src
-application/x-winhelp = hlp
-application/x400-bp
-# XML support
-application/xml = xml dtd xsl ent cat sty
-application/zip = zip
-
-audio/basic = au snd
-audio/midi = mid midi kar
-audio/mpeg = mpga mp2 mp3
-audio/x-aiff = aif aiff aifc
-# various Micro$oft extensions
-audio/x-ms-wma = wma
-audio/x-ms-wax = wax
-audio/x-pn-realaudio = ram rm
-audio/x-pn-realaudio-plugin = rpm
-audio/x-realaudio = ra
-audio/x-voice = voc
-audio/x-wav = wav
-chemical/x-pdb = pdb
-chemical/x-xyz = xyz
-
-image/bmp = bmp
-image/gif = gif
-image/ief = ief
-image/jpeg = jpeg jpg jpe
-image/pict = pict
-image/png = png
-image/tiff = tiff tif
-image/vnd.wap.wbmp = wbmp
-image/x-cmu-raster = ras
-image/x-freehand = fh4 fh7 fh5 fhc fh
-image/x-portable-anymap = pnm
-image/x-portable-bitmap = pbm
-image/x-portable-graymap = pgm
-image/x-portable-pixmap = ppm
-image/x-rgb = rgb
-image/x-xbitmap = xbm
-image/x-xpixmap = xpm
-image/x-xwindowdump = xwd
-model/iges = igs iges
-model/mesh = msh mesh silo
-model/vrml = wrl vrml
-
-text/css = css
-text/html = html htm docmhtml
-text/plain = asc txt
-text/richtext = rtx
-text/rtf = rtf
-text/sgml = sgml sgm
-text/tab-separated-values = tsv
-text/vnd.wap.wml = wml
-text/vnd.wap.wmlscript = wmls
-text/x-setext = etx
-text/xml = xml
-video/mpeg = mpeg mpg mpe
-# various Micro$oft extensions
-video/x-ms-asf = asf asx
-video/x-ms-wm = wm
-video/x-ms-wmv = wmv
-video/x-ms-wmx = wmx
-video/x-ms-wvx = wvx
-video/quicktime = qt mov
-video/x-msvideo = avi
-video/x-sgi-movie = movie
-x-conference/x-cooltalk = ice
-# not sure if these are necessary
-x-world/x-3dmf = 3dmf 3dm qd3d qd3
-x-world/x-vrml = wrl vrml
-
Added: trunk/dna-graph/src/main/resources/org/jboss/dna/graph/mime.types
===================================================================
--- trunk/dna-graph/src/main/resources/org/jboss/dna/graph/mime.types (rev 0)
+++ trunk/dna-graph/src/main/resources/org/jboss/dna/graph/mime.types 2009-05-13 16:36:56 UTC (rev 902)
@@ -0,0 +1,1226 @@
+# This file defines the Internet media types and extensions.
+# For more information about Internet media types,
+# please read RFC 2045, 2046, 2047, 2048, and 2077. The Internet media type
+# registry is at <http://www.iana.org/assignments/media-types/>.
+
+# MIME type Extensions
+application/activemessage
+application/andrew-inset ez
+application/applefile
+application/applixware aw
+application/atom+xml atom
+application/atomcat+xml atomcat
+application/atomicmail
+application/atomsvc+xml atomsvc
+application/auth-policy+xml
+application/batch-smtp
+application/beep+xml
+application/cals-1840
+application/ccxml+xml ccxml
+application/cea-2018+xml
+application/cellml+xml
+application/cnrp+xml
+application/commonground
+application/conference-info+xml
+application/cpl+xml
+application/csta+xml
+application/cstadata+xml
+application/cu-seeme cu
+application/cybercash
+application/davmount+xml davmount
+application/dca-rft
+application/dec-dx
+application/dialog-info+xml
+application/dicom
+application/dns
+application/dvcs
+application/ecmascript ecma
+application/edi-consent
+application/edi-x12
+application/edifact
+application/emma+xml emma
+application/epp+xml
+application/epub+zip epub
+application/eshop
+application/example
+application/fastinfoset
+application/fastsoap
+application/fits
+application/font-tdpfr pfr
+application/h224
+application/http
+application/hyperstudio stk
+application/ibe-key-request+xml
+application/ibe-pkg-reply+xml
+application/ibe-pp-data
+application/iges
+application/im-iscomposing+xml
+application/index
+application/index.cmd
+application/index.obj
+application/index.response
+application/index.vnd
+application/iotp
+application/ipp
+application/isup
+application/java-archive jar
+application/java-serialized-object ser
+application/java-vm class
+application/javascript js
+application/json json
+application/kpml-request+xml
+application/kpml-response+xml
+application/lost+xml lostxml
+application/mac-binhex40 hqx
+application/mac-compactpro cpt
+application/macwriteii
+application/marc mrc
+application/mathematica ma nb mb
+application/mathml+xml mathml
+application/mbms-associated-procedure-description+xml
+application/mbms-deregister+xml
+application/mbms-envelope+xml
+application/mbms-msk+xml
+application/mbms-msk-response+xml
+application/mbms-protection-description+xml
+application/mbms-reception-report+xml
+application/mbms-register+xml
+application/mbms-register-response+xml
+application/mbms-user-service-description+xml
+application/mbox mbox
+application/media_control+xml
+application/mediaservercontrol+xml mscml
+application/mikey
+application/moss-keys
+application/moss-signature
+application/mosskey-data
+application/mosskey-request
+application/mp4 mp4s
+application/mpeg4-generic
+application/mpeg4-iod
+application/mpeg4-iod-xmt
+application/msword doc dot
+application/mxf mxf
+application/nasdata
+application/news-checkgroups
+application/news-groupinfo
+application/news-transmission
+application/nss
+application/ocsp-request
+application/ocsp-response
+application/octet-stream bin dms lha lrf lzh so iso dmg dist distz pkg bpk dump elc
+application/oda oda
+application/oebps-package+xml opf
+application/ogg ogx
+application/onenote onetoc onetoc2 onetmp onepkg
+application/parityfec
+application/patch-ops-error+xml xer
+application/pdf pdf
+application/pgp-encrypted pgp
+application/pgp-keys
+application/pgp-signature asc sig
+application/pics-rules prf
+application/pidf+xml
+application/pidf-diff+xml
+application/pkcs10 p10
+application/pkcs7-mime p7m p7c
+application/pkcs7-signature p7s
+application/pkix-cert cer
+application/pkix-crl crl
+application/pkix-pkipath pkipath
+application/pkixcmp pki
+application/pls+xml pls
+application/poc-settings+xml
+application/postscript ai eps ps
+application/prs.alvestrand.titrax-sheet
+application/prs.cww cww
+application/prs.nprend
+application/prs.plucker
+application/qsig
+application/rdf+xml rdf
+application/reginfo+xml rif
+application/relax-ng-compact-syntax rnc
+application/remote-printing
+application/resource-lists+xml rl
+application/resource-lists-diff+xml rld
+application/riscos
+application/rlmi+xml
+application/rls-services+xml rs
+application/rsd+xml rsd
+application/rss+xml rss
+application/rtf rtf
+application/rtx
+application/samlassertion+xml
+application/samlmetadata+xml
+application/sbml+xml sbml
+application/scvp-cv-request scq
+application/scvp-cv-response scs
+application/scvp-vp-request spq
+application/scvp-vp-response spp
+application/sdp sdp
+application/set-payment
+application/set-payment-initiation setpay
+application/set-registration
+application/set-registration-initiation setreg
+application/sgml
+application/sgml-open-catalog
+application/shf+xml shf
+application/sieve
+application/simple-filter+xml
+application/simple-message-summary
+application/simplesymbolcontainer
+application/slate
+application/smil
+application/smil+xml smi smil
+application/soap+fastinfoset
+application/soap+xml
+application/sparql-query rq
+application/sparql-results+xml srx
+application/spirits-event+xml
+application/srgs gram
+application/srgs+xml grxml
+application/ssml+xml ssml
+application/timestamp-query
+application/timestamp-reply
+application/tve-trigger
+application/ulpfec
+application/vemmi
+application/vividence.scriptfile
+application/vnd.3gpp.bsf+xml
+application/vnd.3gpp.pic-bw-large plb
+application/vnd.3gpp.pic-bw-small psb
+application/vnd.3gpp.pic-bw-var pvb
+application/vnd.3gpp.sms
+application/vnd.3gpp2.bcmcsinfo+xml
+application/vnd.3gpp2.sms
+application/vnd.3gpp2.tcap tcap
+application/vnd.3m.post-it-notes pwn
+application/vnd.accpac.simply.aso aso
+application/vnd.accpac.simply.imp imp
+application/vnd.acucobol acu
+application/vnd.acucorp atc acutc
+application/vnd.adobe.air-application-installer-package+zip air
+application/vnd.adobe.xdp+xml xdp
+application/vnd.adobe.xfdf xfdf
+application/vnd.aether.imp
+application/vnd.airzip.filesecure.azf azf
+application/vnd.airzip.filesecure.azs azs
+application/vnd.amazon.ebook azw
+application/vnd.americandynamics.acc acc
+application/vnd.amiga.ami ami
+application/vnd.android.package-archive apk
+application/vnd.anser-web-certificate-issue-initiation cii
+application/vnd.anser-web-funds-transfer-initiation fti
+application/vnd.antix.game-component atx
+application/vnd.apple.installer+xml mpkg
+application/vnd.arastra.swi swi
+application/vnd.audiograph aep
+application/vnd.autopackage
+application/vnd.avistar+xml
+application/vnd.blueice.multipass mpm
+application/vnd.bluetooth.ep.oob
+application/vnd.bmi bmi
+application/vnd.businessobjects rep
+application/vnd.cab-jscript
+application/vnd.canon-cpdl
+application/vnd.canon-lips
+application/vnd.cendio.thinlinc.clientconf
+application/vnd.chemdraw+xml cdxml
+application/vnd.chipnuts.karaoke-mmd mmd
+application/vnd.cinderella cdy
+application/vnd.cirpack.isdn-ext
+application/vnd.claymore cla
+application/vnd.clonk.c4group c4g c4d c4f c4p c4u
+application/vnd.commerce-battelle
+application/vnd.commonspace csp cst
+application/vnd.contact.cmsg cdbcmsg
+application/vnd.cosmocaller cmc
+application/vnd.crick.clicker clkx
+application/vnd.crick.clicker.keyboard clkk
+application/vnd.crick.clicker.palette clkp
+application/vnd.crick.clicker.template clkt
+application/vnd.crick.clicker.wordbank clkw
+application/vnd.criticaltools.wbs+xml wbs
+application/vnd.ctc-posml pml
+application/vnd.ctct.ws+xml
+application/vnd.cups-pdf
+application/vnd.cups-postscript
+application/vnd.cups-ppd ppd
+application/vnd.cups-raster
+application/vnd.cups-raw
+application/vnd.curl.car car
+application/vnd.curl.pcurl pcurl
+application/vnd.cybank
+application/vnd.data-vision.rdz rdz
+application/vnd.denovo.fcselayout-link fe_launch
+application/vnd.dir-bi.plate-dl-nosuffix
+application/vnd.dna dna
+application/vnd.dolby.mlp mlp
+application/vnd.dolby.mobile.1
+application/vnd.dolby.mobile.2
+application/vnd.dpgraph dpg
+application/vnd.dreamfactory dfac
+application/vnd.dvb.esgcontainer
+application/vnd.dvb.ipdcdftnotifaccess
+application/vnd.dvb.ipdcesgaccess
+application/vnd.dvb.ipdcroaming
+application/vnd.dvb.iptv.alfec-base
+application/vnd.dvb.iptv.alfec-enhancement
+application/vnd.dvb.notif-aggregate-root+xml
+application/vnd.dvb.notif-container+xml
+application/vnd.dvb.notif-generic+xml
+application/vnd.dvb.notif-ia-msglist+xml
+application/vnd.dvb.notif-ia-registration-request+xml
+application/vnd.dvb.notif-ia-registration-response+xml
+application/vnd.dvb.notif-init+xml
+application/vnd.dxr
+application/vnd.dynageo geo
+application/vnd.ecdis-update
+application/vnd.ecowin.chart mag
+application/vnd.ecowin.filerequest
+application/vnd.ecowin.fileupdate
+application/vnd.ecowin.series
+application/vnd.ecowin.seriesrequest
+application/vnd.ecowin.seriesupdate
+application/vnd.emclient.accessrequest+xml
+application/vnd.enliven nml
+application/vnd.epson.esf esf
+application/vnd.epson.msf msf
+application/vnd.epson.quickanime qam
+application/vnd.epson.salt slt
+application/vnd.epson.ssf ssf
+application/vnd.ericsson.quickcall
+application/vnd.eszigno3+xml es3 et3
+application/vnd.etsi.aoc+xml
+application/vnd.etsi.cug+xml
+application/vnd.etsi.iptvcommand+xml
+application/vnd.etsi.iptvdiscovery+xml
+application/vnd.etsi.iptvprofile+xml
+application/vnd.etsi.iptvsad-bc+xml
+application/vnd.etsi.iptvsad-cod+xml
+application/vnd.etsi.iptvsad-npvr+xml
+application/vnd.etsi.iptvueprofile+xml
+application/vnd.etsi.mcid+xml
+application/vnd.etsi.sci+xml
+application/vnd.etsi.simservs+xml
+application/vnd.eudora.data
+application/vnd.ezpix-album ez2
+application/vnd.ezpix-package ez3
+application/vnd.f-secure.mobile
+application/vnd.fdf fdf
+application/vnd.fdsn.mseed mseed
+application/vnd.fdsn.seed seed dataless
+application/vnd.ffsns
+application/vnd.fints
+application/vnd.flographit gph
+application/vnd.fluxtime.clip ftc
+application/vnd.font-fontforge-sfd
+application/vnd.framemaker fm frame maker book
+application/vnd.frogans.fnc fnc
+application/vnd.frogans.ltf ltf
+application/vnd.fsc.weblaunch fsc
+application/vnd.fujitsu.oasys oas
+application/vnd.fujitsu.oasys2 oa2
+application/vnd.fujitsu.oasys3 oa3
+application/vnd.fujitsu.oasysgp fg5
+application/vnd.fujitsu.oasysprs bh2
+application/vnd.fujixerox.art-ex
+application/vnd.fujixerox.art4
+application/vnd.fujixerox.hbpl
+application/vnd.fujixerox.ddd ddd
+application/vnd.fujixerox.docuworks xdw
+application/vnd.fujixerox.docuworks.binder xbd
+application/vnd.fut-misnet
+application/vnd.fuzzysheet fzs
+application/vnd.genomatix.tuxedo txd
+application/vnd.geogebra.file ggb
+application/vnd.geogebra.tool ggt
+application/vnd.geometry-explorer gex gre
+application/vnd.gmx gmx
+application/vnd.google-earth.kml+xml kml
+application/vnd.google-earth.kmz kmz
+application/vnd.grafeq gqf gqs
+application/vnd.gridmp
+application/vnd.groove-account gac
+application/vnd.groove-help ghf
+application/vnd.groove-identity-message gim
+application/vnd.groove-injector grv
+application/vnd.groove-tool-message gtm
+application/vnd.groove-tool-template tpl
+application/vnd.groove-vcard vcg
+application/vnd.handheld-entertainment+xml zmm
+application/vnd.hbci hbci
+application/vnd.hcl-bireports
+application/vnd.hhe.lesson-player les
+application/vnd.hp-hpgl hpgl
+application/vnd.hp-hpid hpid
+application/vnd.hp-hps hps
+application/vnd.hp-jlyt jlt
+application/vnd.hp-pcl pcl
+application/vnd.hp-pclxl pclxl
+application/vnd.httphone
+application/vnd.hydrostatix.sof-data sfd-hdstx
+application/vnd.hzn-3d-crossword x3d
+application/vnd.ibm.afplinedata
+application/vnd.ibm.electronic-media
+application/vnd.ibm.minipay mpy
+application/vnd.ibm.modcap afp listafp list3820
+application/vnd.ibm.rights-management irm
+application/vnd.ibm.secure-container sc
+application/vnd.iccprofile icc icm
+application/vnd.igloader igl
+application/vnd.immervision-ivp ivp
+application/vnd.immervision-ivu ivu
+application/vnd.informedcontrol.rms+xml
+application/vnd.informix-visionary
+application/vnd.intercon.formnet xpw xpx
+application/vnd.intertrust.digibox
+application/vnd.intertrust.nncp
+application/vnd.intu.qbo qbo
+application/vnd.intu.qfx qfx
+application/vnd.iptc.g2.conceptitem+xml
+application/vnd.iptc.g2.knowledgeitem+xml
+application/vnd.iptc.g2.newsitem+xml
+application/vnd.iptc.g2.packageitem+xml
+application/vnd.ipunplugged.rcprofile rcprofile
+application/vnd.irepository.package+xml irp
+application/vnd.is-xpr xpr
+application/vnd.jam jam
+application/vnd.japannet-directory-service
+application/vnd.japannet-jpnstore-wakeup
+application/vnd.japannet-payment-wakeup
+application/vnd.japannet-registration
+application/vnd.japannet-registration-wakeup
+application/vnd.japannet-setstore-wakeup
+application/vnd.japannet-verification
+application/vnd.japannet-verification-wakeup
+application/vnd.jcp.javame.midlet-rms rms
+application/vnd.jisp jisp
+application/vnd.joost.joda-archive joda
+application/vnd.kahootz ktz ktr
+application/vnd.kde.karbon karbon
+application/vnd.kde.kchart chrt
+application/vnd.kde.kformula kfo
+application/vnd.kde.kivio flw
+application/vnd.kde.kontour kon
+application/vnd.kde.kpresenter kpr kpt
+application/vnd.kde.kspread ksp
+application/vnd.kde.kword kwd kwt
+application/vnd.kenameaapp htke
+application/vnd.kidspiration kia
+application/vnd.kinar kne knp
+application/vnd.koan skp skd skt skm
+application/vnd.kodak-descriptor sse
+application/vnd.liberty-request+xml
+application/vnd.llamagraphics.life-balance.desktop lbd
+application/vnd.llamagraphics.life-balance.exchange+xml lbe
+application/vnd.lotus-1-2-3 123
+application/vnd.lotus-approach apr
+application/vnd.lotus-freelance pre
+application/vnd.lotus-notes nsf
+application/vnd.lotus-organizer org
+application/vnd.lotus-screencam scm
+application/vnd.lotus-wordpro lwp
+application/vnd.macports.portpkg portpkg
+application/vnd.marlin.drm.actiontoken+xml
+application/vnd.marlin.drm.conftoken+xml
+application/vnd.marlin.drm.license+xml
+application/vnd.marlin.drm.mdcf
+application/vnd.mcd mcd
+application/vnd.medcalcdata mc1
+application/vnd.mediastation.cdkey cdkey
+application/vnd.meridian-slingshot
+application/vnd.mfer mwf
+application/vnd.mfmp mfm
+application/vnd.micrografx.flo flo
+application/vnd.micrografx.igx igx
+application/vnd.mif mif
+application/vnd.minisoft-hp3000-save
+application/vnd.mitsubishi.misty-guard.trustweb
+application/vnd.mobius.daf daf
+application/vnd.mobius.dis dis
+application/vnd.mobius.mbk mbk
+application/vnd.mobius.mqy mqy
+application/vnd.mobius.msl msl
+application/vnd.mobius.plc plc
+application/vnd.mobius.txf txf
+application/vnd.mophun.application mpn
+application/vnd.mophun.certificate mpc
+application/vnd.motorola.flexsuite
+application/vnd.motorola.flexsuite.adsi
+application/vnd.motorola.flexsuite.fis
+application/vnd.motorola.flexsuite.gotap
+application/vnd.motorola.flexsuite.kmr
+application/vnd.motorola.flexsuite.ttc
+application/vnd.motorola.flexsuite.wem
+application/vnd.motorola.iprm
+application/vnd.mozilla.xul+xml xul
+application/vnd.ms-artgalry cil
+application/vnd.ms-asf asf
+application/vnd.ms-cab-compressed cab
+application/vnd.ms-excel xls xlm xla xlc xlt xlw
+application/vnd.ms-excel.addin.macroenabled.12 xlam
+application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb
+application/vnd.ms-excel.sheet.macroenabled.12 xlsm
+application/vnd.ms-excel.template.macroenabled.12 xltm
+application/vnd.ms-fontobject eot
+application/vnd.ms-htmlhelp chm
+application/vnd.ms-ims ims
+application/vnd.ms-lrm lrm
+application/vnd.ms-pki.seccat cat
+application/vnd.ms-pki.stl stl
+application/vnd.ms-playready.initiator+xml
+application/vnd.ms-powerpoint ppt pps pot
+application/vnd.ms-powerpoint.addin.macroenabled.12 ppam
+application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm
+application/vnd.ms-powerpoint.slide.macroenabled.12 sldm
+application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm
+application/vnd.ms-powerpoint.template.macroenabled.12 potm
+application/vnd.ms-project mpp mpt
+application/vnd.ms-tnef
+application/vnd.ms-wmdrm.lic-chlg-req
+application/vnd.ms-wmdrm.lic-resp
+application/vnd.ms-wmdrm.meter-chlg-req
+application/vnd.ms-wmdrm.meter-resp
+application/vnd.ms-word.document.macroenabled.12 docm
+application/vnd.ms-word.template.macroenabled.12 dotm
+application/vnd.ms-works wps wks wcm wdb
+application/vnd.ms-wpl wpl
+application/vnd.ms-xpsdocument xps
+application/vnd.mseq mseq
+application/vnd.msign
+application/vnd.multiad.creator
+application/vnd.multiad.creator.cif
+application/vnd.music-niff
+application/vnd.musician mus
+application/vnd.muvee.style msty
+application/vnd.ncd.control
+application/vnd.ncd.reference
+application/vnd.nervana
+application/vnd.netfpx
+application/vnd.neurolanguage.nlu nlu
+application/vnd.noblenet-directory nnd
+application/vnd.noblenet-sealer nns
+application/vnd.noblenet-web nnw
+application/vnd.nokia.catalogs
+application/vnd.nokia.conml+wbxml
+application/vnd.nokia.conml+xml
+application/vnd.nokia.isds-radio-presets
+application/vnd.nokia.iptv.config+xml
+application/vnd.nokia.landmark+wbxml
+application/vnd.nokia.landmark+xml
+application/vnd.nokia.landmarkcollection+xml
+application/vnd.nokia.n-gage.ac+xml
+application/vnd.nokia.n-gage.data ngdat
+application/vnd.nokia.n-gage.symbian.install n-gage
+application/vnd.nokia.ncd
+application/vnd.nokia.pcd+wbxml
+application/vnd.nokia.pcd+xml
+application/vnd.nokia.radio-preset rpst
+application/vnd.nokia.radio-presets rpss
+application/vnd.novadigm.edm edm
+application/vnd.novadigm.edx edx
+application/vnd.novadigm.ext ext
+application/vnd.oasis.opendocument.chart odc
+application/vnd.oasis.opendocument.chart-template otc
+application/vnd.oasis.opendocument.database odb
+application/vnd.oasis.opendocument.formula odf
+application/vnd.oasis.opendocument.formula-template odft
+application/vnd.oasis.opendocument.graphics odg
+application/vnd.oasis.opendocument.graphics-template otg
+application/vnd.oasis.opendocument.image odi
+application/vnd.oasis.opendocument.image-template oti
+application/vnd.oasis.opendocument.presentation odp
+application/vnd.oasis.opendocument.presentation-template otp
+application/vnd.oasis.opendocument.spreadsheet ods
+application/vnd.oasis.opendocument.spreadsheet-template ots
+application/vnd.oasis.opendocument.text odt
+application/vnd.oasis.opendocument.text-master otm
+application/vnd.oasis.opendocument.text-template ott
+application/vnd.oasis.opendocument.text-web oth
+application/vnd.obn
+application/vnd.olpc-sugar xo
+application/vnd.oma-scws-config
+application/vnd.oma-scws-http-request
+application/vnd.oma-scws-http-response
+application/vnd.oma.bcast.associated-procedure-parameter+xml
+application/vnd.oma.bcast.drm-trigger+xml
+application/vnd.oma.bcast.imd+xml
+application/vnd.oma.bcast.ltkm
+application/vnd.oma.bcast.notification+xml
+application/vnd.oma.bcast.provisioningtrigger
+application/vnd.oma.bcast.sgboot
+application/vnd.oma.bcast.sgdd+xml
+application/vnd.oma.bcast.sgdu
+application/vnd.oma.bcast.simple-symbol-container
+application/vnd.oma.bcast.smartcard-trigger+xml
+application/vnd.oma.bcast.sprov+xml
+application/vnd.oma.bcast.stkm
+application/vnd.oma.dcd
+application/vnd.oma.dcdc
+application/vnd.oma.dd2+xml dd2
+application/vnd.oma.drm.risd+xml
+application/vnd.oma.group-usage-list+xml
+application/vnd.oma.poc.detailed-progress-report+xml
+application/vnd.oma.poc.final-report+xml
+application/vnd.oma.poc.groups+xml
+application/vnd.oma.poc.invocation-descriptor+xml
+application/vnd.oma.poc.optimized-progress-report+xml
+application/vnd.oma.xcap-directory+xml
+application/vnd.omads-email+xml
+application/vnd.omads-file+xml
+application/vnd.omads-folder+xml
+application/vnd.omaloc-supl-init
+application/vnd.openofficeorg.extension oxt
+application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
+application/vnd.openxmlformats-officedocument.presentationml.slide sldx
+application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
+application/vnd.openxmlformats-officedocument.presentationml.template potx
+application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
+application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
+application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
+application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
+application/vnd.osa.netdeploy
+application/vnd.osgi.bundle
+application/vnd.osgi.dp dp
+application/vnd.otps.ct-kip+xml
+application/vnd.palm pdb pqa oprc
+application/vnd.paos.xml
+application/vnd.pg.format str
+application/vnd.pg.osasli ei6
+application/vnd.piaccess.application-licence
+application/vnd.picsel efif
+application/vnd.poc.group-advertisement+xml
+application/vnd.pocketlearn plf
+application/vnd.powerbuilder6 pbd
+application/vnd.powerbuilder6-s
+application/vnd.powerbuilder7
+application/vnd.powerbuilder7-s
+application/vnd.powerbuilder75
+application/vnd.powerbuilder75-s
+application/vnd.preminet
+application/vnd.previewsystems.box box
+application/vnd.proteus.magazine mgz
+application/vnd.publishare-delta-tree qps
+application/vnd.pvi.ptid1 ptid
+application/vnd.pwg-multiplexed
+application/vnd.pwg-xhtml-print+xml
+application/vnd.qualcomm.brew-app-res
+application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb
+application/vnd.rapid
+application/vnd.recordare.musicxml mxl
+application/vnd.recordare.musicxml+xml musicxml
+application/vnd.renlearn.rlprint
+application/vnd.rim.cod cod
+application/vnd.rn-realmedia rm
+application/vnd.route66.link66+xml link66
+application/vnd.ruckus.download
+application/vnd.s3sms
+application/vnd.sbm.cid
+application/vnd.sbm.mid2
+application/vnd.scribus
+application/vnd.sealed.3df
+application/vnd.sealed.csf
+application/vnd.sealed.doc
+application/vnd.sealed.eml
+application/vnd.sealed.mht
+application/vnd.sealed.net
+application/vnd.sealed.ppt
+application/vnd.sealed.tiff
+application/vnd.sealed.xls
+application/vnd.sealedmedia.softseal.html
+application/vnd.sealedmedia.softseal.pdf
+application/vnd.seemail see
+application/vnd.sema sema
+application/vnd.semd semd
+application/vnd.semf semf
+application/vnd.shana.informed.formdata ifm
+application/vnd.shana.informed.formtemplate itp
+application/vnd.shana.informed.interchange iif
+application/vnd.shana.informed.package ipk
+application/vnd.simtech-mindmapper twd twds
+application/vnd.smaf mmf
+application/vnd.smart.teacher teacher
+application/vnd.software602.filler.form+xml
+application/vnd.software602.filler.form-xml-zip
+application/vnd.solent.sdkm+xml sdkm sdkd
+application/vnd.spotfire.dxp dxp
+application/vnd.spotfire.sfs sfs
+application/vnd.sss-cod
+application/vnd.sss-dtf
+application/vnd.sss-ntf
+application/vnd.stardivision.calc sdc
+application/vnd.stardivision.draw sda
+application/vnd.stardivision.impress sdd
+application/vnd.stardivision.math smf
+application/vnd.stardivision.writer sdw
+application/vnd.stardivision.writer vor
+application/vnd.stardivision.writer-global sgl
+application/vnd.street-stream
+application/vnd.sun.xml.calc sxc
+application/vnd.sun.xml.calc.template stc
+application/vnd.sun.xml.draw sxd
+application/vnd.sun.xml.draw.template std
+application/vnd.sun.xml.impress sxi
+application/vnd.sun.xml.impress.template sti
+application/vnd.sun.xml.math sxm
+application/vnd.sun.xml.writer sxw
+application/vnd.sun.xml.writer.global sxg
+application/vnd.sun.xml.writer.template stw
+application/vnd.sun.wadl+xml
+application/vnd.sus-calendar sus susp
+application/vnd.svd svd
+application/vnd.swiftview-ics
+application/vnd.symbian.install sis sisx
+application/vnd.syncml+xml xsm
+application/vnd.syncml.dm+wbxml bdm
+application/vnd.syncml.dm+xml xdm
+application/vnd.syncml.dm.notification
+application/vnd.syncml.ds.notification
+application/vnd.tao.intent-module-archive tao
+application/vnd.tmobile-livetv tmo
+application/vnd.trid.tpt tpt
+application/vnd.triscape.mxs mxs
+application/vnd.trueapp tra
+application/vnd.truedoc
+application/vnd.ufdl ufd ufdl
+application/vnd.uiq.theme utz
+application/vnd.umajin umj
+application/vnd.unity unityweb
+application/vnd.uoml+xml uoml
+application/vnd.uplanet.alert
+application/vnd.uplanet.alert-wbxml
+application/vnd.uplanet.bearer-choice
+application/vnd.uplanet.bearer-choice-wbxml
+application/vnd.uplanet.cacheop
+application/vnd.uplanet.cacheop-wbxml
+application/vnd.uplanet.channel
+application/vnd.uplanet.channel-wbxml
+application/vnd.uplanet.list
+application/vnd.uplanet.list-wbxml
+application/vnd.uplanet.listcmd
+application/vnd.uplanet.listcmd-wbxml
+application/vnd.uplanet.signal
+application/vnd.vcx vcx
+application/vnd.vd-study
+application/vnd.vectorworks
+application/vnd.vidsoft.vidconference
+application/vnd.visio vsd vst vss vsw
+application/vnd.visionary vis
+application/vnd.vividence.scriptfile
+application/vnd.vsf vsf
+application/vnd.wap.sic
+application/vnd.wap.slc
+application/vnd.wap.wbxml wbxml
+application/vnd.wap.wmlc wmlc
+application/vnd.wap.wmlscriptc wmlsc
+application/vnd.webturbo wtb
+application/vnd.wfa.wsc
+application/vnd.wmc
+application/vnd.wmf.bootstrap
+application/vnd.wordperfect wpd
+application/vnd.wqd wqd
+application/vnd.wrq-hp3000-labelled
+application/vnd.wt.stf stf
+application/vnd.wv.csp+wbxml
+application/vnd.wv.csp+xml
+application/vnd.wv.ssp+xml
+application/vnd.xara xar
+application/vnd.xfdl xfdl
+application/vnd.xfdl.webform
+application/vnd.xmi+xml
+application/vnd.xmpie.cpkg
+application/vnd.xmpie.dpkg
+application/vnd.xmpie.plan
+application/vnd.xmpie.ppkg
+application/vnd.xmpie.xlim
+application/vnd.yamaha.hv-dic hvd
+application/vnd.yamaha.hv-script hvs
+application/vnd.yamaha.hv-voice hvp
+application/vnd.yamaha.openscoreformat osf
+application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg
+application/vnd.yamaha.smaf-audio saf
+application/vnd.yamaha.smaf-phrase spf
+application/vnd.yellowriver-custom-menu cmp
+application/vnd.zul zir zirz
+application/vnd.zzazz.deck+xml zaz
+application/voicexml+xml vxml
+application/watcherinfo+xml
+application/whoispp-query
+application/whoispp-response
+application/winhlp hlp
+application/wita
+application/wordperfect5.1
+application/wsdl+xml wsdl
+application/wspolicy+xml wspolicy
+application/x-abiword abw
+application/x-ace-compressed ace
+application/x-authorware-bin aab x32 u32 vox
+application/x-authorware-map aam
+application/x-authorware-seg aas
+application/x-bcpio bcpio
+application/x-bittorrent torrent
+application/x-bzip bz
+application/x-bzip2 bz2 boz
+application/x-cdlink vcd
+application/x-chat chat
+application/x-chess-pgn pgn
+application/x-compress Z
+application/x-cpio cpio
+application/x-csh csh
+application/x-debian-package deb udeb
+application/x-director dir dcr dxr cst cct cxt w3d fgd swa
+application/x-doom wad
+application/x-dtbncx+xml ncx
+application/x-dtbook+xml dtb
+application/x-dtbresource+xml res
+application/x-dvi dvi
+application/x-font-bdf bdf
+application/x-font-dos
+application/x-font-framemaker
+application/x-font-ghostscript gsf
+application/x-font-libgrx
+application/x-font-linux-psf psf
+application/x-font-otf otf
+application/x-font-pcf pcf
+application/x-font-snf snf
+application/x-font-speedo
+application/x-font-sunos-news
+application/x-font-ttf ttf ttc
+application/x-font-type1 pfa pfb pfm afm
+application/x-font-vfont
+application/x-futuresplash spl
+application/x-gnumeric gnumeric
+application/x-gtar gtar
+application/x-gzip
+application/x-hdf hdf
+application/x-java-jnlp-file jnlp
+application/x-latex latex
+application/x-mobipocket-ebook prc mobi
+application/x-ms-wmd wmd
+application/x-ms-wmz wmz
+application/x-msaccess mdb
+application/x-msbinder obd
+application/x-mscardfile crd
+application/x-msclip clp
+application/x-msdownload exe dll com bat msi
+application/x-msmediaview mvb m13 m14
+application/x-msmetafile wmf
+application/x-msmoney mny
+application/x-mspublisher pub
+application/x-msschedule scd
+application/x-msterminal trm
+application/x-mswrite wri
+application/x-netcdf nc cdf
+application/x-pkcs12 p12 pfx
+application/x-pkcs7-certificates p7b spc
+application/x-pkcs7-certreqresp p7r
+application/x-rar-compressed rar
+application/x-sh sh
+application/x-shar shar
+application/x-shockwave-flash swf
+application/x-stuffit sit
+application/x-stuffitx sitx
+application/x-sv4cpio sv4cpio
+application/x-sv4crc sv4crc
+application/x-tar tar
+application/x-tcl tcl
+application/x-tex tex
+application/x-tex-tfm tfm
+application/x-texinfo texinfo texi
+application/x-ustar ustar
+application/x-wais-source src
+application/x-x509-ca-cert der crt
+application/x-xfig fig
+application/x-xpinstall xpi
+application/x400-bp
+application/xcap-att+xml
+application/xcap-caps+xml
+application/xcap-el+xml
+application/xcap-error+xml
+application/xcap-ns+xml
+application/xcon-conference-info-diff+xml
+application/xcon-conference-info+xml
+application/xenc+xml xenc
+application/xhtml+xml xhtml xht
+application/xhtml-voice+xml
+application/xml xml xsl
+application/xml-dtd dtd
+application/xml-external-parsed-entity
+application/xmpp+xml
+application/xop+xml xop
+application/xslt+xml xslt
+application/xspf+xml xspf
+application/xv+xml mxml xhvml xvml xvm
+application/zip zip
+audio/32kadpcm
+audio/3gpp
+audio/3gpp2
+audio/ac3
+audio/adpcm adp
+audio/amr
+audio/amr-wb
+audio/amr-wb+
+audio/asc
+audio/basic au snd
+audio/bv16
+audio/bv32
+audio/clearmode
+audio/cn
+audio/dat12
+audio/dls
+audio/dsr-es201108
+audio/dsr-es202050
+audio/dsr-es202211
+audio/dsr-es202212
+audio/dvi4
+audio/eac3
+audio/evrc
+audio/evrc-qcp
+audio/evrc0
+audio/evrc1
+audio/evrcb
+audio/evrcb0
+audio/evrcb1
+audio/evrcwb
+audio/evrcwb0
+audio/evrcwb1
+audio/example
+audio/g719
+audio/g722
+audio/g7221
+audio/g723
+audio/g726-16
+audio/g726-24
+audio/g726-32
+audio/g726-40
+audio/g728
+audio/g729
+audio/g7291
+audio/g729d
+audio/g729e
+audio/gsm
+audio/gsm-efr
+audio/ilbc
+audio/l16
+audio/l20
+audio/l24
+audio/l8
+audio/lpc
+audio/midi mid midi kar rmi
+audio/mobile-xmf
+audio/mp4 mp4a
+audio/mp4a-latm
+audio/mpa
+audio/mpa-robust
+audio/mpeg mpga mp2 mp2a mp3 m2a m3a
+audio/mpeg4-generic
+audio/ogg oga ogg spx
+audio/parityfec
+audio/pcma
+audio/pcma-wb
+audio/pcmu-wb
+audio/pcmu
+audio/prs.sid
+audio/qcelp
+audio/red
+audio/rtp-enc-aescm128
+audio/rtp-midi
+audio/rtx
+audio/smv
+audio/smv0
+audio/smv-qcp
+audio/sp-midi
+audio/t140c
+audio/t38
+audio/telephone-event
+audio/tone
+audio/ulpfec
+audio/vdvi
+audio/vmr-wb
+audio/vnd.3gpp.iufp
+audio/vnd.4sb
+audio/vnd.audiokoz
+audio/vnd.celp
+audio/vnd.cisco.nse
+audio/vnd.cmles.radio-events
+audio/vnd.cns.anp1
+audio/vnd.cns.inf1
+audio/vnd.digital-winds eol
+audio/vnd.dlna.adts
+audio/vnd.dolby.heaac.1
+audio/vnd.dolby.heaac.2
+audio/vnd.dolby.mlp
+audio/vnd.dolby.mps
+audio/vnd.dolby.pl2
+audio/vnd.dolby.pl2x
+audio/vnd.dolby.pl2z
+audio/vnd.dts dts
+audio/vnd.dts.hd dtshd
+audio/vnd.everad.plj
+audio/vnd.hns.audio
+audio/vnd.lucent.voice lvp
+audio/vnd.ms-playready.media.pya pya
+audio/vnd.nokia.mobile-xmf
+audio/vnd.nortel.vbk
+audio/vnd.nuera.ecelp4800 ecelp4800
+audio/vnd.nuera.ecelp7470 ecelp7470
+audio/vnd.nuera.ecelp9600 ecelp9600
+audio/vnd.octel.sbc
+audio/vnd.qcelp
+audio/vnd.rhetorex.32kadpcm
+audio/vnd.sealedmedia.softseal.mpeg
+audio/vnd.vmx.cvsd
+audio/vorbis
+audio/vorbis-config
+audio/wav wav
+audio/x-aac aac
+audio/x-aiff aif aiff aifc
+audio/x-mpegurl m3u
+audio/x-ms-wax wax
+audio/x-ms-wma wma
+audio/x-pn-realaudio ram ra
+audio/x-pn-realaudio-plugin rmp
+audio/x-wav wav
+chemical/x-cdx cdx
+chemical/x-cif cif
+chemical/x-cmdf cmdf
+chemical/x-cml cml
+chemical/x-csml csml
+chemical/x-pdb pdb
+chemical/x-xyz xyz
+image/bmp bmp
+image/cgm cgm
+image/example
+image/fits
+image/g3fax g3
+image/gif gif
+image/ief ief
+image/jp2
+image/jpeg jpeg jpg jpe
+image/jpm
+image/jpx
+image/naplps
+image/png png
+image/prs.btif btif
+image/prs.pti
+image/svg+xml svg svgz
+image/t38
+image/tiff tiff tif
+image/tiff-fx
+image/vnd.adobe.photoshop psd
+image/vnd.cns.inf2
+image/vnd.djvu djvu djv
+image/vnd.dwg dwg
+image/vnd.dxf dxf
+image/vnd.fastbidsheet fbs
+image/vnd.fpx fpx
+image/vnd.fst fst
+image/vnd.fujixerox.edmics-mmr mmr
+image/vnd.fujixerox.edmics-rlc rlc
+image/vnd.globalgraphics.pgb
+image/vnd.microsoft.icon
+image/vnd.mix
+image/vnd.ms-modi mdi
+image/vnd.net-fpx npx
+image/vnd.radiance
+image/vnd.sealed.png
+image/vnd.sealedmedia.softseal.gif
+image/vnd.sealedmedia.softseal.jpg
+image/vnd.svf
+image/vnd.wap.wbmp wbmp
+image/vnd.xiff xif
+image/x-cmu-raster ras
+image/x-cmx cmx
+image/x-freehand fh fhc fh4 fh5 fh7
+image/x-icon ico
+image/x-pcx pcx
+image/x-pict pic pct
+image/x-portable-anymap pnm
+image/x-portable-bitmap pbm
+image/x-portable-graymap pgm
+image/x-portable-pixmap ppm
+image/x-rgb rgb
+image/x-xbitmap xbm
+image/x-xpixmap xpm
+image/x-xwindowdump xwd
+message/cpim
+message/delivery-status
+message/disposition-notification
+message/example
+message/external-body
+message/global
+message/global-delivery-status
+message/global-disposition-notification
+message/global-headers
+message/http
+message/imdn+xml
+message/news
+message/partial
+message/rfc822 eml mime
+message/s-http
+message/sip
+message/sipfrag
+message/tracking-status
+message/vnd.si.simp
+model/example
+model/iges igs iges
+model/mesh msh mesh silo
+model/vnd.dwf dwf
+model/vnd.flatland.3dml
+model/vnd.gdl gdl
+model/vnd.gs-gdl
+model/vnd.gs.gdl
+model/vnd.gtw gtw
+model/vnd.moml+xml
+model/vnd.mts mts
+model/vnd.parasolid.transmit.binary
+model/vnd.parasolid.transmit.text
+model/vnd.vtu vtu
+model/vrml wrl vrml
+multipart/alternative
+multipart/appledouble
+multipart/byteranges
+multipart/digest
+multipart/encrypted
+multipart/example
+multipart/form-data
+multipart/header-set
+multipart/mixed
+multipart/parallel
+multipart/related
+multipart/report
+multipart/signed
+multipart/voice-message
+text/calendar ics ifb
+text/css css
+text/csv csv
+text/directory
+text/dns
+text/ecmascript
+text/enriched
+text/example
+text/html html htm
+text/javascript
+text/parityfec
+text/plain txt text conf def list log in
+text/prs.fallenstein.rst
+text/prs.lines.tag dsc
+text/red
+text/rfc822-headers
+text/richtext rtx
+text/rtf
+text/rtp-enc-aescm128
+text/rtx
+text/sgml sgml sgm
+text/t140
+text/tab-separated-values tsv
+text/troff t tr roff man me ms
+text/ulpfec
+text/uri-list uri uris urls
+text/vnd.abc
+text/vnd.curl curl
+text/vnd.curl.dcurl dcurl
+text/vnd.curl.scurl scurl
+text/vnd.curl.mcurl mcurl
+text/vnd.dmclientscript
+text/vnd.esmertec.theme-descriptor
+text/vnd.fly fly
+text/vnd.fmi.flexstor flx
+text/vnd.graphviz gv
+text/vnd.in3d.3dml 3dml
+text/vnd.in3d.spot spot
+text/vnd.iptc.newsml
+text/vnd.iptc.nitf
+text/vnd.latex-z
+text/vnd.motorola.reflex
+text/vnd.ms-mediapackage
+text/vnd.net2phone.commcenter.command
+text/vnd.si.uricatalogue
+text/vnd.sun.j2me.app-descriptor jad
+text/vnd.trolltech.linguist
+text/vnd.wap.si
+text/vnd.wap.sl
+text/vnd.wap.wml wml
+text/vnd.wap.wmlscript wmls
+text/x-asm s asm
+text/x-c c cc cxx cpp h hh dic
+text/x-fortran f for f77 f90
+text/x-pascal p pas
+text/x-java-source java
+text/x-setext etx
+text/x-uuencode uu
+text/x-vcalendar vcs
+text/x-vcard vcf
+text/xml
+text/xml-external-parsed-entity
+video/3gpp 3gp
+video/3gpp-tt
+video/3gpp2 3g2
+video/bmpeg
+video/bt656
+video/celb
+video/dv
+video/example
+video/h261 h261
+video/h263 h263
+video/h263-1998
+video/h263-2000
+video/h264 h264
+video/jpeg jpgv
+video/jpeg2000
+video/jpm jpm jpgm
+video/mj2 mj2 mjp2
+video/mp1s
+video/mp2p
+video/mp2t
+video/mp4 mp4 mp4v mpg4
+video/mp4v-es
+video/mpeg mpeg mpg mpe m1v m2v
+video/mpeg4-generic
+video/mpv
+video/nv
+video/ogg ogv
+video/parityfec
+video/pointer
+video/quicktime qt mov
+video/raw
+video/rtp-enc-aescm128
+video/rtx
+video/smpte292m
+video/ulpfec
+video/vc1
+video/vnd.cctv
+video/vnd.dlna.mpeg-tts
+video/vnd.fvt fvt
+video/vnd.hns.video
+video/vnd.iptvforum.1dparityfec-1010
+video/vnd.iptvforum.1dparityfec-2005
+video/vnd.iptvforum.2dparityfec-1010
+video/vnd.iptvforum.2dparityfec-2005
+video/vnd.iptvforum.ttsavc
+video/vnd.iptvforum.ttsmpeg2
+video/vnd.motorola.video
+video/vnd.motorola.videop
+video/vnd.mpegurl mxu m4u
+video/vnd.ms-playready.media.pyv pyv
+video/vnd.nokia.interleaved-multimedia
+video/vnd.nokia.videovoip
+video/vnd.objectvideo
+video/vnd.sealed.mpeg1
+video/vnd.sealed.mpeg4
+video/vnd.sealed.swf
+video/vnd.sealedmedia.softseal.mov
+video/vnd.vivo viv
+video/x-f4v f4v
+video/x-fli fli
+video/x-flv flv
+video/x-m4v m4v
+video/x-ms-asf asf asx
+video/x-ms-wm wm
+video/x-ms-wmv wmv
+video/x-ms-wmx wmx
+video/x-ms-wvx wvx
+video/x-msvideo avi
+video/x-sgi-movie movie
+x-conference/x-cooltalk ice
\ No newline at end of file
15 years, 1 month
DNA SVN: r901 - in trunk/dna-jcr: src/main/java/org/jboss/dna/jcr and 3 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-05-11 14:39:47 -0400 (Mon, 11 May 2009)
New Revision: 901
Added:
trunk/dna-jcr/src/test/resources/security/
trunk/dna-jcr/src/test/resources/security/jaas.conf.xml
trunk/dna-jcr/src/test/resources/security/tck_roles.properties
trunk/dna-jcr/src/test/resources/security/tck_users.properties
Modified:
trunk/dna-jcr/pom.xml
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
Log:
Added DNA-372_idtrust_auth_auth.patch that replaces the previous patch. This adds all of the functionality of the previous patch plus authorization (i.e., JcrSession.checkPermission now works). Tests were modified accordingly.
The patch uses JBoss IDTrust to declaratively add a (configurable) login manager from InMemoryRepositoryStub. The InMemoryRepositoryStub uses /src/test/resources/security/jaas.config.xml as the configuration file of choice. The test implementation of this file specifies a JBoss UsersRolesLoginModule, that loads its users from /src/test/resources/security/tck_users.properties. Each property name in this file represents a valid user and each property value represents their passwordl The UsersRolesLoginModule also specifies a file of user roles - /src/test/resources/security/tck_roles.properties. Each property name is a user name (which must match a user from tck_users.properties) and each property value is a comma-delimited list of assigned roles for the user. All of this code (and the IDTrust dependencies) are in test scope.
JcrSession loads the roles for the JAAS subject in its contstructor and stores them in a set ("entitlements"). It expects roles named "readonly", "readwrite", "readonly.<workspaceName>", or "readwrite.<workspaceName>". The former two formats imply a global permission that is assigned to the user for all workspaces. JcrSession.checkPermission determines if the permission to be checked is a read permission or if it requires readwrite access and checks to see if the JAAS subject has a role with the naming pattern above assigned. This introduces a dependency on JBoss SX. Per-path permissions are not supported at this time. Finer-grained access ("add_node" vs. "set_property" vs. "remove") are not supported at this time. Better authorization implementations are always welcome.
Modified: trunk/dna-jcr/pom.xml
===================================================================
--- trunk/dna-jcr/pom.xml 2009-05-11 17:25:19 UTC (rev 900)
+++ trunk/dna-jcr/pom.xml 2009-05-11 18:39:47 UTC (rev 901)
@@ -107,5 +107,35 @@
<artifactId>google-collect</artifactId>
<version>snapshot-20080530</version>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-idtrust</artifactId>
+ <version>2.0.2.CR1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-security-spi-bare</artifactId>
+ <version>2.0.2.SP6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx-bare</artifactId>
+ <version>2.0.2.SP6</version>
+ <exclusions>
+ <exclusion>
+ <groupId>apache-xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>apache-xalan</groupId>
+ <artifactId>serializer</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-05-11 17:25:19 UTC (rev 900)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-05-11 18:39:47 UTC (rev 901)
@@ -28,7 +28,10 @@
import java.io.OutputStream;
import java.security.AccessControlException;
import java.security.Principal;
+import java.security.acl.Group;
import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -84,6 +87,9 @@
private static final String[] NO_ATTRIBUTES_NAMES = new String[] {};
+ private static final String READ_PERMISSION = "readonly";
+ private static final String WRITE_PERMISSION = "readwrite";
+
/**
* The repository that created this session.
*/
@@ -115,6 +121,11 @@
*/
private final Graph graph;
+ /**
+ * The set of assigned entitlements for the logged-in subject
+ */
+ private Set<String> entitlements;
+
private final SessionCache cache;
/**
@@ -153,12 +164,29 @@
this.graph);
this.isLive = true;
+ Subject subject = this.executionContext.getSubject();
+ this.entitlements = new HashSet<String>();
+
+ if (subject != null) {
+ for (Principal principal : subject.getPrincipals()) {
+ if (principal instanceof Group) {
+ Group group = (Group)principal;
+ Enumeration<? extends Principal> roles = group.members();
+
+ while (roles.hasMoreElements()) {
+ Principal role = roles.nextElement();
+ entitlements.add(role.getName());
+ }
+ }
+ }
+ }
assert this.repository != null;
assert this.sessionAttributes != null;
assert this.workspace != null;
assert this.executionContext != null;
assert this.sessionRegistry != null;
assert this.graph != null;
+ assert this.entitlements != null;
}
// Added to facilitate mock testing of items without necessarily requiring an entire repository structure to be built
@@ -274,6 +302,18 @@
}
/**
+ * Returns the entitlements (permissions) available to the {@link ExecutionContext#getSubject() subject} for this session.
+ * <p>
+ * Entitlements are exposed through this method to allow for easier mock testing.
+ * </p>
+ *
+ * @return the entitlements (permissions) available to the {@link ExecutionContext#getSubject() subject} for this session.
+ */
+ Set<String> entitlements() {
+ return this.entitlements;
+ }
+
+ /**
* {@inheritDoc}
*
* @throws IllegalArgumentException if either <code>path</code> or <code>actions</code> is empty or <code>null</code>.
@@ -283,9 +323,22 @@
String actions ) {
CheckArg.isNotEmpty(path, "path");
CheckArg.isNotEmpty(actions, "actions");
- if (!"read".equals(actions)) {
- throw new AccessControlException(JcrI18n.permissionDenied.text(path, actions));
+
+ Set<String> entitlements = entitlements();
+ if ("read".equals(actions)) {
+ // readonly access is sufficient
+ if (entitlements.contains(READ_PERMISSION) || entitlements.contains(READ_PERMISSION + "." + this.workspace.getName())) {
+ return;
+ }
}
+
+ // need readwrite access
+ if (entitlements.contains(WRITE_PERMISSION) || entitlements.contains(WRITE_PERMISSION + "." + this.workspace.getName())) {
+ return;
+ }
+
+ throw new AccessControlException(JcrI18n.permissionDenied.text(path, actions));
+
}
/**
@@ -602,11 +655,8 @@
*
* @see javax.jcr.Session#impersonate(javax.jcr.Credentials)
*/
- @SuppressWarnings( "unused" )
public Session impersonate( Credentials credentials ) throws RepositoryException {
- // this is not right:
- // return repository.login(credentials);
- throw new UnsupportedOperationException();
+ return repository.login(credentials, this.workspace.getName());
}
/**
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java 2009-05-11 17:25:19 UTC (rev 900)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/InMemoryRepositoryStub.java 2009-05-11 18:39:47 UTC (rev 901)
@@ -25,12 +25,9 @@
import java.io.File;
import java.net.URI;
-import java.security.AccessControlContext;
-import java.security.AccessController;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
-import javax.jcr.Credentials;
import org.apache.jackrabbit.test.RepositoryStub;
import org.jboss.dna.common.collection.Problem;
import org.jboss.dna.graph.ExecutionContext;
@@ -42,71 +39,56 @@
import org.jboss.dna.graph.io.GraphImporter;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.jcr.JcrRepository.Options;
+import org.jboss.security.config.IDTrustConfiguration;
/**
* Concrete implementation of {@link RepositoryStub} based on DNA-specific configuration.
*/
public class InMemoryRepositoryStub extends RepositoryStub {
private JcrRepository repository;
- protected InMemoryRepositorySource source;
- protected AccessControlContext accessControlContext = AccessController.getContext();
- private Credentials superUserCredentials = new Credentials() {
- private static final long serialVersionUID = 1L;
+ static {
- @SuppressWarnings( "unused" )
- public AccessControlContext getAccessControlContext() {
- return accessControlContext;
- }
- };
+ // Initialize IDTrust
+ String configFile = "security/jaas.conf.xml";
+ IDTrustConfiguration idtrustConfig = new IDTrustConfiguration();
- private Credentials readWriteCredentials = new Credentials() {
- private static final long serialVersionUID = 1L;
-
- @SuppressWarnings( "unused" )
- public AccessControlContext getAccessControlContext() {
- return accessControlContext;
+ try {
+ idtrustConfig.config(configFile);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
}
- };
+ }
- private Credentials readOnlyCredentials = new Credentials() {
- private static final long serialVersionUID = 1L;
-
- @SuppressWarnings( "unused" )
- public AccessControlContext getAccessControlContext() {
- return accessControlContext;
- }
- };
-
- protected ExecutionContext executionContext = new ExecutionContext();
-
- protected RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() {
- public RepositoryConnection createConnection( String sourceName ) {
- return source.getConnection();
- }
- };
-
public InMemoryRepositoryStub( Properties env ) {
super(env);
// Create the in-memory (DNA) repository
- source = new InMemoryRepositorySource();
+ final InMemoryRepositorySource source = new InMemoryRepositorySource();
// Various calls will fail if you do not set a non-null name for the source
source.setName("TestRepositorySource");
- // Make sure the path to the namespaces exists ...
- Graph graph = Graph.create(source.getName(), connectionFactory, executionContext);
- graph.create("/jcr:system").and().create("/jcr:system/dna:namespaces");
+ ExecutionContext executionContext = new ExecutionContext();
+ executionContext.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
+ RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() {
+ public RepositoryConnection createConnection( String sourceName ) {
+ return source.getConnection();
+ }
+ };
+
// Wrap a connection to the in-memory (DNA) repository in a (JCR) repository
Map<Options, String> options = Collections.singletonMap(Options.PROJECT_NODE_TYPES, "false");
- repository = new JcrRepository(executionContext.create(accessControlContext), connectionFactory, source.getName(), null,
- options);
+ repository = new JcrRepository(executionContext, connectionFactory, source.getName(), null, options);
RepositoryNodeTypeManager nodeTypes = repository.getRepositoryTypeManager();
// Set up some sample nodes in the graph to match the expected test configuration
+ Graph graph = Graph.create(source.getName(), connectionFactory, executionContext);
+ GraphImporter importer = new GraphImporter(graph);
+ Path destinationPath = executionContext.getValueFactories().getPathFactory().createRootPath();
+
try {
CndNodeTypeSource nodeTypeSource = new CndNodeTypeSource("/tck_test_types.cnd");
@@ -119,14 +101,8 @@
nodeTypes.registerNodeTypes(nodeTypeSource);
- executionContext.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
-
- Path destinationPath = executionContext.getValueFactories().getPathFactory().create("/");
- GraphImporter importer = new GraphImporter(graph);
-
URI xmlContent = new File("src/test/resources/repositoryForTckTests.xml").toURI();
- Graph.Batch batch = importer.importXml(xmlContent, Location.create(destinationPath));
- batch.execute();
+ importer.importXml(xmlContent, Location.create(destinationPath)).execute();
} catch (Exception ex) {
// The TCK tries to quash this exception. Print it out to be more obvious.
@@ -138,36 +114,6 @@
/**
* {@inheritDoc}
*
- * @see org.apache.jackrabbit.test.RepositoryStub#getSuperuserCredentials()
- */
- @Override
- public Credentials getSuperuserCredentials() {
- return superUserCredentials;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.apache.jackrabbit.test.RepositoryStub#getReadOnlyCredentials()
- */
- @Override
- public Credentials getReadOnlyCredentials() {
- return readOnlyCredentials;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.apache.jackrabbit.test.RepositoryStub#getReadOnlyCredentials()
- */
- @Override
- public Credentials getReadWriteCredentials() {
- return readWriteCredentials;
- }
-
- /**
- * {@inheritDoc}
- *
* @see org.apache.jackrabbit.test.RepositoryStub#getRepository()
*/
@Override
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-05-11 17:25:19 UTC (rev 900)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-05-11 18:39:47 UTC (rev 901)
@@ -38,7 +38,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.security.AccessControlException;
import java.security.Principal;
import java.util.Calendar;
import java.util.Collections;
@@ -192,11 +191,6 @@
session.addLockToken(null);
}
- @Test
- public void shouldAllowCheckReadPermission() throws Exception {
- session.checkPermission("/", "read");
- }
-
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowCheckPermissionWithNoPath() throws Exception {
session.checkPermission(null, "read");
@@ -217,11 +211,6 @@
session.checkPermission("/", "");
}
- @Test( expected = AccessControlException.class )
- public void shouldNotAllowCheckNonReadPermission() throws Exception {
- session.checkPermission("/", "any");
- }
-
@Test
public void shouldReturnNullValueForNullAttributeName() throws Exception {
assertThat(session.getAttribute(null), nullValue());
@@ -365,11 +354,6 @@
assertThat(session.hasPendingChanges(), is(false));
}
- @Test( expected = UnsupportedOperationException.class )
- public void shouldAllowImpersonation() throws Exception {
- assertThat(session.impersonate(null), notNullValue());
- }
-
@Test
public void shouldProvideItemExists() throws Exception {
assertThat(session.itemExists("/a/b"), is(true));
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-05-11 17:25:19 UTC (rev 900)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-05-11 18:39:47 UTC (rev 901)
@@ -27,7 +27,9 @@
import junit.framework.TestSuite;
import org.apache.jackrabbit.test.JCRTestSuite;
import org.apache.jackrabbit.test.api.AddNodeTest;
+import org.apache.jackrabbit.test.api.CheckPermissionTest;
import org.apache.jackrabbit.test.api.DocumentViewImportTest;
+import org.apache.jackrabbit.test.api.ImpersonateTest;
import org.apache.jackrabbit.test.api.NamespaceRegistryTest;
import org.apache.jackrabbit.test.api.NodeAddMixinTest;
import org.apache.jackrabbit.test.api.NodeCanAddMixinTest;
@@ -226,8 +228,8 @@
addTestSuite(WorkspaceMoveVersionableTest.class);
addTestSuite(RepositoryLoginTest.class);
- // addTestSuite(ImpersonateTest.class);
- // addTestSuite(CheckPermissionTest.class);
+ addTestSuite(ImpersonateTest.class);
+ addTestSuite(CheckPermissionTest.class);
addTestSuite(DocumentViewImportTest.class);
addTestSuite(SerializationTest.class);
Added: trunk/dna-jcr/src/test/resources/security/jaas.conf.xml
===================================================================
--- trunk/dna-jcr/src/test/resources/security/jaas.conf.xml (rev 0)
+++ trunk/dna-jcr/src/test/resources/security/jaas.conf.xml 2009-05-11 18:39:47 UTC (rev 901)
@@ -0,0 +1,24 @@
+<?xml version='1.0'?>
+
+<policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:security-config:5.0" xmlns="urn:jboss:security-config:5.0"
+ xmlns:jbxb="urn:jboss:security-config:5.0">
+ <application-policy name="dna-jcr">
+ <authentication>
+ <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
+ <module-option name="usersProperties">security/tck_users.properties</module-option>
+ <module-option name="rolesProperties">security/tck_roles.properties</module-option>
+ <module-option name="name">1.1</module-option>
+ <module-option name="succeed">true</module-option>
+ <module-option name="throwEx">false</module-option>
+ </login-module>
+ </authentication>
+<!--
+ <authorization>
+ <policy-module code="org.jboss.security.idtrust.impl.plugins.authorization.IDTrustAuthorizationModule">
+ <module-option name="roles">validuser</module-option>
+ </policy-module>
+ </authorization>
+-->
+ </application-policy>
+</policy>
Property changes on: trunk/dna-jcr/src/test/resources/security/jaas.conf.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/dna-jcr/src/test/resources/security/tck_roles.properties
===================================================================
--- trunk/dna-jcr/src/test/resources/security/tck_roles.properties (rev 0)
+++ trunk/dna-jcr/src/test/resources/security/tck_roles.properties 2009-05-11 18:39:47 UTC (rev 901)
@@ -0,0 +1,4 @@
+#<userName>=[readonly[.<workspaceName>] | readwrite[.<workspaceName>]][, [readonly[.<workspaceName>] | readwrite[.<workspaceName>]]]*
+superuser=readwrite
+readwrite=readwrite
+readonly=readonly
Added: trunk/dna-jcr/src/test/resources/security/tck_users.properties
===================================================================
--- trunk/dna-jcr/src/test/resources/security/tck_users.properties (rev 0)
+++ trunk/dna-jcr/src/test/resources/security/tck_users.properties 2009-05-11 18:39:47 UTC (rev 901)
@@ -0,0 +1,4 @@
+# <username>=<password>
+superuser=superuser
+readwrite=readwrite
+readonly=readonly
15 years, 1 month
DNA SVN: r900 - in trunk/extensions: dna-web-jcr-rest and 19 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-05-11 13:25:19 -0400 (Mon, 11 May 2009)
New Revision: 900
Added:
trunk/extensions/dna-web-jcr-rest/
trunk/extensions/dna-web-jcr-rest/.classpath
trunk/extensions/dna-web-jcr-rest/.project
trunk/extensions/dna-web-jcr-rest/pom.xml
trunk/extensions/dna-web-jcr-rest/src/
trunk/extensions/dna-web-jcr-rest/src/main/
trunk/extensions/dna-web-jcr-rest/src/main/java/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
trunk/extensions/dna-web-jcr-rest/src/main/resources/
trunk/extensions/dna-web-jcr-rest/src/main/webapp/
trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/
trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml
trunk/extensions/dna-web-jcr-rest/src/test/
trunk/extensions/dna-web-jcr-rest/src/test/java/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
Log:
Adding patch to create the web project for RESTful services along with Maven integration for automatic deployment and in-container unit testing.
Added: trunk/extensions/dna-web-jcr-rest/.classpath
===================================================================
--- trunk/extensions/dna-web-jcr-rest/.classpath (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/.classpath 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: trunk/extensions/dna-web-jcr-rest/.project
===================================================================
--- trunk/extensions/dna-web-jcr-rest/.project (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/.project 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dna-web-jcr-rest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: trunk/extensions/dna-web-jcr-rest/pom.xml
===================================================================
--- trunk/extensions/dna-web-jcr-rest/pom.xml (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/pom.xml 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,98 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>dna</artifactId>
+ <groupId>org.jboss.dna</groupId>
+ <version>0.5-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-web-jcr-rest</artifactId>
+ <packaging>war</packaging>
+ <name>JBoss DNA JCR REST Servlet</name>
+ <description>JBoss DNA servlet that provides RESTful access to JCR items</description>
+ <url>http://labs.jboss.org/dna</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>1.1-RC2</version>
+ </dependency>
+
+ <!--
+ Java Content Repository API
+ -->
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ </dependency>
+
+ <!-- TESTING DEPENDENCIES -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit-dep</artifactId>
+ <version>4.4</version>
+ <scope>integration-test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-client</artifactId>
+ <version>1.0-beta-8</version>
+ <scope>integration-test</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <finalName>resources</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ </configuration>
+ </plugin>
+ <!--
+ Override the default Surefire behavior to run during
+ integration-test phase
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Property changes on: trunk/extensions/dna-web-jcr-rest/pom.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,47 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest;
+
+import java.util.Collections;
+import java.util.Set;
+import javax.ws.rs.core.Application;
+
+/**
+ * Implementation of the JAX-RS {@code Application} class to identify all JAX-RS providers and classes in the application.
+ *
+ * @see Application
+ */
+public class JcrApplication extends Application {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Application#getClasses()
+ */
+ @Override
+ public Set<Class<?>> getClasses() {
+ return Collections.<Class<?>>singleton(JcrResources.class);
+ }
+
+}
Property changes on: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,120 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+/**
+ * RESTEasy handler to provide the JCR resources at the URIs below. Please note that these URIs assume a context of {@code
+ * /resources} for the web application.
+ * <table border="1">
+ * <tr>
+ * <th>URI Pattern</th>
+ * <th>Description</th>
+ * <th>Supported Methods</th>
+ * </tr>
+ * <tr>
+ * <td>/resources</td>
+ * <td>returns a list of accessible repositories</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/repositories</td>
+ * <td>returns a list of accessible repositories</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}</td>
+ * <td>returns a list of accessible workspaces within that repository</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/workspaces</td>
+ * <td>returns a list of accessible workspaces within that repository</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}</td>
+ * <td>returns a list of operations within the workspace</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/item/{path}</td>
+ * <td>accesses the node at the path</td>
+ * <td>ALL</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/item/{path}/@{propertyName}</td>
+ * <td>accesses the named property at the path</td>
+ * <td>ALL (except PUT)</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/item/{path}/@{propertyName}</td>
+ * <td>adds the value from the body to the named property at the path</td>
+ * <td>PUT</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/uuid/{uuid}</td>
+ * <td>accesses the node with the given UUID</td>
+ * <td>ALL</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/lock/{path}</td>
+ * <td>locks the node at the path</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/lock/{path}</td>
+ * <td>unlocks the node at the path</td>
+ * <td>PUT</td>
+ * </tr>
+ * </table>
+ */
+@Path( "/" )
+public class JcrResources {
+
+ /**
+ * Returns the list of JCR repositories available on this server
+ * @return the list of JCR repositories available on this server
+ */
+ @GET
+ @Path( "/repositories" )
+ public String repositories() {
+ return "Hello, DNA!";
+ }
+
+ /**
+ * Returns the list of workspaces available to this user within the named repository.
+ * @param repositoryName the name of the repository
+ * @return the list of workspaces available to this user within the named repository.
+ */
+ @GET
+ @Path( "/{repositoryName}/workspaces" )
+ public String workspaces( @PathParam( "repositoryName" ) String repositoryName ) {
+ return repositoryName;
+ }
+
+}
Property changes on: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<!--
+ JBoss DNA (http://www.jboss.org/dna)
+ See the COPYRIGHT.txt file distributed with this work for information
+ regarding copyright ownership. Some portions may be licensed
+ to Red Hat, Inc. under one or more contributor license agreements.
+ See the AUTHORS.txt file in the distribution for a full listing of
+ individual contributors.
+
+ JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ is licensed to you under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ JBoss DNA is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+ -->
+<web-app>
+ <display-name>JBoss DNA JCR RESTful Interface</display-name>
+
+ <context-param>
+ <param-name>javax.ws.rs.core.Application</param-name>
+ <param-value>org.jboss.dna.web.jcr.rest.JcrApplication</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>
+ org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
+ </listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>Resteasy</servlet-name>
+ <servlet-class>
+ org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
+ </servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Resteasy</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
\ No newline at end of file
Property changes on: trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,75 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JcrResourcesTest {
+
+ private static final String SERVER_URL = "http://localhost:8080/resources";
+
+ private ClientRequest request;
+ private ClientResponse<?> response;
+
+ private ClientRequest requestFor(String path) {
+ return new ClientRequest(SERVER_URL + path);
+ }
+
+ @Ignore
+ @Test
+ public void shouldServeContentAtRoot() throws Exception {
+ request = requestFor("/");
+
+ response = request.get();
+
+ assertThat(response.getStatus(), is(200));
+
+ }
+
+ @Test
+ public void shouldServeListOfRepositories() throws Exception {
+ request = requestFor("/repositories");
+
+ response = request.get();
+
+ assertThat(response.getStatus(), is(200));
+
+ }
+
+ @Test
+ public void shouldServeListOfWorkspaces() throws Exception {
+ String validRepositoryName = "foo"; // Stub this for now
+ request = requestFor("/" + validRepositoryName + "/workspaces");
+
+ response = request.get();
+
+ assertThat(response.getStatus(), is(200));
+ }
+
+}
Property changes on: trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
15 years, 1 month
DNA SVN: r899 - trunk/docs/presentations.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2009-05-11 12:39:50 -0400 (Mon, 11 May 2009)
New Revision: 899
Added:
trunk/docs/presentations/JBUGM_JBoss_DNA_02_05_2009.pdf
Log:
JBUG munich presentation
Added: trunk/docs/presentations/JBUGM_JBoss_DNA_02_05_2009.pdf
===================================================================
(Binary files differ)
Property changes on: trunk/docs/presentations/JBUGM_JBoss_DNA_02_05_2009.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 1 month
DNA SVN: r897 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-07 10:43:54 -0400 (Thu, 07 May 2009)
New Revision: 897
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java
Log:
DNA-398 RepositoryNodeTypeManager is Not Thread-Safe
Corrected the public getAllNodeTypes() method, which was returning the actually values collection associated with an internal map that is modified. This means that although the method atomically returns the collection in a thread-safe manner, the resulting collection is live and may be modified via other calls. The change is to create a defensive and immutable copy of the node types within the lock scope. Currently, this method is only called from the JcrNodeTypeManager implementation (the Session-specific wrapper around the shared RepositoryNodeTypeManager), which is not currently called from within any DNA JCR implementation code. Therefore, the cost of making a copy has little impact.
Also added were JavaDoc for several public methods.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java 2009-05-07 14:30:53 UTC (rev 896)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java 2009-05-07 14:43:54 UTC (rev 897)
@@ -104,11 +104,11 @@
private final ExecutionContext context;
- @GuardedBy("nodeTypeManagerLock")
+ @GuardedBy( "nodeTypeManagerLock" )
private final Map<Name, JcrNodeType> nodeTypes;
- @GuardedBy("nodeTypeManagerLock")
+ @GuardedBy( "nodeTypeManagerLock" )
private final Map<PropertyDefinitionId, JcrPropertyDefinition> propertyDefinitions;
- @GuardedBy("nodeTypeManagerLock")
+ @GuardedBy( "nodeTypeManagerLock" )
private final Map<NodeDefinitionId, JcrNodeDefinition> childNodeDefinitions;
private final PropertyFactory propertyFactory;
private final PathFactory pathFactory;
@@ -146,19 +146,30 @@
nodeTypes = new HashMap<Name, JcrNodeType>(50);
}
+ /**
+ * Return an immutable snapshot of the node types that are currently registered in this node type manager.
+ *
+ * @return the immutable collection of (immutable) node types; never null
+ */
public Collection<JcrNodeType> getAllNodeTypes() {
try {
nodeTypeManagerLock.readLock().lock();
- return nodeTypes.values();
+ return Collections.unmodifiableCollection(new ArrayList<JcrNodeType>(nodeTypes.values()));
} finally {
nodeTypeManagerLock.readLock().unlock();
}
}
+ /**
+ * Return an immutable snapshot of the mixin node types that are currently registered in this node type manager.
+ *
+ * @return the immutable collection of (immutable) mixin node types; never null
+ * @see #getPrimaryNodeTypes()
+ */
public Collection<JcrNodeType> getMixinNodeTypes() {
try {
nodeTypeManagerLock.readLock().lock();
-
+
List<JcrNodeType> types = new ArrayList<JcrNodeType>(nodeTypes.size());
for (JcrNodeType nodeType : nodeTypes.values()) {
@@ -171,6 +182,12 @@
}
}
+ /**
+ * Return an immutable snapshot of the primary node types that are currently registered in this node type manager.
+ *
+ * @return the immutable collection of (immutable) primary node types; never null
+ * @see #getMixinNodeTypes()
+ */
public Collection<JcrNodeType> getPrimaryNodeTypes() {
try {
nodeTypeManagerLock.readLock().lock();
15 years, 1 month
DNA SVN: r896 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-07 10:30:53 -0400 (Thu, 07 May 2009)
New Revision: 896
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java
Log:
DNA-398 RepositoryNodeTypeManager is Not Thread-Safe
Applied the patch that makes RepositoryNodeTypeManager thread safe.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java 2009-05-07 14:30:44 UTC (rev 895)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryNodeTypeManager.java 2009-05-07 14:30:53 UTC (rev 896)
@@ -31,6 +31,8 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.UnsupportedRepositoryOperationException;
@@ -40,7 +42,8 @@
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.version.OnParentVersionAction;
-import net.jcip.annotations.Immutable;
+import net.jcip.annotations.GuardedBy;
+import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.text.TextEncoder;
import org.jboss.dna.common.text.XmlNameEncoder;
import org.jboss.dna.graph.ExecutionContext;
@@ -75,7 +78,7 @@
* {@link javax.jcr.Session}'s transient mappings and then delegating node type lookups to the repository manager.
* </p>
*/
-@Immutable
+@ThreadSafe
class RepositoryNodeTypeManager {
private static final Map<String, Integer> PROPERTY_TYPE_VALUES_FROM_NAME;
@@ -100,11 +103,16 @@
private static final TextEncoder NAME_ENCODER = new XmlNameEncoder();
private final ExecutionContext context;
+
+ @GuardedBy("nodeTypeManagerLock")
private final Map<Name, JcrNodeType> nodeTypes;
+ @GuardedBy("nodeTypeManagerLock")
private final Map<PropertyDefinitionId, JcrPropertyDefinition> propertyDefinitions;
+ @GuardedBy("nodeTypeManagerLock")
private final Map<NodeDefinitionId, JcrNodeDefinition> childNodeDefinitions;
private final PropertyFactory propertyFactory;
private final PathFactory pathFactory;
+ private final ReadWriteLock nodeTypeManagerLock = new ReentrantReadWriteLock();
/**
* List of ways to filter the returned property definitions
@@ -139,39 +147,70 @@
}
public Collection<JcrNodeType> getAllNodeTypes() {
- return nodeTypes.values();
+ try {
+ nodeTypeManagerLock.readLock().lock();
+ return nodeTypes.values();
+ } finally {
+ nodeTypeManagerLock.readLock().unlock();
+ }
}
public Collection<JcrNodeType> getMixinNodeTypes() {
- List<JcrNodeType> types = new ArrayList<JcrNodeType>(nodeTypes.size());
+ try {
+ nodeTypeManagerLock.readLock().lock();
+
+ List<JcrNodeType> types = new ArrayList<JcrNodeType>(nodeTypes.size());
- for (JcrNodeType nodeType : nodeTypes.values()) {
- if (nodeType.isMixin()) types.add(nodeType);
+ for (JcrNodeType nodeType : nodeTypes.values()) {
+ if (nodeType.isMixin()) types.add(nodeType);
+ }
+
+ return types;
+ } finally {
+ nodeTypeManagerLock.readLock().unlock();
}
-
- return types;
}
public Collection<JcrNodeType> getPrimaryNodeTypes() {
- List<JcrNodeType> types = new ArrayList<JcrNodeType>(nodeTypes.size());
+ try {
+ nodeTypeManagerLock.readLock().lock();
+ List<JcrNodeType> types = new ArrayList<JcrNodeType>(nodeTypes.size());
- for (JcrNodeType nodeType : nodeTypes.values()) {
- if (!nodeType.isMixin()) types.add(nodeType);
+ for (JcrNodeType nodeType : nodeTypes.values()) {
+ if (!nodeType.isMixin()) types.add(nodeType);
+ }
+
+ return types;
+ } finally {
+ nodeTypeManagerLock.readLock().unlock();
}
-
- return types;
}
public JcrPropertyDefinition getPropertyDefinition( PropertyDefinitionId id ) {
- return propertyDefinitions.get(id);
+ try {
+ nodeTypeManagerLock.readLock().lock();
+ return propertyDefinitions.get(id);
+ } finally {
+ nodeTypeManagerLock.readLock().unlock();
+ }
}
public JcrNodeDefinition getChildNodeDefinition( NodeDefinitionId id ) {
- return childNodeDefinitions.get(id);
+ try {
+ nodeTypeManagerLock.readLock().lock();
+ return childNodeDefinitions.get(id);
+ } finally {
+ nodeTypeManagerLock.readLock().unlock();
+ }
}
JcrNodeType getNodeType( Name nodeTypeName ) {
- return nodeTypes.get(nodeTypeName);
+ try {
+ nodeTypeManagerLock.readLock().lock();
+ return nodeTypes.get(nodeTypeName);
+ } finally {
+ nodeTypeManagerLock.readLock().unlock();
+ }
}
/**
@@ -517,6 +556,7 @@
PropertyCardinality typeToCheck,
List<JcrNodeType> pendingTypes ) {
assert typeNamesToCheck != null;
+
Collection<JcrPropertyDefinition> propDefs = null;
List<JcrPropertyDefinition> matchingDefs = new ArrayList<JcrPropertyDefinition>();
@@ -790,7 +830,7 @@
Graph.Batch batch = graph.batch();
- for (JcrNodeType nodeType : nodeTypes.values()) {
+ for (JcrNodeType nodeType : getAllNodeTypes()) {
projectNodeTypeOnto(nodeType, parentOfTypeNodes, batch);
}
@@ -975,8 +1015,8 @@
* type name that is already registered
* @throws RepositoryException if another error occurs
*/
- public JcrNodeType registerNodeType( NodeTypeDefinition ntd,
- boolean allowUpdates )
+ JcrNodeType registerNodeType( NodeTypeDefinition ntd,
+ boolean allowUpdates )
throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, RepositoryException {
assert ntd != null;
assert ntd instanceof JcrNodeTypeTemplate;
@@ -1063,8 +1103,8 @@
* type name that is already registered
* @throws RepositoryException if another error occurs
*/
- public List<JcrNodeType> registerNodeTypes( Collection<NodeTypeDefinition> nodeTypeBatch,
- boolean allowUpdates )
+ List<JcrNodeType> registerNodeTypes( Collection<NodeTypeDefinition> nodeTypeBatch,
+ boolean allowUpdates )
throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, RepositoryException {
if (nodeTypeBatch.isEmpty()) {
@@ -1163,76 +1203,82 @@
List<Location> nodeTypeLocations = nodeTypeBatch.getChildren().of("/");
List<JcrNodeType> typesPendingRegistration = new ArrayList<JcrNodeType>(nodeTypeLocations.size());
- for (Location location : nodeTypeLocations) {
- Node nodeTypeNode = nodeTypeBatch.getNodeAt(location);
- assert location.getPath() != null;
+ try {
+ nodeTypeManagerLock.writeLock().lock();
+ for (Location location : nodeTypeLocations) {
+ Node nodeTypeNode = nodeTypeBatch.getNodeAt(location);
+ assert location.getPath() != null;
- Name internalName = location.getPath().getLastSegment().getName();
- if (internalName == null || internalName.getLocalName().length() == 0) {
- throw new InvalidNodeTypeDefinitionException(JcrI18n.invalidNodeTypeName.text());
- }
+ Name internalName = location.getPath().getLastSegment().getName();
+ if (internalName == null || internalName.getLocalName().length() == 0) {
+ throw new InvalidNodeTypeDefinitionException(JcrI18n.invalidNodeTypeName.text());
+ }
- if (nodeTypes.containsKey(internalName)) {
- throw new NodeTypeExistsException(internalName,
- JcrI18n.nodeTypeAlreadyExists.text(internalName.getString(namespaces)));
- }
+ if (nodeTypes.containsKey(internalName)) {
+ throw new NodeTypeExistsException(internalName,
+ JcrI18n.nodeTypeAlreadyExists.text(internalName.getString(namespaces)));
+ }
- List<JcrNodeType> supertypes = supertypesFor(nodeTypeNode, typesPendingRegistration);
- // No need to re-parse the supertypes
- JcrNodeType nodeType = nodeTypeFrom(nodeTypeBatch.getSubgraphOfDepth(2).at(location), supertypes);
+ List<JcrNodeType> supertypes = supertypesFor(nodeTypeNode, typesPendingRegistration);
+ // No need to re-parse the supertypes
+ JcrNodeType nodeType = nodeTypeFrom(nodeTypeBatch.getSubgraphOfDepth(2).at(location), supertypes);
- validate(nodeType, supertypes, typesPendingRegistration);
+ validate(nodeType, supertypes, typesPendingRegistration);
- List<JcrPropertyDefinition> propertyDefs = new ArrayList<JcrPropertyDefinition>(
- nodeType.getDeclaredPropertyDefinitions().length);
+ List<JcrPropertyDefinition> propertyDefs = new ArrayList<JcrPropertyDefinition>(
+ nodeType.getDeclaredPropertyDefinitions().length);
- for (JcrPropertyDefinition propertyDef : nodeType.getDeclaredPropertyDefinitions()) {
- propertyDefs.add(propertyDef.with(this.context));
- }
+ for (JcrPropertyDefinition propertyDef : nodeType.getDeclaredPropertyDefinitions()) {
+ propertyDefs.add(propertyDef.with(this.context));
+ }
- List<JcrNodeDefinition> nodeDefs = new ArrayList<JcrNodeDefinition>(nodeType.getDeclaredChildNodeDefinitions().length);
+ List<JcrNodeDefinition> nodeDefs = new ArrayList<JcrNodeDefinition>(
+ nodeType.getDeclaredChildNodeDefinitions().length);
- for (JcrNodeDefinition nodeDef : nodeType.getDeclaredChildNodeDefinitions()) {
- JcrNodeType[] requiredPrimaryTypes = new JcrNodeType[nodeDef.requiredPrimaryTypeNames().length];
+ for (JcrNodeDefinition nodeDef : nodeType.getDeclaredChildNodeDefinitions()) {
+ JcrNodeType[] requiredPrimaryTypes = new JcrNodeType[nodeDef.requiredPrimaryTypeNames().length];
- int i = 0;
- for (Name primaryTypeName : nodeDef.requiredPrimaryTypeNames()) {
- requiredPrimaryTypes[i] = findTypeInMapOrList(primaryTypeName, typesPendingRegistration);
+ int i = 0;
+ for (Name primaryTypeName : nodeDef.requiredPrimaryTypeNames()) {
+ requiredPrimaryTypes[i] = findTypeInMapOrList(primaryTypeName, typesPendingRegistration);
- if (requiredPrimaryTypes[i] == null) {
- throw new RepositoryException(JcrI18n.invalidPrimaryTypeName.text(primaryTypeName, nodeType.getName()));
+ if (requiredPrimaryTypes[i] == null) {
+ throw new RepositoryException(
+ JcrI18n.invalidPrimaryTypeName.text(primaryTypeName, nodeType.getName()));
+ }
+ i++;
}
- i++;
+
+ nodeDefs.add(nodeDef.with(this.context).with(this));
}
- nodeDefs.add(nodeDef.with(this.context).with(this));
+ // Create a new node type that also has the correct property and child node definitions associated
+ JcrNodeType newNodeType = new JcrNodeType(this.context, this, nodeType.getInternalName(), supertypes,
+ nodeType.getInternalPrimaryItemName(), nodeDefs, propertyDefs,
+ nodeType.isMixin(), nodeType.hasOrderableChildNodes());
+ typesPendingRegistration.add(newNodeType);
}
- // Create a new node type that also has the correct property and child node definitions associated
- JcrNodeType newNodeType = new JcrNodeType(this.context, this, nodeType.getInternalName(), supertypes,
- nodeType.getInternalPrimaryItemName(), nodeDefs, propertyDefs,
- nodeType.isMixin(), nodeType.hasOrderableChildNodes());
- typesPendingRegistration.add(newNodeType);
- }
+ // Graph.Batch batch = graph.batch();
+ for (JcrNodeType nodeType : typesPendingRegistration) {
+ /*
+ * See comment in constructor. Using a ConcurrentHashMap seems to be to weak of a
+ * solution (even it were also used for childNodeDefinitions and propertyDefinitions).
+ * Probably need to block all read access to these maps during this phase of registration.
+ */
+ nodeTypes.put(nodeType.getInternalName(), nodeType);
+ for (JcrNodeDefinition childDefinition : nodeType.childNodeDefinitions()) {
+ childNodeDefinitions.put(childDefinition.getId(), childDefinition);
+ }
+ for (JcrPropertyDefinition propertyDefinition : nodeType.propertyDefinitions()) {
+ propertyDefinitions.put(propertyDefinition.getId(), propertyDefinition);
+ }
- // Graph.Batch batch = graph.batch();
- for (JcrNodeType nodeType : typesPendingRegistration) {
- /*
- * See comment in constructor. Using a ConcurrentHashMap seems to be to weak of a
- * solution (even it were also used for childNodeDefinitions and propertyDefinitions).
- * Probably need to block all read access to these maps during this phase of registration.
- */
- nodeTypes.put(nodeType.getInternalName(), nodeType);
- for (JcrNodeDefinition childDefinition : nodeType.childNodeDefinitions()) {
- childNodeDefinitions.put(childDefinition.getId(), childDefinition);
+ // projectNodeTypeOnto(nodeType, parentOfTypeNodes, batch);
}
- for (JcrPropertyDefinition propertyDefinition : nodeType.propertyDefinitions()) {
- propertyDefinitions.put(propertyDefinition.getId(), propertyDefinition);
- }
-
- // projectNodeTypeOnto(nodeType, parentOfTypeNodes, batch);
+ } finally {
+ nodeTypeManagerLock.writeLock().unlock();
}
-
// batch.execute();
return typesPendingRegistration;
15 years, 1 month
DNA SVN: r895 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-07 10:30:44 -0400 (Thu, 07 May 2009)
New Revision: 895
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java
Log:
DNA-397 Expose JCR Node Type Registration through Public API
Applied the patch, which exposes methods for registering one or multiple NodeTypeDefinitions, as per JSR-283 spec. The patch also adds methods to create node type, node definition, and property definition templates, also per the -283 spec.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java 2009-05-06 21:11:42 UTC (rev 894)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java 2009-05-07 14:30:44 UTC (rev 895)
@@ -28,6 +28,7 @@
import java.util.List;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.Value;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.nodetype.NodeDefinition;
@@ -38,6 +39,12 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate;
+import org.jboss.dna.jcr.nodetype.NodeTypeDefinition;
+import org.jboss.dna.jcr.nodetype.NodeTypeExistsException;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
+import org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate;
/**
* Local implementation of @{link NodeTypeManager}. This class handles translation between {@link Name}s and {@link String}s based
@@ -178,7 +185,7 @@
* This method first attempts to find a single-valued property definition with the supplied property name and
* {@link Value#getType() value's property type} in the primary type, skipping any property definitions that are protected.
* The property definition is returned if it has a matching type (or has an {@link PropertyType#UNDEFINED undefined property
- * type}) and the value satisfies the {@link PropertyDefinition#getValueConstraints() definition's constraints}. Otherwise,
+ * type}) and the value satisfies the {@link PropertyDefinition#getValueConstraints() definition's constraints} . Otherwise,
* the process continues with each of the mixin types, in the order they are named.
* </p>
* <p>
@@ -237,7 +244,7 @@
* This method first attempts to find a single-valued property definition with the supplied property name and
* {@link Value#getType() value's property type} in the primary type, skipping any property definitions that are protected.
* The property definition is returned if it has a matching type (or has an {@link PropertyType#UNDEFINED undefined property
- * type}) and the value satisfies the {@link PropertyDefinition#getValueConstraints() definition's constraints}. Otherwise,
+ * type}) and the value satisfies the {@link PropertyDefinition#getValueConstraints() definition's constraints} . Otherwise,
* the process continues with each of the mixin types, in the order they are named.
* </p>
* <p>
@@ -359,4 +366,88 @@
skipProtected);
}
+ /**
+ * Registers a new node type or updates an existing node type using the specified definition and returns the resulting
+ * {@link NodeType} object.
+ * <p>
+ * Typically, the object passed to this method will be a {@link NodeTypeTemplate} (a subclass of {@link NodeTypeDefinition})
+ * acquired from {@link JcrNodeTypeManager#createNodeTypeTemplate()} and then filled-in with definition information.
+ * </p>
+ *
+ * @param template the new node type to register
+ * @param allowUpdate must be {@code false}; DNA does not allow updating node types at this time
+ * @return the {@code newly created node type}
+ * @throws InvalidNodeTypeDefinitionException if the {@code NodeTypeDefinition} is invalid
+ * @throws NodeTypeExistsException if {@code allowUpdate} is false and the {@code NodeTypeDefinition} specifies a node type
+ * name that already exists
+ * @throws UnsupportedRepositoryOperationException if {@code allowUpdate} is true; DNA does not allow updating node types at
+ * this time.
+ * @throws RepositoryException if another error occurs
+ */
+ public NodeType registerNodeType( NodeTypeDefinition template,
+ boolean allowUpdate )
+ throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException,
+ RepositoryException {
+ return this.repositoryTypeManager.registerNodeType(template, allowUpdate);
+ }
+
+ /**
+ * Registers or updates the specified Collection of {@code NodeTypeDefinition} objects. This method is used to register or
+ * update a set of node types with mutual dependencies. Returns an iterator over the resulting {@code NodeType} objects.
+ * <p>
+ * The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
+ * </p>
+ *
+ * @param templates the new node types to register
+ * @param allowUpdates must be {@code false}; DNA does not allow updating node types at this time
+ * @return the {@code newly created node types}
+ * @throws InvalidNodeTypeDefinitionException if a {@code NodeTypeDefinition} within the collection is invalid
+ * @throws NodeTypeExistsException if {@code allowUpdate} is false and a {@code NodeTypeDefinition} within the collection
+ * specifies a node type name that already exists
+ * @throws UnsupportedRepositoryOperationException if {@code allowUpdate} is true; DNA does not allow updating node types at
+ * this time.
+ * @throws RepositoryException if another error occurs
+ */
+ public NodeTypeIterator registerNodeTypes( Collection<NodeTypeDefinition> templates,
+ boolean allowUpdates )
+ throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException,
+ RepositoryException {
+ return new JcrNodeTypeIterator(this.repositoryTypeManager.registerNodeTypes(templates, allowUpdates));
+ }
+
+ /**
+ * Returns an empty {@code NodeTypeTemplate} which can then be used to define a node type and passed to
+ * {@link JcrNodeTypeManager#registerNodeType(NodeTypeDefinition, boolean)}
+ *
+ * @return an empty {@code NodeTypeTemplate} which can then be used to define a node type and passed to
+ * {@link JcrNodeTypeManager#registerNodeType(NodeTypeDefinition, boolean)}.
+ * @throws RepositoryException if another error occurs
+ */
+ public NodeTypeTemplate createNodeTypeTemplate() throws RepositoryException {
+ return new JcrNodeTypeTemplate(this.context);
+ }
+
+ /**
+ * Returns an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to
+ * a {@code NodeTypeTemplate}.
+ *
+ * @return an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to
+ * a {@code NodeTypeTemplate}.
+ * @throws RepositoryException if another error occurs
+ */
+ public NodeDefinitionTemplate createNodeDefinitionTemplate() throws RepositoryException {
+ return new JcrNodeDefinitionTemplate(this.context);
+ }
+
+ /**
+ * Returns an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to
+ * a {@code NodeTypeTemplate}.
+ *
+ * @return an empty {@code PropertyDefinitionTemplate} which can then be used to create a property definition and attached to
+ * a {@code NodeTypeTemplate}.
+ * @throws RepositoryException if another error occurs
+ */
+ public PropertyDefinitionTemplate createPropertyDefinitionTemplate() throws RepositoryException {
+ return new JcrPropertyDefinitionTemplate(this.context);
+ }
}
15 years, 1 month
DNA SVN: r894 - in tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main: config and 1 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-05-06 17:11:42 -0400 (Wed, 06 May 2009)
New Revision: 894
Added:
tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/config/run.cmd
Modified:
tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml
tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
Log:
Backed DNA-396 patches from trunk into 0.4 branch
Modified: tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml
===================================================================
--- tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml 2009-05-06 20:53:31 UTC (rev 893)
+++ tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml 2009-05-06 21:11:42 UTC (rev 894)
@@ -35,6 +35,10 @@
<fileMode>0744</fileMode>
</file>
<file>
+ <source>src/main/config/run.cmd</source>
+ <fileMode>0744</fileMode>
+ </file>
+ <file>
<source>src/main/resources/jackrabbitConfig.xml</source>
<fileMode>0644</fileMode>
</file>
Added: tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/config/run.cmd
===================================================================
--- tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/config/run.cmd (rev 0)
+++ tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/config/run.cmd 2009-05-06 21:11:42 UTC (rev 894)
@@ -0,0 +1 @@
+java -Djava.ext.dirs=./lib -cp dna-example-sequencers-0.5-SNAPSHOT.jar org.jboss.example.dna.sequencer.SequencingClient %*
Modified: tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-05-06 20:53:31 UTC (rev 893)
+++ tags/dna-0.4/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-05-06 21:11:42 UTC (rev 894)
@@ -316,6 +316,11 @@
String nodePath = this.userInterface.getRepositoryPath("/a/b/" + filename);
String mimeType = getMimeType(url);
+ if (mimeType == null) {
+ System.err.println("Could not determine mime type for file. Cancelling upload.");
+ return;
+ }
+
// Now use the JCR API to upload the file ...
Session session = createSession();
JcrTools tools = this.executionContext.getTools();
@@ -565,7 +570,7 @@
if (filename.endsWith(".ras")) return "image/x-cmu-raster";
if (filename.endsWith(".mp3")) return "audio/mpeg";
if (filename.endsWith(".java")) return "text/x-java-source";
- throw new SystemFailureException("Unknown mime type for " + file);
+ return null;
}
}
15 years, 1 month