airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [13/14] airavata git commit: Refactor JPA configuration for profile-service and add to airavata properties
Date Wed, 08 Mar 2017 23:45:54 GMT
Refactor JPA configuration for profile-service and add to airavata properties


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/fe0ed74e
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/fe0ed74e
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/fe0ed74e

Branch: refs/heads/user-profile
Commit: fe0ed74e9d9f6d30bfa34189fef0e86eaa042972
Parents: 648d8ca
Author: Gourav Shenoy <shenoy.200@gmail.com>
Authored: Wed Mar 8 18:27:04 2017 -0500
Committer: Gourav Shenoy <shenoy.200@gmail.com>
Committed: Wed Mar 8 18:27:04 2017 -0500

----------------------------------------------------------------------
 .../profile/commons/utils/JPAConstants.java      | 19 ++++++++++---------
 .../service/profile/commons/utils/JPAUtils.java  | 16 ++++++----------
 .../service/profile/commons/utils/Utils.java     |  8 --------
 .../src/main/resources/META-INF/persistence.xml  |  2 +-
 .../main/resources/airavata-server.properties    |  7 ++++++-
 5 files changed, 23 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/fe0ed74e/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAConstants.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAConstants.java
b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAConstants.java
index d1f0e02..51b9f6b 100644
--- a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAConstants.java
+++ b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAConstants.java
@@ -18,16 +18,17 @@
  * under the License.
  *
  */
-
 package org.apache.airavata.service.profile.commons.utils;
+
 public class JPAConstants {
-	public static final String KEY_JDBC_URL = "user.profile.catalog.registry.jdbc.url";
-	public static final String KEY_JDBC_USER = "user.profile.catalog.registry.jdbc.user";
-	public static final String KEY_JDBC_PASSWORD = "user.profile.catalog.registry.jdbc.password";
-	public static final String KEY_JDBC_DRIVER = "user.profile.catalog.registry.jdbc.driver";
+	public static final String KEY_JDBC_URL = "profile.service.jdbc.url";
+	public static final String KEY_JDBC_USER = "profile.service.jdbc.user";
+	public static final String KEY_JDBC_PASSWORD = "profile.service.jdbc.password";
+	public static final String KEY_JDBC_DRIVER = "profile.service.jdbc.driver";
+
 	// TODO: is this needed?
-	public static final String KEY_DERBY_START_ENABLE = "user.profile.catalog.start.derby.server.mode";
-	public static final String VALIDATION_QUERY = "user.profile.catalog.validationQuery";
-	public static final String JPA_CACHE_SIZE = "user.profile.catalog.jpa.cache.size";
-	public static final String ENABLE_CACHING = "user.profile.catalog.cache.enable";
+	public static final String KEY_DERBY_START_ENABLE = "profile.service.start.derby.server.mode";
+	public static final String VALIDATION_QUERY = "profile.service.validationQuery";
+	public static final String JPA_CACHE_SIZE = "profile.service.jpa.cache.size";
+	public static final String ENABLE_CACHING = "profile.service.cache.enable";
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/fe0ed74e/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAUtils.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAUtils.java
b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAUtils.java
index 81969a3..9a30370 100644
--- a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAUtils.java
+++ b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/JPAUtils.java
@@ -29,16 +29,15 @@ import java.util.Map;
 
 public class JPAUtils {
     private final static Logger logger = LoggerFactory.getLogger(JPAUtils.class);
-    private static final String PERSISTENCE_UNIT_NAME = "user_profile_catalog";
-    @PersistenceUnit(unitName = "user_profile_catalog")
-    protected static EntityManagerFactory factory;
-    @PersistenceContext(unitName = "user_profile_catalog")
-    private static EntityManager entityManager;
+    private static final String PERSISTENCE_UNIT_NAME = "profile_service";
 
-    public static EntityManager getEntityManager(){
+    @PersistenceUnit(unitName = PERSISTENCE_UNIT_NAME)
+    private static EntityManagerFactory factory;
+
+    private static EntityManager getEntityManager(){
+        EntityManager entityManager;
 
         if (factory == null) {
-            //FIXME
             String connectionProperties = "DriverClassName=" + Utils.getJDBCDriver() + ","
+ "Url=" +
                     Utils.getJDBCURL() + "?autoReconnect=true," +
                     "Username=" + Utils.getJDBCUser() + "," + "Password=" + Utils.getJDBCPassword()
+
@@ -57,7 +56,6 @@ public class JPAUtils {
                     " PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000,
 autoReconnect=true");
             factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
         }
-
         entityManager = factory.createEntityManager();
         return entityManager;
     }
@@ -78,6 +76,4 @@ public class JPAUtils {
             }
         }
     }
-
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/fe0ed74e/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/Utils.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/Utils.java
b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/Utils.java
index 32efb66..71d0029 100644
--- a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/Utils.java
+++ b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/utils/Utils.java
@@ -31,14 +31,6 @@ import java.net.URI;
 public class Utils {
     private final static Logger logger = LoggerFactory.getLogger(Utils.class);
 
-    public static String getJDBCFullURL(){
-		String jdbcUrl = getJDBCURL();
-		String jdbcUser = getJDBCUser();
-		String jdbcPassword = getJDBCPassword();
-        jdbcUrl = jdbcUrl + "?"  + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
-        return jdbcUrl;
-    }
-
     public static String getJDBCURL(){
     	try {
             return ServerSettings.getSetting(JPAConstants.KEY_JDBC_URL);

http://git-wip-us.apache.org/repos/asf/airavata/blob/fe0ed74e/airavata-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
b/airavata-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
index 2a0adc6..06df649 100644
--- a/airavata-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
+++ b/airavata-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
@@ -20,7 +20,7 @@
  *
 * -->
 <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
-    <persistence-unit name="profile_service_catalog">
+    <persistence-unit name="profile_service">
         <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
         <class>org.apache.airavata.service.profile.commons.user.entities.UserProfileEntity</class>
         <class>org.apache.airavata.service.profile.commons.user.entities.NSFDemographicsEntity</class>

http://git-wip-us.apache.org/repos/asf/airavata/blob/fe0ed74e/modules/configuration/server/src/main/resources/airavata-server.properties
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties
index 07a373a..fa3475a 100644
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@ -350,4 +350,9 @@ user.profile.catalog.validationQuery=SELECT 1
 ###########################################################################
 profile.service.server.host=localhost
 profile.service.server.port=8962
-profile_service=org.apache.airavata.service.profile.server.ProfileServiceServer
\ No newline at end of file
+profile_service=org.apache.airavata.service.profile.server.ProfileServiceServer
+profile.service.jdbc.url=jdbc:derby:profile-service;create=true;user=airavata;password=airavata
+profile.service.jdbc.driver=org.apache.derby.jdbc.ClientDriver
+profile.service.jdbc.user=airavata
+profile.service.jdbc.password=airavata
+profile.service.validationQuery=SELECT 1
\ No newline at end of file


Mime
View raw message