Cleanup old gateway related code. Use new Tenant related code

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

Branch: refs/heads/user-profile
Commit: 648d8ca74a12d56a63c1ab136104873ec25a6df8
Parents: 8e83408
Author: Gourav Shenoy <[email protected]>
Authored: Wed Mar 8 18:07:36 2017 -0500
Committer: Gourav Shenoy <[email protected]>
Committed: Wed Mar 8 18:07:36 2017 -0500

----------------------------------------------------------------------
 .../handlers/TenantProfileServiceHandler.java   |   3 -
 .../profile/server/ProfileServiceServer.java    |   3 +
 .../client/ProfileServiceClientFactory.java     |  21 +-
 .../profile/tenant/core/entities/Gateway.java   | 224 ---------------
 .../tenant/core/entities/GatewayProfile.java    | 100 -------
 .../tenant/core/impl/GatewayRegistry.java       | 161 -----------
 .../repositories/TenantProfileRepository.java   |  20 ++
 .../tenant/core/resources/GatewayResource.java  | 278 -------------------
 .../profile/tenant/core/util/GatewayUtils.java  | 265 ------------------
 .../profile/tenant/core/util/JPAConstants.java  |  33 ---
 .../profile/tenant/core/util/JPAUtils.java      |  50 ----
 .../tenant/core/util/QueryConstants.java        |  15 -
 .../service/profile/tenant/core/util/Utils.java | 155 -----------
 13 files changed, 42 insertions(+), 1286 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
 
b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
index ebda0dd..122e98d 100644
--- 
a/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
+++ 
b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/handlers/TenantProfileServiceHandler.java
@@ -22,7 +22,6 @@ package org.apache.airavata.service.profile.handlers;
 
 import org.apache.airavata.model.workspace.Gateway;
 import 
org.apache.airavata.service.profile.commons.tenant.entities.GatewayEntity;
-import org.apache.airavata.service.profile.tenant.core.impl.GatewayRegistry;
 import 
org.apache.airavata.service.profile.tenant.core.repositories.TenantProfileRepository;
 import org.apache.airavata.service.profile.tenant.cpi.TenantProfileService;
 import 
org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException;
@@ -39,8 +38,6 @@ public class TenantProfileServiceHandler implements 
TenantProfileService.Iface {
 
     private final static Logger logger = 
LoggerFactory.getLogger(TenantProfileServiceHandler.class);
 
-    private final GatewayRegistry gatewayRegistry = new GatewayRegistry();
-
     private TenantProfileRepository tenantProfileRepository;
 
     public TenantProfileServiceHandler() {

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/server/ProfileServiceServer.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/server/ProfileServiceServer.java
 
b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/server/ProfileServiceServer.java
index e2c3fd0..c21006b 100644
--- 
a/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/server/ProfileServiceServer.java
+++ 
b/airavata-services/profile-service/profile-service-server/src/main/java/org/apache/airavata/service/profile/server/ProfileServiceServer.java
@@ -41,6 +41,9 @@ import org.slf4j.LoggerFactory;
 import java.net.InetSocketAddress;
 import java.util.Date;
 
+/**
+ * Created by goshenoy on 03/08/2017.
+ */
 public class ProfileServiceServer implements IServer {
 
     private final static Logger logger = 
LoggerFactory.getLogger(ProfileServiceServer.class);

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java
 
b/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java
index 2c14813..8a74d25 100644
--- 
a/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java
+++ 
b/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java
@@ -20,6 +20,9 @@
  */
 package org.apache.airavata.service.profile.client;
 
+import org.apache.airavata.service.profile.tenant.cpi.TenantProfileService;
+import 
org.apache.airavata.service.profile.tenant.cpi.exception.TenantProfileServiceException;
+import 
org.apache.airavata.service.profile.tenant.cpi.profile_tenant_cpiConstants;
 import org.apache.airavata.service.profile.user.cpi.UserProfileService;
 import 
org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException;
 import org.apache.airavata.service.profile.user.cpi.profile_user_cpiConstants;
@@ -30,7 +33,9 @@ import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 
-
+/**
+ * Created by goshenoy on 03/08/2017.
+ */
 public class ProfileServiceClientFactory {
     public static UserProfileService.Client 
createUserProfileServiceClient(String serverHost, int serverPort)  throws 
UserProfileServiceException {
         try {
@@ -40,7 +45,19 @@ public class ProfileServiceClientFactory {
             TMultiplexedProtocol multiplexedProtocol = new 
TMultiplexedProtocol(protocol, profile_user_cpiConstants.USER_PROFILE_CPI_NAME);
             return new UserProfileService.Client(multiplexedProtocol);
         } catch (TTransportException e) {
-            throw new UserProfileServiceException();
+            throw new UserProfileServiceException(e.getMessage());
+        }
+    }
+
+    public static TenantProfileService.Client 
createTenantProfileServiceClient(String serverHost, int serverPort) throws 
TenantProfileServiceException {
+        try {
+            TTransport transport = new TSocket(serverHost, serverPort);
+            transport.open();
+            TProtocol protocol = new TBinaryProtocol(transport);
+            TMultiplexedProtocol multiplexedProtocol = new 
TMultiplexedProtocol(protocol, 
profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME);
+            return new TenantProfileService.Client(multiplexedProtocol);
+        } catch (TTransportException e) {
+            throw new TenantProfileServiceException(e.getMessage());
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/entities/Gateway.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/entities/Gateway.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/entities/Gateway.java
deleted file mode 100644
index 504bf8d..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/entities/Gateway.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- *
- * 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.service.profile.tenant.core.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.sql.Timestamp;
-
-@Entity
-@Table(name = "GATEWAY")
-public class Gateway {
-    private final static Logger logger = 
LoggerFactory.getLogger(Gateway.class);
-    private String gatewayId;
-    private String gatewayName;
-    private String domain;
-    private String emailAddress;
-    private String gatewayApprovalStatus;
-    private String gatewayAcronym;
-    private String gatewayUrl;
-    private String gatewayPublicAbstract;
-    private String reviewProposalDescription;
-    private String gatewayAdminFirstName;
-    private String getGatewayAdminLastName;
-    private String gatewayAdminEmail;
-    private String identityServerUserName;
-    private String identityServerPasswordToken;
-    private String declinedReason;
-    private String oauthClientId;
-    private String getOauthClientSecret;
-    private Timestamp requestCreationTime;
-    private String requesterUsername;
-
-    @Id
-    @Column(name = "GATEWAY_ID")
-    public String getGatewayId() {
-        return gatewayId;
-    }
-
-    public void setGatewayId(String gatewayId) {
-        this.gatewayId = gatewayId;
-    }
-
-    @Column(name = "GATEWAY_NAME")
-    public String getGatewayName() {
-        return gatewayName;
-    }
-
-    public void setGatewayName(String gatewayName) {
-        this.gatewayName = gatewayName;
-    }
-
-    @Column(name = "GATEWAY_DOMAIN")
-    public String getDomain() {
-        return domain;
-    }
-
-    public void setDomain(String domain) {
-        this.domain = domain;
-    }
-
-    @Column(name = "EMAIL_ADDRESS")
-    public String getEmailAddress() {
-        return emailAddress;
-    }
-
-    public void setEmailAddress(String emailAddress) {
-        this.emailAddress = emailAddress;
-    }
-
-    @Column(name = "GATEWAY_APPROVAL_STATUS")
-    public String getGatewayApprovalStatus() {
-        return gatewayApprovalStatus;
-    }
-
-    public void setGatewayApprovalStatus(String gatewayApprovalStatus) {
-        this.gatewayApprovalStatus = gatewayApprovalStatus;
-    }
-
-    @Column(name = "GATEWAY_ACRONYM")
-    public String getGatewayAcronym() {
-        return gatewayAcronym;
-    }
-
-    public void setGatewayAcronym(String gatewayAcronym) {
-        this.gatewayAcronym = gatewayAcronym;
-    }
-
-    @Column(name = "GATEWAY_URL")
-    public String getGatewayUrl() {
-        return gatewayUrl;
-    }
-
-    public void setGatewayUrl(String gatewayUrl) {
-        this.gatewayUrl = gatewayUrl;
-    }
-
-    @Column(name = "GATEWAY_PUBLIC_ABSTRACT")
-    public String getGatewayPublicAbstract() {
-        return gatewayPublicAbstract;
-    }
-
-    public void setGatewayPublicAbstract(String gatewayPublicAbstract) {
-        this.gatewayPublicAbstract = gatewayPublicAbstract;
-    }
-
-    @Column(name = "GATEWAY_REVIEW_PROPOSAL_DESCRIPTION")
-    public String getReviewProposalDescription() {
-        return reviewProposalDescription;
-    }
-
-    public void setReviewProposalDescription(String reviewProposalDescription) 
{
-        this.reviewProposalDescription = reviewProposalDescription;
-    }
-
-    @Column(name = "GATEWAY_ADMIN_FIRST_NAME")
-    public String getGatewayAdminFirstName() {
-        return gatewayAdminFirstName;
-    }
-
-    public void setGatewayAdminFirstName(String gatewayAdminFirstName) {
-        this.gatewayAdminFirstName = gatewayAdminFirstName;
-    }
-
-    @Column(name = "GATEWAY_ADMIN_LAST_NAME")
-    public String getGetGatewayAdminLastName() {
-        return getGatewayAdminLastName;
-    }
-
-    public void setGetGatewayAdminLastName(String getGatewayAdminLastName) {
-        this.getGatewayAdminLastName = getGatewayAdminLastName;
-    }
-
-    @Column(name = "GATEWAY_ADMIN_EMAIL")
-    public String getGatewayAdminEmail() {
-        return gatewayAdminEmail;
-    }
-
-    public void setGatewayAdminEmail(String gatewayAdminEmail) {
-        this.gatewayAdminEmail = gatewayAdminEmail;
-    }
-
-    @Column(name = "IDENTITY_SERVER_USERNAME")
-    public String getIdentityServerUserName() {
-        return identityServerUserName;
-    }
-
-    public void setIdentityServerUserName(String identityServerUserName) {
-        this.identityServerUserName = identityServerUserName;
-    }
-
-    @Column(name = "IDENTITY_SERVER_PASSWORD_TOKEN")
-    public String getIdentityServerPasswordToken() {
-        return identityServerPasswordToken;
-    }
-
-    public void setIdentityServerPasswordToken(String 
identityServerPasswordToken) {
-        this.identityServerPasswordToken = identityServerPasswordToken;
-    }
-
-    @Column(name = "REQUESTER_USERNAME")
-    public String getRequesterUsername() {
-        return requesterUsername;
-    }
-
-    public void setRequesterUsername(String requesterUsername) {
-        this.requesterUsername = requesterUsername;
-    }
-
-    @Column(name = "DECLINED_REASON")
-    public String getDeclinedReason() {
-        return declinedReason;
-    }
-
-    public void setDeclinedReason(String declinedReason) {
-        this.declinedReason = declinedReason;
-    }
-
-    @Column(name = "OAUTH_CLIENT_ID")
-    public String getOauthClientId() {
-        return oauthClientId;
-    }
-
-    public void setOauthClientId(String oauthClientId) {
-        this.oauthClientId = oauthClientId;
-    }
-
-    @Column(name = "REQUEST_CREATION_TIME")
-    public Timestamp getRequestCreationTime() {
-        return requestCreationTime;
-    }
-
-    public void setRequestCreationTime(Timestamp requestCreationTime) {
-        this.requestCreationTime = requestCreationTime;
-    }
-
-    @Column(name = "OAUTH_CLIENT_SECRET")
-    public String getGetOauthClientSecret() {
-        return getOauthClientSecret;
-    }
-
-    public void setGetOauthClientSecret(String oauthClientSecret) {
-        this.getOauthClientSecret = oauthClientSecret;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/entities/GatewayProfile.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/entities/GatewayProfile.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/entities/GatewayProfile.java
deleted file mode 100644
index 6204182..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/entities/GatewayProfile.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *
- * 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.service.profile.tenant.core.entities;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-@Entity
-@Table(name = "GATEWAY_PROFILE")
-public class GatewayProfile implements Serializable {
-    @Id
-    @Column(name = "GATEWAY_ID")
-    private String gatewayID;
-    @Column(name = "CREATION_TIME")
-    private Timestamp creationTime;
-
-    @Column(name = "UPDATE_TIME")
-    private Timestamp updateTime;
-
-    @Column(name = "CS_TOKEN")
-    private String credentialStoreToken;
-
-    @Column(name = "IDENTITY_SERVER_TENANT")
-    private String identityServerTenant;
-
-    @Column(name = "IDENTITY_SERVER_PWD_CRED_TOKEN")
-    private String identityServerPwdCredToken;
-
-    public Timestamp getCreationTime() {
-        return creationTime;
-    }
-
-    public void setCreationTime(Timestamp creationTime) {
-        this.creationTime = creationTime;
-    }
-
-    public Timestamp getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Timestamp updateTime) {
-        this.updateTime = updateTime;
-    }
-
-
-    public String getGatewayID() {
-        return gatewayID;
-    }
-
-    public void setGatewayID(String gatewayID) {
-        this.gatewayID = gatewayID;
-    }
-
-    public String getCredentialStoreToken() {
-        return credentialStoreToken;
-    }
-
-    public void setCredentialStoreToken(String credentialStoreToken) {
-        this.credentialStoreToken = credentialStoreToken;
-    }
-
-    public String getIdentityServerTenant() {
-        return identityServerTenant;
-    }
-
-    public void setIdentityServerTenant(String identityServerTenant) {
-        this.identityServerTenant = identityServerTenant;
-    }
-
-    public String getIdentityServerPwdCredToken() {
-        return identityServerPwdCredToken;
-    }
-
-    public void setIdentityServerPwdCredToken(String 
identityServerPwdCredToken) {
-        this.identityServerPwdCredToken = identityServerPwdCredToken;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/impl/GatewayRegistry.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/impl/GatewayRegistry.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/impl/GatewayRegistry.java
deleted file mode 100644
index 160d8a7..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/impl/GatewayRegistry.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- *
- * 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.service.profile.tenant.core.impl;
-
-import org.apache.airavata.model.workspace.Gateway;
-import org.apache.airavata.model.workspace.GatewayApprovalStatus;
-import org.apache.airavata.service.profile.commons.utils.ObjectMapperSingleton;
-import 
org.apache.airavata.service.profile.tenant.core.resources.GatewayResource;
-import org.apache.airavata.service.profile.tenant.core.util.GatewayUtils;
-import org.dozer.Mapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-public class GatewayRegistry {
-
-    private final static Logger logger = 
LoggerFactory.getLogger(GatewayRegistry.class);
-
-    public GatewayResource getExistingGateway (String gatewayName) throws 
Exception {
-        return GatewayUtils.getGateway(gatewayName);
-    }
-
-    public String addGateway (Gateway gateway) throws Exception {
-        try {
-            GatewayResource resource = 
GatewayUtils.createGateway(gateway.getGatewayId());
-            
resource.setGatewayApprovalStatus(gateway.getGatewayApprovalStatus().toString());
-            resource.setGatewayName(gateway.getGatewayName());
-            resource.setEmailAddress(gateway.getEmailAddress());
-            resource.setDomain(gateway.getDomain());
-            resource.setGatewayAcronym(gateway.getGatewayAcronym());
-            resource.setGatewayUrl(gateway.getGatewayURL());
-            
resource.setGatewayPublicAbstract(gateway.getGatewayPublicAbstract());
-            
resource.setReviewProposalDescription(gateway.getReviewProposalDescription());
-            
resource.setGatewayAdminFirstName(gateway.getGatewayAdminFirstName());
-            
resource.setGetGatewayAdminLastName(gateway.getGatewayAdminLastName());
-            resource.setGatewayAdminEmail(gateway.getGatewayAdminEmail());
-            
resource.setIdentityServerUserName(gateway.getIdentityServerUserName());
-            
resource.setIdentityServerPasswordToken(gateway.getIdentityServerPasswordToken());
-            resource.setDeclinedReason(gateway.getDeclinedReason());
-            resource.setOauthClientId(gateway.getOauthClientId());
-            resource.setOauthClientSecret(gateway.getOauthClientSecret());
-            resource.setRequestCreationTime(new 
Timestamp(System.currentTimeMillis()));
-            resource.setRequesterUsername(gateway.getRequesterUsername());
-            resource.save();
-            return gateway.getGatewayId();
-        } catch (Exception e){
-            logger.error("Error while saving gateway to registry, reason: " + 
e.getMessage(), e);
-            throw e;
-        }
-    }
-
-    public void updateGateway (String gatewayId, Gateway updatedGateway) 
throws Exception {
-        try {
-            GatewayResource existingGateway = 
GatewayUtils.getGateway(gatewayId);
-            
existingGateway.setGatewayApprovalStatus(updatedGateway.getGatewayApprovalStatus().toString());
-            existingGateway.setGatewayName(updatedGateway.getGatewayName());
-            existingGateway.setEmailAddress(updatedGateway.getEmailAddress());
-            existingGateway.setDomain(updatedGateway.getDomain());
-            
existingGateway.setGatewayAcronym(updatedGateway.getGatewayAcronym());
-            existingGateway.setGatewayUrl(updatedGateway.getGatewayURL());
-            
existingGateway.setGatewayPublicAbstract(updatedGateway.getGatewayPublicAbstract());
-            
existingGateway.setReviewProposalDescription(updatedGateway.getReviewProposalDescription());
-            
existingGateway.setGatewayAdminFirstName(updatedGateway.getGatewayAdminFirstName());
-            
existingGateway.setGetGatewayAdminLastName(updatedGateway.getGatewayAdminLastName());
-            
existingGateway.setGatewayAdminEmail(updatedGateway.getGatewayAdminEmail());
-            
existingGateway.setIdentityServerUserName(updatedGateway.getIdentityServerUserName());
-            
existingGateway.setIdentityServerPasswordToken(updatedGateway.getIdentityServerPasswordToken());
-            
existingGateway.setDeclinedReason(updatedGateway.getDeclinedReason());
-            
existingGateway.setOauthClientId(updatedGateway.getOauthClientId());
-            
existingGateway.setOauthClientSecret(updatedGateway.getOauthClientSecret());
-            
existingGateway.setRequesterUsername(updatedGateway.getRequesterUsername());
-            existingGateway.save();
-        } catch (Exception e){
-            logger.error("Error while updating gateway to registry, reason: " 
+ e.getMessage(), e);
-            throw e;
-        }
-    }
-
-    public Gateway getGateway (String gatewayId) throws Exception {
-        try {
-            GatewayResource resource = GatewayUtils.getGateway(gatewayId);
-            return GatewayUtils.toGateway(resource);
-        } catch (Exception e){
-            logger.error("Error while getting gateway, reason: " + 
e.getMessage(), e);
-            throw e;
-        }
-    }
-
-    public boolean isGatewayExist (String gatewayId) throws Exception {
-        try {
-            return GatewayUtils.isGatewayExist(gatewayId);
-        } catch (Exception e){
-            logger.error("Error while checking gateway exists, reason: " + 
e.getMessage(), e);
-            throw e;
-        }
-    }
-
-    public boolean removeGateway (String gatewayId) throws Exception {
-        try {
-            return GatewayUtils.removeGateway(gatewayId);
-        } catch (Exception e){
-            logger.error("Error while removing the gateway, reason: " + 
e.getMessage(), e);
-            throw new Exception(e);
-        }
-    }
-
-    public List<Gateway> getAllGateways () throws Exception {
-        List<Gateway> gatewayList = new ArrayList<Gateway>();
-        try {
-            List<GatewayResource> allGateways = GatewayUtils.getAllGateways();
-            return GatewayUtils.getAllGateways(allGateways);
-        } catch (Exception e){
-            logger.error("Error while getting all the gateways, reason: ", e);
-            throw e;
-        }
-    }
-
-//    public static void main(String args[]) {
-//        Mapper mapper = ObjectMapperSingleton.getInstance();
-//
-//        GatewayEntity g = new GatewayEntity();
-//        g.setGatewayId("sd");
-//        g.setRequestCreationTime(1213232);
-//        g.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE);
-//        System.out.println("T: " + g);
-//
-//        
org.apache.airavata.service.profile.commons.tenant.entities.GatewayEntity ge = 
new org.apache.airavata.service.profile.commons.tenant.entities.GatewayEntity();
-//        ge.setGatewayId("ads");
-//        ge.setRequestCreationTime(new Date().getTime());
-//        ge.setGatewayApprovalStatus("ACTIVE");
-//
-//        Class t = GatewayEntity.class;
-//        Class e = 
org.apache.airavata.service.profile.commons.tenant.entities.GatewayEntity.class;
-//        Object o = mapper.map(ge, t);
-//        System.out.println(o);
-//    }
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
index f8d4b42..ebc5fee 100644
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
+++ 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
@@ -1,3 +1,23 @@
+/*
+ *
+ * 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.service.profile.tenant.core.repositories;
 
 import org.apache.airavata.model.workspace.Gateway;

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/resources/GatewayResource.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/resources/GatewayResource.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/resources/GatewayResource.java
deleted file mode 100644
index 8ddc2d5..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/resources/GatewayResource.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- *
- * 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.service.profile.tenant.core.resources;
-
-import org.apache.airavata.service.profile.tenant.core.entities.Gateway;
-import org.apache.airavata.service.profile.tenant.core.util.JPAUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.sql.Timestamp;
-
-/**
- * Created by goshenoy on 3/7/17.
- */
-public class GatewayResource {
-
-    private final static Logger logger = 
LoggerFactory.getLogger(GatewayResource.class);
-
-    private String gatewayId;
-    private String gatewayName;
-    private String domain;
-    private String emailAddress;
-    private String gatewayApprovalStatus;
-    private String gatewayAcronym;
-    private String gatewayUrl;
-    private String gatewayPublicAbstract;
-    private String reviewProposalDescription;
-    private String gatewayAdminFirstName;
-    private String getGatewayAdminLastName;
-    private String gatewayAdminEmail;
-    private String identityServerUserName;
-    private String identityServerPasswordToken;
-    private String declinedReason;
-    private String oauthClientId;
-    private String oauthClientSecret;
-    private Timestamp requestCreationTime;
-    private String requesterUsername;
-
-    public String getGatewayId() {
-        return gatewayId;
-    }
-
-    public void setGatewayId(String gatewayId) {
-        this.gatewayId = gatewayId;
-    }
-
-    public String getGatewayName() {
-        return gatewayName;
-    }
-
-    public void setGatewayName(String gatewayName) {
-        this.gatewayName = gatewayName;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    public void setDomain(String domain) {
-        this.domain = domain;
-    }
-
-    public String getEmailAddress() {
-        return emailAddress;
-    }
-
-    public void setEmailAddress(String emailAddress) {
-        this.emailAddress = emailAddress;
-    }
-
-    public String getGatewayApprovalStatus() {
-        return gatewayApprovalStatus;
-    }
-
-    public void setGatewayApprovalStatus(String gatewayApprovalStatus) {
-        this.gatewayApprovalStatus = gatewayApprovalStatus;
-    }
-
-    public String getGatewayAcronym() {
-        return gatewayAcronym;
-    }
-
-    public void setGatewayAcronym(String gatewayAcronym) {
-        this.gatewayAcronym = gatewayAcronym;
-    }
-
-    public String getGatewayUrl() {
-        return gatewayUrl;
-    }
-
-    public void setGatewayUrl(String gatewayUrl) {
-        this.gatewayUrl = gatewayUrl;
-    }
-
-    public String getGatewayPublicAbstract() {
-        return gatewayPublicAbstract;
-    }
-
-    public void setGatewayPublicAbstract(String gatewayPublicAbstract) {
-        this.gatewayPublicAbstract = gatewayPublicAbstract;
-    }
-
-    public String getReviewProposalDescription() {
-        return reviewProposalDescription;
-    }
-
-    public void setReviewProposalDescription(String reviewProposalDescription) 
{
-        this.reviewProposalDescription = reviewProposalDescription;
-    }
-
-    public String getGatewayAdminFirstName() {
-        return gatewayAdminFirstName;
-    }
-
-    public void setGatewayAdminFirstName(String gatewayAdminFirstName) {
-        this.gatewayAdminFirstName = gatewayAdminFirstName;
-    }
-
-    public String getGetGatewayAdminLastName() {
-        return getGatewayAdminLastName;
-    }
-
-    public void setGetGatewayAdminLastName(String getGatewayAdminLastName) {
-        this.getGatewayAdminLastName = getGatewayAdminLastName;
-    }
-
-    public String getGatewayAdminEmail() {
-        return gatewayAdminEmail;
-    }
-
-    public void setGatewayAdminEmail(String gatewayAdminEmail) {
-        this.gatewayAdminEmail = gatewayAdminEmail;
-    }
-
-    public String getIdentityServerUserName() {
-        return identityServerUserName;
-    }
-
-    public void setIdentityServerUserName(String identityServerUserName) {
-        this.identityServerUserName = identityServerUserName;
-    }
-
-    public String getIdentityServerPasswordToken() {
-        return identityServerPasswordToken;
-    }
-
-    public void setIdentityServerPasswordToken(String 
identityServerPasswordToken) {
-        this.identityServerPasswordToken = identityServerPasswordToken;
-    }
-
-    public String getDeclinedReason() {
-        return declinedReason;
-    }
-
-    public void setDeclinedReason(String declinedReason) {
-        this.declinedReason = declinedReason;
-    }
-
-    public String getOauthClientId() {
-        return oauthClientId;
-    }
-
-    public void setOauthClientId(String oauthClientId) {
-        this.oauthClientId = oauthClientId;
-    }
-
-    public String getOauthClientSecret() {
-        return oauthClientSecret;
-    }
-
-    public void setOauthClientSecret(String oauthClientSecret) {
-        this.oauthClientSecret = oauthClientSecret;
-    }
-
-    public Timestamp getRequestCreationTime() {
-        return requestCreationTime;
-    }
-
-    public void setRequestCreationTime(Timestamp requestCreationTime) {
-        this.requestCreationTime = requestCreationTime;
-    }
-
-    public String getRequesterUsername() {
-        return requesterUsername;
-    }
-
-    public void setRequesterUsername(String requesterUsername) {
-        this.requesterUsername = requesterUsername;
-    }
-
-    public void save() throws Exception {
-        EntityManager em = null;
-        try {
-            em = JPAUtils.getEntityManager();
-            Gateway existingGateway = em.find(Gateway.class, gatewayId);
-            em.close();
-
-            em = JPAUtils.getEntityManager();
-            em.getTransaction().begin();
-            Gateway gateway = new Gateway();
-            gateway.setGatewayName(gatewayName);
-            gateway.setGatewayId(gatewayId);
-            gateway.setGatewayApprovalStatus(gatewayApprovalStatus);
-            gateway.setDomain(domain);
-            gateway.setEmailAddress(emailAddress);
-            gateway.setGatewayAcronym(gatewayAcronym);
-            gateway.setGatewayUrl(gatewayUrl);
-            gateway.setGatewayPublicAbstract(gatewayPublicAbstract);
-            gateway.setReviewProposalDescription(reviewProposalDescription);
-            gateway.setGatewayAdminFirstName(gatewayAdminFirstName);
-            gateway.setGetGatewayAdminLastName(getGatewayAdminLastName);
-            gateway.setGatewayAdminEmail(gatewayAdminEmail);
-            gateway.setIdentityServerUserName(identityServerUserName);
-            
gateway.setIdentityServerPasswordToken(identityServerPasswordToken);
-            gateway.setDeclinedReason(declinedReason);
-            gateway.setOauthClientId(oauthClientId);
-            gateway.setGetOauthClientSecret(oauthClientSecret);
-            gateway.setRequestCreationTime(requestCreationTime);
-            gateway.setRequesterUsername(requesterUsername);
-            if (existingGateway != null) {
-                existingGateway.setDomain(domain);
-                
existingGateway.setGatewayApprovalStatus(gatewayApprovalStatus);
-                existingGateway.setGatewayName(gatewayName);
-                gateway.setGatewayApprovalStatus(gatewayApprovalStatus);
-                existingGateway.setEmailAddress(emailAddress);
-                existingGateway.setGatewayAcronym(gatewayAcronym);
-                existingGateway.setGatewayUrl(gatewayUrl);
-                
existingGateway.setGatewayPublicAbstract(gatewayPublicAbstract);
-                
existingGateway.setReviewProposalDescription(reviewProposalDescription);
-                
existingGateway.setGatewayAdminFirstName(gatewayAdminFirstName);
-                
existingGateway.setGetGatewayAdminLastName(getGatewayAdminLastName);
-                existingGateway.setGatewayAdminEmail(gatewayAdminEmail);
-                
existingGateway.setIdentityServerUserName(identityServerUserName);
-                
existingGateway.setIdentityServerPasswordToken(identityServerPasswordToken);
-                existingGateway.setDeclinedReason(declinedReason);
-                existingGateway.setOauthClientId(oauthClientId);
-                existingGateway.setGetOauthClientSecret(oauthClientSecret);
-                existingGateway.setRequestCreationTime(requestCreationTime);
-                existingGateway.setRequesterUsername(requesterUsername);
-                em.merge(existingGateway);
-            } else {
-                em.persist(gateway);
-            }
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw e;
-        } finally {
-            if (em != null && em.isOpen()) {
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/GatewayUtils.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/GatewayUtils.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/GatewayUtils.java
deleted file mode 100644
index c9524f0..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/GatewayUtils.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- *
- * 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.service.profile.tenant.core.util;
-
-import org.apache.airavata.model.workspace.GatewayApprovalStatus;
-import org.apache.airavata.service.profile.tenant.core.entities.Gateway;
-import 
org.apache.airavata.service.profile.tenant.core.resources.GatewayResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by goshenoy on 3/7/17.
- */
-public class GatewayUtils {
-
-    private final static Logger logger = 
LoggerFactory.getLogger(GatewayUtils.class);
-
-    /**
-     * This method converts GatewayEntity object to GatewayResource
-     * @param gateway
-     * @return
-     */
-    public static GatewayResource toGatewayResource(Gateway gateway) throws 
Exception {
-        GatewayResource gatewayResource = new GatewayResource();
-        return toGatewayResource(gatewayResource, gateway);
-    }
-
-    /**
-     * This method converts GatewayEntity object to GatewayResource
-     * @param gatewayResource
-     * @param gateway
-     * @return
-     */
-    public static GatewayResource toGatewayResource(GatewayResource 
gatewayResource, Gateway gateway) throws Exception {
-        if (gatewayResource != null) {
-            gatewayResource.setGatewayName(gateway.getGatewayName());
-            gatewayResource.setGatewayId(gateway.getGatewayId());
-            gatewayResource.setDomain(gateway.getDomain());
-            gatewayResource.setEmailAddress(gateway.getEmailAddress());
-            
gatewayResource.setGatewayApprovalStatus(gateway.getGatewayApprovalStatus());
-            gatewayResource.setGatewayAcronym(gateway.getGatewayAcronym());
-            gatewayResource.setGatewayUrl(gateway.getGatewayUrl());
-            
gatewayResource.setGatewayPublicAbstract(gateway.getGatewayPublicAbstract());
-            
gatewayResource.setReviewProposalDescription(gateway.getReviewProposalDescription());
-            
gatewayResource.setGatewayAdminFirstName(gateway.getGatewayAdminFirstName());
-            
gatewayResource.setGetGatewayAdminLastName(gateway.getGetGatewayAdminLastName());
-            
gatewayResource.setGatewayAdminEmail(gateway.getGatewayAdminEmail());
-            
gatewayResource.setIdentityServerUserName(gateway.getIdentityServerUserName());
-            
gatewayResource.setIdentityServerPasswordToken(gateway.getIdentityServerPasswordToken());
-            gatewayResource.setDeclinedReason(gateway.getDeclinedReason());
-            gatewayResource.setOauthClientId(gateway.getOauthClientId());
-            
gatewayResource.setRequestCreationTime(gateway.getRequestCreationTime());
-            
gatewayResource.setRequesterUsername(gateway.getRequesterUsername());
-            
gatewayResource.setOauthClientSecret(gateway.getGetOauthClientSecret());
-        } else {
-            throw new Exception("Could not get GatewayResource object because 
GatewayEntity object is null");
-        }
-        return gatewayResource;
-    }
-
-    /**
-     * This method converts GatewayResource to GatewayEntity
-     * @param resource
-     * @return
-     */
-    public static org.apache.airavata.model.workspace.Gateway toGateway 
(GatewayResource resource){
-        org.apache.airavata.model.workspace.Gateway gateway = new 
org.apache.airavata.model.workspace.Gateway();
-        gateway.setGatewayId(resource.getGatewayId());
-        
gateway.setGatewayApprovalStatus(GatewayApprovalStatus.valueOf(resource.getGatewayApprovalStatus()));
-        gateway.setGatewayName(resource.getGatewayName());
-        gateway.setDomain(resource.getDomain());
-        gateway.setEmailAddress(resource.getEmailAddress());
-        gateway.setGatewayAcronym(resource.getGatewayAcronym());
-        gateway.setGatewayURL(resource.getGatewayUrl());
-        gateway.setGatewayPublicAbstract(resource.getGatewayPublicAbstract());
-        
gateway.setReviewProposalDescription(resource.getReviewProposalDescription());
-        gateway.setDeclinedReason(resource.getDeclinedReason());
-        gateway.setGatewayAdminFirstName(resource.getGatewayAdminFirstName());
-        gateway.setGatewayAdminLastName(resource.getGetGatewayAdminLastName());
-        gateway.setGatewayAdminEmail(resource.getGatewayAdminEmail());
-        
gateway.setIdentityServerUserName(resource.getIdentityServerUserName());
-        
gateway.setIdentityServerPasswordToken(resource.getIdentityServerPasswordToken());
-        gateway.setOauthClientId(resource.getOauthClientId());
-        gateway.setOauthClientSecret(resource.getOauthClientSecret());
-        if (resource.getRequestCreationTime() != null) {
-            
gateway.setRequestCreationTime(resource.getRequestCreationTime().getTime());
-        }
-        gateway.setRequesterUsername(resource.getRequesterUsername());
-        return gateway;
-    }
-
-    /**
-     * This method gets all gateways
-     * @param gatewayList
-     * @return
-     */
-    public static List<org.apache.airavata.model.workspace.Gateway> 
getAllGateways (List<GatewayResource> gatewayList){
-        List<org.apache.airavata.model.workspace.Gateway> gateways = new 
ArrayList<org.apache.airavata.model.workspace.Gateway>();
-        for (GatewayResource resource : gatewayList){
-            gateways.add(toGateway(resource));
-        }
-        return gateways;
-    }
-
-    /**
-     * This method creates new or returns existing gateway
-     * @param gatewayId
-     * @return
-     * @throws Exception
-     */
-    public static GatewayResource createGateway(String gatewayId) throws 
Exception {
-        if (!isGatewayExist(gatewayId)) {
-            GatewayResource gatewayResource = new GatewayResource();
-            gatewayResource.setGatewayId(gatewayId);
-            return gatewayResource;
-        } else {
-            return getGateway(gatewayId);
-        }
-    }
-
-    /**
-     *  This method checks if a gateway exists
-     * @param gatewayId
-     * @return
-     */
-    public static boolean isGatewayExist(String gatewayId) throws Exception {
-        EntityManager em = null;
-        try {
-            em = JPAUtils.getEntityManager();
-            em.getTransaction().begin();
-            Gateway gateway = em.find(Gateway.class, gatewayId);
-            return gateway != null;
-        } catch (Exception e){
-            logger.error("Error checking if gateway exists, reason: " + 
e.getMessage(), e);
-            throw e;
-        } finally {
-            if (em != null && em.isOpen()){
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-
-
-    /**
-     * This method finds a gateway by id
-     * @param gatewayId
-     * @return
-     * @throws Exception
-     */
-    public static GatewayResource getGateway(String gatewayId) throws 
Exception {
-        EntityManager em = null;
-        try {
-            if (isGatewayExist(gatewayId)) {
-                em = JPAUtils.getEntityManager();
-                Gateway gateway = em.find(Gateway.class, gatewayId);
-                GatewayResource gatewayResource = toGatewayResource(gateway);
-                em.close();
-                return gatewayResource;
-            }
-        } catch (Exception e){
-            logger.error("Error finding gateway, reason: " + e.getMessage(), 
e);
-            throw e;
-        } finally {
-            if (em != null && em.isOpen()){
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-        return null;
-    }
-
-    /**
-     * This method returns all gateways
-     * @return
-     * @throws Exception
-     */
-    public static List<GatewayResource> getAllGateways() throws Exception {
-        List<GatewayResource> resourceList = new ArrayList<GatewayResource>();
-        EntityManager em = null;
-        try {
-            em = JPAUtils.getEntityManager();
-            em.getTransaction().begin();
-            Query query = em.createQuery(QueryConstants.GET_ALL_GATEWAYS);
-            List results = query.getResultList();
-
-            if (!results.isEmpty()) {
-                for (Object result : results) {
-                    Gateway gateway = (Gateway) result;
-                    GatewayResource gatewayResource = 
toGatewayResource(gateway);
-                    resourceList.add(gatewayResource);
-                }
-            }
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e){
-            logger.error(e.getMessage(), e);
-            throw e;
-        } finally {
-            if (em != null && em.isOpen()){
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-        return resourceList;
-    }
-
-    /**
-     * This method deletes a gateway
-     * @param gatewayId
-     * @return
-     */
-    public static boolean removeGateway(String gatewayId) {
-        EntityManager em = null;
-        try {
-            em = JPAUtils.getEntityManager();
-            em.getTransaction().begin();
-            Query query = 
em.createQuery(MessageFormat.format(QueryConstants.DELETE_GATEWAY_BY_ID, 
gatewayId));
-            query.executeUpdate();
-            em.getTransaction().commit();
-            em.close();
-            return true;
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return false;
-        }finally {
-            if (em != null && em.isOpen()){
-                if (em.getTransaction().isActive()){
-                    em.getTransaction().rollback();
-                }
-                em.close();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/JPAConstants.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/JPAConstants.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/JPAConstants.java
deleted file mode 100644
index 763c9ec..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/JPAConstants.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * 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.service.profile.tenant.core.util;
-public class JPAConstants {
-       public static final String KEY_JDBC_URL = 
"gateway.profile.catalog.registry.jdbc.url";
-       public static final String KEY_JDBC_USER = 
"gateway.profile.catalog.registry.jdbc.user";
-       public static final String KEY_JDBC_PASSWORD = 
"gateway.profile.catalog.registry.jdbc.password";
-       public static final String KEY_JDBC_DRIVER = 
"gateway.profile.catalog.registry.jdbc.driver";
-       // TODO: is this needed?
-       public static final String KEY_DERBY_START_ENABLE = 
"gateway.profile.catalog.start.derby.server.mode";
-       public static final String VALIDATION_QUERY = 
"gateway.profile.catalog.validationQuery";
-       public static final String JPA_CACHE_SIZE = 
"gateway.profile.catalog.jpa.cache.size";
-       public static final String ENABLE_CACHING = 
"gateway.profile.catalog.cache.enable";
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/JPAUtils.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/JPAUtils.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/JPAUtils.java
deleted file mode 100644
index 08b3394..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/JPAUtils.java
+++ /dev/null
@@ -1,50 +0,0 @@
-
-package org.apache.airavata.service.profile.tenant.core.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by goshenoy on 3/6/17.
- */
-public class JPAUtils {
-
-    private final static Logger logger = 
LoggerFactory.getLogger(JPAUtils.class);
-
-    private static final String PERSISTENCE_UNIT_NAME = 
"gateway_profile_catalog";
-
-    @PersistenceUnit(unitName = PERSISTENCE_UNIT_NAME)
-    private static EntityManagerFactory factory;
-
-    @PersistenceContext(unitName = PERSISTENCE_UNIT_NAME)
-    private static EntityManager entityManager;
-
-    public static EntityManager getEntityManager() {
-        if (factory == null) {
-            String connectionProperties = "DriverClassName=" + 
Utils.getJDBCDriver() + "," + "Url=" +
-                    Utils.getJDBCURL() + "?autoReconnect=true," +
-                    "Username=" + Utils.getJDBCUser() + "," + "Password=" + 
Utils.getJDBCPassword() +
-                    ",validationQuery=" + Utils.getValidationQuery();
-            logger.info(connectionProperties);
-            Map<String, String> properties = new HashMap<String, String>();
-            properties.put("openjpa.ConnectionDriverName", 
"org.apache.commons.dbcp.BasicDataSource");
-            properties.put("openjpa.ConnectionProperties", 
connectionProperties);
-            properties.put("openjpa.DynamicEnhancementAgent", "true");
-            properties.put("openjpa.RuntimeUnenhancedClasses", "warn");
-            properties.put("openjpa.RemoteCommitProvider", "sjvm");
-            properties.put("openjpa.Log", "DefaultLevel=INFO, Runtime=INFO, 
Tool=INFO, SQL=INFO");
-            properties.put("openjpa.jdbc.SynchronizeMappings", 
"buildSchema(ForeignKeys=true)");
-            properties.put("openjpa.jdbc.QuerySQLCache", "false");
-            properties.put("openjpa.ConnectionFactoryProperties", 
"PrettyPrint=true, PrettyPrintLineLength=72," +
-                    " PrintParameters=true, MaxActive=10, MaxIdle=5, 
MinIdle=2, MaxWait=31536000,  autoReconnect=true");
-            factory = 
Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
-        }
-
-        entityManager = factory.createEntityManager();
-        return entityManager;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/QueryConstants.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/QueryConstants.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/QueryConstants.java
deleted file mode 100644
index 27eed48..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/QueryConstants.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.airavata.service.profile.tenant.core.util;
-
-import org.apache.airavata.model.user.UserProfile;
-
-/**
- * Created by goshenoy on 11/11/2016.
- */
-public class QueryConstants {
-
-    public static final String FIND_GATEWAY_BY_ID = "SELECT g FROM 
GatewayEntity g where g.gatewayId='{0}'";
-
-    public static final String GET_ALL_GATEWAYS = "SELECT g FROM GatewayEntity 
g";
-
-    public static final String DELETE_GATEWAY_BY_ID = "DELETE FROM 
GatewayEntity g where g.gatewayId='{0}'";
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/648d8ca7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/Utils.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/Utils.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/Utils.java
deleted file mode 100644
index e3be890..0000000
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/util/Utils.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- *
- * 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.service.profile.tenant.core.util;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static String getHost(){
-        try{
-            String jdbcURL = getJDBCURL();
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getHost();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static int getPort(){
-        try{
-            String jdbcURL = getJDBCURL();
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    public static int getJPACacheSize (){
-        try {
-            String cache = 
ServerSettings.getSetting(JPAConstants.JPA_CACHE_SIZE, "5000");
-            return Integer.parseInt(cache);
-        }catch (Exception e){
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    public static String isCachingEnabled (){
-        try {
-            return ServerSettings.getSetting(JPAConstants.ENABLE_CACHING, 
"true");
-        }catch (Exception e){
-            logger.error(e.getMessage(), e);
-            return "true";
-        }
-    }
-
-    public static String getDBType(){
-        try{
-            String jdbcURL = getJDBCURL();
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getScheme();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static boolean isDerbyStartEnabled(){
-        try {
-            String s = 
ServerSettings.getSetting(JPAConstants.KEY_DERBY_START_ENABLE);
-            if("true".equals(s)){
-                return true;
-            }
-        } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return false;
-        }
-        return false;
-    }
-
-    public static String getJDBCUser(){
-       try {
-                   return 
ServerSettings.getSetting(JPAConstants.KEY_JDBC_USER);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-               }
-    }
-
-    public static String getValidationQuery(){
-       try {
-            return ServerSettings.getSetting(JPAConstants.VALIDATION_QUERY);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-               }
-    }
-
-    public static String getJDBCPassword(){
-       try {
-            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_PASSWORD);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-               }
-
-    }
-
-    public static String getJDBCDriver(){
-       try {
-            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_DRIVER);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-               }
-    }
-}
\ No newline at end of file

Reply via email to