airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [24/50] [abbrv] airavata git commit: Manually refactor Supuns changes to getUpdatedObject from develop branch
Date Wed, 05 Apr 2017 19:10:48 GMT
Manually refactor Supuns changes to getUpdatedObject from develop branch


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

Branch: refs/heads/develop
Commit: 7ba98fa399de6370d87537386bcfa7bbdaf183c6
Parents: 2c16c71
Author: Gourav Shenoy <shenoy.200@gmail.com>
Authored: Tue Apr 4 15:33:40 2017 -0400
Committer: Gourav Shenoy <shenoy.200@gmail.com>
Committed: Tue Apr 4 15:33:40 2017 -0400

----------------------------------------------------------------------
 .../server/SharingRegistryServerHandler.java    | 27 ++++++++++----------
 .../registry/SharingRegistryServiceTest.java    |  3 +++
 2 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/7ba98fa3/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
index aeef289..1af4cd6 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/server/SharingRegistryServerHandler.java
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.util.*;
 
 public class SharingRegistryServerHandler implements SharingRegistryService.Iface{
@@ -925,8 +926,6 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
 
     }
 
-
-
     private <T> T getUpdatedObject(T oldEntity, T newEntity) throws SharingRegistryException
{
         Field[] newEntityFields = newEntity.getClass().getDeclaredFields();
         Hashtable newHT = fieldsToHT(newEntityFields, newEntity);
@@ -935,17 +934,19 @@ public class SharingRegistryServerHandler implements SharingRegistryService.Ifac
         Field[] oldEntityFields = oldEntityClass.getDeclaredFields();
 
         for (Field field : oldEntityFields){
-            field.setAccessible(true);
-            Object o = newHT.get(field.getName());
-            if (o != null){
-                Field f = null;
-                try {
-                    f = oldEntityClass.getDeclaredField(field.getName());
-                    f.setAccessible(true);
-                    logger.debug("setting " + f.getName());
-                    f.set(oldEntity, o);
-                } catch (Exception e) {
-                    throw new SharingRegistryException(e.getMessage());
+            if (!Modifier.isFinal(field.getModifiers())) {
+                field.setAccessible(true);
+                Object o = newHT.get(field.getName());
+                if (o != null) {
+                    Field f = null;
+                    try {
+                        f = oldEntityClass.getDeclaredField(field.getName());
+                        f.setAccessible(true);
+                        logger.debug("setting " + f.getName());
+                        f.set(oldEntity, o);
+                    } catch (Exception e) {
+                        throw new SharingRegistryException(e.getMessage());
+                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/7ba98fa3/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
index 551a140..3edad3e 100644
--- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
@@ -145,6 +145,9 @@ public class SharingRegistryServiceTest {
         userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
 
         sharingServiceClient.createGroup(userGroup1);
+        userGroup1.setDescription("updated description");
+        sharingServiceClient.updateGroup(userGroup1);
+        Assert.assertTrue(sharingServiceClient.getGroup(domainId, userGroup1.groupId).description.equals("updated
description"));
 
         UserGroup userGroup2 = new UserGroup();
         //required


Mime
View raw message