[savara-commits] savara SVN: r405 - in trunk: tools/features/org.jboss.savara.experimental.feature and 22 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Sep 17 11:22:31 EDT 2010
Author: objectiser
Date: 2010-09-17 11:22:30 -0400 (Fri, 17 Sep 2010)
New Revision: 405
Added:
trunk/samples/purchasing/purchasing.tap
trunk/tools/plugins/org.jboss.savara.tap.eclipse/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/.classpath
trunk/tools/plugins/org.jboss.savara.tap.eclipse/.project
trunk/tools/plugins/org.jboss.savara.tap.eclipse/.settings/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/.settings/org.eclipse.jdt.core.prefs
trunk/tools/plugins/org.jboss.savara.tap.eclipse/META-INF/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/META-INF/MANIFEST.MF
trunk/tools/plugins/org.jboss.savara.tap.eclipse/OSGI-INF/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/OSGI-INF/eclipse-resource-loader.xml
trunk/tools/plugins/org.jboss.savara.tap.eclipse/build.properties
trunk/tools/plugins/org.jboss.savara.tap.eclipse/plugin.xml
trunk/tools/plugins/org.jboss.savara.tap.eclipse/pom.xml
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/Activator.java
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/EclipseResourceLoader.java
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/
trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/resources/
trunk/tools/plugins/org.jboss.savara.tap.validation/src/resources/tap.xsd
Removed:
trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/eclipse-resource-loader.xml
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse/EclipseResourceLoader.java
Modified:
trunk/tools/features/org.jboss.savara.experimental.feature/feature.xml
trunk/tools/plugins/org.jboss.savara.tap.validation/.classpath
trunk/tools/plugins/org.jboss.savara.tap.validation/META-INF/MANIFEST.MF
trunk/tools/plugins/org.jboss.savara.tap.validation/build.properties
trunk/tools/plugins/org.jboss.savara.tap.validation/plugin.xml
trunk/tools/plugins/org.jboss.savara.tap.validation/pom.xml
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/ValidateAction.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java
trunk/tools/plugins/pom.xml
Log:
Separate out tap eclipse functionality into a separate plugin.
Added: trunk/samples/purchasing/purchasing.tap
===================================================================
--- trunk/samples/purchasing/purchasing.tap (rev 0)
+++ trunk/samples/purchasing/purchasing.tap 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.savara.org/ta/project" xmlns:xsi="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://www.savara.org/ta/project tap.xsd"
+ name="Purchasing" version="1.0.0">
+
+ <phase name="requirements">
+ <resource id="SuccessfulPurchase.scn">
+ <uri type="eclipse" context="purchasing" locator="/SuccessfulPurchase.scn" />
+ </resource>
+ <resource id="InvalidPurchase.scn">
+ <uri type="eclipse" context="purchasing" locator="/InvalidPurchase.scn" />
+ </resource>
+ </phase>
+
+ <phase name="architecture">
+ <resource id="PurchaseGoods.cdm">
+ <uri type="eclipse" context="purchasing" locator="/PurchaseGoods.cdm" />
+ <relationship type="depends" ref="SuccessfulPurchase.scn" />
+ <relationship type="depends" ref="InvalidPurchase.scn" />
+ </resource>
+ </phase>
+
+ <phase name="implementation">
+ <resource id="PurchaseGoodsProcess_Store.bpel">
+ <uri type="eclipse" context="PurchaseGoodsProcess-Store" locator="/bpelContent/PurchaseGoodsProcess_Store.bpel" />
+ <relationship type="depends" ref="PurchaseGoods.cdm" >
+ <description>Link from the BPEL process to the 'Store' participant within the choreography</description>
+ <link type="role" to="Store" />
+ </relationship>
+ </resource>
+ <resource id="PurchaseGoodsProcess_CreditAgency.bpel">
+ <uri type="eclipse" context="PurchaseGoodsProcess-CreditAgency" locator="/bpelContent/PurchaseGoodsProcess_CreditAgency.bpel" />
+ <relationship type="depends" ref="PurchaseGoods.cdm" >
+ <description>Link from the BPEL process to the 'CreditAgency' participant within the choreography</description>
+ <link type="role" to="CreditAgency" />
+ </relationship>
+ </resource>
+ </phase>
+</project>
\ No newline at end of file
Modified: trunk/tools/features/org.jboss.savara.experimental.feature/feature.xml
===================================================================
--- trunk/tools/features/org.jboss.savara.experimental.feature/feature.xml 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/features/org.jboss.savara.experimental.feature/feature.xml 2010-09-17 15:22:30 UTC (rev 405)
@@ -179,6 +179,13 @@
</requires>
<plugin
+ id="org.jboss.savara.tap.eclipse"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
id="org.jboss.savara.tap.model"
download-size="0"
install-size="0"
@@ -186,6 +193,13 @@
unpack="false"/>
<plugin
+ id="org.jboss.savara.tap.validation"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
id="org.scribble.conformance"
download-size="0"
install-size="0"
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/.classpath
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/.classpath (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/.classpath 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/.project
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/.project (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/.project 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.savara.tap.eclipse</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/.settings/org.eclipse.jdt.core.prefs 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,8 @@
+#Fri Sep 17 14:54:36 BST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/META-INF/MANIFEST.MF (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/META-INF/MANIFEST.MF 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA TAP Eclipse integration
+Bundle-SymbolicName: org.jboss.savara.tap.eclipse; singleton:=true
+Bundle-Version: 1.1.0.qualifier
+Bundle-Activator: org.jboss.savara.tap.eclipse.Activator
+Bundle-Vendor: www.savara.org
+Service-Component: OSGI-INF/eclipse-resource-loader.xml
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.jboss.savara.tap.model,
+ org.jboss.savara.tap.validation,
+ org.scribble.eclipse;bundle-version="[1.1.0,2.0.0)",
+ org.scribble.core;bundle-version="[1.1.0,2.0.0)"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/OSGI-INF/eclipse-resource-loader.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/OSGI-INF/eclipse-resource-loader.xml (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/OSGI-INF/eclipse-resource-loader.xml 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="eclipse-resource-loader">
+ <implementation class="org.jboss.savara.tap.eclipse.EclipseResourceLoader"/>
+ <service>
+ <provide interface="org.jboss.savara.tap.model.admin.ResourceLoader"/>
+ </service>
+</component>
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/build.properties
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/build.properties (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/build.properties 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,16 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ OSGI-INF/,\
+ build.properties,\
+ pom.xml
+src.includes = .project,\
+ .classpath,\
+ META-INF/,\
+ OSGI-INF/,\
+ build.properties,\
+ plugin.xml,\
+ pom.xml,\
+ src/
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/plugin.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/plugin.xml (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/plugin.xml 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IFile"
+ id="org.jboss.savara.tap.eclipse.contribution1">
+ <menu
+ label="Savara"
+ path="additions"
+ id="org.jboss.savara.tools.menu">
+ <separator
+ name="group1">
+ </separator>
+ </menu>
+ <action
+ label="Validate"
+ class="org.jboss.savara.tap.eclipse.actions.ValidateAction"
+ menubarPath="org.jboss.savara.tools.menu/group1"
+ enablesFor="1"
+ id="org.jboss.savara.tap.validation.ValidateAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+</plugin>
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/pom.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/pom.xml (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/pom.xml 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,16 @@
+<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.jboss.savara.tools</groupId>
+ <artifactId>org.jboss.savara.tap.eclipse</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Tools::Plugins::ToolsTAPValidation</name>
+
+ <parent>
+ <groupId>org.jboss.savara.tools</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+</project>
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/Activator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/Activator.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/Activator.java 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,61 @@
+package org.jboss.savara.tap.eclipse;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.savara.tap.eclipse"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/EclipseResourceLoader.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/EclipseResourceLoader.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/EclipseResourceLoader.java 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * 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.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.savara.tap.eclipse;
+
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Path;
+import org.jboss.savara.tap.model.Resource;
+import org.jboss.savara.tap.model.URI;
+import org.jboss.savara.tap.model.admin.ResourceLoader;
+import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.eclipse.model.admin.OSGIModelRepository;
+import org.scribble.model.ModelReference;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class providers the Eclipse resource loader implementation.
+ *
+ */
+public class EclipseResourceLoader implements ResourceLoader {
+
+ private static Logger logger = Logger.getLogger(EclipseResourceLoader.class.getName());
+
+ /**
+ * This method determines whether the resource loader can
+ * retrieve the contents associated with the supplied resource.
+ *
+ * @param resource The resource
+ * @return Whether the contents can be retrieved
+ */
+ public boolean isSupported(Resource resource) {
+ boolean ret=false;
+
+ for (URI uri : resource.getUri()) {
+ if (uri.getType().equalsIgnoreCase("eclipse")) {
+ ret = true;
+ break;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines if the supplied resource exists.
+ *
+ * @param resource The resource
+ * @return Whether the resource exists
+ */
+ public boolean exists(Resource resource) {
+ IFile res=getFile(resource);
+ return(res == null ? false : res.exists());
+ }
+
+ /**
+ * This method retrieves the contents associated with the
+ * supplied resource.
+ *
+ * @param resource The resource
+ * @return The contents, or null if not found
+ */
+ public InputStream getContents(Resource resource) {
+ java.io.InputStream ret=null;
+ IFile res=getFile(resource);
+
+ if (res != null) {
+ try {
+ ret = res.getContents();
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to get contents for resource '"+res+"'", e);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the URI associated with the
+ * supplied resource.
+ *
+ * @param resource The resource
+ * @return The URI, or null if not found
+ */
+ public java.net.URI getURI(Resource resource) {
+ IFile res=getFile(resource);
+ java.net.URI ret=null;
+
+ if (res != null) {
+ ret = res.getRawLocationURI();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the contents associated with the
+ * supplied URI. If the URI is a relative path, then the resource will
+ * be located relative to the supplied model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The contents, or null if not found
+ */
+ public java.io.InputStream getContents(ModelReference ref, String uri) {
+ java.io.InputStream ret=null;
+
+ if (uri != null) {
+
+ if (uri.startsWith("http:")) {
+ // TODO: Implement
+
+ } else {
+ // Try to locate as relative path from supplied model reference
+ IFile file=OSGIModelRepository.getFile(ref);
+
+ // Find folder
+ IFolder folder = (IFolder)file.getParent();
+
+ IFile refFile=folder.getFile(new Path(uri));
+
+ if (refFile != null) {
+ try {
+ ret = refFile.getContents();
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load content from referenced resource '"+uri+"'", e);
+ }
+ } else if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Unable to locate resource '"+uri+"'");
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the URI associated with the
+ * supplied URI string. If the supplied URI is a relative path,
+ * then the resource will be located relative to the supplied
+ * model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The resolved URI, or null if not found
+ */
+ public java.net.URI getURI(ModelReference ref, String uri) {
+ java.net.URI ret=null;
+
+ if (uri != null) {
+
+ if (uri.startsWith("http:")) {
+ try {
+ ret = new java.net.URI(uri);
+ } catch(Exception e) {
+ logger.log(Level.SEVERE, "Invalid URI '"+uri+"'", e);
+ }
+ } else {
+ // Try to locate as relative path from supplied model reference
+ IFile file=OSGIModelRepository.getFile(ref);
+
+ // Find folder
+ IFolder folder = (IFolder)file.getParent();
+
+ IFile refFile=folder.getFile(new Path(uri));
+
+ if (refFile != null) {
+ ret = refFile.getRawLocationURI();
+ } else if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Unable to locate resource '"+uri+"'");
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the contents associated with the
+ * supplied resource.
+ *
+ * @param resource The resource
+ * @return The contents, or null if not found
+ */
+ protected IFile getFile(Resource resource) {
+ String projectName=null;
+ String location=null;
+ IFile ret=null;
+
+ for (URI uri : resource.getUri()) {
+ if (uri.getType().equalsIgnoreCase("eclipse")) {
+ projectName = uri.getContext();
+ location = uri.getLocator();
+ break;
+ }
+ }
+
+ if (projectName != null) {
+ IProject project=org.eclipse.core.resources.ResourcesPlugin.getWorkspace().
+ getRoot().getProject(projectName);
+
+ if (project == null) {
+ logger.severe("Eclipse context (project) '"+projectName+
+ "' does not exist for resource: "+resource.getId());
+ } else if (location == null) {
+ logger.severe("Eclipse locator has not been defined for resource: "+resource.getId());
+ } else {
+ ret = project.getFile(new Path(location));
+
+ if (ret == null) {
+ logger.severe("Eclipse locator '"+location+"' for project '"+projectName+
+ "' does not exist for resource: "+resource.getId());
+ }
+ }
+ } else {
+ logger.severe("Unable to determine Eclipse context (project) for resource: "+
+ resource.getId());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns a model listener associated with the supplied resource.
+ *
+ * @param res The resource
+ * @return The model listener associated with the resource
+ */
+ public ModelListener getResourceModelListener(Resource res) {
+ IFile file=getFile(res);
+ ModelListener ret=null;
+
+ if (file != null) {
+ ret = new OSGIModelListener(file);
+ } else {
+ logger.severe("Failed to get model listener for resource '"+res+"'");
+
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method frees a model listener associated with the supplied resource.
+ *
+ * @param res The resource
+ * @param l The model listener associated with the resource
+ */
+ public void freeResourceModelListener(Resource res, ModelListener l) {
+ if (l instanceof OSGIModelListener) {
+ ((OSGIModelListener)l).finished();
+ }
+ }
+
+ /**
+ * This method returns the model reference associated with the supplied resource.
+ *
+ * @param resource The resource
+ * @return The model reference
+ */
+ public ModelReference getModelReference(Resource resource) {
+ return(OSGIModelRepository.createReference(getFile(resource)));
+ }
+
+}
Added: trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/src/java/org/jboss/savara/tap/eclipse/actions/ValidateAction.java 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,152 @@
+package org.jboss.savara.tap.eclipse.actions;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.savara.tap.model.Project;
+import org.jboss.savara.tap.model.admin.TAPModelUtil;
+import org.jboss.savara.tap.validation.TAPValidator;
+import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+public class ValidateAction implements IObjectActionDelegate {
+
+ private static Logger logger = Logger.getLogger(ValidateAction.class.getName());
+
+ private ISelection m_selection=null;
+ private IWorkbenchPart m_targetPart=null;
+ private static TAPValidator m_validator=TAPValidator.getInstance();
+
+ public ValidateAction() {
+ }
+
+ /**
+ * This method returns the validator.
+ *
+ * @return The validator
+ */
+ public static TAPValidator getValidator() {
+ return(m_validator);
+ }
+
+ /**
+ * This method implements the action's run method.
+ *
+ * @param action The action
+ */
+ public void run(IAction action) {
+
+ if (m_selection instanceof StructuredSelection) {
+ StructuredSelection sel=(StructuredSelection)m_selection;
+
+ IResource res=(IResource)sel.getFirstElement();
+
+ // Obtain the TAP model from the resource
+ if (res instanceof IFile) {
+ Project project=null;
+ OSGIModelListener l=new OSGIModelListener(res);
+ java.io.InputStream is=null;
+
+ try {
+ is = ((IFile)res).getContents();
+
+ // Check the XML document is valid
+ if (TAPValidator.getInstance().isValidTAPDocument(is, l)) {
+
+ is.close();
+
+ // Re-acquire contents to deserialize into project object model
+ is = ((IFile)res).getContents();
+
+ project = TAPModelUtil.deserialize(is);
+
+ is.close();
+
+ if (project != null) {
+ m_validator.validate(project, l);
+ }
+ }
+ } catch(Exception e) {
+ if (is != null) {
+ try {
+ is.close();
+ } catch(Exception ex) {
+ }
+ }
+
+ error(e.getMessage());
+ }
+
+ l.finished();
+ }
+ }
+ }
+
+ /**
+ * This method is used to report an error.
+ *
+ * @param mesg The error message
+ */
+ public void error(String mesg) {
+
+ logger.severe("Error occurred: "+mesg);
+
+ MessageBox mbox=new MessageBox(m_targetPart.getSite().getShell(),
+ SWT.ICON_ERROR|SWT.OK);
+
+ if (mesg == null) {
+ mesg = "Null pointer exception has occurred";
+ }
+
+ mbox.setMessage(mesg);
+ mbox.open();
+ }
+
+ /**
+ * This method indicates that the selection has changed.
+ *
+ * @param action The action
+ * @param selection The selection
+ */
+ public void selectionChanged(IAction action,
+ ISelection selection) {
+ m_selection = selection;
+ }
+
+ /**
+ * This method sets the currently active workbench part.
+ *
+ * @param action The action
+ * @param targetPart The active workbench part
+ */
+ public void setActivePart(IAction action,
+ IWorkbenchPart targetPart) {
+ m_targetPart = targetPart;
+ }
+}
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/.classpath
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/.classpath 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/.classpath 2010-09-17 15:22:30 UTC (rev 405)
@@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/META-INF/MANIFEST.MF 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/META-INF/MANIFEST.MF 2010-09-17 15:22:30 UTC (rev 405)
@@ -5,8 +5,7 @@
Bundle-Version: 1.1.0.qualifier
Bundle-Activator: org.jboss.savara.tap.validation.osgi.Activator
Bundle-Vendor: www.savara.org
-Service-Component: OSGI-INF/eclipse-resource-loader.xml,
- OSGI-INF/bpel-cdm-relationship-validator.xml,
+Service-Component: OSGI-INF/bpel-cdm-relationship-validator.xml,
OSGI-INF/cdm-scenario-relationship-validator.xml
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -18,3 +17,4 @@
org.pi4soa.cdl
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
+Export-Package: org.jboss.savara.tap.validation
Deleted: trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/eclipse-resource-loader.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/eclipse-resource-loader.xml 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/eclipse-resource-loader.xml 2010-09-17 15:22:30 UTC (rev 405)
@@ -1,7 +0,0 @@
-<?xml version="1.0"?>
-<component name="savara-tap-resource-loader">
- <implementation class="org.jboss.savara.tap.model.admin.eclipse.EclipseResourceLoader"/>
- <service>
- <provide interface="org.jboss.savara.tap.model.admin.ResourceLoader"/>
- </service>
-</component>
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/build.properties
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/build.properties 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/build.properties 2010-09-17 15:22:30 UTC (rev 405)
@@ -1,4 +1,18 @@
-source.. = src/java/
+source.. = src/java/,\
+ src/resources/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml,\
+ build.properties,\
+ OSGI-INF/,\
+ Copyright.txt
+src.includes = .classpath,\
+ .project,\
+ Copyright.txt,\
+ META-INF/,\
+ OSGI-INF/,\
+ plugin.xml,\
+ pom.xml,\
+ build.properties,\
+ src/
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/plugin.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/plugin.xml 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/plugin.xml 2010-09-17 15:22:30 UTC (rev 405)
@@ -2,6 +2,7 @@
<?eclipse version="3.4"?>
<plugin>
+<!--
<extension point="org.eclipse.ui.popupMenus">
<objectContribution
id="org.jboss.savara.tap.validation.contribution1"
@@ -22,5 +23,13 @@
</action>
</objectContribution>
</extension>
+-->
+
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="org.jboss.savara.tap.validation.osgi.Activator">
+ </startup>
+ </extension>
</plugin>
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/pom.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/pom.xml 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/pom.xml 2010-09-17 15:22:30 UTC (rev 405)
@@ -13,11 +13,4 @@
<version>1.1.0-SNAPSHOT</version>
</parent>
- <dependencies>
- <dependency>
- <groupId>org.jboss.savara.tools</groupId>
- <artifactId>org.jboss.savara.tap.validation</artifactId>
- <version>${savara.version}</version>
- </dependency>
- </dependencies>
</project>
Deleted: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse/EclipseResourceLoader.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse/EclipseResourceLoader.java 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse/EclipseResourceLoader.java 2010-09-17 15:22:30 UTC (rev 405)
@@ -1,290 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * 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.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.savara.tap.model.admin.eclipse;
-
-import java.io.InputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Path;
-import org.jboss.savara.tap.model.Resource;
-import org.jboss.savara.tap.model.URI;
-import org.jboss.savara.tap.model.admin.ResourceLoader;
-import org.scribble.eclipse.model.admin.OSGIModelListener;
-import org.scribble.eclipse.model.admin.OSGIModelRepository;
-import org.scribble.model.ModelReference;
-import org.scribble.model.admin.ModelListener;
-
-/**
- * This class providers the Eclipse resource loader implementation.
- *
- */
-public class EclipseResourceLoader implements ResourceLoader {
-
- private static Logger logger = Logger.getLogger(EclipseResourceLoader.class.getName());
-
- /**
- * This method determines whether the resource loader can
- * retrieve the contents associated with the supplied resource.
- *
- * @param resource The resource
- * @return Whether the contents can be retrieved
- */
- public boolean isSupported(Resource resource) {
- boolean ret=false;
-
- for (URI uri : resource.getUri()) {
- if (uri.getType().equalsIgnoreCase("eclipse")) {
- ret = true;
- break;
- }
- }
-
- return(ret);
- }
-
- /**
- * This method determines if the supplied resource exists.
- *
- * @param resource The resource
- * @return Whether the resource exists
- */
- public boolean exists(Resource resource) {
- IFile res=getFile(resource);
- return(res == null ? false : res.exists());
- }
-
- /**
- * This method retrieves the contents associated with the
- * supplied resource.
- *
- * @param resource The resource
- * @return The contents, or null if not found
- */
- public InputStream getContents(Resource resource) {
- java.io.InputStream ret=null;
- IFile res=getFile(resource);
-
- if (res != null) {
- try {
- ret = res.getContents();
- } catch(Exception e) {
- logger.log(Level.SEVERE,
- "Failed to get contents for resource '"+res+"'", e);
- }
- }
-
- return(ret);
- }
-
- /**
- * This method retrieves the URI associated with the
- * supplied resource.
- *
- * @param resource The resource
- * @return The URI, or null if not found
- */
- public java.net.URI getURI(Resource resource) {
- IFile res=getFile(resource);
- java.net.URI ret=null;
-
- if (res != null) {
- ret = res.getRawLocationURI();
- }
-
- return(ret);
- }
-
- /**
- * This method retrieves the contents associated with the
- * supplied URI. If the URI is a relative path, then the resource will
- * be located relative to the supplied model reference.
- *
- * @param ref The model reference
- * @param uri The URI
- * @return The contents, or null if not found
- */
- public java.io.InputStream getContents(ModelReference ref, String uri) {
- java.io.InputStream ret=null;
-
- if (uri != null) {
-
- if (uri.startsWith("http:")) {
- // TODO: Implement
-
- } else {
- // Try to locate as relative path from supplied model reference
- IFile file=OSGIModelRepository.getFile(ref);
-
- // Find folder
- IFolder folder = (IFolder)file.getParent();
-
- IFile refFile=folder.getFile(new Path(uri));
-
- if (refFile != null) {
- try {
- ret = refFile.getContents();
- } catch(Exception e) {
- logger.log(Level.SEVERE,
- "Failed to load content from referenced resource '"+uri+"'", e);
- }
- } else if (logger.isLoggable(Level.FINE)) {
- logger.fine("Unable to locate resource '"+uri+"'");
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method retrieves the URI associated with the
- * supplied URI string. If the supplied URI is a relative path,
- * then the resource will be located relative to the supplied
- * model reference.
- *
- * @param ref The model reference
- * @param uri The URI
- * @return The resolved URI, or null if not found
- */
- public java.net.URI getURI(ModelReference ref, String uri) {
- java.net.URI ret=null;
-
- if (uri != null) {
-
- if (uri.startsWith("http:")) {
- try {
- ret = new java.net.URI(uri);
- } catch(Exception e) {
- logger.log(Level.SEVERE, "Invalid URI '"+uri+"'", e);
- }
- } else {
- // Try to locate as relative path from supplied model reference
- IFile file=OSGIModelRepository.getFile(ref);
-
- // Find folder
- IFolder folder = (IFolder)file.getParent();
-
- IFile refFile=folder.getFile(new Path(uri));
-
- if (refFile != null) {
- ret = refFile.getRawLocationURI();
- } else if (logger.isLoggable(Level.FINE)) {
- logger.fine("Unable to locate resource '"+uri+"'");
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method retrieves the contents associated with the
- * supplied resource.
- *
- * @param resource The resource
- * @return The contents, or null if not found
- */
- protected IFile getFile(Resource resource) {
- String projectName=null;
- String location=null;
- IFile ret=null;
-
- for (URI uri : resource.getUri()) {
- if (uri.getType().equalsIgnoreCase("eclipse")) {
- projectName = uri.getContext();
- location = uri.getLocator();
- break;
- }
- }
-
- if (projectName != null) {
- IProject project=org.eclipse.core.resources.ResourcesPlugin.getWorkspace().
- getRoot().getProject(projectName);
-
- if (project == null) {
- logger.severe("Eclipse context (project) '"+projectName+
- "' does not exist for resource: "+resource.getId());
- } else if (location == null) {
- logger.severe("Eclipse locator has not been defined for resource: "+resource.getId());
- } else {
- ret = project.getFile(new Path(location));
-
- if (ret == null) {
- logger.severe("Eclipse locator '"+location+"' for project '"+projectName+
- "' does not exist for resource: "+resource.getId());
- }
- }
- } else {
- logger.severe("Unable to determine Eclipse context (project) for resource: "+
- resource.getId());
- }
-
- return(ret);
- }
-
- /**
- * This method returns a model listener associated with the supplied resource.
- *
- * @param res The resource
- * @return The model listener associated with the resource
- */
- public ModelListener getResourceModelListener(Resource res) {
- IFile file=getFile(res);
- ModelListener ret=null;
-
- if (file != null) {
- ret = new OSGIModelListener(file);
- } else {
- logger.severe("Failed to get model listener for resource '"+res+"'");
-
- }
-
- return(ret);
- }
-
- /**
- * This method frees a model listener associated with the supplied resource.
- *
- * @param res The resource
- * @param l The model listener associated with the resource
- */
- public void freeResourceModelListener(Resource res, ModelListener l) {
- if (l instanceof OSGIModelListener) {
- ((OSGIModelListener)l).finished();
- }
- }
-
- /**
- * This method returns the model reference associated with the supplied resource.
- *
- * @param resource The resource
- * @return The model reference
- */
- public ModelReference getModelReference(Resource resource) {
- return(OSGIModelRepository.createReference(getFile(resource)));
- }
-
-}
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java 2010-09-17 15:22:30 UTC (rev 405)
@@ -21,11 +21,23 @@
*/
package org.jboss.savara.tap.validation;
+import java.io.IOException;
import java.text.MessageFormat;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
import org.jboss.savara.tap.model.Phase;
import org.jboss.savara.tap.model.Project;
import org.jboss.savara.tap.model.Relationship;
@@ -33,6 +45,8 @@
import org.jboss.savara.tap.model.admin.ResourceLoader;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
/**
* This class provides the validation control mechanism for a TAP
@@ -50,6 +64,15 @@
private static java.util.List<RelationshipValidator> m_relationshipValidators=
new java.util.Vector<RelationshipValidator>();
+ private static TAPValidator m_instance=new TAPValidator();
+
+ protected TAPValidator() {
+ }
+
+ public static TAPValidator getInstance() {
+ return(m_instance);
+ }
+
/**
* This method adds a resource loader.
*
@@ -194,6 +217,59 @@
}
}
+ /**
+ * This method can be used to determine whether the supplied input stream
+ * contains a valid TAP document.
+ *
+ * @param is The TAP content
+ * @param l
+ * @return
+ */
+ public boolean isValidTAPDocument(java.io.InputStream is, ModelListener l) {
+ boolean ret=false;
+
+ try {
+
+ // Parse an XML document into a DOM tree.
+ DocumentBuilderFactory f=DocumentBuilderFactory.newInstance();
+ f.setNamespaceAware(true);
+
+ DocumentBuilder parser=f.newDocumentBuilder();
+
+ Document document = parser.parse(is);
+
+ // Create a SchemaFactory capable of understanding WXS schemas.
+ SchemaFactory factory =
+ SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+ // Load a WXS schema, represented by a Schema instance.
+ java.io.InputStream schemais=TAPValidator.class.getResourceAsStream("/tap.xsd");
+
+ Source schemaFile = new StreamSource(schemais);
+ Schema schema = factory.newSchema(schemaFile);
+
+ schemais.close();
+
+ // Create a Validator object, which can be used to validate
+ // an instance document.
+ Validator validator = schema.newValidator();
+
+ // Validate the DOM tree.
+ validator.validate(new DOMSource(document));
+
+ ret = true;
+
+ } catch (ParserConfigurationException e) {
+ l.error(new ModelIssue(null, "Failed to parse TAP document: "+e.getMessage()));
+ } catch (SAXException e) {
+ l.error(new ModelIssue(null, "Invalid TAP document: "+e.getMessage()));
+ } catch (IOException e) {
+ l.error(new ModelIssue(null, "Failed to load TAP document: "+e.getMessage()));
+ }
+
+ return(ret);
+ }
+
protected ResourceLoader getResourceLoader(Resource resource) {
ResourceLoader ret=null;
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/ValidateAction.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/ValidateAction.java 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/action/ValidateAction.java 2010-09-17 15:22:30 UTC (rev 405)
@@ -19,10 +19,23 @@
*/
package org.jboss.savara.tap.validation.action;
+import java.io.IOException;
import java.util.logging.Logger;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -34,6 +47,10 @@
import org.jboss.savara.tap.model.admin.TAPModelUtil;
import org.jboss.savara.tap.validation.TAPValidator;
import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
/**
* This class invokes the validation action on the selected
@@ -46,7 +63,7 @@
private ISelection m_selection=null;
private IWorkbenchPart m_targetPart=null;
- private static TAPValidator m_validator=new TAPValidator();
+ //private static TAPValidator m_validator=new TAPValidator();
public ValidateAction() {
}
@@ -56,9 +73,11 @@
*
* @return The validator
*/
+ /*
public static TAPValidator getValidator() {
return(m_validator);
}
+ */
/**
* This method implements the action's run method.
@@ -66,7 +85,7 @@
* @param action The action
*/
public void run(IAction action) {
-
+ /*
if (m_selection instanceof StructuredSelection) {
StructuredSelection sel=(StructuredSelection)m_selection;
@@ -75,28 +94,82 @@
// Obtain the TAP model from the resource
if (res instanceof IFile) {
Project project=null;
+ OSGIModelListener l=new OSGIModelListener(res);
- try {
- java.io.InputStream is=((IFile)res).getContents();
+ // Check the XML document is valid
+ if (isValidTAPDocument((IFile)res, l)) {
+
+ try {
+ java.io.InputStream is=((IFile)res).getContents();
+
+ project = TAPModelUtil.deserialize(is);
+
+ is.close();
+ } catch(Exception e) {
+ error(e.getMessage());
+ }
- project = TAPModelUtil.deserialize(is);
-
- is.close();
- } catch(Exception e) {
- error("Failed to load TAP project file: "+e);
+ if (project != null) {
+ m_validator.validate(project, l);
+ }
}
- if (project != null) {
- OSGIModelListener l=new OSGIModelListener(res);
-
- m_validator.validate(project, l);
-
- l.finished();
- }
+ l.finished();
}
}
+ */
}
+ protected boolean isValidTAPDocument(IFile file, ModelListener l) {
+ boolean ret=false;
+
+ try {
+
+ // Parse an XML document into a DOM tree.
+ DocumentBuilderFactory f=DocumentBuilderFactory.newInstance();
+ f.setNamespaceAware(true);
+
+ DocumentBuilder parser=f.newDocumentBuilder();
+
+ java.io.InputStream is=file.getContents();
+ Document document = parser.parse(is);
+
+ is.close();
+
+ // Create a SchemaFactory capable of understanding WXS schemas.
+ SchemaFactory factory =
+ SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+
+ // Load a WXS schema, represented by a Schema instance.
+ java.io.InputStream schemais=ValidateAction.class.getResourceAsStream("/tap.xsd");
+
+ Source schemaFile = new StreamSource(schemais);
+ Schema schema = factory.newSchema(schemaFile);
+
+ schemais.close();
+
+ // Create a Validator object, which can be used to validate
+ // an instance document.
+ Validator validator = schema.newValidator();
+
+ // Validate the DOM tree.
+ validator.validate(new DOMSource(document));
+
+ ret = true;
+
+ } catch (ParserConfigurationException e) {
+ l.error(new ModelIssue(null, "Failed to parse TAP document: "+e.getMessage()));
+ } catch (SAXException e) {
+ l.error(new ModelIssue(null, "Invalid TAP document: "+e.getMessage()));
+ } catch (IOException e) {
+ l.error(new ModelIssue(null, "Failed to load TAP document: "+e.getMessage()));
+ } catch (CoreException e) {
+ l.error(new ModelIssue(null, "Failed to load TAP document: "+e.getMessage()));
+ }
+
+ return(ret);
+ }
+
/**
* This method is used to report an error.
*
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/osgi/Activator.java 2010-09-17 15:22:30 UTC (rev 405)
@@ -6,6 +6,7 @@
import org.jboss.savara.tap.model.admin.ResourceLoader;
import org.jboss.savara.tap.validation.RelationshipValidator;
import org.jboss.savara.tap.validation.ResourceValidator;
+import org.jboss.savara.tap.validation.TAPValidator;
import org.jboss.savara.tap.validation.action.ValidateAction;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -13,7 +14,7 @@
/**
* The activator class controls the plug-in life cycle
*/
-public class Activator extends AbstractUIPlugin {
+public class Activator extends AbstractUIPlugin implements org.eclipse.ui.IStartup {
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.savara.tap.validation"; //$NON-NLS-1$
@@ -45,7 +46,7 @@
ResourceLoader rl=(ResourceLoader)context.getService(sr);
if (rl != null) {
- ValidateAction.getValidator().addResourceLoader(rl);
+ TAPValidator.getInstance().addResourceLoader(rl);
} else {
logger.severe("ResourceLoader does not exist for service ref: "+sr);
}
@@ -60,7 +61,7 @@
ResourceValidator rv=(ResourceValidator)context.getService(sr);
if (rv != null) {
- ValidateAction.getValidator().addResourceValidator(rv);
+ TAPValidator.getInstance().addResourceValidator(rv);
} else {
logger.severe("ResourceValidator does not exist for service ref: "+sr);
}
@@ -75,7 +76,7 @@
RelationshipValidator rv=(RelationshipValidator)context.getService(sr);
if (rv != null) {
- ValidateAction.getValidator().addRelationshipValidator(rv);
+ TAPValidator.getInstance().addRelationshipValidator(rv);
} else {
logger.severe("RelationshipValidator does not exist for service ref: "+sr);
}
@@ -101,4 +102,6 @@
return plugin;
}
+ public void earlyStartup() {
+ }
}
Added: trunk/tools/plugins/org.jboss.savara.tap.validation/src/resources/tap.xsd
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/resources/tap.xsd (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/resources/tap.xsd 2010-09-17 15:22:30 UTC (rev 405)
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema targetNamespace="http://www.savara.org/ta/project" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.savara.org/ta/project">
+
+
+ <complexType name="Project">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="phase" type="tns:Phase"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ </sequence>
+ <attribute name="name" type="string" use="required"></attribute>
+ <attribute name="version" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Phase">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="resource" type="tns:Resource" maxOccurs="unbounded" minOccurs="0"></element>
+ </sequence>
+ <attribute name="name" type="string" use="required"></attribute>
+
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Resource">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="uri" type="tns:URI"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ <element name="relationship" type="tns:Relationship" maxOccurs="unbounded" minOccurs="0"></element>
+ </sequence>
+ <attribute name="id" type="ID" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Relationship">
+ <complexContent>
+ <extension base="tns:Root">
+ <sequence>
+ <element name="link" type="tns:Link"
+ maxOccurs="unbounded" minOccurs="0">
+ </element>
+ </sequence>
+ <attribute name="ref" type="IDREF" use="required"></attribute>
+ <attribute name="type" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="Link">
+ <complexContent>
+ <extension base="tns:Root">
+ <attribute name="from" type="string"></attribute>
+
+ <attribute name="to" type="string"></attribute>
+
+ <attribute name="type" type="string" use="required"></attribute>
+
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+ <complexType name="Root">
+ <sequence>
+ <element name="description" type="string" maxOccurs="1"
+ minOccurs="0">
+ </element>
+ <any namespace="##other" processContents="lax" maxOccurs="100"
+ minOccurs="0" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <complexType name="URI">
+ <complexContent>
+ <extension base="tns:Root">
+ <attribute name="type" type="string" use="required"></attribute>
+ <attribute name="context" type="string" use="required"></attribute>
+ <attribute name="locator" type="string" use="required"></attribute>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <element name="project" type="tns:Project"></element>
+</schema>
Modified: trunk/tools/plugins/pom.xml
===================================================================
--- trunk/tools/plugins/pom.xml 2010-09-17 09:19:43 UTC (rev 404)
+++ trunk/tools/plugins/pom.xml 2010-09-17 15:22:30 UTC (rev 405)
@@ -19,6 +19,8 @@
<module>org.jboss.savara.pi4soa.cdm</module>
<module>org.jboss.savara.protocol.contract</module>
<module>org.jboss.savara.tap.model</module>
+ <module>org.jboss.savara.tap.validation</module>
+ <module>org.jboss.savara.tap.eclipse</module>
<module>org.jboss.savara.tools.bpel</module>
<module>org.jboss.savara.tools.validator</module>
<module>org.jboss.savara.tools.wsdl</module>
More information about the savara-commits
mailing list