airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1382992 - in /incubator/airavata/trunk/modules: airavata-client/ airavata-client/src/test/java/org/apache/airavata/client/airavata/ commons/registry-api/src/main/java/org/apache/airavata/registry/api/util/ commons/utils/src/main/java/org/a...
Date Mon, 10 Sep 2012 17:24:07 GMT
Author: lahiru
Date: Mon Sep 10 17:24:06 2012
New Revision: 1382992

URL: http://svn.apache.org/viewvc?rev=1382992&view=rev
Log:
fixing https://issues.apache.org/jira/browse/AIRAVATA-566 and more changes to use new registyr-api

Modified:
    incubator/airavata/trunk/modules/airavata-client/pom.xml
    incubator/airavata/trunk/modules/airavata-client/src/test/java/org/apache/airavata/client/airavata/AiravataClientTest.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java
    incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
    incubator/airavata/trunk/modules/distribution/src/main/resources/conf/repository.properties
    incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java

Modified: incubator/airavata/trunk/modules/airavata-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/airavata-client/pom.xml?rev=1382992&r1=1382991&r2=1382992&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/airavata-client/pom.xml (original)
+++ incubator/airavata/trunk/modules/airavata-client/pom.xml Mon Sep 10 17:24:06 2012
@@ -47,6 +47,11 @@
             <artifactId>airavata-xbaya-gui</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-jpa-registry</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 
 </project>

Modified: incubator/airavata/trunk/modules/airavata-client/src/test/java/org/apache/airavata/client/airavata/AiravataClientTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/airavata-client/src/test/java/org/apache/airavata/client/airavata/AiravataClientTest.java?rev=1382992&r1=1382991&r2=1382992&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/airavata-client/src/test/java/org/apache/airavata/client/airavata/AiravataClientTest.java
(original)
+++ incubator/airavata/trunk/modules/airavata-client/src/test/java/org/apache/airavata/client/airavata/AiravataClientTest.java
Mon Sep 10 17:24:06 2012
@@ -21,11 +21,21 @@
 package org.apache.airavata.client.airavata;
 
 import org.apache.airavata.common.registry.api.exception.RegistryException;
+import org.apache.airavata.common.registry.api.impl.JCRRegistry;
 import org.apache.airavata.xbaya.interpretor.NameValue;
+import org.apache.jackrabbit.core.RepositoryCopier;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.junit.Test;
 
-import java.io.IOException;
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Calendar;
+import java.util.HashMap;
 import java.util.List;
 import java.util.UUID;
 
@@ -51,4 +61,54 @@ public class AiravataClientTest {
 //            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
 //        }
     }
+
+    @Test
+    public void testExperimentDeletion() {
+        URI uri1 = null,uri2 = null;
+        try {
+            uri1 = new URI("http://gw56.quarry.iu.teragrid.org:8090/jackrabbit-webapp-2.4.0/rmi");
+            uri2 = new URI("http://gf7.ucs.indiana.edu:8030/jackrabbit/rmi");
+        } catch (URISyntaxException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+        }
+        HashMap<String, String> map = new HashMap<String, String>();
+        map.put("org.apache.jackrabbit.repository.uri", "http://gf7.ucs.indiana.edu:8030/jackrabbit/rmi");
+        try {
+            JCRRegistry jcrRegistry1 = new JCRRegistry(
+                    uri1,
+                    "org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory",
+                    "admin",
+                    "admin", map);
+            Session session = jcrRegistry1.getSession();
+//            session.importXML("/SERVICE_HOST",export, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+            javax.jcr.Node serviceHost = jcrRegistry1.getOrAddNode(jcrRegistry1.getRootNode(session),
"experiments");
+            serviceHost.remove();
+            session.save();
+//            javax.jcr.Node appHost = jcrRegistry1.getOrAddNode(jcrRegistry1.getRootNode(session),
"APP_HOST");
+//            javax.jcr.Node workflows = jcrRegistry1.getOrAddNode(jcrRegistry1.getRootNode(session),
"WORKFLOWS");
+//
+//            HashMap<String, String> map2 = new HashMap<String, String>();
+//            map2.put("org.apache.jackrabbit.repository.uri", "http://gf7.ucs.indiana.edu:8030/jackrabbit/rmi");
+//            JCRRegistry jcrRegistry2 = new JCRRegistry(
+//                    uri2,
+//                    "org.apache.jackrabbit.rmi.repository.RmiRepositoryFactory",
+//                    "admin",
+//                    "admin", map2);
+//            Session session2 = jcrRegistry2.getSession();
+//
+//            RepositoryCopier.copy(session.getRepository(),jcrRegistry2.getRepository());
+//            Node service_host = jcrRegistry2.getOrAddNode(jcrRegistry2.getRootNode(session2),
"SERVICE_HOST");
+//            service_host = serviceHost;
+//            session2.save();
+//
+
+        } catch (RepositoryException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+        }  catch (RegistryException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+        }
+    }
+
+
+
 }

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java?rev=1382992&r1=1382991&r2=1382992&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java
(original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/util/RegistryUtils.java
Mon Sep 10 17:24:06 2012
@@ -34,13 +34,9 @@ import org.apache.airavata.registry.api.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
 import java.io.IOException;
 import java.net.*;
 import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
 public class RegistryUtils {
@@ -50,7 +46,6 @@ public class RegistryUtils {
 
     public static final String REGISTRY_USER = "registry.user";
 
-    public static final String REPOSITORY_PROPERTIES = "repository.properties";
 
     public static String validateAxisService(String urlString)throws RegistryException {
         if(!urlString.endsWith("?wsdl")){

Modified: incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java?rev=1382992&r1=1382991&r2=1382992&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
(original)
+++ incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServiceUtils.java
Mon Sep 10 17:24:06 2012
@@ -22,6 +22,7 @@
 package org.apache.airavata.common.utils;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.SocketException;
 import java.net.URL;
 import java.util.HashMap;
@@ -31,33 +32,55 @@ import java.util.Properties;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.util.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ServiceUtils {
+    private static final Logger log = LoggerFactory.getLogger(ServiceUtils.class);
     private static final String REPOSITORY_PROPERTIES = "repository.properties";
+    public static final String IP = "ip";
+    public static final String PORT = "port";
 
 	public static String generateServiceURLFromConfigurationContext(
-			ConfigurationContext configctx, String serviceName) throws IOException,
-			SocketException {
-		URL propurl = ServiceUtils.class.getClassLoader()
+			ConfigurationContext context, String serviceName) throws IOException {
+		URL url = ServiceUtils.class.getClassLoader()
 				.getResource(REPOSITORY_PROPERTIES);
-		Properties propFile = new Properties();
-		propFile.load(propurl.openStream());
-		Map<String, String> map = new HashMap<String, String>((Map) propFile);
-		String localAddress = Utils.getIpAddress(configctx
-				.getAxisConfiguration());
-		TransportInDescription transportInDescription = configctx
-				.getAxisConfiguration().getTransportsIn().get("http");
-		String port;
-		if (transportInDescription != null
-				&& transportInDescription.getParameter("port") != null) {
-			port = (String) transportInDescription.getParameter("port")
-					.getValue();
-		} else {
-			port = map.get("port");
-		}
-		localAddress = "http://" + localAddress + ":" + port;
-		localAddress = localAddress + "/" + configctx.getContextRoot() + "/"
-				+ configctx.getServicePath() + "/" + serviceName;
-		return localAddress;
+		 String localAddress = null;
+        String port = null;
+        Properties properties = new Properties();
+        try {
+            properties.load(url.openStream());
+            localAddress = (String) properties.get(IP);
+            port = (String) properties.get(PORT);
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        if(localAddress == null){
+        try {
+            localAddress = Utils.getIpAddress(context
+                    .getAxisConfiguration());
+        } catch (SocketException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
+        }
+        }
+        TransportInDescription transportInDescription = context
+                .getAxisConfiguration().getTransportsIn()
+                .get("http");
+        if (port == null) {
+            if (transportInDescription != null
+                    && transportInDescription.getParameter("port") != null) {
+                port = (String) transportInDescription
+                        .getParameter("port").getValue();
+            }
+        }
+        localAddress = "http://" + localAddress + ":" + port;
+        localAddress = localAddress + "/"
+                + context.getContextRoot() + "/"
+                + context.getServicePath() + "/"
+                + serviceName;
+        log.debug("Service Address Configured:" + localAddress);
+        return localAddress;
 	}
 }

Modified: incubator/airavata/trunk/modules/distribution/src/main/resources/conf/repository.properties
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/distribution/src/main/resources/conf/repository.properties?rev=1382992&r1=1382991&r2=1382992&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/distribution/src/main/resources/conf/repository.properties
(original)
+++ incubator/airavata/trunk/modules/distribution/src/main/resources/conf/repository.properties
Mon Sep 10 17:24:06 2012
@@ -73,9 +73,11 @@ myproxy.pass=password
 myproxy.life=3600
 #Port details will be used by gfac-axis2 when deployed on tomcat
 port=8080
+#ip=192.2.33.12 if you configure the ip we will pick this ip address rather picking it from
axisconfiguration
 
 #Registry Configuration
 class.registry.accessor=org.apache.airavata.persistance.registry.jpa.impl.AiravataJPARegistry
 registry.user=airavata
 registry.password=ljsfousf
-gateway.id=airavata.gateway
\ No newline at end of file
+gateway.id=airavata.gateway
+

Modified: incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java?rev=1382992&r1=1382991&r2=1382992&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
(original)
+++ incubator/airavata/trunk/modules/gfac-axis2/src/main/java/org/apache/airavata/services/gfac/axis2/GFacService.java
Mon Sep 10 17:24:06 2012
@@ -33,6 +33,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.airavata.common.exception.AiravataConfigurationException;
+import org.apache.airavata.common.utils.ServiceUtils;
 import org.apache.airavata.core.gfac.context.GFacConfiguration;
 import org.apache.airavata.registry.api.AiravataRegistry2;
 import org.apache.airavata.registry.api.AiravataRegistryFactory;
@@ -66,6 +67,9 @@ public class GFacService implements Serv
     public static final int JCR_AVAIALABILITY_WAIT_INTERVAL = 1000 * 10;
 
     public static final String REGISTRY_USER = "registry.user";
+
+    public static final String SERVICE_NAME = "GFacService";
+
     /*
      * Properties for JCR
      */
@@ -136,8 +140,7 @@ public class GFacService implements Serv
                         e.printStackTrace();
                     }
                     registry = RegistryUtils.getRegistryFromConfig(url);
-
-                    context.setProperty(GFAC_URL,properties.get(GFAC_URL));
+                    context.setProperty(GFAC_URL, ServiceUtils.generateServiceURLFromConfigurationContext(context,SERVICE_NAME));
                     GFacConfiguration gfacConfig = new GFacConfiguration(properties.getProperty(MYPROXY_SERVER),properties.getProperty(MYPROXY_USER),
                             properties.getProperty(MYPROXY_PASS),Integer.parseInt(properties.getProperty(MYPROXY_LIFE)),registry,properties.getProperty(TRUSTED_CERT_LOCATION));
 					context.setProperty(GFAC_CONFIGURATION,

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java?rev=1382992&r1=1382991&r2=1382992&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
Mon Sep 10 17:24:06 2012
@@ -107,6 +107,12 @@ public class AiravataJPARegistry extends
 		return values;
     }
 
+    @Override
+    public void closeConnection() {
+        //todo close the database connection safely
+
+    }
+
     public void setConfiguration(String key, String value, Date expire) {
     	ConfigurationResource config;
 		if (ResourceUtils.isConfigurationExist(key)) {



Mime
View raw message