You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2012/10/02 19:15:25 UTC

svn commit: r1393041 - in /airavata/trunk/modules: commons/registry-api/src/main/java/org/apache/airavata/registry/api/ registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/

Author: samindaw
Date: Tue Oct  2 17:15:24 2012
New Revision: 1393041

URL: http://svn.apache.org/viewvc?rev=1393041&view=rev
Log:
allowing 3rd party registry connection data provider

Added:
    airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java   (with props)
Modified:
    airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java
    airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java

Added: airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java?rev=1393041&view=auto
==============================================================================
--- airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java (added)
+++ airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java Tue Oct  2 17:15:24 2012
@@ -0,0 +1,29 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.registry.api;
+
+import org.apache.airavata.registry.api.exception.UnknownRegistryConnectionDataException;
+
+public interface AiravataRegistryConnectionDataProvider {
+	public void setIdentity(Gateway gateway, AiravataUser use);
+	public Object getValue(String key) throws UnknownRegistryConnectionDataException;
+}

Propchange: airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryConnectionDataProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java?rev=1393041&r1=1393040&r2=1393041&view=diff
==============================================================================
--- airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java (original)
+++ airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/AiravataRegistryFactory.java Tue Oct  2 17:15:24 2012
@@ -35,6 +35,7 @@ public class AiravataRegistryFactory {
 
 	private static final String REPOSITORY_PROPERTIES = "repository.properties";
 	private static final String REGISTRY_ACCESSOR_CLASS = "class.registry.accessor";
+	private static AiravataRegistryConnectionDataProvider dataProvider;
 
 	/***
 	 * Return a registry accessor object capable of handling all data in the
@@ -116,5 +117,17 @@ public class AiravataRegistryFactory {
 		return null;
 
 	}
+	
+	public static void registerRegistryConnectionDataProvider(AiravataRegistryConnectionDataProvider provider){
+		dataProvider=provider;
+	}
+	
+	public static void unregisterRegistryConnectionDataProvider(){
+		dataProvider=null;
+	}
+	
+	public static AiravataRegistryConnectionDataProvider getRegistryConnectionDataProvider(){
+		return dataProvider;
+	}
 
 }

Modified: airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java?rev=1393041&r1=1393040&r2=1393041&view=diff
==============================================================================
--- airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java (original)
+++ airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java Tue Oct  2 17:15:24 2012
@@ -20,16 +20,33 @@
  */
 package org.apache.airavata.persistance.registry.jpa.resources;
 
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-
 import java.io.IOException;
 import java.net.URL;
-import java.sql.Blob;
-import java.sql.SQLException;
 import java.util.Properties;
 
+import org.apache.airavata.persistance.registry.jpa.JPAConstants;
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.model.Application_Descriptor;
+import org.apache.airavata.persistance.registry.jpa.model.Configuration;
+import org.apache.airavata.persistance.registry.jpa.model.Experiment;
+import org.apache.airavata.persistance.registry.jpa.model.Experiment_Data;
+import org.apache.airavata.persistance.registry.jpa.model.Experiment_Metadata;
+import org.apache.airavata.persistance.registry.jpa.model.Gateway;
+import org.apache.airavata.persistance.registry.jpa.model.Gateway_Worker;
+import org.apache.airavata.persistance.registry.jpa.model.Gram_Data;
+import org.apache.airavata.persistance.registry.jpa.model.Host_Descriptor;
+import org.apache.airavata.persistance.registry.jpa.model.Node_Data;
+import org.apache.airavata.persistance.registry.jpa.model.Project;
+import org.apache.airavata.persistance.registry.jpa.model.Published_Workflow;
+import org.apache.airavata.persistance.registry.jpa.model.Service_Descriptor;
+import org.apache.airavata.persistance.registry.jpa.model.User_Workflow;
+import org.apache.airavata.persistance.registry.jpa.model.Users;
+import org.apache.airavata.persistance.registry.jpa.model.Workflow_Data;
+import org.apache.airavata.registry.api.AiravataRegistryConnectionDataProvider;
+import org.apache.airavata.registry.api.AiravataRegistryFactory;
+import org.apache.airavata.registry.api.exception.UnknownRegistryConnectionDataException;
+
 
 public class Utils {
 
@@ -45,33 +62,63 @@ public class Utils {
     }
 
     public static String getJDBCFullURL(){
-        String jdbcUrl = null;
-        Properties properties = loadProperties();
-        jdbcUrl = properties.getProperty("registry.jdbc.url");
-        String jdbcUser = properties.getProperty("registry.jdbc.user");
-        String jdbcPassword = properties.getProperty("registry.jdbc.password");
+		String jdbcUrl = getJDBCURL();
+		String jdbcUser = getJDBCUser();
+		String jdbcPassword = getJDBCPassword();
         jdbcUrl = jdbcUrl + "?"  + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
         return jdbcUrl;
     }
 
     public static String getJDBCURL(){
-        Properties properties = loadProperties();
-        return properties.getProperty("registry.jdbc.url");
+    	try {
+			if (getProvider()!=null){
+				return getProvider().getValue(JPAConstants.KEY_JDBC_URL).toString();
+			}
+		} catch (UnknownRegistryConnectionDataException e) {
+			e.printStackTrace();
+		}
+    	Properties properties = loadProperties();
+        return properties.getProperty(JPAConstants.KEY_JDBC_URL);
     }
 
+	private static AiravataRegistryConnectionDataProvider getProvider() {
+		return AiravataRegistryFactory.getRegistryConnectionDataProvider();
+	}
+
     public static String getJDBCUser(){
+    	try {
+			if (getProvider()!=null){
+				return getProvider().getValue(JPAConstants.KEY_JDBC_USER).toString();
+			}
+		} catch (UnknownRegistryConnectionDataException e) {
+			e.printStackTrace();
+		}
         Properties properties = loadProperties();
-        return properties.getProperty("registry.jdbc.user");
+        return properties.getProperty(JPAConstants.KEY_JDBC_USER);
     }
 
     public static String getJDBCPassword(){
+    	try {
+			if (getProvider()!=null){
+				return getProvider().getValue(JPAConstants.KEY_JDBC_PASSWORD).toString();
+			}
+		} catch (UnknownRegistryConnectionDataException e) {
+			e.printStackTrace();
+		}
         Properties properties = loadProperties();
-        return properties.getProperty("registry.jdbc.password");
+        return properties.getProperty(JPAConstants.KEY_JDBC_PASSWORD);
     }
 
     public static String getJDBCDriver(){
+    	try {
+			if (getProvider()!=null){
+				return getProvider().getValue(JPAConstants.KEY_JDBC_DRIVER).toString();
+			}
+		} catch (UnknownRegistryConnectionDataException e) {
+			e.printStackTrace();
+		}
         Properties properties = loadProperties();
-        return properties.getProperty("registry.jdbc.driver");
+        return properties.getProperty(JPAConstants.KEY_JDBC_DRIVER);
     }
 
     /**