[savara-commits] savara SVN: r404 - in trunk/tools/plugins: org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin and 7 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Sep 17 05:19:44 EDT 2010
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));
- }
-
- }
-}
More information about the savara-commits
mailing list