airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1181842 - in /incubator/airavata/trunk/modules: commons/registry-api/src/main/java/org/apache/airavata/registry/api/ commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/ xbaya-gui/src/main/java/org/apache/airavata/xbay...
Date Tue, 11 Oct 2011 15:32:46 GMT
Author: lahiru
Date: Tue Oct 11 15:32:46 2011
New Revision: 1181842

URL: http://svn.apache.org/viewvc?rev=1181842&view=rev
Log:
fixing https://issues.apache.org/jira/browse/AIRAVATA-123. AIRAVATA-123-BE-2.patch

Modified:
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java?rev=1181842&r1=1181841&r2=1181842&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
(original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
Tue Oct 11 15:32:46 2011
@@ -141,7 +141,27 @@ public interface Registry {
 	 * @throws DeploymentDescriptionRetrieveException 
 	 */
 	public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName,
String hostName) throws DeploymentDescriptionRetrieveException, PathNotFoundException;
+	
+	/**
+	 * Search deployment description from a service and/or a hostname
+	 *
+	 * @param serviceName 
+	 * @param hostName
+	 * @param applicationName
+	 * @return the deployment descriptions with matched service name, host name & reg-ex
supported application name
+	 * @throws PathNotFoundException 
+	 * @throws DeploymentDescriptionRetrieveException 
+	 */
+	public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName,
String hostName, String applicationName) throws PathNotFoundException, DeploymentDescriptionRetrieveException;
 
+	/**
+	 * Return all deployment descriptions
+	 *
+	 * @return all deployment descriptions on a map with their values containing the service
& host as a string separated by "$"
+	 * @throws PathNotFoundException 
+	 * @throws DeploymentDescriptionRetrieveException 
+	 */
+	public Map<ApplicationDeploymentDescription,String> searchDeploymentDescription()
throws PathNotFoundException, DeploymentDescriptionRetrieveException;
     /**
      * This method can be used to save the gfacURL in to registry
      * @param gfacURL

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java?rev=1181842&r1=1181841&r2=1181842&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
(original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
Tue Oct 11 15:32:46 2011
@@ -423,10 +423,98 @@ public class JCRRegistry implements Axis
 		return result;
 	}
 
+	public Map<ApplicationDeploymentDescription,String> searchDeploymentDescription()
throws PathNotFoundException, DeploymentDescriptionRetrieveException {
+		Session session = null;
+		Map<ApplicationDeploymentDescription,String> result = new HashMap<ApplicationDeploymentDescription,String>();
+        try {
+            session = getSession();
+            Node deploymentNode = getDeploymentNode(session);
+			NodeIterator serviceNodes = deploymentNode.getNodes();
+
+            for (; serviceNodes.hasNext();) {
+				Node serviceNode = serviceNodes.nextNode();
+				NodeIterator hostNodes = serviceNode.getNodes();
+
+            	for (; hostNodes.hasNext();) {
+            		Node hostNode = hostNodes.nextNode();
+    				NodeIterator nodes = hostNode.getNodes();
+                	for (; nodes.hasNext();) {
+						Node app = nodes.nextNode();
+						Property prop = app.getProperty(XML_PROPERTY_NAME);
+						result.put((ApplicationDeploymentDescription) SchemaUtil
+								.parseFromXML(prop.getString()),serviceNode.getName()+"$"+hostNode.getName());
+                	}
+            	}
+			}
+		}catch(PathNotFoundException e){
+			throw e;
+        } catch (Exception e) {
+            throw new DeploymentDescriptionRetrieveException(e);
+        } finally {
+            if (session != null && session.isLive()) {
+                session.logout();
+            }
+        }	   
+		return result;
+	}
+	
 	public List<ApplicationDeploymentDescription> searchDeploymentDescription(
-			String serviceName, String hostName) {
-		// TODO implementation
-		return null;
+			String serviceName, String hostName, String applicationName) throws PathNotFoundException,
DeploymentDescriptionRetrieveException {
+	    Session session = null;
+        List<ApplicationDeploymentDescription> result = new ArrayList<ApplicationDeploymentDescription>();
+        try {
+            session = getSession();
+            Node deploymentNode = getDeploymentNode(session);
+			Node serviceNode = deploymentNode.getNode(serviceName);
+			Node hostNode = serviceNode.getNode(hostName);
+			NodeIterator nodes = hostNode.getNodes();
+			for (; nodes.hasNext();) {
+				Node app = nodes.nextNode();
+				Property prop = app.getProperty(XML_PROPERTY_NAME);
+				ApplicationDeploymentDescription appDesc = (ApplicationDeploymentDescription) SchemaUtil
+						.parseFromXML(prop.getString());
+				if (appDesc.getName().matches(applicationName)){
+					result.add(appDesc);
+				}
+			}
+		}catch(PathNotFoundException e){
+			throw e;
+        } catch (Exception e) {
+            throw new DeploymentDescriptionRetrieveException(e);
+        } finally {
+            if (session != null && session.isLive()) {
+                session.logout();
+            }
+        }	   
+		return result;
+	}
+	
+	public List<ApplicationDeploymentDescription> searchDeploymentDescription(
+			String serviceName, String hostName) throws PathNotFoundException, DeploymentDescriptionRetrieveException
{
+	    Session session = null;
+        List<ApplicationDeploymentDescription> result = new ArrayList<ApplicationDeploymentDescription>();
+        try {
+            session = getSession();
+            Node deploymentNode = getDeploymentNode(session);
+			Node serviceNode = deploymentNode.getNode(serviceName);
+			Node hostNode = serviceNode.getNode(hostName);
+			NodeIterator nodes = hostNode.getNodes();
+			for (; nodes.hasNext();) {
+				Node app = nodes.nextNode();
+				Property prop = app.getProperty(XML_PROPERTY_NAME);
+				result.add((ApplicationDeploymentDescription) SchemaUtil
+						.parseFromXML(prop.getString()));
+			}
+		}catch(PathNotFoundException e){
+			throw e;
+        } catch (Exception e) {
+            throw new DeploymentDescriptionRetrieveException(e);
+        } finally {
+            if (session != null && session.isLive()) {
+                session.logout();
+            }
+        }	   
+		return result;
 	}
 
     public String saveWSDL(String name, String WSDL) {

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java?rev=1181842&r1=1181841&r2=1181842&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java
Tue Oct 11 15:32:46 2011
@@ -1,7 +1,19 @@
 package org.apache.airavata.xbaya.appwrapper;
 
 import java.awt.BorderLayout;
+import java.awt.Color;
 import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.List;
+import java.util.regex.Pattern;
 
 import javax.jcr.PathNotFoundException;
 import javax.swing.GroupLayout;
@@ -14,27 +26,15 @@ import javax.swing.JPanel;
 import javax.swing.JSeparator;
 import javax.swing.JTextField;
 import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.SwingConstants;
 
+import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.commons.gfac.type.app.ShellApplicationDeployment;
-import org.apache.airavata.registry.api.exception.ServiceDescriptionRetrieveException;
 import org.apache.airavata.xbaya.XBayaEngine;
 import org.apache.airavata.xbaya.component.registry.JCRComponentRegistry;
-
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.Color;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
 import org.apache.airavata.xbaya.gui.XBayaLinkButton;
-import javax.swing.SwingConstants;
-import java.awt.Font;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.List;
 
 public class ApplicationDescriptionDialog extends JDialog {
 	/**
@@ -80,7 +80,18 @@ public class ApplicationDescriptionDialo
 				int i=1;
 				String defaultName=baseName+i;
 				try {
-					while(getJCRComponentRegistry().getHostDescription(defaultName)!=null){
+					List<ApplicationDeploymentDescription> applicationDescriptions = getJCRComponentRegistry().getRegistry().searchDeploymentDescription(getServiceName(),
getHostName());
+					while(true){
+						boolean notFound=true;
+						for (ApplicationDeploymentDescription deploymentDescription : applicationDescriptions)
{
+							if (deploymentDescription.getName().equals(defaultName)){
+								notFound=false;
+								break;
+							}
+						}
+						if (notFound){
+							break;
+						}
 						defaultName=baseName+(++i);
 					}
 				} catch (Exception e) {
@@ -348,6 +359,7 @@ public class ApplicationDescriptionDialo
 		} catch (Exception e) {
 			setError(e.getLocalizedMessage());
 		}
+		updateServiceName();
 	}
 	
 	private void loadHostDescriptions(){
@@ -361,6 +373,7 @@ public class ApplicationDescriptionDialo
 		} catch (Exception e) {
 			setError(e.getLocalizedMessage());
 		}
+		updateHostName();
 	}
 	
 	public XBayaEngine getEngine() {
@@ -465,6 +478,18 @@ public class ApplicationDescriptionDialo
 		if (getHostName()==null || getHostName().trim().equals("")){
 			throw new Exception("Please select/create host to bind to this deployment description");
 		}
+		
+		List<ApplicationDeploymentDescription> deploymentDescriptions=null;
+		try {
+			deploymentDescriptions = getJCRComponentRegistry().getRegistry().searchDeploymentDescription(getServiceName(),
getHostName(), Pattern.quote(getApplicationName()));
+		} catch (PathNotFoundException e) {
+			//what we want
+		} catch (Exception e){
+			throw e;
+		}
+		if (deploymentDescriptions.size()>0){
+			throw new Exception("Application descriptor with the given name already exists!!!");
+		}
 	}
 
 	public String getServiceName() {

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java?rev=1181842&r1=1181841&r2=1181842&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java
Tue Oct 11 15:32:46 2011
@@ -9,6 +9,7 @@ import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
+import java.util.regex.Pattern;
 
 import javax.jcr.PathNotFoundException;
 import javax.swing.GroupLayout;
@@ -234,7 +235,7 @@ public class HostDescriptionDialog exten
 		
 		HostDescription hostDescription2=null;
 		try {
-			hostDescription2 = getJCRComponentRegistry().getHostDescription(getHostName());
+			hostDescription2 = getJCRComponentRegistry().getHostDescription(Pattern.quote(getHostName()));
 		} catch (PathNotFoundException e) {
 			//what we want
 		} catch (Exception e){

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java?rev=1181842&r1=1181841&r2=1181842&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java
Tue Oct 11 15:32:46 2011
@@ -43,6 +43,7 @@ import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Pattern;
 
 public class ServiceDescriptionDialog extends JDialog {
 
@@ -336,7 +337,7 @@ public class ServiceDescriptionDialog ex
 		
 		ServiceDescription serviceDescription2=null;
 		try {
-			serviceDescription2 = getJCRComponentRegistry().getServiceDescription(getServiceName());
+			serviceDescription2 = getJCRComponentRegistry().getServiceDescription(Pattern.quote(getServiceName()));
 		} catch (PathNotFoundException e) {
 			//what we want
 		} catch (Exception e){

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java?rev=1181842&r1=1181841&r2=1181842&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java
Tue Oct 11 15:32:46 2011
@@ -128,7 +128,7 @@ public class JCRComponentRegistry extend
 		return registry.getHostDescription(nameRegEx);
 	}
 	
-	public List<ApplicationDeploymentDescription> searchApplicationDescription(String
serviceName, String host) throws HostDescriptionRetrieveException {
+	public List<ApplicationDeploymentDescription> searchApplicationDescription(String
serviceName, String host) throws HostDescriptionRetrieveException, PathNotFoundException,
DeploymentDescriptionRetrieveException {
 		return registry.searchDeploymentDescription(serviceName, host);
 	}
 	



Mime
View raw message