savara SVN: r412 - trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-09-20 11:55:15 -0400 (Mon, 20 Sep 2010)
New Revision: 412
Modified:
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/ValidatorConfigGenerator.java
Log:
Fixed issue with jbossesb validation.
Modified: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/ValidatorConfigGenerator.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/ValidatorConfigGenerator.java 2010-09-20 13:06:32 UTC (rev 411)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/ValidatorConfigGenerator.java 2010-09-20 15:55:15 UTC (rev 412)
@@ -26,6 +26,7 @@
import org.jboss.util.xml.DOMWriter;
import org.pi4soa.cdl.*;
import org.pi4soa.common.annotations.*;
+import org.pi4soa.common.xml.XMLUtils;
/**
* This class provides a generator for the JBossESB Validator
@@ -39,6 +40,29 @@
private static final String SERVICE_ELEMENT = "service";
private static final String VALIDATOR_ELEMENT = "validator";
+ public static void main(String[] args) {
+ if (args.length != 1) {
+ System.err.println("Usage: ValidatorConfigGenerator cdmPath");
+ System.exit(1);
+ }
+
+ try {
+ java.io.FileInputStream is=new java.io.FileInputStream(args[0]);
+
+ org.pi4soa.cdl.Package cdlpack=org.pi4soa.cdl.CDLManager.load(is);
+
+ is.close();
+
+ ValidatorConfigGenerator gen=new ValidatorConfigGenerator();
+
+ org.w3c.dom.Element config=gen.generate(cdlpack, args[0]);
+
+ System.out.println("CONFIG:\r\n"+XMLUtils.getText(config, true));
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
/**
* The default constructor.
*/
@@ -247,13 +271,15 @@
if (from) {
if (details.getAction() == ExchangeActionType.REQUEST) {
elemName = OUTPUT_ELEMENT;
- } else if (dest.getAttribute(TYPE_ATTR).equals(DESTINATION_TYPE_ENDPOINT_ADDRESS)) {
+ } else if (dest.getAttribute(TYPE_ATTR).trim().length() == 0 ||
+ dest.getAttribute(TYPE_ATTR).equals(DESTINATION_TYPE_ENDPOINT_ADDRESS)) {
elemName = INPUT_ELEMENT;
}
} else {
if (details.getAction() == ExchangeActionType.REQUEST) {
elemName = INPUT_ELEMENT;
- } else if (dest.getAttribute(TYPE_ATTR).equals(DESTINATION_TYPE_ENDPOINT_ADDRESS)) {
+ } else if (dest.getAttribute(TYPE_ATTR).trim().length() == 0 ||
+ dest.getAttribute(TYPE_ATTR).equals(DESTINATION_TYPE_ENDPOINT_ADDRESS)) {
elemName = OUTPUT_ELEMENT;
}
}
13 years, 7 months
savara SVN: r411 - in trunk: samples/purchasing/completed/store and 1 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-09-20 09:06:32 -0400 (Mon, 20 Sep 2010)
New Revision: 411
Modified:
trunk/samples/jbossesb/trailblazer/build.xml
trunk/samples/purchasing/completed/store/PurchaseGoodsProcess_Store.bpel
trunk/tools/plugins/org.jboss.savara.tap.eclipse/plugin.xml
Log:
Fix the jbossesb trailblazer deploy, as was dependent upon the jbossws.sar which no longer exists, the 'completed' store bpel in purchasing example as had invalid text, and the TAP validate action is now restricted to tap files.
Modified: trunk/samples/jbossesb/trailblazer/build.xml
===================================================================
--- trunk/samples/jbossesb/trailblazer/build.xml 2010-09-17 16:42:35 UTC (rev 410)
+++ trunk/samples/jbossesb/trailblazer/build.xml 2010-09-20 13:06:32 UTC (rev 411)
@@ -82,7 +82,6 @@
<fileset dir="${soa.esb.lib.ext.dir}"/>
<fileset dir="${esb.lib.dir}/ext" includes="*.jar"/>
<fileset dir="${org.jboss.as.home}/client" includes="jboss-jaxrpc.jar jbossall-client.jar jbossws-client.jar mail.jar"/>
- <fileset dir="${org.jboss.as.home}/server/${org.jboss.as.config}/deploy/jbossws.sar" includes="jboss-jaxrpc.jar"/>
<fileset dir="${soa.esb.lib.dir}" includes="*.jar"/>
<fileset dir="${esb.samples.trailblazer.client.lib.dir}/ext" includes="*.jar"/>
<fileset dir="${esb.dest}/dist" includes="trailblazer-esb.jar"/>
Modified: trunk/samples/purchasing/completed/store/PurchaseGoodsProcess_Store.bpel
===================================================================
--- trunk/samples/purchasing/completed/store/PurchaseGoodsProcess_Store.bpel 2010-09-17 16:42:35 UTC (rev 410)
+++ trunk/samples/purchasing/completed/store/PurchaseGoodsProcess_Store.bpel 2010-09-20 13:06:32 UTC (rev 411)
@@ -69,7 +69,7 @@
</assign>
<invoke inputVariable="creditCheckRequestVar" name="Send_CreditCheckRequest" operation="checkCredit" outputVariable="creditCheckOkVar" partnerLink="StoreToCreditAgency" portType="ca:CreditAgencyInterface"/>
- portType="ca:CreditAgencyInterface"/>
+
<assign name="CopyPurchaseDetails">
<bpel:copy>
<bpel:from>
Modified: trunk/tools/plugins/org.jboss.savara.tap.eclipse/plugin.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.eclipse/plugin.xml 2010-09-17 16:42:35 UTC (rev 410)
+++ trunk/tools/plugins/org.jboss.savara.tap.eclipse/plugin.xml 2010-09-20 13:06:32 UTC (rev 411)
@@ -6,7 +6,8 @@
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.resources.IFile"
- id="org.jboss.savara.tap.eclipse.contribution1">
+ id="org.jboss.savara.tap.eclipse.contribution1"
+ nameFilter="*.tap" >
<menu
label="Savara"
path="additions"
13 years, 7 months
savara SVN: r410 - trunk/tools/plugins/org.jboss.savara.tap.eclipse.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-09-17 12:42:35 -0400 (Fri, 17 Sep 2010)
New Revision: 410
Modified:
trunk/tools/plugins/org.jboss.savara.tap.eclipse/
Log:
Property changes on: trunk/tools/plugins/org.jboss.savara.tap.eclipse
___________________________________________________________________
Name: svn:ignore
- bin
+ bin
target
13 years, 7 months
savara SVN: r409 - trunk/tools/plugins/org.scribble.eclipse.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-09-17 11:58:07 -0400 (Fri, 17 Sep 2010)
New Revision: 409
Modified:
trunk/tools/plugins/org.scribble.eclipse/plugin.xml
Log:
Modified: trunk/tools/plugins/org.scribble.eclipse/plugin.xml
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/plugin.xml 2010-09-17 15:47:25 UTC (rev 408)
+++ trunk/tools/plugins/org.scribble.eclipse/plugin.xml 2010-09-17 15:58:07 UTC (rev 409)
@@ -11,7 +11,7 @@
<extension
id="org.scribble.ScribbleProblem"
- name="SAVARA Problem"
+ name="Testable Architecture Problem"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
13 years, 7 months
savara SVN: r408 - trunk/tools/plugins/org.scribble.eclipse.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-09-17 11:47:25 -0400 (Fri, 17 Sep 2010)
New Revision: 408
Modified:
trunk/tools/plugins/org.scribble.eclipse/plugin.xml
Log:
Change problem 'name' to be SAVARA instead of Scribble.
Modified: trunk/tools/plugins/org.scribble.eclipse/plugin.xml
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/plugin.xml 2010-09-17 15:41:49 UTC (rev 407)
+++ trunk/tools/plugins/org.scribble.eclipse/plugin.xml 2010-09-17 15:47:25 UTC (rev 408)
@@ -11,7 +11,7 @@
<extension
id="org.scribble.ScribbleProblem"
- name="Scribble Problem"
+ name="SAVARA Problem"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
13 years, 7 months
savara SVN: r407 - trunk/tools/plugins/org.jboss.savara.tap.eclipse.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-09-17 11:41:49 -0400 (Fri, 17 Sep 2010)
New Revision: 407
Modified:
trunk/tools/plugins/org.jboss.savara.tap.eclipse/
Log:
Ignore bin
Property changes on: trunk/tools/plugins/org.jboss.savara.tap.eclipse
___________________________________________________________________
Name: svn:ignore
+ bin
13 years, 7 months
savara SVN: r405 - in trunk: tools/features/org.jboss.savara.experimental.feature and 22 other directories.
by do-not-reply@jboss.org
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>
13 years, 7 months
savara SVN: r404 - in trunk/tools/plugins: org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin and 7 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-09-17 05:19:43 -0400 (Fri, 17 Sep 2010)
New Revision: 404
Added:
trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-cdm-relationship-validator.xml
trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/cdm-scenario-relationship-validator.xml
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/cdl/
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/cdl/CDMScenarioRelationshipValidator.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELCDMRelationshipValidator.java
Removed:
trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-relationship-validator.xml
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java
Modified:
trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java
trunk/tools/plugins/org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin/ResourceLoader.java
trunk/tools/plugins/org.jboss.savara.tap.validation/META-INF/MANIFEST.MF
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/validation/osgi/Activator.java
Log:
SAVARA-130 - added support for relationship validation between choreography and scenario.
Modified: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java 2010-09-16 17:34:48 UTC (rev 403)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java 2010-09-17 09:19:43 UTC (rev 404)
@@ -105,8 +105,10 @@
@Override
public void enrich(ModelIssue issue) {
- // Set the EMF URI attribute
- issue.getProperties().put(EValidator.URI_ATTRIBUTE,
- issue.getModelObject().getSource().getComponentURI());
+ if (issue.getModelObject() != null) {
+ // Set the EMF URI attribute
+ issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+ issue.getModelObject().getSource().getComponentURI());
+ }
}
}
Modified: trunk/tools/plugins/org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin/ResourceLoader.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin/ResourceLoader.java 2010-09-16 17:34:48 UTC (rev 403)
+++ trunk/tools/plugins/org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin/ResourceLoader.java 2010-09-17 09:19:43 UTC (rev 404)
@@ -54,6 +54,15 @@
public java.io.InputStream getContents(Resource resource);
/**
+ * 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);
+
+ /**
* 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.
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-16 17:34:48 UTC (rev 403)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/META-INF/MANIFEST.MF 2010-09-17 09:19:43 UTC (rev 404)
@@ -6,12 +6,15 @@
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-relationship-validator.xml
+ OSGI-INF/bpel-cdm-relationship-validator.xml,
+ OSGI-INF/cdm-scenario-relationship-validator.xml
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.jboss.savara.tap.model,
org.scribble.core;bundle-version="[1.1.0,2.0.0)",
- org.scribble.eclipse;bundle-version="[1.1.0,2.0.0)"
+ org.scribble.eclipse;bundle-version="[1.1.0,2.0.0)",
+ org.pi4soa.scenario,
+ org.pi4soa.cdl
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Copied: trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-cdm-relationship-validator.xml (from rev 400, trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-relationship-validator.xml)
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-cdm-relationship-validator.xml (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-cdm-relationship-validator.xml 2010-09-17 09:19:43 UTC (rev 404)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="bpel-cdm-relationship-validator">
+ <implementation class="org.jboss.savara.tap.validation.ws.BPELCDMRelationshipValidator"/>
+ <service>
+ <provide interface="org.jboss.savara.tap.validation.RelationshipValidator"/>
+ </service>
+</component>
Deleted: trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-relationship-validator.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-relationship-validator.xml 2010-09-16 17:34:48 UTC (rev 403)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/bpel-relationship-validator.xml 2010-09-17 09:19:43 UTC (rev 404)
@@ -1,7 +0,0 @@
-<?xml version="1.0"?>
-<component name="bpel-relationship-validator">
- <implementation class="org.jboss.savara.tap.validation.ws.BPELRelationshipValidator"/>
- <service>
- <provide interface="org.jboss.savara.tap.validation.RelationshipValidator"/>
- </service>
-</component>
Added: trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/cdm-scenario-relationship-validator.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/cdm-scenario-relationship-validator.xml (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/OSGI-INF/cdm-scenario-relationship-validator.xml 2010-09-17 09:19:43 UTC (rev 404)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="cdm-scenario-relationship-validator">
+ <implementation class="org.jboss.savara.tap.validation.cdl.CDMScenarioRelationshipValidator"/>
+ <service>
+ <provide interface="org.jboss.savara.tap.validation.RelationshipValidator"/>
+ </service>
+</component>
Modified: 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-16 17:34:48 UTC (rev 403)
+++ 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)
@@ -100,6 +100,24 @@
}
/**
+ * 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.
Added: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/cdl/CDMScenarioRelationshipValidator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/cdl/CDMScenarioRelationshipValidator.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/cdl/CDMScenarioRelationshipValidator.java 2010-09-17 09:19:43 UTC (rev 404)
@@ -0,0 +1,114 @@
+/*
+ * 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.validation.cdl;
+
+import org.jboss.savara.tap.model.Relationship;
+import org.jboss.savara.tap.model.Resource;
+import org.jboss.savara.tap.model.admin.ResourceLoader;
+import org.jboss.savara.tap.validation.RelationshipValidator;
+import org.pi4soa.cdl.CDLManager;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+public class CDMScenarioRelationshipValidator implements RelationshipValidator {
+
+ /**
+ * This method determines whether the validator supports the
+ * supplied resource and relationship types.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param toResource The 'to' resource to be validated
+ * @return Whether the validator supports the resource types
+ */
+ public boolean isSupported(Relationship rel, Resource fromResource, Resource toResource) {
+ boolean ret=false;
+
+ if (fromResource.getId().endsWith(".cdm") && toResource.getId().endsWith(".scn")) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method validates the supplied resources and relationship,
+ * and reports any issues to the supplied model listener.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param fromRL The 'from' resource loader
+ * @param toResource The 'to' resource to be validated
+ * @param toRL The 'to' resource loader
+ * @param l The model listener
+ */
+ public void validate(Relationship rel, Resource fromResource, final ResourceLoader fromRL,
+ Resource toResource, final ResourceLoader toRL, ModelListener l) {
+ java.net.URI cdmURI=fromRL.getURI(fromResource);
+ java.net.URI scnURI=toRL.getURI(toResource);
+
+ Simulator simulator=new Simulator(scnURI.getPath(), cdmURI.getPath());
+
+ simulator.run();
+
+ if (simulator.isFailed()) {
+ l.error(new ModelIssue(null, "Choreography does not satisfy scenario with id '"+
+ toResource.getId()+"'"));
+ }
+ }
+
+ public class Simulator extends org.pi4soa.scenario.simulation.ScenarioSimulator {
+
+ private String m_cdmPath=null;
+ private boolean m_failed=false;
+
+ public Simulator(String scenarioPath, String cdmPath) {
+ super(scenarioPath, null);
+
+ m_cdmPath = cdmPath;
+ }
+
+ @Override
+ protected org.pi4soa.cdl.Package loadCDL(String cdlurl,
+ String scenarioFile) {
+ // Ignore the parameters and use the TAP configured file
+ org.pi4soa.cdl.Package ret=null;
+
+ try {
+ ret = CDLManager.load(m_cdmPath);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return(ret);
+ }
+
+ @Override
+ protected void failed(String id, String text) {
+ m_failed = true;
+ }
+
+ public boolean isFailed() {
+ return(m_failed);
+ }
+ }
+}
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-16 17:34:48 UTC (rev 403)
+++ 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)
@@ -1,5 +1,7 @@
package org.jboss.savara.tap.validation.osgi;
+import java.util.logging.Logger;
+
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.savara.tap.model.admin.ResourceLoader;
import org.jboss.savara.tap.validation.RelationshipValidator;
@@ -16,6 +18,8 @@
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.savara.tap.validation"; //$NON-NLS-1$
+ private static Logger logger=Logger.getLogger(Activator.class.getName());
+
// The shared instance
private static Activator plugin;
@@ -34,44 +38,47 @@
plugin = this;
// Get resource loaders
- ServiceReference sr=context.getServiceReference(ResourceLoader.class.getName());
+ ServiceReference[] srefs=context.getServiceReferences(ResourceLoader.class.getName(), null);
- // NOTE: May need to cater for multiple resource loader implementations
- if (sr != null) {
- ResourceLoader rl=(ResourceLoader)context.getService(sr);
-
- if (rl != null) {
- ValidateAction.getValidator().addResourceLoader(rl);
- } else {
- System.err.println("ERROR: ResourceLoader does not exist");
+ if (srefs != null) {
+ for (ServiceReference sr : srefs) {
+ ResourceLoader rl=(ResourceLoader)context.getService(sr);
+
+ if (rl != null) {
+ ValidateAction.getValidator().addResourceLoader(rl);
+ } else {
+ logger.severe("ResourceLoader does not exist for service ref: "+sr);
+ }
}
}
// Get resource validators
- sr = context.getServiceReference(ResourceValidator.class.getName());
+ srefs = context.getServiceReferences(ResourceValidator.class.getName(), null);
- // NOTE: May need to cater for multiple resource validator implementations
- if (sr != null) {
- ResourceValidator rv=(ResourceValidator)context.getService(sr);
-
- if (rv != null) {
- ValidateAction.getValidator().addResourceValidator(rv);
- } else {
- System.err.println("ERROR: ResourceValidator does not exist");
+ if (srefs != null) {
+ for (ServiceReference sr : srefs) {
+ ResourceValidator rv=(ResourceValidator)context.getService(sr);
+
+ if (rv != null) {
+ ValidateAction.getValidator().addResourceValidator(rv);
+ } else {
+ logger.severe("ResourceValidator does not exist for service ref: "+sr);
+ }
}
}
// Get relationship validators
- sr = context.getServiceReference(RelationshipValidator.class.getName());
+ srefs = context.getServiceReferences(RelationshipValidator.class.getName(), null);
- // NOTE: May need to cater for multiple relationship validator implementations
- if (sr != null) {
- RelationshipValidator rv=(RelationshipValidator)context.getService(sr);
-
- if (rv != null) {
- ValidateAction.getValidator().addRelationshipValidator(rv);
- } else {
- System.err.println("ERROR: RelationshipValidator does not exist");
+ if (srefs != null) {
+ for (ServiceReference sr : srefs) {
+ RelationshipValidator rv=(RelationshipValidator)context.getService(sr);
+
+ if (rv != null) {
+ ValidateAction.getValidator().addRelationshipValidator(rv);
+ } else {
+ logger.severe("RelationshipValidator does not exist for service ref: "+sr);
+ }
}
}
}
Copied: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELCDMRelationshipValidator.java (from rev 401, trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java)
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELCDMRelationshipValidator.java (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELCDMRelationshipValidator.java 2010-09-17 09:19:43 UTC (rev 404)
@@ -0,0 +1,175 @@
+/*
+ * 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.validation.ws;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.savara.tap.model.Link;
+import org.jboss.savara.tap.model.Relationship;
+import org.jboss.savara.tap.model.Resource;
+import org.jboss.savara.tap.model.admin.ResourceLoader;
+import org.jboss.savara.tap.validation.RelationshipValidator;
+import org.scribble.model.Model;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Role;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+
+public class BPELCDMRelationshipValidator implements RelationshipValidator {
+
+ /**
+ * This method determines whether the validator supports the
+ * supplied resource and relationship types.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param toResource The 'to' resource to be validated
+ * @return Whether the validator supports the resource types
+ */
+ public boolean isSupported(Relationship rel, Resource fromResource, Resource toResource) {
+ boolean ret=false;
+
+ // NOTE: When more than one choreography model is available, we may need to just find
+ // a way to identify whether a parser exists to convert the 'toResource' into a
+ // global protocol model
+ if (fromResource.getId().endsWith(".bpel") && toResource.getId().endsWith(".cdm")) {
+
+ // Check that a link exists with type 'role' and a 'to' field containing the target
+ // role (or participant in CDL case)
+ for (Link link : rel.getLink()) {
+ if (link.getType().equals("role") && link.getTo() != null) {
+ ret = true;
+ break;
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method validates the supplied resources and relationship,
+ * and reports any issues to the supplied model listener.
+ *
+ * @param rel The relationship details
+ * @param fromResource The 'from' resource to be validated
+ * @param fromRL The 'from' resource loader
+ * @param toResource The 'to' resource to be validated
+ * @param toRL The 'to' resource loader
+ * @param l The model listener
+ */
+ public void validate(Relationship rel, Resource fromResource, final ResourceLoader fromRL,
+ Resource toResource, final ResourceLoader toRL, ModelListener l) {
+ String roleName=null;
+
+ // Get the 'to' role associated with the link
+ for (Link link : rel.getLink()) {
+ if (link.getType().equals("role") && link.getTo() != null) {
+ roleName = link.getTo();
+ break;
+ }
+ }
+
+ if (roleName == null) {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage("Role not defined on relationship link");
+ l.error(issue);
+ } else {
+ org.scribble.parser.Parser p=new org.scribble.parser.DefaultParser();
+
+ org.scribble.model.ModelReference fromRef=fromRL.getModelReference(fromResource);
+ //new org.scribble.model.ModelReference("bpel");
+
+ java.io.InputStream fromIS=fromRL.getContents(fromResource);
+
+ org.scribble.model.Model fromModel=p.parse(fromRef, fromIS, l,
+ new ResourceLoaderContext(fromRL));
+
+ if (fromModel == null) {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage("Failed to parse '"+fromResource.getId()+"'");
+ l.error(issue);
+ } else {
+
+ org.scribble.model.ModelReference toRef=toRL.getModelReference(toResource);
+ //new org.scribble.model.ModelReference("cdm");
+
+ java.io.InputStream toIS=fromRL.getContents(toResource);
+
+ org.scribble.model.Model toModel=p.parse(toRef, toIS, l,
+ new ResourceLoaderContext(toRL));
+
+ if (toModel == null) {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage("Failed to parse related resource '"+toResource.getId()+
+ "' for resource '"+fromResource.getId()+"'");
+ l.error(issue);
+
+ } else {
+ org.scribble.projector.Projector projector=new org.scribble.projector.DefaultProjector();
+
+ Role role=new Role(roleName);
+
+ org.scribble.model.Model toLocalModel=projector.project(toRef, toModel, role, l);
+
+ if (toLocalModel == null) {
+ ModelIssue issue=new ModelIssue();
+ issue.setMessage("Failed to project related resource '"+toResource.getId()+
+ "', role '"+roleName+"', for resource '"+fromResource.getId()+"'");
+ l.error(issue);
+ } else {
+ org.scribble.comparator.Comparator comparator=new org.scribble.comparator.DefaultComparator();
+
+ if (comparator.compare((Model)fromModel, fromRef, (Model)toLocalModel, toRef, l)) {
+ //System.out.println("COMPARE OK");
+ } else {
+ //System.out.println("COMPARE NOT OK");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public class ResourceLoaderContext implements Context {
+
+ private ResourceLoader m_resourceLoader=null;
+
+ public ResourceLoaderContext(ResourceLoader rl) {
+ m_resourceLoader = rl;
+ }
+
+ @Override
+ public InputStream getResource(ModelReference ref, String uri) {
+ return(m_resourceLoader.getContents(ref, uri));
+ }
+
+ @Override
+ public java.net.URI getResourceURI(ModelReference ref, String uri) {
+ return(m_resourceLoader.getURI(ref, uri));
+ }
+
+ }
+}
Deleted: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java 2010-09-16 17:34:48 UTC (rev 403)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java 2010-09-17 09:19:43 UTC (rev 404)
@@ -1,175 +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.validation.ws;
-
-import java.io.InputStream;
-
-import javax.xml.namespace.QName;
-
-import org.jboss.savara.tap.model.Link;
-import org.jboss.savara.tap.model.Relationship;
-import org.jboss.savara.tap.model.Resource;
-import org.jboss.savara.tap.model.admin.ResourceLoader;
-import org.jboss.savara.tap.validation.RelationshipValidator;
-import org.scribble.model.Model;
-import org.scribble.model.ModelReference;
-import org.scribble.model.Role;
-import org.scribble.model.admin.Context;
-import org.scribble.model.admin.ModelIssue;
-import org.scribble.model.admin.ModelListener;
-
-public class BPELRelationshipValidator implements RelationshipValidator {
-
- /**
- * This method determines whether the validator supports the
- * supplied resource and relationship types.
- *
- * @param rel The relationship details
- * @param fromResource The 'from' resource to be validated
- * @param toResource The 'to' resource to be validated
- * @return Whether the validator supports the resource types
- */
- public boolean isSupported(Relationship rel, Resource fromResource, Resource toResource) {
- boolean ret=false;
-
- // NOTE: When more than one choreography model is available, we may need to just find
- // a way to identify whether a parser exists to convert the 'toResource' into a
- // global protocol model
- if (fromResource.getId().endsWith(".bpel") && toResource.getId().endsWith(".cdm")) {
-
- // Check that a link exists with type 'role' and a 'to' field containing the target
- // role (or participant in CDL case)
- for (Link link : rel.getLink()) {
- if (link.getType().equals("role") && link.getTo() != null) {
- ret = true;
- break;
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * This method validates the supplied resources and relationship,
- * and reports any issues to the supplied model listener.
- *
- * @param rel The relationship details
- * @param fromResource The 'from' resource to be validated
- * @param fromRL The 'from' resource loader
- * @param toResource The 'to' resource to be validated
- * @param toRL The 'to' resource loader
- * @param l The model listener
- */
- public void validate(Relationship rel, Resource fromResource, final ResourceLoader fromRL,
- Resource toResource, final ResourceLoader toRL, ModelListener l) {
- String roleName=null;
-
- // Get the 'to' role associated with the link
- for (Link link : rel.getLink()) {
- if (link.getType().equals("role") && link.getTo() != null) {
- roleName = link.getTo();
- break;
- }
- }
-
- if (roleName == null) {
- ModelIssue issue=new ModelIssue();
- issue.setMessage("Role not defined on relationship link");
- l.error(issue);
- } else {
- org.scribble.parser.Parser p=new org.scribble.parser.DefaultParser();
-
- org.scribble.model.ModelReference fromRef=fromRL.getModelReference(fromResource);
- //new org.scribble.model.ModelReference("bpel");
-
- java.io.InputStream fromIS=fromRL.getContents(fromResource);
-
- org.scribble.model.Model fromModel=p.parse(fromRef, fromIS, l,
- new ResourceLoaderContext(fromRL));
-
- if (fromModel == null) {
- ModelIssue issue=new ModelIssue();
- issue.setMessage("Failed to parse '"+fromResource.getId()+"'");
- l.error(issue);
- } else {
-
- org.scribble.model.ModelReference toRef=toRL.getModelReference(toResource);
- //new org.scribble.model.ModelReference("cdm");
-
- java.io.InputStream toIS=fromRL.getContents(toResource);
-
- org.scribble.model.Model toModel=p.parse(toRef, toIS, l,
- new ResourceLoaderContext(toRL));
-
- if (toModel == null) {
- ModelIssue issue=new ModelIssue();
- issue.setMessage("Failed to parse related resource '"+toResource.getId()+
- "' for resource '"+fromResource.getId()+"'");
- l.error(issue);
-
- } else {
- org.scribble.projector.Projector projector=new org.scribble.projector.DefaultProjector();
-
- Role role=new Role(roleName);
-
- org.scribble.model.Model toLocalModel=projector.project(toRef, toModel, role, l);
-
- if (toLocalModel == null) {
- ModelIssue issue=new ModelIssue();
- issue.setMessage("Failed to project related resource '"+toResource.getId()+
- "', role '"+roleName+"', for resource '"+fromResource.getId()+"'");
- l.error(issue);
- } else {
- org.scribble.comparator.Comparator comparator=new org.scribble.comparator.DefaultComparator();
-
- if (comparator.compare((Model)fromModel, fromRef, (Model)toLocalModel, toRef, l)) {
- //System.out.println("COMPARE OK");
- } else {
- //System.out.println("COMPARE NOT OK");
- }
- }
- }
- }
- }
- }
-
- public class ResourceLoaderContext implements Context {
-
- private ResourceLoader m_resourceLoader=null;
-
- public ResourceLoaderContext(ResourceLoader rl) {
- m_resourceLoader = rl;
- }
-
- @Override
- public InputStream getResource(ModelReference ref, String uri) {
- return(m_resourceLoader.getContents(ref, uri));
- }
-
- @Override
- public java.net.URI getResourceURI(ModelReference ref, String uri) {
- return(m_resourceLoader.getURI(ref, uri));
- }
-
- }
-}
13 years, 7 months
savara SVN: r403 - in trunk/tools: plugins and 1 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-09-16 13:34:48 -0400 (Thu, 16 Sep 2010)
New Revision: 403
Removed:
trunk/tools/plugins/org.scribble.lang.comparator/
Modified:
trunk/tools/features/org.jboss.savara.experimental.feature/feature.xml
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
trunk/tools/plugins/pom.xml
Log:
Fixed the double error reporting issue.
Modified: trunk/tools/features/org.jboss.savara.experimental.feature/feature.xml
===================================================================
--- trunk/tools/features/org.jboss.savara.experimental.feature/feature.xml 2010-09-16 16:12:30 UTC (rev 402)
+++ trunk/tools/features/org.jboss.savara.experimental.feature/feature.xml 2010-09-16 17:34:48 UTC (rev 403)
@@ -199,11 +199,4 @@
version="0.0.0"
unpack="false"/>
- <plugin
- id="org.scribble.lang.comparator"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
</feature>
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2010-09-16 16:12:30 UTC (rev 402)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2010-09-16 17:34:48 UTC (rev 403)
@@ -923,21 +923,8 @@
iref.setNamespace(mainpart.substring(0, index));
iref.setLocalpart(mainpart.substring(index+1));
}
-
+
ret.getImplements().add(iref);
- //ret.getConformsTo().add(iref);
-
- /* GPB: TO REMOVE
- org.scribble.model.admin.DependencyManager dm=
- (org.scribble.model.admin.DependencyManager)
- org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
- org.scribble.model.admin.DependencyManager.class, null);
-
- if (dm != null) {
- dm.recordDependency(getModel().getModelReference(),
- iref, DependencyType.Implements);
- }
- */
} else {
logger.warn("Conversation type does not " +
Modified: trunk/tools/plugins/pom.xml
===================================================================
--- trunk/tools/plugins/pom.xml 2010-09-16 16:12:30 UTC (rev 402)
+++ trunk/tools/plugins/pom.xml 2010-09-16 17:34:48 UTC (rev 403)
@@ -34,7 +34,6 @@
<module>org.scribble.core</module>
<module>org.scribble.eclipse</module>
<module>org.scribble.expression.xpath</module>
- <module>org.scribble.lang.comparator</module>
<module>org.scribble.lang.model</module>
</modules>
13 years, 7 months