Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mode 1342 ported XSD sequencer to 3.x #278

Merged
merged 1 commit into from
Jan 24, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,20 @@ protected boolean registerNamespace(String namespacePrefix, String namespaceUri,
* @param nodeTypeManager the node type manager with which the cnd will be registered
* @param allowUpdate a boolean which indicates whether updates on existing node types are allowed or no.
* See {@link NodeTypeManager#registerNodeType(javax.jcr.nodetype.NodeTypeDefinition, boolean)}
* @throws RepositoryException
* @throws NodeTypeExistsException
* @throws IOException
* @throws RepositoryException if anything fails
* @throws IOException if any stream related operations fail
*/
protected void registerNodeTypes( String cndFile, NodeTypeManager nodeTypeManager, boolean allowUpdate ) throws RepositoryException, NodeTypeExistsException, IOException {
protected void registerNodeTypes( String cndFile, NodeTypeManager nodeTypeManager, boolean allowUpdate ) throws RepositoryException, IOException {
InputStream cndStream = getClass().getResourceAsStream(cndFile);
registerNodeTypes(cndStream, nodeTypeManager, allowUpdate);
}

/**
* See {@link Sequencer#registerNodeTypes(String, org.modeshape.jcr.api.nodetype.NodeTypeManager, boolean)}
*/
protected void registerNodeTypes( InputStream cndStream, NodeTypeManager nodeTypeManager, boolean allowUpdate ) throws RepositoryException, IOException {
if (cndStream == null) {
throw new IllegalArgumentException("Cannot locate the compact node definition file on classpath: " + cndFile);
throw new IllegalArgumentException("The stream to the given cnd file is null");
}
nodeTypeManager.registerNodeTypes(cndStream, allowUpdate);
}
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<module>sequencers/modeshape-sequencer-ddl</module>
<module>sequencers/modeshape-sequencer-mp3</module>
<module>sequencers/modeshape-sequencer-text</module>
<module>sequencers/modeshape-sequencer-sramp</module>
<module>sequencers/modeshape-sequencer-xsd</module>
</modules>
<properties>
<rootDir>${project.basedir}</rootDir>
Expand Down Expand Up @@ -61,7 +63,6 @@
<module>extensions/modeshape-sequencer-jbpm-jpdl</module>
<module>extensions/modeshape-sequencer-java</module>
<module>extensions/modeshape-sequencer-msoffice</module>
<module>extensions/modeshape-sequencer-sramp</module>
<module>extensions/modeshape-sequencer-teiid</module>
<module>extensions/modeshape-sequencer-xml</module>
<module>extensions/modeshape-sequencer-xsd</module>
Expand Down
100 changes: 100 additions & 0 deletions sequencers/modeshape-sequencer-sramp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<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.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>3.0-SNAPSHOT</version>
<relativePath>../../modeshape-parent</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
<artifactId>modeshape-sequencer-sramp</artifactId>
<packaging>jar</packaging>
<name>ModeShape S-RAMP Sequencer</name>
<description>ModeShape Sequencer library defining the S-RAMP core model lexicon and CND, useful for other sequencers that
reuse or extend S-RAMP definitions.
</description>
<url>http://www.modeshape.org</url>
<dependencies>
<dependency>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-common</artifactId>
</dependency>

<dependency>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-jcr-api</artifactId>
</dependency>

</dependencies>
<build>
<plugins>
<!--
Adding OSGI metadata to the JAR without changing the packaging type.
-->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>assembly</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>modeshape-assembly-descriptors</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<configuration>
<descriptorRefs>
<descriptorRef>sequencer-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>${project.artifactId}-${project.version}</finalName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* ModeShape (http://www.modeshape.org)
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
* See the AUTHORS.txt file in the distribution for a full listing of
* individual contributors.
*
* ModeShape is free software. Unless otherwise indicated, all code in ModeShape
* is licensed to you under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* ModeShape is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org
*/
package org.modeshape.sequencer.sramp;

import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
import org.modeshape.jcr.api.nodetype.NodeTypeManager;
import org.modeshape.jcr.api.sequencer.Sequencer;
import java.io.IOException;

/**
* Base class for sequencers which are based on the S-RAMP specification.

* @author Horia Chiorean
*/
public abstract class AbstractSrampSequencer extends Sequencer {

@Override
public void initialize( NamespaceRegistry registry, NodeTypeManager nodeTypeManager ) throws RepositoryException, IOException {
super.registerNodeTypes(AbstractSrampSequencer.class.getResourceAsStream("sramp.cnd"), nodeTypeManager, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* ModeShape (http://www.modeshape.org)
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
* See the AUTHORS.txt file in the distribution for a full listing of
* individual contributors.
*
* ModeShape is free software. Unless otherwise indicated, all code in ModeShape
* is licensed to you under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* ModeShape is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org
*/
package org.modeshape.sequencer.sramp;

import org.modeshape.common.annotation.Immutable;
import static org.modeshape.sequencer.sramp.SrampLexicon.Namespace.PREFIX;

/**
* A lexicon of S-RAMP names used within the XSD sequencer.
*/
@Immutable
public class SrampLexicon {
private SrampLexicon() {
}

public static class Namespace {
public static final String URI = "http://s-ramp.org/xmlns/2010/s-ramp";
public static final String PREFIX = "sramp";
}

public static final String BASE_ARTIFACT_TYPE = PREFIX + ":baseArtifactType";
public static final String CLASSIFIED_BY = PREFIX + ":classifiedBy";
public static final String DESCRIPTION = PREFIX + ":description";

public static final String DOCUMENT_ARTIFACT_TYPE = PREFIX + ":documentArtifactType";
public static final String CONTENT_TYPE = PREFIX + ":contentType";
public static final String CONTENT_SIZE = PREFIX + ":contentSize";

public static final String XML_DOCUMENT = PREFIX + ":xmlDocument";
public static final String CONTENT_ENCODING = PREFIX + ":contentEncoding";

public static final String DOCUMENT = PREFIX + ":document";

public static final String DERIVED_ARTIFACT_TYPE = PREFIX + ":derivedArtifactType";
public static final String RELATED_DOCUMENTS = PREFIX + ":relatedDocuments";

public static final String USER_DEFINED_ARTIFACT_TYPE = PREFIX + ":userDefinedArtifactType";
public static final String USER_TYPE = PREFIX + ":userType";

public static final String STORED_QUERY = PREFIX + ":storedQuery";
public static final String PROPERTY_LIST = PREFIX + ":propertyList";

public static final String RELATED_TO = PREFIX + ":relatedTo";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* ModeShape (http://www.modeshape.org)
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
* See the AUTHORS.txt file in the distribution for a full listing of
* individual contributors.
*
* ModeShape is free software. Unless otherwise indicated, all code in ModeShape
* is licensed to you under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* ModeShape is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org
*/
/**
* The classes that make up the S-RAMP library.
*/

package org.modeshape.sequencer.sramp;

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* ModeShape (http://www.modeshape.org)
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
* See the AUTHORS.txt file in the distribution for a full listing of
* individual contributors.
*
* ModeShape is free software. Unless otherwise indicated, all code in ModeShape
* is licensed to you under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* ModeShape is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

//------------------------------------------------------------------------------
// N A M E S P A C E S
//------------------------------------------------------------------------------
<jcr='http://www.jcp.org/jcr/1.0'>
<nt='http://www.jcp.org/jcr/nt/1.0'>
<mix='http://www.jcp.org/jcr/mix/1.0'>
<sramp = "http://s-ramp.org/xmlns/2010/s-ramp">

//------------------------------------------------------------------------------
// N O D E T Y P E S
//------------------------------------------------------------------------------

// -------------------------------------------------------
// S-RAMP Core Model Artifacts
// -------------------------------------------------------

[sramp:baseArtifactType] > mix:created, mix:lastModified, mix:referenceable, mix:versionable abstract mixin
- sramp:classifiedBy (reference) multiple < 'owl:class'
- sramp:description (string)
- * (string)
- * (string) multiple

[sramp:documentArtifactType] > sramp:baseArtifactType abstract mixin
- sramp:contentType (string)
- sramp:contentSize (long)

[sramp:xmlDocument] > sramp:documentArtifactType mixin
- sramp:contentEncoding (string) mandatory

[sramp:document] > sramp:documentArtifactType mixin

[sramp:derivedArtifactType] > sramp:baseArtifactType abstract mixin
- sramp:relatedDocuments (reference) < 'sramp:documentArtifactType'

[sramp:userDefinedArtifactType] > sramp:baseArtifactType mixin
- sramp:userType (string) mandatory

[sramp:storedQuery] > nt:query
- sramp:propertyList (string) multiple

[sramp:relatedTo] mixin
- * (weakreference) multiple