Skip to content

Commit

Permalink
MODE-2356 Added embeddable WebDAV example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Horia Chiorean committed Nov 7, 2014
1 parent 43df29a commit cf1609c
Show file tree
Hide file tree
Showing 13 changed files with 464 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ignore Maven generated target folders
target
overlays

# ignore eclipse files and folders
.project
Expand Down
1 change: 1 addition & 0 deletions modeshape-rest-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<!--Exclude the default repository JSON config from the default Modeshape WAR-->
<overlay>
<id>exclude-default-config</id>
<groupId>org.modeshape</groupId>
Expand Down
4 changes: 2 additions & 2 deletions modeshape-rest-example/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<display-name>ModeShape JCR RESTful Interface Custom Configuration</display-name>

<!--
This servlet uses the ServiceLoader to find a RepositoryFactory that returns a non-null
Repository instance. (This is the idiomatic way to obtain a JCR Repository.)
This parameter defines the location of the configuration file, or can specify
the JNDI location of the Repository or Repositories implementation.
(If the object in JNDI is a ModeShape Repositories instance, then this web application
Expand All @@ -15,6 +13,8 @@
If a file is specified, ModeShape will first check for a file at this path in the filesystem.
If not file exists at this path, ModeShape will attempt to load this as a resource
from the classpath.
The JNDI location can be specified in the form jndi:<jndi_name>
-->
<context-param>
<param-name>org.modeshape.jcr.URL</param-name>
Expand Down
72 changes: 72 additions & 0 deletions modeshape-webdav-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Example Using the ModeShape WebDAV service with a custom configuration
=========================================================

What is it?
-----------

This is a self-contained and deployable Maven 3 project that shows how to use the ModeShape REST service with a custom
repository configuration

System requirements
-------------------

All you need to build this project is Java 7.0 (Java SDK 1.7) or better, Maven 3.0 or better.
The application this project produces is designed to be run on Tomcat 7.x or greater.

Build and Deploy the Example
-------------------------
_NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must use the `settings.xml`
file from the root of this project. See [this ModeShape community article](http://community.jboss.org/wiki/ModeShapeandMaven)
for help on how to install and configure Maven 3._

This project is self-contained and can be built at the top level of your local clone of the Git repository, or by simply building this project
using Maven 3.

1. Type this command to build the archive:

mvn clean package

2. This will produce a WAR file named `target/modeshape-webdav-example.war`
3. Copy the above WAR into your local `%TOMCAT_HOME%/webapps` folder
4. Start the Tomcat server


Accessing the application
-------------------------

The application will be running by default at the following URL: <http://localhost:8080/modeshape-webdav-example/>.
Open this URL in your browser and you should see and be able to navigate the configured repository.

The ModeShape project
---------------------
ModeShape is an open source implementation of the JCR 2.0
([JSR-283](http://www.jcp.org/en/jsr/detail?id=283])) specification and
standard API. To your applications, ModeShape looks and behaves like a
regular JCR repository. Applications can search, query, navigate, change,
version, listen for changes, etc. But ModeShape can store that content
in a variety of back-end stores (including relational databases, Infinispan
data grids, JBoss Cache, etc.), or it can access and update existing content
from *other* kinds of systems (including file systems, SVN repositories,
JDBC database metadata, and other JCR repositories). ModeShape's connector
architecture means that you can write custom connectors to access any
kind of system. And ModeShape can even federate multiple back-end systems
into a single, unified virtual repository.

For more information on ModeShape, including getting started guides,
reference guides, and downloadable binaries, visit the project's website
at [http://www.modeshape.org]() or follow us on our [blog](http://modeshape.wordpress.org)
or on [Twitter](http://twitter.com/modeshape). Or hop into our
[IRC chat room](http://www.jboss.org/modeshape/chat) and talk our community
of contributors and users.

The official Git repository for the project is also on GitHub at
[http://github.com/ModeShape/modeshape]().

Need help ?
-----------

ModeShape is open source software with a dedicated community. If you have
any questions or problems, post a question in our
[user forum](http://community.jboss.org/en/modeshape) or hop into our
[IRC chat room](http://www.jboss.org/modeshape/chat) and talk our
community of contributors and users.
146 changes: 146 additions & 0 deletions modeshape-webdav-example/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>org.modeshape.example</groupId>
<artifactId>modeshape-webdav-example</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Example of a custom web application that exposes the ModeShape WebDAV endpoint</name>
<description>
A simple web application that overlays a custom repository configuration on top of the OOTB modeshape-web-jcr-webdav-war.
This is the idiomatic way in which projects can customize ModeShape with their own configuration and expose the WebDAV enpoint.
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>

<!-- Maven plugin versions -->
<version.assembly.plugin>2.4</version.assembly.plugin>
<version.clean.plugin>2.5</version.clean.plugin>
<version.compiler.plugin>3.0</version.compiler.plugin>
<version.dependency.plugin>2.6</version.dependency.plugin>
<version.install.plugin>2.4</version.install.plugin>
<version.jar.plugin>2.4</version.jar.plugin>
<version.resources.plugin>2.6</version.resources.plugin>
<version.surefire.plugin>2.12.3</version.surefire.plugin>
<version.war.plugin>2.3</version.war.plugin>

<!-- Global dependency version information-->
<modeshape.version>4.0.0.Final</modeshape.version>
<jdbc.h2.version>1.2.124</jdbc.h2.version>
<version.log4j>1.2.16</version.log4j>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.modeshape.bom</groupId>
<artifactId>modeshape-bom-embedded</artifactId>
<version>${modeshape.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!--This is the default WAR WebDAV-Service which Maven will overlay with the custom files & dependencies from this project -->
<dependency>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-web-jcr-webdav-war</artifactId>
<type>war</type>
<scope>runtime</scope>
</dependency>
<!--This examples uses Infinispan's JDBC cache store, which requires C3P0 and a JDBC database driver -->
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-cachestore-jdbc</artifactId>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${jdbc.h2.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${version.log4j}</version>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>

<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${version.assembly.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>${version.clean.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
<showDeprecation>false</showDeprecation>
<showWarnings>false</showWarnings>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>${version.dependency.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>${version.install.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${version.jar.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${version.resources.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<id>exclude-default-config</id>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-web-jcr-webdav-war</artifactId>
<excludes>
<exclude>**/*.json</exclude>
</excludes>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
</project>
48 changes: 48 additions & 0 deletions modeshape-webdav-example/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<profiles>
<profile>
<id>jboss-public-repository</id>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>

<activeProfiles>
<activeProfile>jboss-public-repository</activeProfile>
</activeProfiles>

</settings>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
xmlns="urn:infinispan:config:6.0">
<namedCache name="sample">
<persistence passivation="false">
<stringKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0"
fetchPersistentState="false"
ignoreModifications="false"
purgeOnStartup="false">
<connectionPool
connectionUrl="jdbc:h2:file:../temp/modeshape_webdav/content;DB_CLOSE_DELAY=-1"
driverClass="org.h2.Driver"
username="sa"/>
<stringKeyedTable
prefix="ISPN_STRING_TABLE"
createOnStart="true"
dropOnExit="false">
<idColumn name="ID_COLUMN" type="VARCHAR(255)"/>
<dataColumn name="DATA_COLUMN" type="BINARY"/>
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT"/>
</stringKeyedTable>
</stringKeyedJdbcStore>
</persistence>
<transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.DummyTransactionManagerLookup"
transactionMode="TRANSACTIONAL"
lockingMode="OPTIMISTIC" />
</namedCache>
</infinispan>
27 changes: 27 additions & 0 deletions modeshape-webdav-example/src/main/resources/initial_content.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0">
<folder1 jcr:mixinTypes="mix:created, mix:lastModified" jcr:primaryType="nt:folder">
<file1 jcr:primaryType="nt:file">
<jcr:content jcr:primaryType="nt:resource">
<jcr:data type="binary">caution.gif</jcr:data>
</jcr:content>
</file1>
<file2 jcr:primaryType="nt:file">
<jcr:content jcr:primaryType="nt:resource">
<jcr:data type="binary">caution.gif</jcr:data>
</jcr:content>
</file2>
</folder1>
<folder2 jcr:mixinTypes="mix:created, mix:lastModified" jcr:primaryType="nt:folder">
<file1 jcr:primaryType="nt:file">
<jcr:content jcr:primaryType="nt:resource">
<jcr:data type="binary">caution.gif</jcr:data>
</jcr:content>
</file1>
<file2 jcr:primaryType="nt:file">
<jcr:content jcr:primaryType="nt:resource">
<jcr:data type="binary">caution.gif</jcr:data>
</jcr:content>
</file2>
</folder2>
</jcr:root>
11 changes: 11 additions & 0 deletions modeshape-webdav-example/src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n

# Root logger option
log4j.rootLogger=INFO, stdout

# Set up the default logging to be INFO level, then override specific units
log4j.logger.org.modeshape=INFO
Loading

0 comments on commit cf1609c

Please sign in to comment.