You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by sb...@apache.org on 2015/02/16 19:14:22 UTC

svn commit: r1660179 [1/3] - in /sling/trunk/contrib/commons/js/nodetypes: ./ src/ src/main/ src/main/java/ src/main/java/de/ src/main/java/de/sandroboehme/ src/main/java/de/sandroboehme/jsnodetypes/ src/main/java/de/sandroboehme/jsnodetypes/downloadde...

Author: sboehme
Date: Mon Feb 16 18:14:21 2015
New Revision: 1660179

URL: http://svn.apache.org/r1660179
Log:
SLING-4364 :: Integrate new JavaScript node type library

Added:
    sling/trunk/contrib/commons/js/nodetypes/LICENSE.txt
    sling/trunk/contrib/commons/js/nodetypes/README.md
    sling/trunk/contrib/commons/js/nodetypes/pom.xml
    sling/trunk/contrib/commons/js/nodetypes/src/
    sling/trunk/contrib/commons/js/nodetypes/src/main/
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONItemDefinition.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeDefinition.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeType.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONPropertyDefinition.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONValue.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/NodeTypesJSONServlet.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AbstractPropertyMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AutoCreatedMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/DownloadDefaultBinaryValueServlet.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MandatoryMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MultipleMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/OnParentVersionMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyNameMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/ProtectedMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/RequiredPropertyTypeMatcher.java
    sling/trunk/contrib/commons/js/nodetypes/src/main/javascript/
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/content.json
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/documentation/
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/documentation/html.jsp
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/js/
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/js/defaultNT/
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/js/defaultNT/defaultNT.json
    sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/js/jsnodetypes.js
    sling/trunk/contrib/commons/js/nodetypes/src/test/
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/ChildNodeDefGenerationTest.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/DefaultNodeTypeTest.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/GenerationConstants.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/NodeTypeGenerationTest.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/PropertyDefGenerationTest.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/DownloadDefaultBinaryValueTest.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/mock/
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/mock/MockNodeTypeGenerator.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/mock/MockPropertyDefGenerator.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/test/
    sling/trunk/contrib/commons/js/nodetypes/src/test/java/de/sandroboehme/jsnodetypes/test/JSONAssert.java
    sling/trunk/contrib/commons/js/nodetypes/src/test/javascript/
    sling/trunk/contrib/commons/js/nodetypes/src/test/javascript/NodeTypesSpec.js
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/applicableChildNodeTypesDatastructure.jpg   (with props)
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteBinaryPropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteBooleanPropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteChildNodeDefinitions.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteDatePropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteDoublePropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteLongPropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteNamePropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteNodeTypes.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompletePathPropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteReferencePropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testCompleteStringPropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testIfDefaultsAreOmittedWithServlet.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testIfDefaultsAreOmittedWithoutServlet.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testMultipleConstraints.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testMultipleDefaultValues.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testNodeTypeWithEmptyName.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testOneSimpleChildNodeDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testOneSimpleNodeType.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testOneSimplePropertyDefinition.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testResidualChildNodeDefinitions.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testSimpleChildNodeDefinitions.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testSimpleNodeTypes.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testSupertypeList.json
    sling/trunk/contrib/commons/js/nodetypes/src/test/resources/expectedNTJSON/testTwoResidualPropertyDefinitions.json
Modified:
    sling/trunk/contrib/commons/js/nodetypes/   (props changed)

Propchange: sling/trunk/contrib/commons/js/nodetypes/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Feb 16 18:14:21 2015
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project

Added: sling/trunk/contrib/commons/js/nodetypes/LICENSE.txt
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/LICENSE.txt?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/LICENSE.txt (added)
+++ sling/trunk/contrib/commons/js/nodetypes/LICENSE.txt Mon Feb 16 18:14:21 2015
@@ -0,0 +1,175 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.

Added: sling/trunk/contrib/commons/js/nodetypes/README.md
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/README.md?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/README.md (added)
+++ sling/trunk/contrib/commons/js/nodetypes/README.md Mon Feb 16 18:14:21 2015
@@ -0,0 +1,5 @@
+jsNodeTypes - The JavaScript Node Types library for Apache Sling
+=============
+
+A public documentation of the library can be found at: http://www.jcrbrowser.org/sling/libs/jsnodetypes/content/documentation.html.
+The documentation of the library version you deployed is shipped with the bundle. It can be found at http://[yourserver]:[yourport]/libs/jsnodetypes/content/documentation.html

Added: sling/trunk/contrib/commons/js/nodetypes/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/pom.xml?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/pom.xml (added)
+++ sling/trunk/contrib/commons/js/nodetypes/pom.xml Mon Feb 16 18:14:21 2015
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+	license agreements. See the NOTICE file distributed with this work for additional 
+	information regarding copyright ownership. The ASF licenses this file to 
+	you under the Apache License, Version 2.0 (the "License"); you may not use 
+	this file except in compliance with the License. You may obtain a copy of 
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+	by applicable law or agreed to in writing, software distributed under the 
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+	OF ANY KIND, either express or implied. See the License for the specific 
+	language governing permissions and limitations under the License. -->
+<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>
+		<groupId>org.apache.sling</groupId>
+		<artifactId>sling</artifactId>
+		<version>22</version>
+		<relativePath>../../../../parent/pom.xml</relativePath>
+	</parent>
+
+	<artifactId>org.apache.sling.commons.js.nodetypes</artifactId>
+	<packaging>bundle</packaging>
+	<version>0.1.0-SNAPSHOT</version>
+
+	<name>jsNodeTypes</name>
+	<description>
+	Uses Apache Sling to generate a JavaScript representation of JCR node types.
+    </description>
+
+	<licenses>
+		<license>
+			<name>The Apache Software License, Version 2.0</name>
+			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+			<distribution>repo</distribution>
+		</license>
+	</licenses>
+
+	<scm>
+		<connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/commons/jsnodetypes</connection>
+		<developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/commons/jsnodetypes</developerConnection>
+		<url>http://svn.apache.org/viewvc/sling/trunk/contrib/commons/jsnodetypes</url>
+	</scm>
+
+	<build>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<groupId>com.github.searls</groupId>
+					<artifactId>jasmine-maven-plugin</artifactId>
+					<version>1.3.1.0</version>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+		<plugins>
+			<plugin>
+				<groupId>com.github.searls</groupId>
+				<artifactId>jasmine-maven-plugin</artifactId>
+				<version>1.3.1.0</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>test</goal>
+						</goals>
+					</execution>
+				</executions>
+				<configuration>
+					<specRunnerTemplate>DEFAULT</specRunnerTemplate>
+					<jsSrcDir>${project.basedir}/src/main/resources/SLING-INF/libs/jsnodetypes/js</jsSrcDir>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Sling-Initial-Content>SLING-INF/libs/jsnodetypes;overwrite:=true;path:=/libs/jsnodetypes;uninstall:=true,SLING-INF/libs/jsnodetypes/documentation;overwrite:=true;path:=/libs/jsnodetypes/documentation;ignoreImportProviders:=json;uninstall:=true,SLING-INF/libs/jsnodetypes/js;overwrite:=true;path:=/libs/jsnodetypes/js;ignoreImportProviders:=json;uninstall:=true</Sling-Initial-Content>
+						<Export-Package>de.sandroboehme.jsnodetypes.javascript</Export-Package>
+						<Provide-Capability>${project.artifactId}; version:Version=1.0.7</Provide-Capability>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-scr-plugin</artifactId>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.sling</groupId>
+				<artifactId>maven-sling-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>install-bundle</id>
+						<goals>
+							<goal>validate</goal>
+							<goal>install</goal>
+						</goals>
+						<configuration>
+							<mountByFS>false</mountByFS>
+							<slingUrl>http://localhost:8080/system/console</slingUrl>
+							<user>admin</user>
+							<password>admin</password>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<argLine>-Xmx448m</argLine>
+				</configuration>
+			</plugin>
+		</plugins>
+		<extensions>
+			<extension>
+				<groupId>org.apache.maven.wagon</groupId>
+				<artifactId>wagon-webdav-jackrabbit</artifactId>
+				<version>2.2</version>
+			</extension>
+		</extensions>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.sling</groupId>
+			<artifactId>org.apache.sling.commons.json</artifactId>
+			<version>2.0.10</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.jackrabbit</groupId>
+			<artifactId>jackrabbit-jcr-commons</artifactId>
+			<version>2.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>javax.jcr</groupId>
+			<artifactId>jcr</artifactId>
+			<version>2.0</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.sling</groupId>
+			<artifactId>org.apache.sling.api</artifactId>
+			<version>2.0.8</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.sling</groupId>
+			<artifactId>org.apache.sling.commons.osgi</artifactId>
+			<version>2.0.6</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.scr.annotations</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<!-- Testing -->
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-all</artifactId>
+			<version>1.9.5</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-simple</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+</project>
\ No newline at end of file

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONItemDefinition.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONItemDefinition.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONItemDefinition.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONItemDefinition.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes;
+
+import javax.jcr.nodetype.ItemDefinition;
+import javax.jcr.version.OnParentVersionAction;
+
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+
+/**
+ * Represents an ItemDefinition in JSON.
+ */
+public class JSONItemDefinition {
+
+	protected JSONObject jsonObj = new JSONObject();
+	
+	public JSONItemDefinition(ItemDefinition itemDefinition) throws JSONException {
+		
+		jsonObj.put("name", itemDefinition.getName());
+		
+		if (itemDefinition.isAutoCreated()){
+			jsonObj.put("autoCreated", true);
+		}
+		if (itemDefinition.isMandatory()){
+			jsonObj.put("mandatory", true);
+		}
+		if (itemDefinition.isProtected()){
+			jsonObj.put("protected", true);
+		}
+		boolean onParentVersionIsUnset = itemDefinition.getOnParentVersion() == 0;
+		int onParentVersion = onParentVersionIsUnset ? OnParentVersionAction.COPY : itemDefinition.getOnParentVersion();
+		String onParentVersionAction = OnParentVersionAction.nameFromValue(onParentVersion);
+		if (!"COPY".equals(onParentVersionAction)){
+			jsonObj.put("onParentVersion", onParentVersionAction);
+		}
+	}
+	
+	JSONObject getJSONObject(){
+		return jsonObj;
+	}
+	
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeDefinition.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeDefinition.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeDefinition.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeDefinition.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
+
+/**
+ * Represents a NodeDefinition in JSON.
+ *
+ */
+public class JSONNodeDefinition extends JSONItemDefinition {
+
+	public JSONNodeDefinition(NodeDefinition childNodeDefinition) throws JSONException {
+		super(childNodeDefinition);
+
+		if (childNodeDefinition.allowsSameNameSiblings()){
+			jsonObj.put("allowsSameNameSiblings", true);
+		}
+		NodeType defaultPrimaryType = childNodeDefinition.getDefaultPrimaryType();
+		if (defaultPrimaryType!=null){
+			String defaultPrimaryTypeName = defaultPrimaryType.getName();
+			if (defaultPrimaryTypeName != null && !defaultPrimaryTypeName.equals("")){
+				jsonObj.put("defaultPrimaryType", defaultPrimaryTypeName);
+			}
+		}
+
+		NodeType[] primaryTypes = childNodeDefinition.getRequiredPrimaryTypes();
+		List<String> primaryTypeNames = new ArrayList<String>();
+		for (NodeType primaryType : primaryTypes) {
+			String primaryTypeName = primaryType.getName();
+			if (primaryTypeName != null) {
+				primaryTypeNames.add(primaryTypeName);
+			}
+		}
+		if (primaryTypeNames.size()>0 && !(primaryTypeNames.size()==1 && primaryTypeNames.get(0).equals("nt:base")) ){
+			jsonObj.put("requiredPrimaryTypes", new JSONArray(primaryTypeNames));
+		}
+	}
+
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeType.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeType.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeType.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONNodeType.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.PropertyDefinition;
+
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+
+/**
+ * Represents a NodeType in JSON.
+ *
+ */
+public class JSONNodeType {
+
+	private JSONObject jsonObj = new JSONObject();
+
+	public JSONNodeType(NodeType nodeType) throws ValueFormatException, RepositoryException, JSONException {
+		NodeDefinition[] declaredChildNodeDefinitions = nodeType.getDeclaredChildNodeDefinitions();
+		if (declaredChildNodeDefinitions != null) {
+			JSONArray jsonChildNodeDefArray = new JSONArray();
+			for (NodeDefinition childNodeDefinition : nodeType.getDeclaredChildNodeDefinitions()) {
+				String childNodeName = childNodeDefinition.getName();
+				if (childNodeName != null) {
+					JSONNodeDefinition jsonChildNodeDefinition = new JSONNodeDefinition(childNodeDefinition);
+					jsonChildNodeDefArray.put(jsonChildNodeDefinition.getJSONObject());
+				}
+			}
+			if (jsonChildNodeDefArray.length()>0){
+				jsonObj.put("declaredChildNodeDefinitions",jsonChildNodeDefArray);
+			}
+		}
+
+		PropertyDefinition[] declaredPropertyDefinitions = nodeType.getDeclaredPropertyDefinitions();
+		if (declaredPropertyDefinitions != null) {
+			JSONArray jsonPropDefArray = new JSONArray();
+			for (PropertyDefinition propertyDefinition : declaredPropertyDefinitions) {
+				JSONPropertyDefinition jsonPropertyDefinition = new JSONPropertyDefinition(propertyDefinition);
+				jsonPropDefArray.put(jsonPropertyDefinition.getJSONObject());
+			}
+			if (jsonPropDefArray.length()>0){
+				jsonObj.put("declaredPropertyDefinitions",jsonPropDefArray);
+			}
+		}
+
+		NodeType[] superTypes = nodeType.getDeclaredSupertypes();
+		List<String> superTypeNames = new ArrayList<String>();
+		for (NodeType superType : superTypes) {
+			superTypeNames.add(superType.getName());
+		}
+		if (superTypeNames.size()>0 && !("nt:base".equals(superTypeNames.get(0)) && superTypeNames.size()==1)){
+			jsonObj.put("declaredSupertypes", new JSONArray(superTypeNames));
+		}
+		if (nodeType.isMixin()){
+			jsonObj.put("mixin", true);
+		}
+		if (nodeType.hasOrderableChildNodes()){
+			jsonObj.put("orderableChildNodes", true);
+		}
+		String thePrimaryItemName = nodeType.getPrimaryItemName();
+		if (thePrimaryItemName != null && !thePrimaryItemName.equals("")){
+			jsonObj.put("primaryItemName", nodeType.getPrimaryItemName());
+		}
+	}
+	
+	JSONObject getJson(){
+		return jsonObj;
+	}
+
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONPropertyDefinition.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONPropertyDefinition.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONPropertyDefinition.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONPropertyDefinition.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.PropertyDefinition;
+
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
+
+/**
+ * Represents a PropertyDefinition in JSON.
+ *
+ */
+public class JSONPropertyDefinition extends JSONItemDefinition {
+
+	public JSONPropertyDefinition(PropertyDefinition propertyDefinition) throws ValueFormatException, RepositoryException, JSONException {
+		super(propertyDefinition);
+
+		Value[] defaultValues = propertyDefinition.getDefaultValues();
+		JSONArray defaultValueArray = new JSONArray();
+		if (defaultValues != null) {
+			if (defaultValues !=null){
+				for (int i=0; i<defaultValues.length; i++){
+					Value defaultValue = defaultValues[i];
+					JSONValue jsonValue = new JSONValue(defaultValue, i, propertyDefinition);
+					defaultValueArray.put(jsonValue.getJSONObject());
+				}
+			}
+		}
+
+		if (defaultValueArray.length()>0){
+			jsonObj.put("defaultValues", defaultValueArray);
+		}
+		String theRequiredType = PropertyType.nameFromValue(propertyDefinition.getRequiredType());
+		if (theRequiredType!=null && !theRequiredType.equals("") && !("String".equals(theRequiredType))){
+			jsonObj.put("requiredType", theRequiredType);
+		}
+		if (propertyDefinition.getValueConstraints()!=null){
+			List<String> theValueConstraints = Arrays.asList(propertyDefinition.getValueConstraints());
+			if (theValueConstraints != null && theValueConstraints.size()>0){
+				jsonObj.put("valueConstraints", theValueConstraints);
+			}
+		}
+		if (propertyDefinition.isMultiple()){
+			jsonObj.put("multiple", true);
+		}
+	}
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONValue.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONValue.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONValue.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/JSONValue.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.version.OnParentVersionAction;
+
+import org.apache.jackrabbit.util.ISO8601;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+
+/**
+ * Represents a javax.jcr.Value in JSON.
+ *
+ */
+public class JSONValue {
+
+	transient JSONObject jsonObj = new JSONObject();
+	
+    public JSONValue(Value aValue, int index, PropertyDefinition propertyDef) throws ValueFormatException, RepositoryException, IllegalStateException, JSONException{
+    	switch (aValue.getType()) {
+		case PropertyType.STRING:
+			jsonObj.put("string", aValue.getString());
+			break;
+		case PropertyType.DATE:
+	    	String date = aValue.getDate() == null ? "" : ISO8601.format(aValue.getDate());
+			jsonObj.put("date", date);
+			break;
+		case PropertyType.BINARY:
+			String binary = getBinaryDownloadURLFromPropertyDef(index, propertyDef);
+			jsonObj.put("binary", binary);
+			break;
+		case PropertyType.DOUBLE:
+			jsonObj.put("double", aValue.getDouble());
+			break;
+		case PropertyType.LONG:
+			jsonObj.put("long", aValue.getLong());
+			break;
+		case PropertyType.BOOLEAN:
+			jsonObj.put("boolean", aValue.getBoolean());
+			break;
+		case PropertyType.NAME:
+			jsonObj.put("name",  aValue.getString());
+			break;
+		case PropertyType.PATH:
+			jsonObj.put("path",  aValue.getString());
+			break;
+		case PropertyType.REFERENCE:
+			jsonObj.put("reference",  aValue.getString());
+			break;
+		case PropertyType.UNDEFINED:
+			jsonObj.put("undefined",  aValue.getString());
+			break;
+/// The following property types are from JSR-283 / JCR 2.0
+		case PropertyType.WEAKREFERENCE:
+			jsonObj.put("weakReference",  aValue.getString());
+			break;
+		case PropertyType.URI:
+			jsonObj.put("uri",  aValue.getString());
+			break;
+		case PropertyType.DECIMAL:
+			String decimal = aValue.getDecimal() == null ? "" : aValue.getDecimal().toString();
+			jsonObj.put("decimal", decimal);
+			break;
+
+		default:
+			break;
+		}
+    	String type = PropertyType.nameFromValue(aValue.getType());
+		jsonObj.put("type", type);
+	}
+
+	private String getBinaryDownloadURLFromPropertyDef(int index, PropertyDefinition propertyDef) {
+		String nodeTypeName = propertyDef.getDeclaringNodeType().getName();
+		String propertyName = propertyDef.getName();
+		String propertyType = PropertyType.nameFromValue(propertyDef.getRequiredType());
+		boolean isAutoCreated = propertyDef.isAutoCreated();
+		boolean isMandatory = propertyDef.isMandatory();
+		boolean isProtected = propertyDef.isProtected();
+		boolean isMultiple = propertyDef.isMultiple();
+		String onParentVersionAction = OnParentVersionAction.nameFromValue(propertyDef.getOnParentVersion());
+		return String.format("/%s/%s/%s/%s/%s/%s/%s/%s/%s.default_binary_value.bin", nodeTypeName, propertyName,
+				propertyType, isAutoCreated, isMandatory, isProtected, isMultiple, onParentVersionAction, index);
+	}
+	
+    JSONObject getJSONObject(){
+    	return jsonObj;
+    }
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/NodeTypesJSONServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/NodeTypesJSONServlet.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/NodeTypesJSONServlet.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/NodeTypesJSONServlet.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Returns all completely registered node types of the repository in JSON format. Nodetypes without names will not end up in the JSON file.
+ * The binary default values of properties will not be part of the JSON file. They will have a String containing a URL. Use this URL to
+ * download the binary content.
+ *  
+ * The URL is <code>/libs/jsnodetypes/content/nodetypes.json</code>.
+ */
+@Component
+@Service(Servlet.class)
+@Properties({ @Property(name = "service.description", value = "Returns the node types as a JSON file"),
+		@Property(name = "service.vendor", value = "Sandro Boehme"),
+		@Property(name = "sling.servlet.extensions", value = "json"),
+		@Property(name = "sling.servlet.resourceTypes", value = "jsnodetypes")
+
+})
+public class NodeTypesJSONServlet extends SlingSafeMethodsServlet {
+	/*
+	 * In /src/main/resources/libs/jsnodetypes/content.json there is an automatically loaded node with a child node
+	 * that has the resource type 'jsnodetypes'. This servlet can render this resource type and thus provides the JSON
+	 * content at the URL as written in the JavaDoc.
+	 */
+
+	private static final long serialVersionUID = -1L;
+
+	/** default log */
+	private final Logger log = LoggerFactory.getLogger(NodeTypesJSONServlet.class);
+
+	@Override
+	protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
+		response.setContentType("application/json; charset=UTF-8");
+		PrintWriter writer = response.getWriter();
+		Resource resource = request.getResource();
+		Node currentNode = resource.adaptTo(Node.class);
+		try {
+			NodeTypeIterator nodeTypeIterator = currentNode.getSession().getWorkspace().getNodeTypeManager().getAllNodeTypes();
+	        JSONObject nodeTypes = new JSONObject();
+			while (nodeTypeIterator.hasNext()) {
+				NodeType nodeType = nodeTypeIterator.nextNodeType();
+				if (nodeType.getName() != null) {
+					JSONNodeType jsonNodeType = new JSONNodeType(nodeType);
+					nodeTypes.put(nodeType.getName(), jsonNodeType.getJson());
+				}
+			}
+			writer.println(nodeTypes.toString(2));
+			writer.flush();
+			writer.close();
+		} catch (RepositoryException e) {
+			log.error("Could not generate the node types.", e);
+			response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+		} catch (JSONException e) {
+			log.error("Could not generate the node types.", e);
+			response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+		}
+
+	}
+
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AbstractPropertyMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AbstractPropertyMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AbstractPropertyMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AbstractPropertyMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+/**
+ * Makes it possible to specify the array and index but retrieving it on demand lazily. 
+ */
+public class AbstractPropertyMatcher {
+	
+	protected String[] idFields;
+	protected int index;
+
+	public String getArrayValue(String[] idFields, int index) {
+		if (index <= idFields.length-1){
+			return idFields[index];
+		}
+		return null;
+	}
+
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AutoCreatedMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AutoCreatedMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AutoCreatedMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/AutoCreatedMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import javax.jcr.nodetype.PropertyDefinition;
+
+public class AutoCreatedMatcher extends AbstractPropertyMatcher implements PropertyMatcher{
+
+	public AutoCreatedMatcher(String[] idFields, int index){
+		super.idFields = idFields;
+		super.index = index;
+	}
+	
+	@Override
+	public boolean match(PropertyDefinition propertyDefinition) {
+		String arrayValue = super.getArrayValue(idFields, index);
+		if (arrayValue!=null){
+			boolean isAutoCreated = Boolean.parseBoolean(arrayValue);
+			return isAutoCreated == propertyDefinition.isAutoCreated();
+		}
+		return false;
+	}
+	
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/DownloadDefaultBinaryValueServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/DownloadDefaultBinaryValueServlet.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/DownloadDefaultBinaryValueServlet.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/DownloadDefaultBinaryValueServlet.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides a download for binary default values.
+ * 
+ * The fully qualified URL to specify a default value looks like this:
+ * <code>/ns:ntName/binPropDef/binary/true/true/true/true/version/1.default_binary_value.bin</code>
+ * The fully qualified format is: <code>/node type/property definition
+ * name/required property type name/is autoCreated/is mandatory/is
+ * protected/is multiple/on parent version action name/index of the
+ * default value.default_binary_value.bin</code>
+ * 
+ * In case you know which elements identify a property definition unambiguously
+ * you can shorten the URL. E.g. if you are sure the property definition
+ * 'binPropDef' does not exist twice within the node type 'ns:ntName' you can
+ * use the URL <code>/ns:ntName/binPropDef/1.default_binary_value.bin</code> to
+ * download the second binary default value from that property definition.
+ * 
+ * If you want to download the first binary default value you can shorten the
+ * URL even more by skipping the index in the URL like this:
+ * <code>/ns:ntName/binPropDef/default_binary_value.bin</code>
+ * 
+ * The type name, the boolean Strings and the parent version action name are
+ * case insensitive.
+ * 
+ * This long identification is needed as a property definition name with its
+ * type may not be unique within a node type. This is not only the case for
+ * residual property definitions. The JCR does not specify that there can be
+ * only one combination of property definition name / required property type
+ * name. Thats the reason why it is qualified like this.
+ * 
+ */
+
+@Component
+@Service(Servlet.class)
+@Properties({ @Property(name = "service.description", value = "Download Servlet for binary properties"),
+		@Property(name = "service.vendor", value = "Sandro Boehme"),
+		@Property(name = "sling.servlet.selectors", value = "default_binary_value"),
+		@Property(name = "sling.servlet.extensions", value = "bin"),
+		@Property(name = "sling.servlet.resourceTypes", value = "sling/servlet/default")
+
+})
+public class DownloadDefaultBinaryValueServlet extends SlingSafeMethodsServlet {
+
+	private static final long serialVersionUID = -1L;
+
+	/** default log */
+	private final Logger log = LoggerFactory.getLogger(DownloadDefaultBinaryValueServlet.class);
+
+	@SuppressWarnings("deprecation")
+	@Override
+	protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
+		response.setContentType("application/octet-stream; charset=UTF-8");
+		String requestURI = request.getRequestURI();
+		String[] idFields = requestURI.substring(1).split("/");
+		try {
+			NodeTypeManager nodeTypeManager = request.getResourceResolver().getResource("/").adaptTo(Node.class).getSession()
+					.getWorkspace().getNodeTypeManager();
+			NodeType nodeType = nodeTypeManager.getNodeType(idFields[0]);
+			PropertyDefinition[] propertyDefinitions = nodeType.getPropertyDefinitions();
+			List<PropertyDefinition> propertyDefinitionList = Arrays.asList(propertyDefinitions);
+			if (propertyDefinitionList != null) {
+				
+				// Every matcher represents a path element in the URL and is initialized with its value.
+				// It will try to match the value of a path element with the corresponding property 
+				// element of all property definitions from the node type in findMatchingPropertyDef().
+				PropertyMatcher[] propertyMatcher = new PropertyMatcher[] { new PropertyNameMatcher(idFields, 1),
+						new RequiredPropertyTypeMatcher(idFields, 2), new AutoCreatedMatcher(idFields, 3),
+						new MandatoryMatcher(idFields, 4), new ProtectedMatcher(idFields, 5), new MultipleMatcher(idFields, 6),
+						new OnParentVersionMatcher(idFields, 7) };
+
+				PropertyDefinition propDef = findMatchingPropertyDef(propertyDefinitionList, new LinkedList<PropertyMatcher>(
+						Arrays.asList(propertyMatcher)));
+				if (propDef != null) {
+					Value[] defaultValues = propDef.getDefaultValues();
+					if (defaultValues != null && defaultValues.length > 0) {
+						int startIndex = requestURI.lastIndexOf('/') + 1;
+						int endIndex = requestURI.indexOf("default_binary_value.bin") - 1;
+						int defaultValueIndex = 0;
+						if (endIndex - startIndex == 1) {
+							String indexString = requestURI.substring(startIndex, endIndex);
+							defaultValueIndex = Integer.parseInt(indexString);
+						}
+						try {
+							if (defaultValueIndex < defaultValues.length) {
+								Value defaultValue = defaultValues[defaultValueIndex];
+								InputStream stream = defaultValue.getStream();
+								BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream));
+								PrintWriter writer = response.getWriter();
+								String line = null;
+								while ((line = bufferedReader.readLine()) != null) {
+									writer.write(line);
+								}
+								writer.flush();
+								writer.close();
+								response.setStatus(HttpServletResponse.SC_OK);
+							} else {
+								response.sendError(HttpServletResponse.SC_NOT_FOUND);
+							}
+						} catch (NumberFormatException nfe) {
+							response.sendError(HttpServletResponse.SC_NOT_FOUND);
+						}
+					} else {
+						response.sendError(HttpServletResponse.SC_NOT_FOUND);
+					}
+				} else {
+					response.sendError(HttpServletResponse.SC_NOT_FOUND);
+				}
+			}
+		} catch (RepositoryException e) {
+			log.error("Could not return the binary file.", e);
+			throw new ServletException(e);
+		}
+	}
+
+	/**
+	 * This method pulls the first matcher out of the list and iterates over the list of specified property definitions to find matches. 
+	 * Lets say this is a PropertyNameMatcher that has been initialized with the property name from the URL. Than it will match for every
+	 * property definition who's name is equal to the one specified in the URL. The matched property definitions and the rest of the matchers
+	 * will be provided for the next recursive call of the method to work through the other path elements until all matchers are processed or
+	 * until only one property definition matches. In the first case null is returned and in the second case the identified property definition
+	 * is returned. 
+	 * @param propertyDefinitions The list of property definitions.
+	 * @param propertyMatcherList The list of matcher in the order of appearance of their type in the URL. A matcher checks if the
+	 * content of a path element it was initialized with matches its corresponding value in the property definition.
+	 * @return Returns the property definition that is identified by the URL or null if no property definition matches the values specified in the URL.
+	 */
+	private PropertyDefinition findMatchingPropertyDef(List<PropertyDefinition> propertyDefinitions,
+			List<PropertyMatcher> propertyMatcherList) {
+		if (propertyMatcherList.size() > 0) {
+			// retrieve the matcher to be used for this iteration
+			PropertyMatcher propertyMatcher = propertyMatcherList.get(0);
+			// remove the matcher to make the next matcher available for the
+			// next iteration
+			propertyMatcherList.remove(0);
+			List<PropertyDefinition> matchedPropDefs = new LinkedList<PropertyDefinition>();
+			// try to match all property definitions with the top matcher
+			for (PropertyDefinition propertyDefinition : propertyDefinitions) {
+				if (propertyMatcher.match(propertyDefinition)) {
+					matchedPropDefs.add(propertyDefinition);
+				}
+			}
+			if (matchedPropDefs.size() == 1) {
+				return matchedPropDefs.get(0);
+			} else if (matchedPropDefs.size() > 1) {
+				return findMatchingPropertyDef(matchedPropDefs, propertyMatcherList);
+			}
+		}
+		return null;
+	}
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MandatoryMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MandatoryMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MandatoryMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MandatoryMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import javax.jcr.nodetype.PropertyDefinition;
+
+public class MandatoryMatcher extends AbstractPropertyMatcher implements PropertyMatcher{
+
+	public MandatoryMatcher(String[] idFields, int index){
+		super.idFields = idFields;
+		super.index = index;
+	}
+	
+	@Override
+	public boolean match(PropertyDefinition propertyDefinition) {
+		String arrayValue = super.getArrayValue(idFields, index);
+		if (arrayValue!=null){
+			boolean isMandatory = Boolean.parseBoolean(arrayValue);
+			return isMandatory == propertyDefinition.isMandatory();
+		}
+		return false;
+	}
+	
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MultipleMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MultipleMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MultipleMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/MultipleMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import javax.jcr.nodetype.PropertyDefinition;
+
+public class MultipleMatcher extends AbstractPropertyMatcher implements PropertyMatcher{
+
+	public MultipleMatcher(String[] idFields, int index){
+		super.idFields = idFields;
+		super.index = index;
+	}
+
+	@Override
+	public boolean match(PropertyDefinition propertyDefinition) {
+		String arrayValue = super.getArrayValue(idFields, index);
+		if (arrayValue!=null){
+			boolean isMultiple = Boolean.parseBoolean(arrayValue);
+			return isMultiple == propertyDefinition.isMultiple();
+		}
+		return false;
+	}
+	
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/OnParentVersionMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/OnParentVersionMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/OnParentVersionMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/OnParentVersionMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.version.OnParentVersionAction;
+
+/**
+ * The names are not case sensitive.
+ *
+ */
+public class OnParentVersionMatcher extends AbstractPropertyMatcher implements PropertyMatcher{
+
+	public OnParentVersionMatcher(String[] idFields, int index){
+		super.idFields = idFields;
+		super.index = index;
+	}
+	
+	@Override
+	public boolean match(PropertyDefinition propertyDefinition) {
+		String arrayValue = super.getArrayValue(idFields, index);
+		if (arrayValue!=null){
+			int onParentVersion = OnParentVersionAction.valueFromName(arrayValue.toUpperCase());
+			return onParentVersion == propertyDefinition.getOnParentVersion();
+		}
+		return false;
+	}
+	
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import javax.jcr.nodetype.PropertyDefinition;
+
+public interface PropertyMatcher {
+
+	boolean match(PropertyDefinition propertyDefinition);
+
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyNameMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyNameMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyNameMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/PropertyNameMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import javax.jcr.nodetype.PropertyDefinition;
+
+public class PropertyNameMatcher extends AbstractPropertyMatcher implements PropertyMatcher{
+
+	public PropertyNameMatcher(String[] idFields, int index){
+		super.idFields = idFields;
+		super.index = index;
+	}
+	
+	@Override
+	public boolean match(PropertyDefinition propertyDefinition) {
+		String arrayValue = super.getArrayValue(idFields, index);
+		if (arrayValue!=null){
+			String propName = propertyDefinition.getName();
+			return arrayValue.equals(propName);
+		}
+		return false;
+	}
+	
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/ProtectedMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/ProtectedMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/ProtectedMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/ProtectedMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import javax.jcr.nodetype.PropertyDefinition;
+
+public class ProtectedMatcher extends AbstractPropertyMatcher implements PropertyMatcher{
+
+	public ProtectedMatcher(String[] idFields, int index){
+		super.idFields = idFields;
+		super.index = index;
+	}
+	
+	@Override
+	public boolean match(PropertyDefinition propertyDefinition) {
+		String arrayValue = super.getArrayValue(idFields, index);
+		if (arrayValue!=null){
+			boolean isProtected = Boolean.parseBoolean(arrayValue);
+			return isProtected == propertyDefinition.isProtected();
+		}
+		return false;
+	}
+	
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/RequiredPropertyTypeMatcher.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/RequiredPropertyTypeMatcher.java?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/RequiredPropertyTypeMatcher.java (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/java/de/sandroboehme/jsnodetypes/downloaddefaultbinary/RequiredPropertyTypeMatcher.java Mon Feb 16 18:14:21 2015
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package de.sandroboehme.jsnodetypes.downloaddefaultbinary;
+
+import javax.jcr.PropertyType;
+import javax.jcr.nodetype.PropertyDefinition;
+
+/**
+ * The names are not case sensitive.
+ *
+ */
+public class RequiredPropertyTypeMatcher extends AbstractPropertyMatcher implements PropertyMatcher{
+
+	public RequiredPropertyTypeMatcher(String[] idFields, int index){
+		super.idFields = idFields;
+		super.index = index;
+	}
+	
+	@Override
+	public boolean match(PropertyDefinition propertyDefinition) {
+		String arrayValue = super.getArrayValue(idFields, index);
+		if (arrayValue!=null){
+			String propTypeName = (""+arrayValue.charAt(0)).toUpperCase()+arrayValue.substring(1).toLowerCase();
+			int requiredType = PropertyType.valueFromName(propTypeName);
+			return requiredType == propertyDefinition.getRequiredType();
+		}
+		return false;
+	}
+	
+}

Added: sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/content.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/content.json?rev=1660179&view=auto
==============================================================================
--- sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/content.json (added)
+++ sling/trunk/contrib/commons/js/nodetypes/src/main/resources/SLING-INF/libs/jsnodetypes/content.json Mon Feb 16 18:14:21 2015
@@ -0,0 +1,9 @@
+{
+	"primaryNodeType": "nt:unstructured",
+	"nodetypes" : {
+		"sling:resourceType" : "jsnodetypes"
+	},
+	"documentation" : {
+		"sling:resourceType" : "jsnodetypes/documentation"
+	}
+}