You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ya...@apache.org on 2025/12/11 16:09:57 UTC
(airavata) 07/19: transform non-jpa sql classes (prepared stmt) with entity classes
This is an automated email from the ASF dual-hosted git repository.
yasith pushed a commit to branch service-layer-improvements
in repository https://gitbox.apache.org/repos/asf/airavata.git
commit e0756a9d564611854ed41a93e1a6aea432787ed2
Author: yasithdev <ya...@icloud.com>
AuthorDate: Sun Dec 7 01:28:30 2025 -0600
transform non-jpa sql classes (prepared stmt) with entity classes
---
README.md | 4 +-
airavata-api/pom.xml | 6 +
.../airavata/common/utils/BuildConstant.java | 24 -
.../accountprovisioning/SSHAccountManager.java | 2 +-
.../client/CredentialServiceClientFactory.java | 2 +-
.../thrift/handler/CredentialServiceHandler.java | 84 +++-
.../api/thrift/handler/IamAdminServiceHandler.java | 2 +-
.../handler/TenantProfileServiceHandler.java | 2 +-
.../api/thrift/server/SharingRegistryServer.java | 12 +-
.../airavata/common/utils/ApplicationSettings.java | 2 +-
.../apache/airavata/common/utils/StringUtil.java | 3 +
.../config/AiravataPropertiesConfiguration.java | 20 +-
.../airavata/config/AiravataServerProperties.java | 11 +-
.../java/org/apache/airavata/config/JpaConfig.java | 48 ++
.../credential/entities/CommunityUserEntity.java | 81 ++++
.../credential/entities/CommunityUserEntityPK.java | 69 +++
.../credential/entities/CredentialEntity.java | 116 +++++
.../credential/entities/CredentialEntityPK.java | 69 +++
.../CredentialStoreException.java | 2 +-
.../notifier}/EmailNotificationMessage.java | 4 +-
.../impl => impl/notifier}/EmailNotifier.java | 8 +-
.../notifier}/EmailNotifierConfiguration.java | 2 +-
.../impl/store/CertificateCredentialWriter.java | 68 +++
.../impl/store/CredentialReaderImpl.java | 113 +++++
.../credential/impl/store/SSHCredentialWriter.java | 52 +++
.../notifier/CredentialStoreNotifier.java | 59 ---
.../repositories/CommunityUserRepository.java | 59 +++
.../repositories/CredentialRepository.java | 64 +++
.../services/CommunityUserEntityService.java | 149 +++++++
.../services/CredentialEntityService.java | 296 ++++++++++++
.../store/impl/CertificateCredentialWriter.java | 120 -----
.../store/impl/CredentialReaderImpl.java | 186 --------
.../credential/store/impl/SSHCredentialWriter.java | 83 ----
.../credential/store/impl/db/CommunityUserDAO.java | 250 -----------
.../credential/store/impl/db/CredentialsDAO.java | 495 ---------------------
.../credential/store/impl/db/ParentDAO.java | 32 --
.../{util => utils}/ConfigurationReader.java | 4 +-
.../{store => utils}/CredentialReader.java | 3 +-
.../{store => utils}/CredentialReaderFactory.java | 33 +-
.../{util => utils}/CredentialStoreConstants.java | 2 +-
.../CredentialStoreDBInitConfig.java | 2 +-
.../credential/utils/CredentialStoreNotifier.java | 59 +++
.../{store => utils}/CredentialWriter.java | 3 +-
.../{notifier => utils}/NotificationMessage.java | 2 +-
.../{notifier => utils}/NotifierBootstrap.java | 24 +-
.../{util => utils}/PrivateKeyStore.java | 2 +-
.../credential/{util => utils}/TokenGenerator.java | 2 +-
.../credential/{util => utils}/Utility.java | 2 +-
.../messaging/client/RabbitMQListener.java | 3 +
.../monitor/cluster/ClusterStatusMonitorJob.java | 18 +
.../orchestrator/job/GFACPassiveJobSubmitter.java | 2 +-
.../airavata/orchestrator/job/JobSubmitter.java | 2 +-
.../orchestrator/utils/OrchestratorUtils.java | 7 +-
.../services/ApplicationDeploymentService.java | 1 -
.../registry/services/ComputeResourceService.java | 2 +-
.../registry/services/DataProductService.java | 15 +
.../services/DataReplicaLocationService.java | 29 ++
.../registry/services/ExperimentErrorService.java | 20 +-
...putService.java => ExperimentInputService.java} | 40 +-
.../registry/services/ExperimentOutputService.java | 8 +
.../registry/services/ExperimentStatusService.java | 24 +-
.../registry/services/GatewayGroupsService.java | 4 +
.../registry/services/NotificationService.java | 5 +-
.../registry/services/ProcessErrorService.java | 20 +-
...OutputService.java => ProcessInputService.java} | 40 +-
.../registry/services/ProcessOutputService.java | 7 +
.../registry/services/QueueStatusService.java | 3 +-
.../registry/services/TaskErrorService.java | 20 +-
.../registry/services/TaskStatusService.java | 21 +
.../airavata/registry/services/UserService.java | 11 +
.../registry/services/WorkflowService.java | 14 +
.../security/GatewayGroupsInitializer.java | 2 +-
.../apache/airavata/service/AiravataService.java | 2 +-
.../airavata/service/CredentialStoreService.java | 213 ++++-----
.../apache/airavata/service/IamAdminService.java | 2 +-
.../airavata/service/OrchestratorService.java | 2 +-
.../airavata/service/TenantProfileService.java | 2 +-
...avata-server.properties => airavata.properties} | 0
...avata-server.properties => airavata.properties} | 0
...avata-server.properties => airavata.properties} | 0
.../airavata/api/thrift/client/TestSSLClient.java | 33 +-
.../thrift/handler/TestSharingRegistryHandler.java | 9 +-
.../server/TestOrchestratorServiceServer.java | 83 ++--
.../thrift/server/TestSharingRegistryServer.java | 35 +-
.../cpi/SSHSummaryTest/SSHSummaryTest.java | 15 +-
.../notifier/impl/EmailNotifierTest.java | 3 +
.../store/impl/db/CommunityUserDAOTest.java | 192 --------
.../store/impl/db/CredentialsDAOTest.java | 464 -------------------
.../store/impl/db/SSHCredentialTest.java | 14 +-
.../{util => utils}/ConfigurationReaderTest.java | 2 +-
.../{util => utils}/TokenGeneratorTest.java | 2 +-
.../core => entities}/SetupNewGateway.java | 5 +-
.../ApplicationDeploymentRepositoryTest.java | 8 +-
.../ApplicationInterfaceRepositoryTest.java | 153 +++----
.../appcatalog/ComputeResourceRepositoryTest.java | 203 +++++----
.../appcatalog/GatewayGroupsRepositoryTest.java | 27 +-
.../appcatalog/GatewayProfileRepositoryTest.java | 42 +-
.../GroupResourceProfileRepositoryTest.java | 114 +++--
.../JobSubmissionInterfaceRepositoryTest.java | 34 +-
.../appcatalog/StorageResourceRepositoryTest.java | 30 +-
.../UserResourceProfileRepositoryTest.java | 41 +-
.../expcatalog/ExperimentErrorRepositoryTest.java | 50 ++-
.../expcatalog/ExperimentInputRepositoryTest.java | 50 ++-
.../expcatalog/ExperimentOutputRepositoryTest.java | 53 ++-
.../expcatalog/ExperimentRepositoryTest.java | 62 +--
.../expcatalog/ExperimentStatusRepositoryTest.java | 55 ++-
.../ExperimentSummaryRepositoryTest.java | 117 ++---
.../expcatalog/GatewayRepositoryTest.java | 2 +-
.../repositories/expcatalog/JobRepositoryTest.java | 6 +-
.../expcatalog/JobStatusRepositoryTest.java | 83 ++--
.../expcatalog/NotificationRepositoryTest.java | 26 +-
.../expcatalog/ProcessErrorRepositoryTest.java | 62 +--
.../expcatalog/ProcessInputRepositoryTest.java | 62 +--
.../expcatalog/ProcessOutputRepositoryTest.java | 62 +--
.../expcatalog/ProcessRepositoryTest.java | 66 +--
.../expcatalog/ProcessStatusRepositoryTest.java | 6 +-
.../expcatalog/ProjectRepositoryTest.java | 14 +-
.../expcatalog/QueueStatusRepositoryTest.java | 17 +-
.../expcatalog/TaskErrorRepositoryTest.java | 71 +--
.../expcatalog/TaskRepositoryTest.java | 67 +--
.../expcatalog/TaskStatusRepositoryTest.java | 72 +--
.../expcatalog/UserRepositoryTest.java | 49 +-
.../replicacatalog/DataProductRepositoryTest.java | 58 ++-
.../DataReplicaLocationRepositoryTest.java | 47 +-
.../workflowcatalog/WorkflowRepositoryTest.java | 14 +-
airavata-api/src/test/resources/PBSTemplate.xslt | 77 ----
.../src/test/resources/airavata-server.properties | 72 ---
.../resources/airavata.properties} | 0
.../src/test/resources/application-test.properties | 91 ----
airavata-api/src/test/resources/gsissh.properties | 26 --
airavata-api/src/test/resources/monitor.properties | 30 --
.../src/test/resources/orchestrator.properties | 21 -
.../ansible/roles/airavata_deploy/tasks/main.yml | 6 +-
dev-tools/ansible/roles/api-orch/tasks/main.yml | 4 +-
...server.properties.j2 => airavata.properties.j2} | 0
dev-tools/ansible/roles/helix_setup/tasks/main.yml | 4 +-
...server.properties.j2 => airavata.properties.j2} | 0
.../controller/helixcontroller.service.j2 | 2 +-
...server.properties.j2 => airavata.properties.j2} | 0
...server.properties.j2 => airavata.properties.j2} | 0
.../participant/helixparticipant.service.j2 | 2 +-
...server.properties.j2 => airavata.properties.j2} | 0
.../templates/post-wm/postwm.service.j2 | 2 +-
...server.properties.j2 => airavata.properties.j2} | 0
.../helix_setup/templates/pre-wm/prewm.service.j2 | 2 +-
dev-tools/ansible/roles/job_monitor/tasks/main.yml | 4 +-
...server.properties.j2 => airavata.properties.j2} | 0
...server.properties.j2 => airavata.properties.j2} | 0
dev-tools/ansible/roles/registry/tasks/main.yml | 4 +-
...server.properties.j2 => airavata.properties.j2} | 0
...avata-server.properties => airavata.properties} | 0
.../deployment-scripts/distribution_update.sh | 2 +-
dev-tools/deployment-scripts/docker-startup.sh | 2 +-
docker-compose.yml | 4 +-
modules/ide-integration/README.md | 2 +-
155 files changed, 2876 insertions(+), 3437 deletions(-)
diff --git a/README.md b/README.md
index 19008596dd..a0650c73c4 100644
--- a/README.md
+++ b/README.md
@@ -201,7 +201,7 @@ distribution
├── services_down.sh
├── services_up.sh
└── vault
- ├── airavata-server.properties
+ ├── airavata.properties
├── airavata.sym.p12
├── application-agent-service.yml
├── application-research-service.yml
@@ -214,7 +214,7 @@ distribution
**What's in the vault?**
* `airavata.sym.p12` - contains the symmetric key used to secure stored credentials.
-* `airavata-server.properties` - config file for the airavata api server.
+* `airavata.properties` - config file for the airavata api server.
* `application-agent-service.yml` - config file for the airavata agent service.
* `application-file-server.yml` - config file for the airavata file server.
* `application-research-service.yml` - config file for the airavata research service.
diff --git a/airavata-api/pom.xml b/airavata-api/pom.xml
index 148e064ed9..cd96c544ea 100644
--- a/airavata-api/pom.xml
+++ b/airavata-api/pom.xml
@@ -168,6 +168,11 @@ under the License.
</dependency>
<!-- Test dependencies -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
@@ -501,6 +506,7 @@ under the License.
<!-- -->
<systemPropertyVariables>
<credential.module.directory>${basedir}</credential.module.directory>
+ <airavata.config.dir>${project.basedir}/src/test/resources</airavata.config.dir>
</systemPropertyVariables>
<excludes>
<exclude>**/DAOBaseTestCase.java</exclude>
diff --git a/airavata-api/src/main/java-templates/org/apache/airavata/common/utils/BuildConstant.java b/airavata-api/src/main/java-templates/org/apache/airavata/common/utils/BuildConstant.java
deleted file mode 100644
index 89f080d0ba..0000000000
--- a/airavata-api/src/main/java-templates/org/apache/airavata/common/utils/BuildConstant.java
+++ /dev/null
@@ -1,24 +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.common.utils;
-
-public class BuildConstant {
- public static final String VERSION = "${git-describe}";
-}
\ No newline at end of file
diff --git a/airavata-api/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java b/airavata-api/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java
index a74ed18140..2c39ff41d8 100644
--- a/airavata-api/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java
+++ b/airavata-api/src/main/java/org/apache/airavata/accountprovisioning/SSHAccountManager.java
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
-import org.apache.airavata.credential.exception.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface;
import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol;
diff --git a/airavata-api/src/main/java/org/apache/airavata/api/thrift/client/CredentialServiceClientFactory.java b/airavata-api/src/main/java/org/apache/airavata/api/thrift/client/CredentialServiceClientFactory.java
index f19c7ea184..e06e50a130 100644
--- a/airavata-api/src/main/java/org/apache/airavata/api/thrift/client/CredentialServiceClientFactory.java
+++ b/airavata-api/src/main/java/org/apache/airavata/api/thrift/client/CredentialServiceClientFactory.java
@@ -20,7 +20,7 @@
package org.apache.airavata.api.thrift.client;
import org.apache.airavata.credential.cpi.CredentialStoreService;
-import org.apache.airavata.credential.exception.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
diff --git a/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/CredentialServiceHandler.java b/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/CredentialServiceHandler.java
index 435214b109..46ba672909 100644
--- a/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/CredentialServiceHandler.java
+++ b/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/CredentialServiceHandler.java
@@ -45,76 +45,134 @@ public class CredentialServiceHandler implements org.apache.airavata.credential.
return credential_store_cpiConstants.CS_CPI_VERSION;
}
+ private CredentialStoreException wrapException(org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ CredentialStoreException thriftException = new CredentialStoreException();
+ thriftException.setMessage(e.getMessage());
+ return thriftException;
+ }
+
@Override
public String addSSHCredential(SSHCredential sshCredential) throws CredentialStoreException {
- return credentialStoreService.addSSHCredential(sshCredential);
+ try {
+ return credentialStoreService.addSSHCredential(sshCredential);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public String addCertificateCredential(CertificateCredential certificateCredential)
throws CredentialStoreException {
- return credentialStoreService.addCertificateCredential(certificateCredential);
+ try {
+ return credentialStoreService.addCertificateCredential(certificateCredential);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public String addPasswordCredential(PasswordCredential passwordCredential) throws CredentialStoreException {
- return credentialStoreService.addPasswordCredential(passwordCredential);
+ try {
+ return credentialStoreService.addPasswordCredential(passwordCredential);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public SSHCredential getSSHCredential(String tokenId, String gatewayId) throws CredentialStoreException {
- return credentialStoreService.getSSHCredential(tokenId, gatewayId);
+ try {
+ return credentialStoreService.getSSHCredential(tokenId, gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public CredentialSummary getCredentialSummary(String tokenId, String gatewayId) throws CredentialStoreException {
- return credentialStoreService.getCredentialSummary(tokenId, gatewayId);
+ try {
+ return credentialStoreService.getCredentialSummary(tokenId, gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public List<CredentialSummary> getAllCredentialSummaries(
SummaryType type, List<String> accessibleTokenIds, String gatewayId) throws CredentialStoreException {
- return credentialStoreService.getAllCredentialSummaries(type, accessibleTokenIds, gatewayId);
+ try {
+ return credentialStoreService.getAllCredentialSummaries(type, accessibleTokenIds, gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public CertificateCredential getCertificateCredential(String tokenId, String gatewayId)
throws CredentialStoreException {
- return credentialStoreService.getCertificateCredential(tokenId, gatewayId);
+ try {
+ return credentialStoreService.getCertificateCredential(tokenId, gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public PasswordCredential getPasswordCredential(String tokenId, String gatewayId) throws CredentialStoreException {
- return credentialStoreService.getPasswordCredential(tokenId, gatewayId);
+ try {
+ return credentialStoreService.getPasswordCredential(tokenId, gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
@Deprecated
public List<CredentialSummary> getAllCredentialSummaryForGateway(SummaryType type, String gatewayId)
throws CredentialStoreException {
- return credentialStoreService.getAllCredentialSummaryForGateway(type, gatewayId);
+ try {
+ return credentialStoreService.getAllCredentialSummaryForGateway(type, gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
@Deprecated
public List<CredentialSummary> getAllCredentialSummaryForUserInGateway(
SummaryType type, String gatewayId, String userId) throws CredentialStoreException {
- return credentialStoreService.getAllCredentialSummaryForUserInGateway(type, gatewayId, userId);
+ try {
+ return credentialStoreService.getAllCredentialSummaryForUserInGateway(type, gatewayId, userId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
@Deprecated
public Map<String, String> getAllPWDCredentialsForGateway(String gatewayId) throws CredentialStoreException {
- return credentialStoreService.getAllPWDCredentialsForGateway(gatewayId);
+ try {
+ return credentialStoreService.getAllPWDCredentialsForGateway(gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public boolean deleteSSHCredential(String tokenId, String gatewayId) throws CredentialStoreException {
- return credentialStoreService.deleteSSHCredential(tokenId, gatewayId);
+ try {
+ return credentialStoreService.deleteSSHCredential(tokenId, gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
@Override
public boolean deletePWDCredential(String tokenId, String gatewayId) throws CredentialStoreException {
- return credentialStoreService.deletePWDCredential(tokenId, gatewayId);
+ try {
+ return credentialStoreService.deletePWDCredential(tokenId, gatewayId);
+ } catch (org.apache.airavata.credential.exceptions.CredentialStoreException e) {
+ throw wrapException(e);
+ }
}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/IamAdminServiceHandler.java b/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/IamAdminServiceHandler.java
index ba6171c047..4b0fd5cc19 100644
--- a/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/IamAdminServiceHandler.java
+++ b/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/IamAdminServiceHandler.java
@@ -20,7 +20,7 @@
package org.apache.airavata.api.thrift.handler;
import java.util.List;
-import org.apache.airavata.credential.exception.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.airavata.model.error.AiravataSystemException;
import org.apache.airavata.model.error.AuthorizationException;
import org.apache.airavata.model.security.AuthzToken;
diff --git a/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/TenantProfileServiceHandler.java b/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/TenantProfileServiceHandler.java
index d4fa02ebda..075fa9a885 100644
--- a/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/TenantProfileServiceHandler.java
+++ b/airavata-api/src/main/java/org/apache/airavata/api/thrift/handler/TenantProfileServiceHandler.java
@@ -20,7 +20,7 @@
package org.apache.airavata.api.thrift.handler;
import java.util.List;
-import org.apache.airavata.credential.exception.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.airavata.model.error.AiravataSystemException;
import org.apache.airavata.model.error.AuthorizationException;
import org.apache.airavata.model.security.AuthzToken;
diff --git a/airavata-api/src/main/java/org/apache/airavata/api/thrift/server/SharingRegistryServer.java b/airavata-api/src/main/java/org/apache/airavata/api/thrift/server/SharingRegistryServer.java
index be87924286..2eafdfb230 100644
--- a/airavata-api/src/main/java/org/apache/airavata/api/thrift/server/SharingRegistryServer.java
+++ b/airavata-api/src/main/java/org/apache/airavata/api/thrift/server/SharingRegistryServer.java
@@ -29,7 +29,8 @@ import org.apache.airavata.config.AiravataServerProperties;
import org.apache.airavata.sharing.messaging.SharingServiceDBEventMessagingFactory;
import org.apache.airavata.sharing.models.SharingRegistryException;
import org.apache.airavata.sharing.service.cpi.SharingRegistryService;
-import org.apache.airavata.sharing.utils.SharingRegistryDBInitConfig;
+// Unused import - commented out
+// import org.apache.airavata.sharing.utils.SharingRegistryDBInitConfig;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TSSLTransportFactory;
@@ -54,7 +55,8 @@ public class SharingRegistryServer implements IServer {
private IServer.ServerStatus status;
private TServer server;
- private boolean testMode = false;
+ // Unused field - commented out
+ // private boolean testMode = false;
@Autowired
private ApplicationContext applicationContext;
@@ -190,10 +192,15 @@ public class SharingRegistryServer implements IServer {
this.server = server;
}
+ // Unused method - commented out (testMode field also unused)
+ /*
public void setTestMode(boolean testMode) {
this.testMode = testMode;
}
+ */
+ // Unused method - commented out
+ /*
private SharingRegistryDBInitConfig createSharingRegistryDBInitConfig() {
SharingRegistryDBInitConfig sharingRegistryDBInitConfig = new SharingRegistryDBInitConfig();
if (this.testMode) {
@@ -201,4 +208,5 @@ public class SharingRegistryServer implements IServer {
}
return sharingRegistryDBInitConfig;
}
+ */
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java b/airavata-api/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
index 57c55652fd..7b3d6f65d2 100644
--- a/airavata-api/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
+++ b/airavata-api/src/main/java/org/apache/airavata/common/utils/ApplicationSettings.java
@@ -34,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ApplicationSettings {
- public static final String SERVER_PROPERTIES = "airavata-server.properties";
+ public static final String SERVER_PROPERTIES = "airavata.properties";
public static final String AIRAVATA_CONFIG_DIR = "airavata.config.dir";
public static String ADDITIONAL_SETTINGS_FILES = "external.settings";
diff --git a/airavata-api/src/main/java/org/apache/airavata/common/utils/StringUtil.java b/airavata-api/src/main/java/org/apache/airavata/common/utils/StringUtil.java
index 3c36e4767e..51253ed597 100644
--- a/airavata-api/src/main/java/org/apache/airavata/common/utils/StringUtil.java
+++ b/airavata-api/src/main/java/org/apache/airavata/common/utils/StringUtil.java
@@ -123,9 +123,12 @@ public class StringUtil {
return true;
}
+ // Unused method - commented out
+ /*
private static boolean isQuoted(String s) {
return isQuoted(s, DELIMETER);
}
+ */
/**
* Create a delimiter separated string out of a list
diff --git a/airavata-api/src/main/java/org/apache/airavata/config/AiravataPropertiesConfiguration.java b/airavata-api/src/main/java/org/apache/airavata/config/AiravataPropertiesConfiguration.java
index 7dfa9a4303..6fc161861f 100644
--- a/airavata-api/src/main/java/org/apache/airavata/config/AiravataPropertiesConfiguration.java
+++ b/airavata-api/src/main/java/org/apache/airavata/config/AiravataPropertiesConfiguration.java
@@ -34,22 +34,22 @@ import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertySourceFactory;
/**
- * Configuration class that loads airavata-server.properties from the correct location.
+ * Configuration class that loads airavata.properties from the correct location.
* Respects the airavata.config.dir system property, checking file system first, then classpath.
*/
@Configuration
@PropertySource(
- value = "classpath:airavata-server.properties",
+ value = "classpath:airavata.properties",
factory = AiravataPropertiesConfiguration.AiravataPropertySourceFactory.class,
ignoreResourceNotFound = true)
public class AiravataPropertiesConfiguration {
private static final Logger logger = LoggerFactory.getLogger(AiravataPropertiesConfiguration.class);
- private static final String SERVER_PROPERTIES = "airavata-server.properties";
+ private static final String SERVER_PROPERTIES = "airavata.properties";
private static final String AIRAVATA_CONFIG_DIR = "airavata.config.dir";
/**
- * Custom PropertySourceFactory that loads airavata-server.properties
+ * Custom PropertySourceFactory that loads airavata.properties
* from airavata.config.dir if set, otherwise from classpath.
*/
public static class AiravataPropertySourceFactory implements PropertySourceFactory {
@@ -68,13 +68,12 @@ public class AiravataPropertiesConfiguration {
File configFile = new File(filePath);
if (configFile.exists() && configFile.isFile()) {
- logger.info("Loading airavata-server.properties from: {}", configFile.getAbsolutePath());
+ logger.info("Loading airavata.properties from: {}", configFile.getAbsolutePath());
Properties props = new Properties();
try (InputStream is = new FileInputStream(configFile)) {
props.load(is);
}
- return new org.springframework.core.env.PropertiesPropertySource(
- "airavata-server-properties", props);
+ return new org.springframework.core.env.PropertiesPropertySource("airavata-properties", props);
} else {
logger.debug("Properties file not found at {}, falling back to classpath", filePath);
}
@@ -87,14 +86,13 @@ public class AiravataPropertiesConfiguration {
URL classpathUrl =
AiravataPropertiesConfiguration.class.getClassLoader().getResource(SERVER_PROPERTIES);
if (classpathUrl != null) {
- logger.info("Loading airavata-server.properties from classpath: {}", classpathUrl);
+ logger.info("Loading airavata.properties from classpath: {}", classpathUrl);
return defaultFactory.createPropertySource(name, resource);
}
- logger.warn("airavata-server.properties not found in airavata.config.dir or classpath");
+ logger.warn("airavata.properties not found in airavata.config.dir or classpath");
// Return empty property source if not found
- return new org.springframework.core.env.PropertiesPropertySource(
- "airavata-server-properties", new Properties());
+ return new org.springframework.core.env.PropertiesPropertySource("airavata-properties", new Properties());
}
}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/config/AiravataServerProperties.java b/airavata-api/src/main/java/org/apache/airavata/config/AiravataServerProperties.java
index 61c0810d12..513e1bec83 100644
--- a/airavata-api/src/main/java/org/apache/airavata/config/AiravataServerProperties.java
+++ b/airavata-api/src/main/java/org/apache/airavata/config/AiravataServerProperties.java
@@ -24,7 +24,7 @@ import org.springframework.stereotype.Component;
/**
* Spring Boot configuration properties for Airavata server.
- * Maps all properties from airavata-server.properties to strongly-typed Java objects.
+ * Maps all properties from airavata.properties to strongly-typed Java objects.
*/
@Component
@ConfigurationProperties(prefix = "")
@@ -378,6 +378,7 @@ public class AiravataServerProperties {
private String jdbcUrl;
private String jdbcUser;
private String jdbcPassword;
+ private String validationQuery = "SELECT 1 from CONFIGURATION";
public String getJdbcDriver() {
return jdbcDriver;
@@ -410,6 +411,14 @@ public class AiravataServerProperties {
public void setJdbcPassword(String jdbcPassword) {
this.jdbcPassword = jdbcPassword;
}
+
+ public String getValidationQuery() {
+ return validationQuery;
+ }
+
+ public void setValidationQuery(String validationQuery) {
+ this.validationQuery = validationQuery;
+ }
}
public static class AppCatalog {
diff --git a/airavata-api/src/main/java/org/apache/airavata/config/JpaConfig.java b/airavata-api/src/main/java/org/apache/airavata/config/JpaConfig.java
index 9ac91f8152..5803b70e02 100644
--- a/airavata-api/src/main/java/org/apache/airavata/config/JpaConfig.java
+++ b/airavata-api/src/main/java/org/apache/airavata/config/JpaConfig.java
@@ -52,6 +52,7 @@ public class JpaConfig {
public static final String REPLICACATALOG_PU = "replicacatalog_data_new";
public static final String WORKFLOWCATALOG_PU = "workflowcatalog_data_new";
public static final String SHARING_REGISTRY_PU = "airavata-sharing-registry";
+ public static final String CREDENTIAL_STORE_PU = "credential_store";
@Bean(name = "profileServiceEntityManagerFactory")
@Primary
@@ -126,6 +127,34 @@ public class JpaConfig {
db.getValidationQuery());
}
+ @Bean(name = "credentialStoreEntityManagerFactory")
+ public EntityManagerFactory credentialStoreEntityManagerFactory() {
+ var db = properties.getDatabase().getCredentialStore();
+ // Fallback to registry database if credential store DB not configured
+ String jdbcUrl = db.getJdbcUrl();
+ if (jdbcUrl == null || jdbcUrl.isEmpty()) {
+ jdbcUrl = properties.getDatabase().getRegistry().getJdbcUrl();
+ }
+ String jdbcUser = db.getJdbcUser();
+ if (jdbcUser == null || jdbcUser.isEmpty()) {
+ jdbcUser = properties.getDatabase().getRegistry().getJdbcUser();
+ }
+ String jdbcPassword = db.getJdbcPassword();
+ if (jdbcPassword == null || jdbcPassword.isEmpty()) {
+ jdbcPassword = properties.getDatabase().getRegistry().getJdbcPassword();
+ }
+ String jdbcDriver = db.getJdbcDriver();
+ if (jdbcDriver == null || jdbcDriver.isEmpty()) {
+ jdbcDriver = properties.getDatabase().getRegistry().getJdbcDriver();
+ }
+ String validationQuery = db.getJdbcValidationQuery();
+ if (validationQuery == null || validationQuery.isEmpty()) {
+ validationQuery = properties.getDatabase().getRegistry().getValidationQuery();
+ }
+ return JPAUtils.getEntityManagerFactory(
+ CREDENTIAL_STORE_PU, jdbcDriver, jdbcUrl, jdbcUser, jdbcPassword, validationQuery);
+ }
+
// Transaction managers for each persistence unit
@Bean(name = "profileServiceTransactionManager")
@Primary
@@ -158,6 +187,11 @@ public class JpaConfig {
return new JpaTransactionManager(sharingRegistryEntityManagerFactory());
}
+ @Bean(name = "credentialStoreTransactionManager")
+ public PlatformTransactionManager credentialStoreTransactionManager() {
+ return new JpaTransactionManager(credentialStoreEntityManagerFactory());
+ }
+
// EntityManager beans for injection into repositories
// Note: EntityManagers are thread-safe when used with Spring's transaction management
// We use prototype scope to create new instances as needed
@@ -204,6 +238,13 @@ public class JpaConfig {
return emf.createEntityManager();
}
+ @Bean(name = "credentialStoreEntityManager")
+ @Scope("prototype")
+ public EntityManager credentialStoreEntityManager(
+ @Qualifier("credentialStoreEntityManagerFactory") EntityManagerFactory emf) {
+ return emf.createEntityManager();
+ }
+
// Spring Data JPA Repository Configuration for each persistence unit
@Configuration
@EnableJpaRepositories(
@@ -246,4 +287,11 @@ public class JpaConfig {
entityManagerFactoryRef = "sharingRegistryEntityManagerFactory",
transactionManagerRef = "sharingRegistryTransactionManager")
static class SharingRegistryJpaRepositoriesConfig {}
+
+ @Configuration
+ @EnableJpaRepositories(
+ basePackages = "org.apache.airavata.credential.repositories",
+ entityManagerFactoryRef = "credentialStoreEntityManagerFactory",
+ transactionManagerRef = "credentialStoreTransactionManager")
+ static class CredentialStoreJpaRepositoriesConfig {}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/entities/CommunityUserEntity.java b/airavata-api/src/main/java/org/apache/airavata/credential/entities/CommunityUserEntity.java
new file mode 100644
index 0000000000..d1103a1ba9
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/entities/CommunityUserEntity.java
@@ -0,0 +1,81 @@
+/**
+*
+* 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.credential.entities;
+
+import jakarta.persistence.*;
+import java.io.Serializable;
+
+/**
+ * JPA entity for COMMUNITY_USER table.
+ */
+@Entity
+@Table(name = "COMMUNITY_USER")
+@IdClass(CommunityUserEntityPK.class)
+public class CommunityUserEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @Column(name = "GATEWAY_ID", length = 256, nullable = false)
+ private String gatewayId;
+
+ @Id
+ @Column(name = "COMMUNITY_USER_NAME", length = 256, nullable = false)
+ private String communityUserName;
+
+ @Column(name = "TOKEN_ID", length = 256)
+ private String tokenId;
+
+ @Column(name = "COMMUNITY_USER_EMAIL", length = 256)
+ private String communityUserEmail;
+
+ public CommunityUserEntity() {}
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getCommunityUserName() {
+ return communityUserName;
+ }
+
+ public void setCommunityUserName(String communityUserName) {
+ this.communityUserName = communityUserName;
+ }
+
+ public String getTokenId() {
+ return tokenId;
+ }
+
+ public void setTokenId(String tokenId) {
+ this.tokenId = tokenId;
+ }
+
+ public String getCommunityUserEmail() {
+ return communityUserEmail;
+ }
+
+ public void setCommunityUserEmail(String communityUserEmail) {
+ this.communityUserEmail = communityUserEmail;
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/entities/CommunityUserEntityPK.java b/airavata-api/src/main/java/org/apache/airavata/credential/entities/CommunityUserEntityPK.java
new file mode 100644
index 0000000000..cb5ae197a7
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/entities/CommunityUserEntityPK.java
@@ -0,0 +1,69 @@
+/**
+*
+* 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.credential.entities;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Composite primary key for CommunityUserEntity.
+ */
+public class CommunityUserEntityPK implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String gatewayId;
+ private String communityUserName;
+
+ public CommunityUserEntityPK() {}
+
+ public CommunityUserEntityPK(String gatewayId, String communityUserName) {
+ this.gatewayId = gatewayId;
+ this.communityUserName = communityUserName;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getCommunityUserName() {
+ return communityUserName;
+ }
+
+ public void setCommunityUserName(String communityUserName) {
+ this.communityUserName = communityUserName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ CommunityUserEntityPK that = (CommunityUserEntityPK) o;
+ return Objects.equals(gatewayId, that.gatewayId) && Objects.equals(communityUserName, that.communityUserName);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(gatewayId, communityUserName);
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/entities/CredentialEntity.java b/airavata-api/src/main/java/org/apache/airavata/credential/entities/CredentialEntity.java
new file mode 100644
index 0000000000..9c0d9d3665
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/entities/CredentialEntity.java
@@ -0,0 +1,116 @@
+/**
+*
+* 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.credential.entities;
+
+import jakarta.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * JPA entity for CREDENTIALS table.
+ */
+@Entity
+@Table(name = "CREDENTIALS")
+@IdClass(CredentialEntityPK.class)
+public class CredentialEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @Column(name = "GATEWAY_ID", length = 256, nullable = false)
+ private String gatewayId;
+
+ @Id
+ @Column(name = "TOKEN_ID", length = 256, nullable = false)
+ private String tokenId;
+
+ @Lob
+ @Column(name = "CREDENTIAL", nullable = false)
+ private byte[] credential;
+
+ @Column(name = "PORTAL_USER_ID", length = 256, nullable = false)
+ private String portalUserId;
+
+ @Column(name = "TIME_PERSISTED")
+ private Timestamp timePersisted;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+ @Column(name = "CREDENTIAL_OWNER_TYPE", length = 50)
+ private String credentialOwnerType;
+
+ public CredentialEntity() {}
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getTokenId() {
+ return tokenId;
+ }
+
+ public void setTokenId(String tokenId) {
+ this.tokenId = tokenId;
+ }
+
+ public byte[] getCredential() {
+ return credential;
+ }
+
+ public void setCredential(byte[] credential) {
+ this.credential = credential;
+ }
+
+ public String getPortalUserId() {
+ return portalUserId;
+ }
+
+ public void setPortalUserId(String portalUserId) {
+ this.portalUserId = portalUserId;
+ }
+
+ public Timestamp getTimePersisted() {
+ return timePersisted;
+ }
+
+ public void setTimePersisted(Timestamp timePersisted) {
+ this.timePersisted = timePersisted;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getCredentialOwnerType() {
+ return credentialOwnerType;
+ }
+
+ public void setCredentialOwnerType(String credentialOwnerType) {
+ this.credentialOwnerType = credentialOwnerType;
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/entities/CredentialEntityPK.java b/airavata-api/src/main/java/org/apache/airavata/credential/entities/CredentialEntityPK.java
new file mode 100644
index 0000000000..7396478b12
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/entities/CredentialEntityPK.java
@@ -0,0 +1,69 @@
+/**
+*
+* 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.credential.entities;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Composite primary key for CredentialEntity.
+ */
+public class CredentialEntityPK implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String gatewayId;
+ private String tokenId;
+
+ public CredentialEntityPK() {}
+
+ public CredentialEntityPK(String gatewayId, String tokenId) {
+ this.gatewayId = gatewayId;
+ this.tokenId = tokenId;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getTokenId() {
+ return tokenId;
+ }
+
+ public void setTokenId(String tokenId) {
+ this.tokenId = tokenId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ CredentialEntityPK that = (CredentialEntityPK) o;
+ return Objects.equals(gatewayId, that.gatewayId) && Objects.equals(tokenId, that.tokenId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(gatewayId, tokenId);
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialStoreException.java b/airavata-api/src/main/java/org/apache/airavata/credential/exceptions/CredentialStoreException.java
similarity index 95%
rename from airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialStoreException.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/exceptions/CredentialStoreException.java
index 8556d564b1..f9b4a0757f 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialStoreException.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/exceptions/CredentialStoreException.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.store;
+package org.apache.airavata.credential.exceptions;
/**
* An exception class for credential store.
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotificationMessage.java b/airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotificationMessage.java
similarity index 92%
rename from airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotificationMessage.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotificationMessage.java
index 261b4c1e78..b517726f04 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotificationMessage.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotificationMessage.java
@@ -17,9 +17,9 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.notifier.impl;
+package org.apache.airavata.credential.impl.notifier;
-import org.apache.airavata.credential.notifier.NotificationMessage;
+import org.apache.airavata.credential.utils.NotificationMessage;
/**
* User: AmilaJ (amilaj@apache.org)
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotifier.java b/airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotifier.java
similarity index 90%
rename from airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotifier.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotifier.java
index 537e89926f..96bfdc7260 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotifier.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotifier.java
@@ -17,11 +17,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.notifier.impl;
+package org.apache.airavata.credential.impl.notifier;
-import org.apache.airavata.credential.notifier.CredentialStoreNotifier;
-import org.apache.airavata.credential.notifier.NotificationMessage;
-import org.apache.airavata.credential.store.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
+import org.apache.airavata.credential.utils.CredentialStoreNotifier;
+import org.apache.airavata.credential.utils.NotificationMessage;
import org.apache.commons.mail.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotifierConfiguration.java b/airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotifierConfiguration.java
similarity index 97%
rename from airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotifierConfiguration.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotifierConfiguration.java
index 2722e6eca9..d6a4c69ae0 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/impl/EmailNotifierConfiguration.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/impl/notifier/EmailNotifierConfiguration.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.notifier.impl;
+package org.apache.airavata.credential.impl.notifier;
/**
* User: AmilaJ (amilaj@apache.org)
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/CertificateCredentialWriter.java b/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/CertificateCredentialWriter.java
new file mode 100644
index 0000000000..b61b4666fa
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/CertificateCredentialWriter.java
@@ -0,0 +1,68 @@
+/**
+*
+* 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.credential.impl.store;
+
+import org.apache.airavata.credential.CommunityUser;
+import org.apache.airavata.credential.Credential;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
+import org.apache.airavata.credential.impl.certificate.CertificateCredential;
+import org.apache.airavata.credential.services.CommunityUserEntityService;
+import org.apache.airavata.credential.services.CredentialEntityService;
+import org.apache.airavata.credential.utils.CredentialWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Writes certificate credentials to database.
+ */
+@Component
+public class CertificateCredentialWriter implements CredentialWriter {
+
+ protected static Logger log = LoggerFactory.getLogger(CertificateCredentialWriter.class);
+
+ @Autowired
+ private CredentialEntityService credentialEntityService;
+
+ @Autowired
+ private CommunityUserEntityService communityUserEntityService;
+
+ public CertificateCredentialWriter() {}
+
+ public void writeCredentials(Credential credential) throws CredentialStoreException {
+ CertificateCredential certificateCredential = (CertificateCredential) credential;
+
+ // Write community user
+ writeCommunityUser(certificateCredential.getCommunityUser(), credential.getToken());
+
+ // Delete existing credentials and add the new certificate
+ credentialEntityService.deleteCredential(
+ certificateCredential.getCommunityUser().getGatewayName(), certificateCredential.getToken());
+ credentialEntityService.saveCredential(
+ certificateCredential.getCommunityUser().getGatewayName(), credential);
+ }
+
+ public void writeCommunityUser(CommunityUser communityUser, String token) throws CredentialStoreException {
+ // Delete existing community user and persist new one
+ communityUserEntityService.deleteCommunityUserByToken(communityUser, token);
+ communityUserEntityService.saveCommunityUser(communityUser, token);
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/CredentialReaderImpl.java b/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/CredentialReaderImpl.java
new file mode 100644
index 0000000000..1dbfdbb71e
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/CredentialReaderImpl.java
@@ -0,0 +1,113 @@
+/**
+*
+* 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.credential.impl.store;
+
+import java.io.Serializable;
+import java.util.List;
+import org.apache.airavata.credential.CommunityUser;
+import org.apache.airavata.credential.Credential;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
+import org.apache.airavata.credential.impl.certificate.CertificateAuditInfo;
+import org.apache.airavata.credential.impl.certificate.CertificateCredential;
+import org.apache.airavata.credential.services.CredentialEntityService;
+import org.apache.airavata.credential.utils.CredentialReader;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Credential store API implementation.
+ */
+@Component
+public class CredentialReaderImpl implements CredentialReader, Serializable {
+
+ @Autowired
+ private CredentialEntityService credentialEntityService;
+
+ public CredentialReaderImpl() {}
+
+ @Override
+ public Credential getCredential(String gatewayId, String tokenId) throws CredentialStoreException {
+ return credentialEntityService.getCredential(gatewayId, tokenId);
+ }
+
+ public List<Credential> getAllCredentials() throws CredentialStoreException {
+ return credentialEntityService.getAllCredentials();
+ }
+
+ @Override
+ public List<Credential> getAllCredentialsPerGateway(String gatewayId) throws CredentialStoreException {
+ return credentialEntityService.getCredentials(gatewayId);
+ }
+
+ @Override
+ public List<Credential> getAllAccessibleCredentialsPerGateway(String gatewayId, List<String> accessibleTokenIds)
+ throws CredentialStoreException {
+ return credentialEntityService.getCredentials(gatewayId, accessibleTokenIds);
+ }
+
+ @Override
+ public List<Credential> getAllCredentialsPerUser(String userName) throws CredentialStoreException {
+ return null;
+ }
+
+ public String getPortalUser(String gatewayName, String tokenId) throws CredentialStoreException {
+ Credential credential = credentialEntityService.getCredential(gatewayName, tokenId);
+ if (credential == null) {
+ return null;
+ }
+ return credential.getPortalUserName();
+ }
+
+ public CertificateAuditInfo getAuditInfo(String gatewayName, String tokenId) throws CredentialStoreException {
+ CertificateCredential certificateCredential =
+ (CertificateCredential) credentialEntityService.getCredential(gatewayName, tokenId);
+
+ if (certificateCredential == null) {
+ return null;
+ }
+
+ CertificateAuditInfo certificateAuditInfo = new CertificateAuditInfo();
+
+ CommunityUser retrievedUser = certificateCredential.getCommunityUser();
+ certificateAuditInfo.setCommunityUserName(retrievedUser.getUserName());
+ certificateAuditInfo.setCredentialLifeTime(certificateCredential.getLifeTime());
+ certificateAuditInfo.setCredentialsRequestedTime(certificateCredential.getCertificateRequestedTime());
+ certificateAuditInfo.setGatewayName(gatewayName);
+ certificateAuditInfo.setNotAfter(certificateCredential.getNotAfter());
+ certificateAuditInfo.setNotBefore(certificateCredential.getNotBefore());
+ certificateAuditInfo.setPortalUserName(certificateCredential.getPortalUserName());
+
+ return certificateAuditInfo;
+ }
+
+ public void updateCommunityUserEmail(String gatewayName, String communityUser, String email)
+ throws CredentialStoreException {
+ // TODO
+ }
+
+ public void removeCredentials(String gatewayName, String tokenId) throws CredentialStoreException {
+ credentialEntityService.deleteCredential(gatewayName, tokenId);
+ }
+
+ @Override
+ public String getGatewayID(String tokenId) throws CredentialStoreException {
+ return credentialEntityService.getGatewayId(tokenId);
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/SSHCredentialWriter.java b/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/SSHCredentialWriter.java
new file mode 100644
index 0000000000..100694d08a
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/impl/store/SSHCredentialWriter.java
@@ -0,0 +1,52 @@
+/**
+*
+* 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.credential.impl.store;
+
+import org.apache.airavata.credential.Credential;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
+import org.apache.airavata.credential.impl.ssh.SSHCredential;
+import org.apache.airavata.credential.services.CredentialEntityService;
+import org.apache.airavata.credential.utils.CredentialWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Writes SSH credentials to database.
+ */
+@Component
+public class SSHCredentialWriter implements CredentialWriter {
+
+ protected static Logger logger = LoggerFactory.getLogger(SSHCredentialWriter.class);
+
+ @Autowired
+ private CredentialEntityService credentialEntityService;
+
+ public SSHCredentialWriter() {}
+
+ public void writeCredentials(Credential credential) throws CredentialStoreException {
+ SSHCredential sshCredential = (SSHCredential) credential;
+
+ // Delete existing credentials and add the new one
+ credentialEntityService.deleteCredential(sshCredential.getGateway(), sshCredential.getToken());
+ credentialEntityService.saveCredential(sshCredential.getGateway(), credential);
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/CredentialStoreNotifier.java b/airavata-api/src/main/java/org/apache/airavata/credential/notifier/CredentialStoreNotifier.java
deleted file mode 100644
index 26eaaa9810..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/CredentialStoreNotifier.java
+++ /dev/null
@@ -1,59 +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.credential.notifier; /*
- *
- * 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.
- *
- */
-
-import org.apache.airavata.credential.store.CredentialStoreException;
-
-/**
- * This class is used to notify particular entity with expiring credentials.
- * The default implementation uses email messages.
- * User: AmilaJ (amilaj@apache.org)
- * Date: 12/3/13
- * Time: 4:17 PM
- */
-public interface CredentialStoreNotifier {
-
- /**
- * The specific notifier implementation needs to implement following method.
- * This method should actually deliver message to desired entity.
- * @param message The actual message encapsulated
- * @throws CredentialStoreException
- */
- void notifyMessage(NotificationMessage message) throws CredentialStoreException;
-}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/repositories/CommunityUserRepository.java b/airavata-api/src/main/java/org/apache/airavata/credential/repositories/CommunityUserRepository.java
new file mode 100644
index 0000000000..b1b2c5cd3e
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/repositories/CommunityUserRepository.java
@@ -0,0 +1,59 @@
+/**
+*
+* 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.credential.repositories;
+
+import java.util.List;
+import java.util.Optional;
+import org.apache.airavata.credential.entities.CommunityUserEntity;
+import org.apache.airavata.credential.entities.CommunityUserEntityPK;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Spring Data JPA repository for CommunityUserEntity.
+ */
+@Repository
+public interface CommunityUserRepository extends JpaRepository<CommunityUserEntity, CommunityUserEntityPK> {
+
+ /**
+ * Find community user by gateway ID and community user name.
+ */
+ Optional<CommunityUserEntity> findByGatewayIdAndCommunityUserName(String gatewayId, String communityUserName);
+
+ /**
+ * Find community user by gateway ID and token ID.
+ */
+ Optional<CommunityUserEntity> findByGatewayIdAndTokenId(String gatewayId, String tokenId);
+
+ /**
+ * Find all community users for a gateway.
+ */
+ List<CommunityUserEntity> findByGatewayId(String gatewayId);
+
+ /**
+ * Delete community user by gateway ID and community user name.
+ */
+ void deleteByGatewayIdAndCommunityUserName(String gatewayId, String communityUserName);
+
+ /**
+ * Delete community user by gateway ID, community user name, and token ID.
+ */
+ void deleteByGatewayIdAndCommunityUserNameAndTokenId(String gatewayId, String communityUserName, String tokenId);
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/repositories/CredentialRepository.java b/airavata-api/src/main/java/org/apache/airavata/credential/repositories/CredentialRepository.java
new file mode 100644
index 0000000000..6a6d9de67b
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/repositories/CredentialRepository.java
@@ -0,0 +1,64 @@
+/**
+*
+* 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.credential.repositories;
+
+import java.util.List;
+import java.util.Optional;
+import org.apache.airavata.credential.entities.CredentialEntity;
+import org.apache.airavata.credential.entities.CredentialEntityPK;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Spring Data JPA repository for CredentialEntity.
+ */
+@Repository
+public interface CredentialRepository extends JpaRepository<CredentialEntity, CredentialEntityPK> {
+
+ /**
+ * Find credential by gateway ID and token ID.
+ */
+ Optional<CredentialEntity> findByGatewayIdAndTokenId(String gatewayId, String tokenId);
+
+ /**
+ * Find all credentials for a gateway.
+ */
+ List<CredentialEntity> findByGatewayId(String gatewayId);
+
+ /**
+ * Find credentials for a gateway with specific token IDs.
+ */
+ @Query("SELECT c FROM CredentialEntity c WHERE c.gatewayId = :gatewayId AND c.tokenId IN :tokenIds")
+ List<CredentialEntity> findByGatewayIdAndTokenIdIn(
+ @Param("gatewayId") String gatewayId, @Param("tokenIds") List<String> tokenIds);
+
+ /**
+ * Find gateway ID by token ID.
+ */
+ @Query("SELECT c.gatewayId FROM CredentialEntity c WHERE c.tokenId = :tokenId")
+ Optional<String> findGatewayIdByTokenId(@Param("tokenId") String tokenId);
+
+ /**
+ * Delete credential by gateway ID and token ID.
+ */
+ void deleteByGatewayIdAndTokenId(String gatewayId, String tokenId);
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/services/CommunityUserEntityService.java b/airavata-api/src/main/java/org/apache/airavata/credential/services/CommunityUserEntityService.java
new file mode 100644
index 0000000000..ac5caaa084
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/services/CommunityUserEntityService.java
@@ -0,0 +1,149 @@
+/**
+*
+* 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.credential.services;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import org.apache.airavata.credential.CommunityUser;
+import org.apache.airavata.credential.entities.CommunityUserEntity;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
+import org.apache.airavata.credential.repositories.CommunityUserRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Service for managing community user entities.
+ */
+@Service
+@Transactional
+public class CommunityUserEntityService {
+
+ private static final Logger logger = LoggerFactory.getLogger(CommunityUserEntityService.class);
+
+ @Autowired
+ private CommunityUserRepository communityUserRepository;
+
+ /**
+ * Add or update community user.
+ */
+ public void saveCommunityUser(CommunityUser user, String token) throws CredentialStoreException {
+ try {
+ // Delete existing user with same token if exists
+ communityUserRepository.deleteByGatewayIdAndCommunityUserNameAndTokenId(
+ user.getGatewayName(), user.getUserName(), token);
+
+ CommunityUserEntity entity = new CommunityUserEntity();
+ entity.setGatewayId(user.getGatewayName());
+ entity.setCommunityUserName(user.getUserName());
+ entity.setTokenId(token);
+ entity.setCommunityUserEmail(user.getUserEmail());
+
+ communityUserRepository.save(entity);
+ } catch (Exception e) {
+ logger.error(
+ "Error saving community user for gateway: {}, user: {}, token: {}",
+ user.getGatewayName(),
+ user.getUserName(),
+ token,
+ e);
+ throw new CredentialStoreException("Error saving community user", e);
+ }
+ }
+
+ /**
+ * Delete community user.
+ */
+ public void deleteCommunityUser(CommunityUser user) throws CredentialStoreException {
+ try {
+ communityUserRepository.deleteByGatewayIdAndCommunityUserName(user.getGatewayName(), user.getUserName());
+ } catch (Exception e) {
+ logger.error(
+ "Error deleting community user for gateway: {}, user: {}",
+ user.getGatewayName(),
+ user.getUserName(),
+ e);
+ throw new CredentialStoreException("Error deleting community user", e);
+ }
+ }
+
+ /**
+ * Delete community user by token.
+ */
+ public void deleteCommunityUserByToken(CommunityUser user, String token) throws CredentialStoreException {
+ try {
+ communityUserRepository.deleteByGatewayIdAndCommunityUserNameAndTokenId(
+ user.getGatewayName(), user.getUserName(), token);
+ } catch (Exception e) {
+ logger.error(
+ "Error deleting community user by token for gateway: {}, user: {}, token: {}",
+ user.getGatewayName(),
+ user.getUserName(),
+ token,
+ e);
+ throw new CredentialStoreException("Error deleting community user by token", e);
+ }
+ }
+
+ /**
+ * Get community user by gateway ID and community user name.
+ */
+ public CommunityUser getCommunityUser(String gatewayName, String communityUserName)
+ throws CredentialStoreException {
+ Optional<CommunityUserEntity> entityOpt =
+ communityUserRepository.findByGatewayIdAndCommunityUserName(gatewayName, communityUserName);
+ if (entityOpt.isEmpty()) {
+ return null;
+ }
+
+ CommunityUserEntity entity = entityOpt.get();
+ return new CommunityUser(entity.getGatewayId(), entity.getCommunityUserName(), entity.getCommunityUserEmail());
+ }
+
+ /**
+ * Get community user by gateway ID and token ID.
+ */
+ public CommunityUser getCommunityUserByToken(String gatewayName, String tokenId) throws CredentialStoreException {
+ Optional<CommunityUserEntity> entityOpt =
+ communityUserRepository.findByGatewayIdAndTokenId(gatewayName, tokenId);
+ if (entityOpt.isEmpty()) {
+ return null;
+ }
+
+ CommunityUserEntity entity = entityOpt.get();
+ return new CommunityUser(entity.getGatewayId(), entity.getCommunityUserName(), entity.getCommunityUserEmail());
+ }
+
+ /**
+ * Get all community users for a gateway.
+ */
+ public List<CommunityUser> getCommunityUsers(String gatewayName) throws CredentialStoreException {
+ List<CommunityUserEntity> entities = communityUserRepository.findByGatewayId(gatewayName);
+ List<CommunityUser> users = new ArrayList<>();
+ for (CommunityUserEntity entity : entities) {
+ users.add(new CommunityUser(
+ entity.getGatewayId(), entity.getCommunityUserName(), entity.getCommunityUserEmail()));
+ }
+ return users;
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/services/CredentialEntityService.java b/airavata-api/src/main/java/org/apache/airavata/credential/services/CredentialEntityService.java
new file mode 100644
index 0000000000..88fc574578
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/services/CredentialEntityService.java
@@ -0,0 +1,296 @@
+/**
+*
+* 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.credential.services;
+
+import java.io.*;
+import java.security.GeneralSecurityException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ApplicationSettings;
+import org.apache.airavata.common.utils.DefaultKeyStorePasswordCallback;
+import org.apache.airavata.common.utils.KeyStorePasswordCallback;
+import org.apache.airavata.common.utils.SecurityUtil;
+import org.apache.airavata.credential.Credential;
+import org.apache.airavata.credential.CredentialOwnerType;
+import org.apache.airavata.credential.entities.CredentialEntity;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
+import org.apache.airavata.credential.repositories.CredentialRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Service for managing credential entities with encryption/decryption support.
+ */
+@Service
+@Transactional
+public class CredentialEntityService {
+
+ private static final Logger logger = LoggerFactory.getLogger(CredentialEntityService.class);
+
+ @Autowired
+ private CredentialRepository credentialRepository;
+
+ private String keyStorePath;
+ private String secretKeyAlias;
+ private KeyStorePasswordCallback keyStorePasswordCallback;
+
+ @jakarta.annotation.PostConstruct
+ public void init() {
+ try {
+ this.keyStorePath = ApplicationSettings.getCredentialStoreKeyStorePath();
+ this.secretKeyAlias = ApplicationSettings.getCredentialStoreKeyAlias();
+ this.keyStorePasswordCallback = new DefaultKeyStorePasswordCallback();
+ } catch (ApplicationSettingsException e) {
+ logger.warn("Failed to initialize keystore settings, encryption will be disabled", e);
+ this.keyStorePath = null;
+ }
+ }
+
+ /**
+ * Add or update credentials.
+ */
+ public void saveCredential(String gatewayId, Credential credential) throws CredentialStoreException {
+ try {
+ CredentialEntity entity = new CredentialEntity();
+ entity.setGatewayId(gatewayId);
+ entity.setTokenId(credential.getToken());
+ entity.setCredential(convertObjectToByteArray(credential));
+ entity.setPortalUserId(credential.getPortalUserName());
+ entity.setTimePersisted(new Timestamp(System.currentTimeMillis()));
+ entity.setDescription(credential.getDescription());
+ if (credential.getCredentialOwnerType() != null) {
+ entity.setCredentialOwnerType(
+ credential.getCredentialOwnerType().toString());
+ }
+
+ credentialRepository.save(entity);
+ } catch (Exception e) {
+ logger.error("Error saving credential for gateway: {}, token: {}", gatewayId, credential.getToken(), e);
+ throw new CredentialStoreException("Error saving credential", e);
+ }
+ }
+
+ /**
+ * Delete credentials.
+ */
+ public void deleteCredential(String gatewayId, String tokenId) throws CredentialStoreException {
+ try {
+ credentialRepository.deleteByGatewayIdAndTokenId(gatewayId, tokenId);
+ } catch (Exception e) {
+ logger.error("Error deleting credential for gateway: {}, token: {}", gatewayId, tokenId, e);
+ throw new CredentialStoreException("Error deleting credential", e);
+ }
+ }
+
+ /**
+ * Get credential by gateway ID and token ID.
+ */
+ public Credential getCredential(String gatewayId, String tokenId) throws CredentialStoreException {
+ Optional<CredentialEntity> entityOpt = credentialRepository.findByGatewayIdAndTokenId(gatewayId, tokenId);
+ if (entityOpt.isEmpty()) {
+ return null;
+ }
+
+ CredentialEntity entity = entityOpt.get();
+ try {
+ Credential credential = (Credential) convertByteArrayToObject(entity.getCredential());
+ credential.setToken(entity.getTokenId());
+ credential.setPortalUserName(entity.getPortalUserId());
+ credential.setCertificateRequestedTime(entity.getTimePersisted());
+ credential.setDescription(entity.getDescription());
+ if (entity.getCredentialOwnerType() != null) {
+ credential.setCredentialOwnerType(CredentialOwnerType.valueOf(entity.getCredentialOwnerType()));
+ }
+ return credential;
+ } catch (Exception e) {
+ logger.error("Error retrieving credential for gateway: {}, token: {}", gatewayId, tokenId, e);
+ throw new CredentialStoreException("Error retrieving credential", e);
+ }
+ }
+
+ /**
+ * Get gateway ID by token ID.
+ */
+ public String getGatewayId(String tokenId) throws CredentialStoreException {
+ Optional<String> gatewayIdOpt = credentialRepository.findGatewayIdByTokenId(tokenId);
+ return gatewayIdOpt.orElse(null);
+ }
+
+ /**
+ * Get all credentials for a gateway.
+ */
+ public List<Credential> getCredentials(String gatewayId) throws CredentialStoreException {
+ return getCredentialsInternal(gatewayId, null);
+ }
+
+ /**
+ * Get credentials for a gateway with specific token IDs.
+ */
+ public List<Credential> getCredentials(String gatewayId, List<String> accessibleTokenIds)
+ throws CredentialStoreException {
+ if (accessibleTokenIds == null || accessibleTokenIds.isEmpty()) {
+ return Collections.emptyList();
+ }
+ return getCredentialsInternal(gatewayId, accessibleTokenIds);
+ }
+
+ private List<Credential> getCredentialsInternal(String gatewayId, List<String> accessibleTokenIds)
+ throws CredentialStoreException {
+ List<CredentialEntity> entities;
+ if (accessibleTokenIds != null && !accessibleTokenIds.isEmpty()) {
+ entities = credentialRepository.findByGatewayIdAndTokenIdIn(gatewayId, accessibleTokenIds);
+ } else {
+ entities = credentialRepository.findByGatewayId(gatewayId);
+ }
+
+ List<Credential> credentials = new ArrayList<>();
+ for (CredentialEntity entity : entities) {
+ try {
+ Credential credential = (Credential) convertByteArrayToObject(entity.getCredential());
+ credential.setToken(entity.getTokenId());
+ credential.setPortalUserName(entity.getPortalUserId());
+ credential.setCertificateRequestedTime(entity.getTimePersisted());
+ credential.setDescription(entity.getDescription());
+ if (entity.getCredentialOwnerType() != null) {
+ credential.setCredentialOwnerType(CredentialOwnerType.valueOf(entity.getCredentialOwnerType()));
+ }
+ credentials.add(credential);
+ } catch (Exception e) {
+ logger.error(
+ "Error converting entity to credential for gateway: {}, token: {}",
+ gatewayId,
+ entity.getTokenId(),
+ e);
+ throw new CredentialStoreException("Error converting entity to credential", e);
+ }
+ }
+ return credentials;
+ }
+
+ /**
+ * Get all credentials.
+ */
+ public List<Credential> getAllCredentials() throws CredentialStoreException {
+ List<CredentialEntity> entities = credentialRepository.findAll();
+ List<Credential> credentials = new ArrayList<>();
+ for (CredentialEntity entity : entities) {
+ try {
+ Credential credential = (Credential) convertByteArrayToObject(entity.getCredential());
+ credential.setToken(entity.getTokenId());
+ credential.setPortalUserName(entity.getPortalUserId());
+ credential.setCertificateRequestedTime(entity.getTimePersisted());
+ credential.setDescription(entity.getDescription());
+ if (entity.getCredentialOwnerType() != null) {
+ credential.setCredentialOwnerType(CredentialOwnerType.valueOf(entity.getCredentialOwnerType()));
+ }
+ credentials.add(credential);
+ } catch (Exception e) {
+ logger.error(
+ "Error converting entity to credential for gateway: {}, token: {}",
+ entity.getGatewayId(),
+ entity.getTokenId(),
+ e);
+ throw new CredentialStoreException("Error converting entity to credential", e);
+ }
+ }
+ return credentials;
+ }
+
+ /**
+ * Convert byte array to object (with decryption if enabled).
+ */
+ private Object convertByteArrayToObject(byte[] data) throws CredentialStoreException {
+ ObjectInputStream objectInputStream = null;
+ try {
+ // Decrypt the data first if encryption is enabled
+ if (shouldEncrypt()) {
+ data = SecurityUtil.decrypt(keyStorePath, secretKeyAlias, keyStorePasswordCallback, data);
+ }
+
+ objectInputStream = new ObjectInputStream(new ByteArrayInputStream(data));
+ return objectInputStream.readObject();
+ } catch (IOException e) {
+ throw new CredentialStoreException("Error de-serializing object", e);
+ } catch (ClassNotFoundException e) {
+ throw new CredentialStoreException("Error de-serializing object", e);
+ } catch (GeneralSecurityException e) {
+ throw new CredentialStoreException("Error decrypting data", e);
+ } finally {
+ if (objectInputStream != null) {
+ try {
+ objectInputStream.close();
+ } catch (IOException e) {
+ logger.error("Error closing stream", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Convert object to byte array (with encryption if enabled).
+ */
+ private byte[] convertObjectToByteArray(Serializable o) throws CredentialStoreException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ ObjectOutputStream objectOutputStream = null;
+ try {
+ objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
+ objectOutputStream.writeObject(o);
+ objectOutputStream.flush();
+ } catch (IOException e) {
+ throw new CredentialStoreException("Error serializing object", e);
+ } finally {
+ if (objectOutputStream != null) {
+ try {
+ objectOutputStream.close();
+ } catch (IOException e) {
+ logger.error("Error closing object output stream", e);
+ }
+ }
+ }
+
+ // Encrypt the byte array if encryption is enabled
+ if (shouldEncrypt()) {
+ byte[] array = byteArrayOutputStream.toByteArray();
+ try {
+ return SecurityUtil.encrypt(keyStorePath, secretKeyAlias, keyStorePasswordCallback, array);
+ } catch (GeneralSecurityException e) {
+ throw new CredentialStoreException("Error encrypting data", e);
+ } catch (IOException e) {
+ throw new CredentialStoreException("Error encrypting data", e);
+ }
+ } else {
+ return byteArrayOutputStream.toByteArray();
+ }
+ }
+
+ /**
+ * Check if encryption should be enabled.
+ */
+ private boolean shouldEncrypt() {
+ return keyStorePath != null;
+ }
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/CertificateCredentialWriter.java b/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/CertificateCredentialWriter.java
deleted file mode 100644
index ff6b5c2f5e..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/CertificateCredentialWriter.java
+++ /dev/null
@@ -1,120 +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.credential.store.impl;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ApplicationSettings;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.DefaultKeyStorePasswordCallback;
-import org.apache.airavata.credential.CommunityUser;
-import org.apache.airavata.credential.Credential;
-import org.apache.airavata.credential.impl.certificate.CertificateCredential;
-import org.apache.airavata.credential.store.CredentialStoreException;
-import org.apache.airavata.credential.store.CredentialWriter;
-import org.apache.airavata.credential.store.impl.db.CommunityUserDAO;
-import org.apache.airavata.credential.store.impl.db.CredentialsDAO;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Writes certificate credentials to database.
- */
-public class CertificateCredentialWriter implements CredentialWriter {
-
- private CredentialsDAO credentialsDAO;
- private CommunityUserDAO communityUserDAO;
-
- protected static Logger log = LoggerFactory.getLogger(CertificateCredentialWriter.class);
-
- private DBUtil dbUtil;
-
- public CertificateCredentialWriter(DBUtil dbUtil) throws ApplicationSettingsException {
-
- this.dbUtil = dbUtil;
-
- this.credentialsDAO = new CredentialsDAO(
- ApplicationSettings.getCredentialStoreKeyStorePath(),
- ApplicationSettings.getCredentialStoreKeyAlias(),
- new DefaultKeyStorePasswordCallback());
-
- communityUserDAO = new CommunityUserDAO();
- }
-
- public void writeCredentials(Credential credential) throws CredentialStoreException {
-
- CertificateCredential certificateCredential = (CertificateCredential) credential;
-
- Connection connection = null;
-
- try {
-
- connection = dbUtil.getConnection();
- // Write community user
- writeCommunityUser(certificateCredential.getCommunityUser(), credential.getToken(), connection);
- // First delete existing credentials
- credentialsDAO.deleteCredentials(
- certificateCredential.getCommunityUser().getGatewayName(),
- certificateCredential.getToken(),
- connection);
- // Add the new certificate
- credentialsDAO.addCredentials(
- certificateCredential.getCommunityUser().getGatewayName(), credential, connection);
-
- if (!connection.getAutoCommit()) {
- connection.commit();
- }
-
- } catch (SQLException e) {
- if (connection != null) {
- try {
- connection.rollback();
- } catch (SQLException e1) {
- log.error("Unable to rollback transaction", e1);
- }
- }
- throw new CredentialStoreException("Unable to retrieve database connection.", e);
- } finally {
- DBUtil.cleanup(connection);
- }
- }
-
- public void writeCommunityUser(CommunityUser communityUser, String token, Connection connection)
- throws CredentialStoreException {
-
- // First delete existing community user
- communityUserDAO.deleteCommunityUserByToken(communityUser, token, connection);
-
- // Persist new community user
- communityUserDAO.addCommunityUser(communityUser, token, connection);
- }
-
- /*
- * TODO Remove later - If we dont need to expose this in the interface public void writeCommunityUser(CommunityUser
- * communityUser, String token) throws CredentialStoreException {
- *
- * Connection connection = null; try { connection = dbUtil.getConnection(); writeCommunityUser(communityUser, token,
- * connection);
- *
- * } catch (SQLException e) { throw new CredentialStoreException("Unable to retrieve database connection.", e); }
- * finally { DBUtil.cleanup(connection); } }
- */
-}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/CredentialReaderImpl.java b/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/CredentialReaderImpl.java
deleted file mode 100644
index ab5e1d7a8b..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/CredentialReaderImpl.java
+++ /dev/null
@@ -1,186 +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.credential.store.impl;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.List;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ApplicationSettings;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.DefaultKeyStorePasswordCallback;
-import org.apache.airavata.credential.CommunityUser;
-import org.apache.airavata.credential.Credential;
-import org.apache.airavata.credential.impl.certificate.CertificateAuditInfo;
-import org.apache.airavata.credential.impl.certificate.CertificateCredential;
-import org.apache.airavata.credential.store.CredentialReader;
-import org.apache.airavata.credential.store.CredentialStoreException;
-import org.apache.airavata.credential.store.impl.db.CredentialsDAO;
-
-/**
- * Credential store API implementation.
- */
-public class CredentialReaderImpl implements CredentialReader, Serializable {
-
- private CredentialsDAO credentialsDAO;
-
- private DBUtil dbUtil;
-
- public CredentialReaderImpl(DBUtil dbUtil) throws ApplicationSettingsException {
-
- this.credentialsDAO = new CredentialsDAO(
- ApplicationSettings.getCredentialStoreKeyStorePath(),
- ApplicationSettings.getCredentialStoreKeyAlias(),
- new DefaultKeyStorePasswordCallback());
-
- this.dbUtil = dbUtil;
- }
-
- private Connection getConnection() throws CredentialStoreException {
- try {
- return this.dbUtil.getConnection();
- } catch (SQLException e) {
- throw new CredentialStoreException("Unable to retrieve database connection.", e);
- }
- }
-
- @Override
- public Credential getCredential(String gatewayId, String tokenId) throws CredentialStoreException {
-
- Connection connection = getConnection();
-
- try {
- return this.credentialsDAO.getCredential(gatewayId, tokenId, connection);
- } finally {
- DBUtil.cleanup(connection);
- }
- }
-
- public List<Credential> getAllCredentials() throws CredentialStoreException {
-
- Connection connection = getConnection();
-
- try {
- return this.credentialsDAO.getCredentials(connection);
- } finally {
- DBUtil.cleanup(connection);
- }
- }
-
- @Override
- public List<Credential> getAllCredentialsPerGateway(String gatewayId) throws CredentialStoreException {
- Connection connection = getConnection();
-
- try {
- return this.credentialsDAO.getCredentials(gatewayId, connection);
- } finally {
- DBUtil.cleanup(connection);
- }
- }
-
- @Override
- public List<Credential> getAllAccessibleCredentialsPerGateway(String gatewayId, List<String> accessibleTokenIds)
- throws CredentialStoreException {
- Connection connection = getConnection();
-
- try {
- return this.credentialsDAO.getCredentials(gatewayId, accessibleTokenIds, connection);
- } finally {
- DBUtil.cleanup(connection);
- }
- }
-
- @Override
- public List<Credential> getAllCredentialsPerUser(String userName) throws CredentialStoreException {
- return null;
- }
-
- public String getPortalUser(String gatewayName, String tokenId) throws CredentialStoreException {
-
- Connection connection = getConnection();
-
- Credential credential;
-
- try {
- credential = this.credentialsDAO.getCredential(gatewayName, tokenId, connection);
-
- } finally {
- DBUtil.cleanup(connection);
- }
-
- return credential.getPortalUserName();
- }
-
- public CertificateAuditInfo getAuditInfo(String gatewayName, String tokenId) throws CredentialStoreException {
-
- Connection connection = getConnection();
-
- CertificateAuditInfo certificateAuditInfo;
-
- try {
-
- CertificateCredential certificateCredential =
- (CertificateCredential) this.credentialsDAO.getCredential(gatewayName, tokenId, connection);
-
- certificateAuditInfo = new CertificateAuditInfo();
-
- CommunityUser retrievedUser = certificateCredential.getCommunityUser();
- certificateAuditInfo.setCommunityUserName(retrievedUser.getUserName());
- certificateAuditInfo.setCredentialLifeTime(certificateCredential.getLifeTime());
- certificateAuditInfo.setCredentialsRequestedTime(certificateCredential.getCertificateRequestedTime());
- certificateAuditInfo.setGatewayName(gatewayName);
- certificateAuditInfo.setNotAfter(certificateCredential.getNotAfter());
- certificateAuditInfo.setNotBefore(certificateCredential.getNotBefore());
- certificateAuditInfo.setPortalUserName(certificateCredential.getPortalUserName());
-
- } finally {
- DBUtil.cleanup(connection);
- }
-
- return certificateAuditInfo;
- }
-
- public void updateCommunityUserEmail(String gatewayName, String communityUser, String email)
- throws CredentialStoreException {
- // TODO
- }
-
- public void removeCredentials(String gatewayName, String tokenId) throws CredentialStoreException {
-
- Connection connection = getConnection();
-
- try {
- credentialsDAO.deleteCredentials(gatewayName, tokenId, connection);
- } finally {
- DBUtil.cleanup(connection);
- }
- }
-
- @Override
- public String getGatewayID(String tokenId) throws CredentialStoreException {
- Connection connection = getConnection();
- try {
- return this.credentialsDAO.getGatewayID(tokenId, connection);
- } finally {
- DBUtil.cleanup(connection);
- }
- }
-}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/SSHCredentialWriter.java b/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/SSHCredentialWriter.java
deleted file mode 100644
index dc6a0c770b..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/SSHCredentialWriter.java
+++ /dev/null
@@ -1,83 +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.credential.store.impl;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ApplicationSettings;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.DefaultKeyStorePasswordCallback;
-import org.apache.airavata.credential.Credential;
-import org.apache.airavata.credential.impl.ssh.SSHCredential;
-import org.apache.airavata.credential.store.CredentialStoreException;
-import org.apache.airavata.credential.store.CredentialWriter;
-import org.apache.airavata.credential.store.impl.db.CredentialsDAO;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Writes SSH credentials to database.
- */
-public class SSHCredentialWriter implements CredentialWriter {
-
- private CredentialsDAO credentialsDAO;
- private DBUtil dbUtil;
-
- protected static Logger logger = LoggerFactory.getLogger(SSHCredentialWriter.class);
-
- public SSHCredentialWriter(DBUtil dbUtil) throws ApplicationSettingsException {
- this.dbUtil = dbUtil;
- this.credentialsDAO = new CredentialsDAO(
- ApplicationSettings.getCredentialStoreKeyStorePath(),
- ApplicationSettings.getCredentialStoreKeyAlias(),
- new DefaultKeyStorePasswordCallback());
- }
-
- public void writeCredentials(Credential credential) throws CredentialStoreException {
-
- SSHCredential sshCredential = (SSHCredential) credential;
- Connection connection = null;
-
- try {
- connection = dbUtil.getConnection();
- // First delete existing credentials
- credentialsDAO.deleteCredentials(sshCredential.getGateway(), sshCredential.getToken(), connection);
- // Add the new certificate
- credentialsDAO.addCredentials(sshCredential.getGateway(), credential, connection);
-
- if (!connection.getAutoCommit()) {
- connection.commit();
- }
-
- } catch (SQLException e) {
- if (connection != null) {
- try {
- connection.rollback();
- } catch (SQLException e1) {
- logger.error("Unable to rollback transaction", e1);
- }
- }
- throw new CredentialStoreException("Unable to retrieve database connection.", e);
- } finally {
- DBUtil.cleanup(connection);
- }
- }
-}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/CommunityUserDAO.java b/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/CommunityUserDAO.java
deleted file mode 100644
index d6d3b2f02e..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/CommunityUserDAO.java
+++ /dev/null
@@ -1,250 +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.credential.store.impl.db;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.credential.CommunityUser;
-import org.apache.airavata.credential.store.CredentialStoreException;
-
-/**
- * Data access class for community_user table.
- */
-public class CommunityUserDAO extends ParentDAO {
-
- public CommunityUserDAO() {
- super();
- }
-
- public void addCommunityUser(CommunityUser user, String token, Connection connection)
- throws CredentialStoreException {
-
- String sql = "INSERT INTO COMMUNITY_USER VALUES (?, ?, ?, ?)";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, user.getGatewayName());
- preparedStatement.setString(2, user.getUserName());
- preparedStatement.setString(3, token);
- preparedStatement.setString(4, user.getUserEmail());
-
- preparedStatement.executeUpdate();
-
- connection.commit();
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error persisting community user.");
- stringBuilder.append("gateway - ").append(user.getGatewayName());
- stringBuilder.append("community user name - ").append(user.getUserName());
- stringBuilder.append("community user email - ").append(user.getUserEmail());
- stringBuilder.append("token id - ").append(token);
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
-
- DBUtil.cleanup(preparedStatement);
- }
- }
-
- public void deleteCommunityUser(CommunityUser user, Connection connection) throws CredentialStoreException {
-
- String sql = "DELETE FROM COMMUNITY_USER WHERE GATEWAY_ID=? AND COMMUNITY_USER_NAME=?";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, user.getGatewayName());
- preparedStatement.setString(2, user.getUserName());
-
- preparedStatement.executeUpdate();
-
- connection.commit();
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error deleting community user.");
- stringBuilder.append("gateway - ").append(user.getGatewayName());
- stringBuilder.append("community user name - ").append(user.getUserName());
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement);
- }
- }
-
- public void deleteCommunityUserByToken(CommunityUser user, String token, Connection connection)
- throws CredentialStoreException {
-
- String sql = "DELETE FROM COMMUNITY_USER WHERE GATEWAY_ID=? AND COMMUNITY_USER_NAME=? AND TOKEN_ID=?";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, user.getGatewayName());
- preparedStatement.setString(2, user.getUserName());
- preparedStatement.setString(3, token);
-
- preparedStatement.executeUpdate();
-
- connection.commit();
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error deleting community user.");
- stringBuilder.append("gateway - ").append(user.getGatewayName());
- stringBuilder.append("community user name - ").append(user.getUserName());
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement);
- }
- }
-
- public void updateCommunityUser(CommunityUser user) throws CredentialStoreException {
-
- // TODO
- }
-
- public CommunityUser getCommunityUser(String gatewayName, String communityUserName, Connection connection)
- throws CredentialStoreException {
-
- String sql = "SELECT * FROM COMMUNITY_USER WHERE GATEWAY_ID=? AND COMMUNITY_USER_NAME=?";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, gatewayName);
- preparedStatement.setString(2, communityUserName);
-
- ResultSet resultSet = preparedStatement.executeQuery();
-
- if (resultSet.next()) {
- String email = resultSet.getString("COMMUNITY_USER_EMAIL"); // TODO fix typo
-
- return new CommunityUser(gatewayName, communityUserName, email);
- }
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error retrieving community user.");
- stringBuilder.append("gateway - ").append(gatewayName);
- stringBuilder.append("community user name - ").append(communityUserName);
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement);
- }
-
- return null;
- }
-
- public CommunityUser getCommunityUserByToken(String gatewayName, String tokenId, Connection connection)
- throws CredentialStoreException {
-
- String sql = "SELECT * FROM COMMUNITY_USER WHERE GATEWAY_ID=? AND TOKEN_ID=?";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, gatewayName);
- preparedStatement.setString(2, tokenId);
-
- ResultSet resultSet = preparedStatement.executeQuery();
-
- if (resultSet.next()) {
- String communityUserName = resultSet.getString("COMMUNITY_USER_NAME");
- String email = resultSet.getString("COMMUNITY_USER_EMAIL"); // TODO fix typo
-
- return new CommunityUser(gatewayName, communityUserName, email);
- }
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error retrieving community user.");
- stringBuilder.append("gateway - ").append(gatewayName);
- stringBuilder.append("token- ").append(tokenId);
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement);
- }
-
- return null;
- }
-
- public List<CommunityUser> getCommunityUsers(String gatewayName, Connection connection)
- throws CredentialStoreException {
-
- List<CommunityUser> userList = new ArrayList<CommunityUser>();
-
- String sql = "SELECT * FROM COMMUNITY_USER WHERE GATEWAY_ID=?";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, gatewayName);
-
- ResultSet resultSet = preparedStatement.executeQuery();
-
- while (resultSet.next()) {
- String userName = resultSet.getString("COMMUNITY_USER_NAME");
- String email = resultSet.getString("COMMUNITY_USER_EMAIL"); // TODO fix typo
-
- userList.add(new CommunityUser(gatewayName, userName, email));
- }
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error retrieving community users for ");
- stringBuilder.append("gateway - ").append(gatewayName);
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement);
- }
-
- return userList;
- }
-}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/CredentialsDAO.java b/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/CredentialsDAO.java
deleted file mode 100644
index 33e6ed3ed2..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/CredentialsDAO.java
+++ /dev/null
@@ -1,495 +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.credential.store.impl.db;
-
-import java.io.*;
-import java.security.GeneralSecurityException;
-import java.sql.*;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.KeyStorePasswordCallback;
-import org.apache.airavata.common.utils.SecurityUtil;
-import org.apache.airavata.credential.Credential;
-import org.apache.airavata.credential.CredentialOwnerType;
-import org.apache.airavata.credential.store.CredentialStoreException;
-
-/**
- * Data access class for credential store.
- */
-public class CredentialsDAO extends ParentDAO {
-
- private String keyStorePath = null;
- private String secretKeyAlias = null;
- private KeyStorePasswordCallback keyStorePasswordCallback = null;
-
- public CredentialsDAO() {}
-
- public CredentialsDAO(String keyStore, String alias, KeyStorePasswordCallback passwordCallback) {
- this.keyStorePath = keyStore;
- this.secretKeyAlias = alias;
- this.keyStorePasswordCallback = passwordCallback;
- }
-
- public String getKeyStorePath() {
- return keyStorePath;
- }
-
- public void setKeyStorePath(String keyStorePath) {
- this.keyStorePath = keyStorePath;
- }
-
- public String getSecretKeyAlias() {
- return secretKeyAlias;
- }
-
- public void setSecretKeyAlias(String secretKeyAlias) {
- this.secretKeyAlias = secretKeyAlias;
- }
-
- public KeyStorePasswordCallback getKeyStorePasswordCallback() {
- return keyStorePasswordCallback;
- }
-
- public void setKeyStorePasswordCallback(KeyStorePasswordCallback keyStorePasswordCallback) {
- this.keyStorePasswordCallback = keyStorePasswordCallback;
- }
-
- /**
- * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + " GATEWAY_ID VARCHAR(256) NOT NULL,\n" +
- * " TOKEN_ID VARCHAR(256) NOT NULL,\n" + // Actual token used to identify the credential
- * " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n" +
- * " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n" + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n"
- * + ")";
- */
- public void addCredentials(String gatewayId, Credential credential, Connection connection)
- throws CredentialStoreException {
-
- String sql =
- "INSERT INTO CREDENTIALS (GATEWAY_ID, TOKEN_ID, CREDENTIAL, PORTAL_USER_ID, TIME_PERSISTED, DESCRIPTION, CREDENTIAL_OWNER_TYPE) VALUES (?, ?, ?, ?, ?, ?, ?)";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, gatewayId);
- preparedStatement.setString(2, credential.getToken());
-
- InputStream isCert = new ByteArrayInputStream(convertObjectToByteArray(credential));
- preparedStatement.setBinaryStream(3, isCert);
-
- preparedStatement.setString(4, credential.getPortalUserName());
-
- Timestamp timestamp = new Timestamp(System.currentTimeMillis());
-
- preparedStatement.setTimestamp(5, timestamp);
-
- preparedStatement.setString(6, credential.getDescription());
-
- preparedStatement.setString(7, credential.getCredentialOwnerType().toString());
-
- preparedStatement.executeUpdate();
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error persisting credentials.");
- stringBuilder.append(" gateway - ").append(gatewayId);
- stringBuilder.append(" token id - ").append(credential.getToken());
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
-
- DBUtil.cleanup(preparedStatement);
- }
- }
-
- public void deleteCredentials(String gatewayName, String tokenId, Connection connection)
- throws CredentialStoreException {
-
- String sql = "DELETE FROM CREDENTIALS WHERE GATEWAY_ID=? AND TOKEN_ID=?";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, gatewayName);
- preparedStatement.setString(2, tokenId);
-
- preparedStatement.executeUpdate();
- connection.commit();
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error deleting credentials for .");
- stringBuilder.append("gateway - ").append(gatewayName);
- stringBuilder.append("token id - ").append(tokenId);
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement);
- }
- }
-
- /**
- * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + " GATEWAY_ID VARCHAR(256) NOT NULL,\n" +
- * " TOKEN_ID VARCHAR(256) NOT NULL,\n" + // Actual token used to identify the credential
- * " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n" +
- * " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n" + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n"
- * + ")";
- */
- public void updateCredentials(String gatewayId, Credential credential, Connection connection)
- throws CredentialStoreException {
-
- String sql =
- "UPDATE CREDENTIALS set CREDENTIAL = ?, PORTAL_USER_ID = ?, TIME_PERSISTED = ?, DESCRIPTION = ?, CREDENTIAL_OWNER_TYPE = ? where GATEWAY_ID = ? and TOKEN_ID = ?";
-
- PreparedStatement preparedStatement = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- InputStream isCert = new ByteArrayInputStream(convertObjectToByteArray(credential));
- preparedStatement.setBinaryStream(1, isCert);
-
- preparedStatement.setString(2, credential.getPortalUserName());
-
- preparedStatement.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
- preparedStatement.setString(4, credential.getDescription());
- preparedStatement.setString(5, credential.getCredentialOwnerType().toString());
- preparedStatement.setString(6, gatewayId);
- preparedStatement.setString(7, credential.getToken());
-
- preparedStatement.executeUpdate();
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error updating credentials.");
- stringBuilder.append(" gateway - ").append(gatewayId);
- stringBuilder.append(" token id - ").append(credential.getToken());
-
- log.error(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
-
- DBUtil.cleanup(preparedStatement);
- }
- }
-
- /**
- * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + " GATEWAY_ID VARCHAR(256) NOT NULL,\n" +
- * " TOKEN_ID VARCHAR(256) NOT NULL,\n" + // Actual token used to identify the credential
- * " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n" +
- * " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n" + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n"
- * + ")";
- */
- public Credential getCredential(String gatewayName, String tokenId, Connection connection)
- throws CredentialStoreException {
-
- String sql = "SELECT * FROM CREDENTIALS WHERE GATEWAY_ID=? AND TOKEN_ID=?";
-
- PreparedStatement preparedStatement = null;
- ResultSet resultSet = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, gatewayName);
- preparedStatement.setString(2, tokenId);
-
- resultSet = preparedStatement.executeQuery();
-
- if (resultSet.next()) {
- // CertificateCredential certificateCredential = new CertificateCredential();
-
- Blob blobCredentials = resultSet.getBlob("CREDENTIAL");
- byte[] certificate = blobCredentials.getBytes(1, (int) blobCredentials.length());
-
- Credential certificateCredential = (Credential) convertByteArrayToObject(certificate);
-
- certificateCredential.setPortalUserName(resultSet.getString("PORTAL_USER_ID"));
- certificateCredential.setCertificateRequestedTime(resultSet.getTimestamp("TIME_PERSISTED"));
- certificateCredential.setDescription(resultSet.getString("DESCRIPTION"));
- certificateCredential.setCredentialOwnerType(
- CredentialOwnerType.valueOf(resultSet.getString("CREDENTIAL_OWNER_TYPE")));
-
- return certificateCredential;
- }
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error retrieving credentials for user.");
- stringBuilder.append("gateway - ").append(gatewayName);
- stringBuilder.append("token id - ").append(tokenId);
-
- log.debug(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement, resultSet);
- }
-
- return null;
- }
- /**
- *
- */
- public String getGatewayID(String tokenId, Connection connection) throws CredentialStoreException {
-
- String sql = "SELECT GATEWAY_ID FROM CREDENTIALS WHERE TOKEN_ID=?";
-
- PreparedStatement preparedStatement = null;
- ResultSet resultSet = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- preparedStatement.setString(1, tokenId);
-
- resultSet = preparedStatement.executeQuery();
-
- if (resultSet.next()) {
- return resultSet.getString("GATEWAY_ID");
- }
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error retrieving credentials for user.");
- stringBuilder.append("token id - ").append(tokenId);
-
- log.debug(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement, resultSet);
- }
-
- return null;
- }
- /**
- * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + " GATEWAY_ID VARCHAR(256) NOT NULL,\n" +
- * " TOKEN_ID VARCHAR(256) NOT NULL,\n" + // Actual token used to identify the credential
- * " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n" +
- * " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n" + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n"
- * + ")";
- */
- public List<Credential> getCredentials(String gatewayName, Connection connection) throws CredentialStoreException {
-
- return getCredentialsInternal(gatewayName, null, connection);
- }
-
- public List<Credential> getCredentials(String gatewayId, List<String> accessibleTokenIds, Connection connection)
- throws CredentialStoreException {
-
- if (accessibleTokenIds == null || accessibleTokenIds.isEmpty()) {
- return Collections.emptyList();
- }
- return getCredentialsInternal(gatewayId, accessibleTokenIds, connection);
- }
-
- private List<Credential> getCredentialsInternal(
- String gatewayId, List<String> accessibleTokenIds, Connection connection) throws CredentialStoreException {
- List<Credential> credentialList = new ArrayList<>();
-
- String sql = "SELECT * FROM CREDENTIALS WHERE GATEWAY_ID=?";
- if (accessibleTokenIds != null && !accessibleTokenIds.isEmpty()) {
- String tokenIdBindParameters = String.join(
- ", ", accessibleTokenIds.stream().map(tokenId -> "?").collect(Collectors.toList()));
- sql += " AND TOKEN_ID IN (" + tokenIdBindParameters + ")";
- }
-
- PreparedStatement preparedStatement = null;
- ResultSet resultSet = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- int parameterIndex = 1;
- preparedStatement.setString(parameterIndex++, gatewayId);
- if (accessibleTokenIds != null) {
- for (String tokenId : accessibleTokenIds) {
-
- preparedStatement.setString(parameterIndex++, tokenId);
- }
- }
-
- resultSet = preparedStatement.executeQuery();
-
- Credential certificateCredential;
-
- while (resultSet.next()) {
-
- Blob blobCredentials = resultSet.getBlob("CREDENTIAL");
- byte[] certificate = blobCredentials.getBytes(1, (int) blobCredentials.length());
-
- certificateCredential = (Credential) convertByteArrayToObject(certificate);
- certificateCredential.setToken(resultSet.getString("TOKEN_ID"));
- certificateCredential.setPortalUserName(resultSet.getString("PORTAL_USER_ID"));
- certificateCredential.setCertificateRequestedTime(resultSet.getTimestamp("TIME_PERSISTED"));
- certificateCredential.setDescription(resultSet.getString("DESCRIPTION"));
-
- credentialList.add(certificateCredential);
- }
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error retrieving credential list for ");
- stringBuilder.append("gateway - ").append(gatewayId);
-
- log.debug(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement, resultSet);
- }
-
- return credentialList;
- }
-
- /**
- * Gets all credentials.
- * @param connection The database connection
- * @return All credentials as a list
- * @throws CredentialStoreException If an error occurred while rerieving credentials.
- */
- public List<Credential> getCredentials(Connection connection) throws CredentialStoreException {
-
- List<Credential> credentialList = new ArrayList<Credential>();
-
- String sql = "SELECT * FROM CREDENTIALS";
-
- PreparedStatement preparedStatement = null;
- ResultSet resultSet = null;
-
- try {
- preparedStatement = connection.prepareStatement(sql);
-
- resultSet = preparedStatement.executeQuery();
-
- Credential certificateCredential;
-
- while (resultSet.next()) {
-
- Blob blobCredentials = resultSet.getBlob("CREDENTIAL");
- byte[] certificate = blobCredentials.getBytes(1, (int) blobCredentials.length());
-
- certificateCredential = (Credential) convertByteArrayToObject(certificate);
- certificateCredential.setToken(resultSet.getString("TOKEN_ID"));
- certificateCredential.setPortalUserName(resultSet.getString("PORTAL_USER_ID"));
- certificateCredential.setCertificateRequestedTime(resultSet.getTimestamp("TIME_PERSISTED"));
- certificateCredential.setDescription(resultSet.getString("DESCRIPTION"));
- certificateCredential.setCredentialOwnerType(
- CredentialOwnerType.valueOf(resultSet.getString("CREDENTIAL_OWNER_TYPE")));
-
- credentialList.add(certificateCredential);
- }
-
- } catch (SQLException e) {
- StringBuilder stringBuilder = new StringBuilder("Error retrieving all credentials");
-
- log.debug(stringBuilder.toString(), e);
-
- throw new CredentialStoreException(stringBuilder.toString(), e);
- } finally {
- DBUtil.cleanup(preparedStatement, resultSet);
- }
-
- return credentialList;
- }
-
- public Object convertByteArrayToObject(byte[] data) throws CredentialStoreException {
- ObjectInputStream objectInputStream = null;
- Object o = null;
- try {
- try {
- // decrypt the data first
- if (encrypt()) {
- data = SecurityUtil.decrypt(
- this.keyStorePath, this.secretKeyAlias, this.keyStorePasswordCallback, data);
- }
-
- objectInputStream = new ObjectInputStream(new ByteArrayInputStream(data));
- o = objectInputStream.readObject();
-
- } catch (IOException e) {
- throw new CredentialStoreException("Error de-serializing object.", e);
- } catch (ClassNotFoundException e) {
- throw new CredentialStoreException("Error de-serializing object.", e);
- } catch (GeneralSecurityException e) {
- throw new CredentialStoreException("Error decrypting data.", e);
- }
- } finally {
- if (objectInputStream != null) {
- try {
- objectInputStream.close();
- } catch (IOException e) {
- log.error("Error occurred while closing the stream", e);
- }
- }
- }
- return o;
- }
-
- public byte[] convertObjectToByteArray(Serializable o) throws CredentialStoreException {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-
- ObjectOutputStream objectOutputStream = null;
- try {
- objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
- objectOutputStream.writeObject(o);
- objectOutputStream.flush();
- } catch (IOException e) {
- throw new CredentialStoreException("Error serializing object.", e);
- } finally {
- if (objectOutputStream != null) {
- try {
- objectOutputStream.close();
- } catch (IOException e) {
- log.error("Error occurred while closing object output stream", e);
- }
- }
- }
-
- // encrypt the byte array
- if (encrypt()) {
- byte[] array = byteArrayOutputStream.toByteArray();
- try {
- return SecurityUtil.encrypt(
- this.keyStorePath, this.secretKeyAlias, this.keyStorePasswordCallback, array);
- } catch (GeneralSecurityException e) {
- throw new CredentialStoreException("Error encrypting data", e);
- } catch (IOException e) {
- throw new CredentialStoreException("Error encrypting data. IO exception.", e);
- }
- } else {
- return byteArrayOutputStream.toByteArray();
- }
- }
-
- /**
- * Says whether to encrypt data or not. if alias, keystore is set
- * we treat encryption true.
- * @return true if data should encrypt else false.
- */
- private boolean encrypt() {
- return this.keyStorePath != null;
- }
-}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/ParentDAO.java b/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/ParentDAO.java
deleted file mode 100644
index 56f68ad694..0000000000
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/db/ParentDAO.java
+++ /dev/null
@@ -1,32 +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.credential.store.impl.db;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Super class to abstract out Data access classes.
- */
-public class ParentDAO {
- protected static Logger log = LoggerFactory.getLogger(ParentDAO.class);
-
- public ParentDAO() {}
-}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/util/ConfigurationReader.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/ConfigurationReader.java
similarity index 96%
rename from airavata-api/src/main/java/org/apache/airavata/credential/util/ConfigurationReader.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/ConfigurationReader.java
index 363e7f74d1..af26388b8b 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/util/ConfigurationReader.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/ConfigurationReader.java
@@ -17,14 +17,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.util;
+package org.apache.airavata.credential.utils;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.airavata.credential.store.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialReader.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialReader.java
similarity index 97%
rename from airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialReader.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialReader.java
index fa244470fe..537e115d25 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialReader.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialReader.java
@@ -17,11 +17,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.store;
+package org.apache.airavata.credential.utils;
import java.util.List;
import org.apache.airavata.credential.AuditInfo;
import org.apache.airavata.credential.Credential;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
/**
* This interface provides an API for Credential Store. Provides methods to manipulate credential store data.
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialReaderFactory.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialReaderFactory.java
similarity index 60%
rename from airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialReaderFactory.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialReaderFactory.java
index 7b3d7127b0..7c2831b9a0 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialReaderFactory.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialReaderFactory.java
@@ -17,37 +17,62 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.store;
+package org.apache.airavata.credential.utils;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.credential.store.impl.CredentialReaderImpl;
+import org.apache.airavata.credential.impl.store.CredentialReaderImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
/**
* Factory class to create credential store readers.
+ * @deprecated Use Spring dependency injection instead. This factory is kept for backward compatibility.
*/
+@Component
+@Deprecated
public class CredentialReaderFactory {
+ private static ApplicationContext applicationContext;
+
+ @Autowired
+ public void setApplicationContext(ApplicationContext applicationContext) {
+ CredentialReaderFactory.applicationContext = applicationContext;
+ }
+
/**
* Creates a credential reader using supplied database configurations.
+ * @deprecated Use Spring dependency injection instead.
* @param dbUti The database configurations.
* @return CredentialReader object.
*/
+ @Deprecated
public static CredentialReader createCredentialStoreReader(DBUtil dbUti) throws ApplicationSettingsException {
- return new CredentialReaderImpl(dbUti);
+ if (applicationContext != null) {
+ return applicationContext.getBean(CredentialReaderImpl.class);
+ }
+ throw new IllegalStateException(
+ "CredentialReaderFactory not initialized. Use Spring dependency injection instead.");
}
/**
* Creates credential reader using default configurations for credential store database.
+ * @deprecated Use Spring dependency injection instead.
* @return The credential reader.
* @throws ClassNotFoundException If an error occurred while instantiating jdbc driver
* @throws ApplicationSettingsException If an error occurred while reading database configurations.
* @throws InstantiationException If an error occurred while instantiating jdbc driver
* @throws IllegalAccessException A security exception accessing jdbc driver.
*/
+ @Deprecated
public static CredentialReader createCredentialStoreReader()
throws ClassNotFoundException, ApplicationSettingsException, InstantiationException,
IllegalAccessException {
- return new CredentialReaderImpl(DBUtil.getCredentialStoreDBUtil());
+ if (applicationContext != null) {
+ return applicationContext.getBean(CredentialReaderImpl.class);
+ }
+ throw new IllegalStateException(
+ "CredentialReaderFactory not initialized. Use Spring dependency injection instead.");
}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/util/CredentialStoreConstants.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreConstants.java
similarity index 96%
rename from airavata-api/src/main/java/org/apache/airavata/credential/util/CredentialStoreConstants.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreConstants.java
index 60ed8f9ec4..e392cda65e 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/util/CredentialStoreConstants.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreConstants.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.util;
+package org.apache.airavata.credential.utils;
/**
* User: AmilaJ (amilaj@apache.org)
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/util/CredentialStoreDBInitConfig.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreDBInitConfig.java
similarity index 97%
rename from airavata-api/src/main/java/org/apache/airavata/credential/store/impl/util/CredentialStoreDBInitConfig.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreDBInitConfig.java
index e96d467c4e..4bbabb851b 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/impl/util/CredentialStoreDBInitConfig.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreDBInitConfig.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.store.impl.util;
+package org.apache.airavata.credential.utils;
import org.apache.airavata.common.utils.DBInitConfig;
import org.apache.airavata.config.AiravataServerProperties;
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreNotifier.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreNotifier.java
new file mode 100644
index 0000000000..ce0395c430
--- /dev/null
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialStoreNotifier.java
@@ -0,0 +1,59 @@
+/**
+*
+* 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.credential.utils; /*
+ *
+ * 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.
+ *
+ */
+
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
+
+/**
+ * This class is used to notify particular entity with expiring credentials.
+ * The default implementation uses email messages.
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 12/3/13
+ * Time: 4:17 PM
+ */
+public interface CredentialStoreNotifier {
+
+ /**
+ * The specific notifier implementation needs to implement following method.
+ * This method should actually deliver message to desired entity.
+ * @param message The actual message encapsulated
+ * @throws CredentialStoreException
+ */
+ void notifyMessage(NotificationMessage message) throws CredentialStoreException;
+}
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialWriter.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialWriter.java
similarity index 90%
rename from airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialWriter.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialWriter.java
index e0a2d15384..7334c242fc 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/store/CredentialWriter.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/CredentialWriter.java
@@ -17,9 +17,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.store;
+package org.apache.airavata.credential.utils;
import org.apache.airavata.credential.Credential;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
/**
* The entity who's writing credentials to DB will use this interface.
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/NotificationMessage.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/NotificationMessage.java
similarity index 96%
rename from airavata-api/src/main/java/org/apache/airavata/credential/notifier/NotificationMessage.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/NotificationMessage.java
index 153b1a87b8..ab65f5d8c1 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/NotificationMessage.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/NotificationMessage.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.notifier;
+package org.apache.airavata.credential.utils;
/**
* User: AmilaJ (amilaj@apache.org)
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/NotifierBootstrap.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/NotifierBootstrap.java
similarity index 81%
rename from airavata-api/src/main/java/org/apache/airavata/credential/notifier/NotifierBootstrap.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/NotifierBootstrap.java
index e2250060ab..fc20352eef 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/notifier/NotifierBootstrap.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/NotifierBootstrap.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.notifier;
+package org.apache.airavata.credential.utils;
/**
* User: AmilaJ (amilaj@apache.org)
@@ -27,18 +27,13 @@ package org.apache.airavata.credential.notifier;
import java.text.ParseException;
import java.util.*;
import java.util.Calendar;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.DBUtil;
import org.apache.airavata.credential.CommunityUser;
import org.apache.airavata.credential.Credential;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.airavata.credential.impl.certificate.CertificateCredential;
-import org.apache.airavata.credential.notifier.impl.EmailNotificationMessage;
-import org.apache.airavata.credential.notifier.impl.EmailNotifier;
-import org.apache.airavata.credential.notifier.impl.EmailNotifierConfiguration;
-import org.apache.airavata.credential.store.CredentialReader;
-import org.apache.airavata.credential.store.CredentialStoreException;
-import org.apache.airavata.credential.store.impl.CredentialReaderImpl;
-import org.apache.airavata.credential.util.Utility;
+import org.apache.airavata.credential.impl.notifier.EmailNotificationMessage;
+import org.apache.airavata.credential.impl.notifier.EmailNotifier;
+import org.apache.airavata.credential.impl.notifier.EmailNotifierConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,7 +48,7 @@ public class NotifierBootstrap extends TimerTask {
private static String MESSAGE = "Credentials for community user {0} expires at {1}";
private static String SUBJECT = "Expiring credentials for user {0}";
- private DBUtil dbUtil;
+ private CredentialReader credentialReader;
private long period;
@@ -61,7 +56,7 @@ public class NotifierBootstrap extends TimerTask {
private CredentialStoreNotifier credentialStoreNotifier;
- public NotifierBootstrap(long period, DBUtil db, EmailNotifierConfiguration configuration) {
+ public NotifierBootstrap(long period, CredentialReader credentialReader, EmailNotifierConfiguration configuration) {
this.period = period;
// bootstrap
@@ -70,7 +65,7 @@ public class NotifierBootstrap extends TimerTask {
timer.scheduleAtFixedRate(this, 0, period);
}
- this.dbUtil = db;
+ this.credentialReader = credentialReader;
this.credentialStoreNotifier = new EmailNotifier(configuration);
}
@@ -98,7 +93,6 @@ public class NotifierBootstrap extends TimerTask {
// retrieve OA4MP credentials
try {
- CredentialReader credentialReader = new CredentialReaderImpl(this.dbUtil);
List<Credential> credentials = credentialReader.getAllCredentials();
for (Credential credential : credentials) {
@@ -126,8 +120,6 @@ public class NotifierBootstrap extends TimerTask {
}
}
- } catch (ApplicationSettingsException e) {
- log.error("Error configuring email senders.", e);
} catch (CredentialStoreException e) {
log.error("Error sending emails about credential expiring.", e);
} catch (ParseException e) {
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/util/PrivateKeyStore.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/PrivateKeyStore.java
similarity index 97%
rename from airavata-api/src/main/java/org/apache/airavata/credential/util/PrivateKeyStore.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/PrivateKeyStore.java
index e2ceba7567..fcfef96e9f 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/util/PrivateKeyStore.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/PrivateKeyStore.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.util;
+package org.apache.airavata.credential.utils;
import java.security.PrivateKey;
import java.util.HashMap;
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/util/TokenGenerator.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/TokenGenerator.java
similarity index 96%
rename from airavata-api/src/main/java/org/apache/airavata/credential/util/TokenGenerator.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/TokenGenerator.java
index f4ad2746e9..d693a62d8c 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/util/TokenGenerator.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/TokenGenerator.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.util;
+package org.apache.airavata.credential.utils;
/**
* User: AmilaJ (amilaj@apache.org)
diff --git a/airavata-api/src/main/java/org/apache/airavata/credential/util/Utility.java b/airavata-api/src/main/java/org/apache/airavata/credential/utils/Utility.java
similarity index 98%
rename from airavata-api/src/main/java/org/apache/airavata/credential/util/Utility.java
rename to airavata-api/src/main/java/org/apache/airavata/credential/utils/Utility.java
index 1ff7982282..b964c81d52 100644
--- a/airavata-api/src/main/java/org/apache/airavata/credential/util/Utility.java
+++ b/airavata-api/src/main/java/org/apache/airavata/credential/utils/Utility.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.util;
+package org.apache.airavata.credential.utils;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.KeyPair;
diff --git a/airavata-api/src/main/java/org/apache/airavata/messaging/client/RabbitMQListener.java b/airavata-api/src/main/java/org/apache/airavata/messaging/client/RabbitMQListener.java
index 4007540400..fbf625b718 100644
--- a/airavata-api/src/main/java/org/apache/airavata/messaging/client/RabbitMQListener.java
+++ b/airavata-api/src/main/java/org/apache/airavata/messaging/client/RabbitMQListener.java
@@ -88,10 +88,13 @@ public class RabbitMQListener {
}
}
+ // Unused enum - commented out
+ /*
private enum LEVEL {
ALL,
GATEWAY,
EXPERIMENT,
JOB;
}
+ */
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/monitor/cluster/ClusterStatusMonitorJob.java b/airavata-api/src/main/java/org/apache/airavata/monitor/cluster/ClusterStatusMonitorJob.java
index d20e7f187d..fa61ecd0c2 100644
--- a/airavata-api/src/main/java/org/apache/airavata/monitor/cluster/ClusterStatusMonitorJob.java
+++ b/airavata-api/src/main/java/org/apache/airavata/monitor/cluster/ClusterStatusMonitorJob.java
@@ -249,48 +249,66 @@ public class ClusterStatusMonitorJob implements Job {
return hostName;
}
+ // Unused setter methods - commented out
+ /*
public void setHostName(String hostName) {
this.hostName = hostName;
}
+ */
public String getUserName() {
return userName;
}
+ // Unused setter method - commented out
+ /*
public void setUserName(String userName) {
this.userName = userName;
}
+ */
public int getPort() {
return port;
}
+ // Unused setter method - commented out
+ /*
public void setPort(int port) {
this.port = port;
}
+ */
public String getCredentialStoreToken() {
return credentialStoreToken;
}
+ // Unused setter method - commented out
+ /*
public void setCredentialStoreToken(String credentialStoreToken) {
this.credentialStoreToken = credentialStoreToken;
}
+ */
public List<String> getQueueNames() {
return queueNames;
}
+ // Unused setter method - commented out
+ /*
public void setQueueNames(List<String> queueNames) {
this.queueNames = queueNames;
}
+ */
public String getResourceManagerType() {
return resourceManagerType;
}
+ // Unused setter method - commented out
+ /*
public void setResourceManagerType(String resourceManagerType) {
this.resourceManagerType = resourceManagerType;
}
+ */
}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/GFACPassiveJobSubmitter.java b/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/GFACPassiveJobSubmitter.java
index e6a7e4d005..a607ddcea3 100644
--- a/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/GFACPassiveJobSubmitter.java
+++ b/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/GFACPassiveJobSubmitter.java
@@ -23,7 +23,7 @@ import java.util.UUID;
import org.apache.airavata.common.exception.AiravataException;
import org.apache.airavata.common.utils.AiravataUtils;
import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.credential.store.CredentialReader;
+import org.apache.airavata.credential.utils.CredentialReader;
import org.apache.airavata.messaging.core.MessageContext;
import org.apache.airavata.messaging.core.MessagingFactory;
import org.apache.airavata.messaging.core.Publisher;
diff --git a/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/JobSubmitter.java b/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/JobSubmitter.java
index caf72928ae..cc2fd4ca87 100644
--- a/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/JobSubmitter.java
+++ b/airavata-api/src/main/java/org/apache/airavata/orchestrator/job/JobSubmitter.java
@@ -26,7 +26,7 @@ import org.apache.airavata.orchestrator.exception.OrchestratorException;
* This is the submitter interface, orchestrator can
* submit jobs to gfac in different modes, gfac running embedded
* or gfac running in server mode. This can be configured in
- * airavata-server.properties
+ * airavata.properties
* todo provide a way to configure this in a dynamic way
*/
public interface JobSubmitter {
diff --git a/airavata-api/src/main/java/org/apache/airavata/orchestrator/utils/OrchestratorUtils.java b/airavata-api/src/main/java/org/apache/airavata/orchestrator/utils/OrchestratorUtils.java
index 4209d2ad2a..5405016582 100644
--- a/airavata-api/src/main/java/org/apache/airavata/orchestrator/utils/OrchestratorUtils.java
+++ b/airavata-api/src/main/java/org/apache/airavata/orchestrator/utils/OrchestratorUtils.java
@@ -26,10 +26,9 @@ import java.util.Comparator;
import java.util.List;
import org.apache.airavata.common.exception.AiravataException;
import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.DBUtil;
import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.credential.store.CredentialReader;
-import org.apache.airavata.credential.store.impl.CredentialReaderImpl;
+import org.apache.airavata.credential.impl.store.CredentialReaderImpl;
+import org.apache.airavata.credential.utils.CredentialReader;
import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
import org.apache.airavata.model.appcatalog.computeresource.CloudJobSubmission;
import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
@@ -355,7 +354,7 @@ public class OrchestratorUtils {
String jdbcUsr = ServerSettings.getCredentialStoreDBUser();
String jdbcPass = ServerSettings.getCredentialStoreDBPassword();
String driver = ServerSettings.getCredentialStoreDBDriver();
- return new CredentialReaderImpl(new DBUtil(jdbcUrl, jdbcUsr, jdbcPass, driver));
+ return new CredentialReaderImpl();
} catch (ApplicationSettingsException e) {
logger.error("Error while getting credential reader", e);
return null;
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ApplicationDeploymentService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ApplicationDeploymentService.java
index b841edfa2e..d65a1222d8 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ApplicationDeploymentService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ApplicationDeploymentService.java
@@ -33,7 +33,6 @@ import org.apache.airavata.registry.cpi.ApplicationDeployment;
import org.apache.airavata.registry.entities.appcatalog.ApplicationDeploymentEntity;
import org.apache.airavata.registry.exceptions.AppCatalogException;
import org.apache.airavata.registry.repositories.appcatalog.ApplicationDeploymentRepository;
-import org.apache.airavata.registry.services.ComputeResourceService;
import org.apache.airavata.registry.utils.DBConstants;
import org.apache.airavata.registry.utils.ObjectMapperSingleton;
import org.slf4j.Logger;
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ComputeResourceService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ComputeResourceService.java
index 1879f047b9..5da7a79118 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ComputeResourceService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ComputeResourceService.java
@@ -205,7 +205,7 @@ public class ComputeResourceService {
}
}
- private Map<FileSystems, String> getFileSystems(String computeResourceId) {
+ public Map<FileSystems, String> getFileSystems(String computeResourceId) {
List<ComputeResourceFileSystemEntity> computeResourceFileSystemEntityList =
computeResourceFileSystemRepository.findByComputeResourceId(computeResourceId);
Map<FileSystems, String> fileSystemsMap = new HashMap<>();
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/DataProductService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/DataProductService.java
index e93c6b7c2b..ff26ecc337 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/DataProductService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/DataProductService.java
@@ -75,4 +75,19 @@ public class DataProductService {
DataProductEntity saved = dataProductRepository.save(entity);
return saved.getProductUri();
}
+
+ public boolean isDataProductExists(String productUri) throws ReplicaCatalogException {
+ return dataProductRepository.existsById(productUri);
+ }
+
+ public boolean updateDataProduct(DataProductModel dataProductModel) throws ReplicaCatalogException {
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ DataProductEntity entity = mapper.map(dataProductModel, DataProductEntity.class);
+ dataProductRepository.save(entity);
+ return true;
+ }
+
+ public void removeDataProduct(String productUri) throws ReplicaCatalogException {
+ dataProductRepository.deleteById(productUri);
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/DataReplicaLocationService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/DataReplicaLocationService.java
index 4b726251c9..9557b9590d 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/DataReplicaLocationService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/DataReplicaLocationService.java
@@ -20,6 +20,8 @@
package org.apache.airavata.registry.services;
import com.github.dozermapper.core.Mapper;
+import java.util.List;
+import java.util.stream.Collectors;
import org.apache.airavata.model.data.replica.DataReplicaLocationModel;
import org.apache.airavata.registry.entities.replicacatalog.DataReplicaLocationEntity;
import org.apache.airavata.registry.exceptions.ReplicaCatalogException;
@@ -42,4 +44,31 @@ public class DataReplicaLocationService {
DataReplicaLocationEntity saved = dataReplicaLocationRepository.save(entity);
return saved.getReplicaId();
}
+
+ public DataReplicaLocationModel getReplicaLocation(String replicaId) throws ReplicaCatalogException {
+ DataReplicaLocationEntity entity =
+ dataReplicaLocationRepository.findById(replicaId).orElse(null);
+ if (entity == null) return null;
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ return mapper.map(entity, DataReplicaLocationModel.class);
+ }
+
+ public List<DataReplicaLocationModel> getAllReplicaLocations(String productUri) throws ReplicaCatalogException {
+ List<DataReplicaLocationEntity> entities = dataReplicaLocationRepository.findByProductUri(productUri);
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ return entities.stream()
+ .map(e -> mapper.map(e, DataReplicaLocationModel.class))
+ .collect(Collectors.toList());
+ }
+
+ public boolean updateReplicaLocation(DataReplicaLocationModel replicaLocationModel) throws ReplicaCatalogException {
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ DataReplicaLocationEntity entity = mapper.map(replicaLocationModel, DataReplicaLocationEntity.class);
+ dataReplicaLocationRepository.save(entity);
+ return true;
+ }
+
+ public void removeReplicaLocation(String replicaId) throws ReplicaCatalogException {
+ dataReplicaLocationRepository.deleteById(replicaId);
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentErrorService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentErrorService.java
index 434e26fb84..4732b7d5c1 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentErrorService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentErrorService.java
@@ -20,6 +20,8 @@
package org.apache.airavata.registry.services;
import com.github.dozermapper.core.Mapper;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.airavata.model.commons.ErrorModel;
import org.apache.airavata.registry.entities.expcatalog.ExperimentErrorEntity;
import org.apache.airavata.registry.exceptions.RegistryException;
@@ -35,10 +37,26 @@ public class ExperimentErrorService {
@Autowired
private ExperimentErrorRepository experimentErrorRepository;
- public void addExperimentError(ErrorModel error, String experimentId) throws RegistryException {
+ public String addExperimentError(ErrorModel error, String experimentId) throws RegistryException {
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ ExperimentErrorEntity entity = mapper.map(error, ExperimentErrorEntity.class);
+ entity.setExperimentId(experimentId);
+ ExperimentErrorEntity saved = experimentErrorRepository.save(entity);
+ return saved.getErrorId();
+ }
+
+ public void updateExperimentError(ErrorModel error, String experimentId) throws RegistryException {
Mapper mapper = ObjectMapperSingleton.getInstance();
ExperimentErrorEntity entity = mapper.map(error, ExperimentErrorEntity.class);
entity.setExperimentId(experimentId);
experimentErrorRepository.save(entity);
}
+
+ public List<ErrorModel> getExperimentErrors(String experimentId) throws RegistryException {
+ List<ExperimentErrorEntity> entities = experimentErrorRepository.findByExperimentId(experimentId);
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ List<ErrorModel> result = new ArrayList<>();
+ entities.forEach(e -> result.add(mapper.map(e, ErrorModel.class)));
+ return result;
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentOutputService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentInputService.java
similarity index 55%
copy from airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentOutputService.java
copy to airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentInputService.java
index cae2f6f656..b01853fa0c 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentOutputService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentInputService.java
@@ -22,10 +22,10 @@ package org.apache.airavata.registry.services;
import com.github.dozermapper.core.Mapper;
import java.util.ArrayList;
import java.util.List;
-import org.apache.airavata.model.application.io.OutputDataObjectType;
-import org.apache.airavata.registry.entities.expcatalog.ExperimentOutputEntity;
+import org.apache.airavata.model.application.io.InputDataObjectType;
+import org.apache.airavata.registry.entities.expcatalog.ExperimentInputEntity;
import org.apache.airavata.registry.exceptions.RegistryException;
-import org.apache.airavata.registry.repositories.expcatalog.ExperimentOutputRepository;
+import org.apache.airavata.registry.repositories.expcatalog.ExperimentInputRepository;
import org.apache.airavata.registry.utils.ObjectMapperSingleton;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,24 +33,32 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
-public class ExperimentOutputService {
+public class ExperimentInputService {
@Autowired
- private ExperimentOutputRepository experimentOutputRepository;
+ private ExperimentInputRepository experimentInputRepository;
- public List<OutputDataObjectType> getExperimentOutputs(String experimentId) throws RegistryException {
- List<ExperimentOutputEntity> entities = experimentOutputRepository.findByExperimentId(experimentId);
+ public String addExperimentInputs(List<InputDataObjectType> inputs, String experimentId) throws RegistryException {
Mapper mapper = ObjectMapperSingleton.getInstance();
- List<OutputDataObjectType> result = new ArrayList<>();
- entities.forEach(e -> result.add(mapper.map(e, OutputDataObjectType.class)));
- return result;
+ for (InputDataObjectType input : inputs) {
+ ExperimentInputEntity entity = mapper.map(input, ExperimentInputEntity.class);
+ entity.setExperimentId(experimentId);
+ experimentInputRepository.save(entity);
+ }
+ return experimentId;
+ }
+
+ public void updateExperimentInputs(List<InputDataObjectType> inputs, String experimentId) throws RegistryException {
+ // Delete existing inputs and add new ones
+ List<ExperimentInputEntity> existing = experimentInputRepository.findByExperimentId(experimentId);
+ experimentInputRepository.deleteAll(existing);
+ addExperimentInputs(inputs, experimentId);
}
- public void addExperimentOutputs(List<OutputDataObjectType> outputs, String experimentId) throws RegistryException {
+ public List<InputDataObjectType> getExperimentInputs(String experimentId) throws RegistryException {
+ List<ExperimentInputEntity> entities = experimentInputRepository.findByExperimentId(experimentId);
Mapper mapper = ObjectMapperSingleton.getInstance();
- for (OutputDataObjectType output : outputs) {
- ExperimentOutputEntity entity = mapper.map(output, ExperimentOutputEntity.class);
- entity.setExperimentId(experimentId);
- experimentOutputRepository.save(entity);
- }
+ List<InputDataObjectType> result = new ArrayList<>();
+ entities.forEach(e -> result.add(mapper.map(e, InputDataObjectType.class)));
+ return result;
}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentOutputService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentOutputService.java
index cae2f6f656..c72889ce69 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentOutputService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentOutputService.java
@@ -53,4 +53,12 @@ public class ExperimentOutputService {
experimentOutputRepository.save(entity);
}
}
+
+ public void updateExperimentOutputs(List<OutputDataObjectType> outputs, String experimentId)
+ throws RegistryException {
+ // Delete existing outputs and add new ones
+ List<ExperimentOutputEntity> existing = experimentOutputRepository.findByExperimentId(experimentId);
+ experimentOutputRepository.deleteAll(existing);
+ addExperimentOutputs(outputs, experimentId);
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentStatusService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentStatusService.java
index e87d75f4cb..9e83f228fd 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentStatusService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ExperimentStatusService.java
@@ -26,6 +26,7 @@ import org.apache.airavata.model.status.ExperimentStatus;
import org.apache.airavata.registry.entities.expcatalog.ExperimentStatusEntity;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.expcatalog.ExperimentStatusRepository;
+import org.apache.airavata.registry.utils.ExpCatalogUtils;
import org.apache.airavata.registry.utils.ObjectMapperSingleton;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -37,6 +38,21 @@ public class ExperimentStatusService {
@Autowired
private ExperimentStatusRepository experimentStatusRepository;
+ public String addExperimentStatus(ExperimentStatus experimentStatus, String experimentId) throws RegistryException {
+ if (experimentStatus.getStatusId() == null) {
+ experimentStatus.setStatusId(ExpCatalogUtils.getID("EXPERIMENT_STATE"));
+ }
+ if (experimentStatus.getTimeOfStateChange() == 0) {
+ experimentStatus.setTimeOfStateChange(
+ AiravataUtils.getCurrentTimestamp().getTime());
+ }
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ ExperimentStatusEntity entity = mapper.map(experimentStatus, ExperimentStatusEntity.class);
+ entity.setExperimentId(experimentId);
+ ExperimentStatusEntity saved = experimentStatusRepository.save(entity);
+ return saved.getStatusId();
+ }
+
public ExperimentStatus getExperimentStatus(String experimentId) throws RegistryException {
List<ExperimentStatusEntity> entities =
experimentStatusRepository.findByExperimentIdOrderByTimeOfStateChangeDesc(experimentId);
@@ -45,8 +61,11 @@ public class ExperimentStatusService {
return mapper.map(entities.get(0), ExperimentStatus.class);
}
- public void updateExperimentStatus(ExperimentStatus experimentStatus, String experimentId)
+ public String updateExperimentStatus(ExperimentStatus experimentStatus, String experimentId)
throws RegistryException {
+ if (experimentStatus.getStatusId() == null) {
+ experimentStatus.setStatusId(ExpCatalogUtils.getID("EXPERIMENT_STATE"));
+ }
if (experimentStatus.getTimeOfStateChange() == 0) {
experimentStatus.setTimeOfStateChange(
AiravataUtils.getCurrentTimestamp().getTime());
@@ -54,6 +73,7 @@ public class ExperimentStatusService {
Mapper mapper = ObjectMapperSingleton.getInstance();
ExperimentStatusEntity entity = mapper.map(experimentStatus, ExperimentStatusEntity.class);
entity.setExperimentId(experimentId);
- experimentStatusRepository.save(entity);
+ ExperimentStatusEntity saved = experimentStatusRepository.save(entity);
+ return saved.getStatusId();
}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/GatewayGroupsService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/GatewayGroupsService.java
index 53d2dc11a4..49fa3bc495 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/GatewayGroupsService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/GatewayGroupsService.java
@@ -59,4 +59,8 @@ public class GatewayGroupsService {
GatewayGroupsEntity saved = gatewayGroupsRepository.save(entity);
return mapper.map(saved, GatewayGroups.class);
}
+
+ public void delete(String gatewayId) throws RegistryException {
+ gatewayGroupsRepository.deleteById(gatewayId);
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/NotificationService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/NotificationService.java
index 1f7d7da866..58ef0a7d40 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/NotificationService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/NotificationService.java
@@ -55,10 +55,11 @@ public class NotificationService {
return entities.stream().map(e -> mapper.map(e, Notification.class)).collect(Collectors.toList());
}
- public void createNotification(Notification notification) throws RegistryException {
+ public String createNotification(Notification notification) throws RegistryException {
Mapper mapper = ObjectMapperSingleton.getInstance();
NotificationEntity entity = mapper.map(notification, NotificationEntity.class);
- notificationRepository.save(entity);
+ NotificationEntity saved = notificationRepository.save(entity);
+ return saved.getNotificationId();
}
public void updateNotification(Notification notification) throws RegistryException {
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessErrorService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessErrorService.java
index 11145e51f6..528647f266 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessErrorService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessErrorService.java
@@ -20,6 +20,8 @@
package org.apache.airavata.registry.services;
import com.github.dozermapper.core.Mapper;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.airavata.model.commons.ErrorModel;
import org.apache.airavata.registry.entities.expcatalog.ProcessErrorEntity;
import org.apache.airavata.registry.exceptions.RegistryException;
@@ -35,10 +37,26 @@ public class ProcessErrorService {
@Autowired
private ProcessErrorRepository processErrorRepository;
- public void addProcessError(ErrorModel error, String processId) throws RegistryException {
+ public String addProcessError(ErrorModel error, String processId) throws RegistryException {
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ ProcessErrorEntity entity = mapper.map(error, ProcessErrorEntity.class);
+ entity.setProcessId(processId);
+ ProcessErrorEntity saved = processErrorRepository.save(entity);
+ return saved.getErrorId();
+ }
+
+ public void updateProcessError(ErrorModel error, String processId) throws RegistryException {
Mapper mapper = ObjectMapperSingleton.getInstance();
ProcessErrorEntity entity = mapper.map(error, ProcessErrorEntity.class);
entity.setProcessId(processId);
processErrorRepository.save(entity);
}
+
+ public List<ErrorModel> getProcessError(String processId) throws RegistryException {
+ List<ProcessErrorEntity> entities = processErrorRepository.findByProcessId(processId);
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ List<ErrorModel> result = new ArrayList<>();
+ entities.forEach(e -> result.add(mapper.map(e, ErrorModel.class)));
+ return result;
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessOutputService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessInputService.java
similarity index 56%
copy from airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessOutputService.java
copy to airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessInputService.java
index e066aa97e6..c92c097617 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessOutputService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessInputService.java
@@ -22,10 +22,10 @@ package org.apache.airavata.registry.services;
import com.github.dozermapper.core.Mapper;
import java.util.ArrayList;
import java.util.List;
-import org.apache.airavata.model.application.io.OutputDataObjectType;
-import org.apache.airavata.registry.entities.expcatalog.ProcessOutputEntity;
+import org.apache.airavata.model.application.io.InputDataObjectType;
+import org.apache.airavata.registry.entities.expcatalog.ProcessInputEntity;
import org.apache.airavata.registry.exceptions.RegistryException;
-import org.apache.airavata.registry.repositories.expcatalog.ProcessOutputRepository;
+import org.apache.airavata.registry.repositories.expcatalog.ProcessInputRepository;
import org.apache.airavata.registry.utils.ObjectMapperSingleton;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,24 +33,32 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
-public class ProcessOutputService {
+public class ProcessInputService {
@Autowired
- private ProcessOutputRepository processOutputRepository;
+ private ProcessInputRepository processInputRepository;
- public List<OutputDataObjectType> getProcessOutputs(String processId) throws RegistryException {
- List<ProcessOutputEntity> entities = processOutputRepository.findByProcessId(processId);
+ public String addProcessInputs(List<InputDataObjectType> inputs, String processId) throws RegistryException {
Mapper mapper = ObjectMapperSingleton.getInstance();
- List<OutputDataObjectType> result = new ArrayList<>();
- entities.forEach(e -> result.add(mapper.map(e, OutputDataObjectType.class)));
- return result;
+ for (InputDataObjectType input : inputs) {
+ ProcessInputEntity entity = mapper.map(input, ProcessInputEntity.class);
+ entity.setProcessId(processId);
+ processInputRepository.save(entity);
+ }
+ return processId;
+ }
+
+ public void updateProcessInputs(List<InputDataObjectType> inputs, String processId) throws RegistryException {
+ // Delete existing inputs and add new ones
+ List<ProcessInputEntity> existing = processInputRepository.findByProcessId(processId);
+ processInputRepository.deleteAll(existing);
+ addProcessInputs(inputs, processId);
}
- public void addProcessOutputs(List<OutputDataObjectType> outputs, String processId) throws RegistryException {
+ public List<InputDataObjectType> getProcessInputs(String processId) throws RegistryException {
+ List<ProcessInputEntity> entities = processInputRepository.findByProcessId(processId);
Mapper mapper = ObjectMapperSingleton.getInstance();
- for (OutputDataObjectType output : outputs) {
- ProcessOutputEntity entity = mapper.map(output, ProcessOutputEntity.class);
- entity.setProcessId(processId);
- processOutputRepository.save(entity);
- }
+ List<InputDataObjectType> result = new ArrayList<>();
+ entities.forEach(e -> result.add(mapper.map(e, InputDataObjectType.class)));
+ return result;
}
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessOutputService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessOutputService.java
index e066aa97e6..0b8814aa15 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessOutputService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/ProcessOutputService.java
@@ -53,4 +53,11 @@ public class ProcessOutputService {
processOutputRepository.save(entity);
}
}
+
+ public void updateProcessOutputs(List<OutputDataObjectType> outputs, String processId) throws RegistryException {
+ // Delete existing outputs and add new ones
+ List<ProcessOutputEntity> existing = processOutputRepository.findByProcessId(processId);
+ processOutputRepository.deleteAll(existing);
+ addProcessOutputs(outputs, processId);
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/QueueStatusService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/QueueStatusService.java
index 5c299becee..99435a4225 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/QueueStatusService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/QueueStatusService.java
@@ -49,12 +49,13 @@ public class QueueStatusService {
return result;
}
- public void createQueueStatuses(List<QueueStatusModel> queueStatuses) throws RegistryException {
+ public boolean createQueueStatuses(List<QueueStatusModel> queueStatuses) throws RegistryException {
Mapper mapper = ObjectMapperSingleton.getInstance();
for (QueueStatusModel status : queueStatuses) {
QueueStatusEntity entity = mapper.map(status, QueueStatusEntity.class);
queueStatusRepository.save(entity);
}
+ return true;
}
public QueueStatusModel getQueueStatus(String hostName, String queueName) throws RegistryException {
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/TaskErrorService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/TaskErrorService.java
index 080003db23..5475e3d363 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/TaskErrorService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/TaskErrorService.java
@@ -20,6 +20,8 @@
package org.apache.airavata.registry.services;
import com.github.dozermapper.core.Mapper;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.airavata.model.commons.ErrorModel;
import org.apache.airavata.registry.entities.expcatalog.TaskErrorEntity;
import org.apache.airavata.registry.exceptions.RegistryException;
@@ -35,10 +37,26 @@ public class TaskErrorService {
@Autowired
private TaskErrorRepository taskErrorRepository;
- public void addTaskError(ErrorModel error, String taskId) throws RegistryException {
+ public String addTaskError(ErrorModel error, String taskId) throws RegistryException {
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ TaskErrorEntity entity = mapper.map(error, TaskErrorEntity.class);
+ entity.setTaskId(taskId);
+ TaskErrorEntity saved = taskErrorRepository.save(entity);
+ return saved.getErrorId();
+ }
+
+ public void updateTaskError(ErrorModel error, String taskId) throws RegistryException {
Mapper mapper = ObjectMapperSingleton.getInstance();
TaskErrorEntity entity = mapper.map(error, TaskErrorEntity.class);
entity.setTaskId(taskId);
taskErrorRepository.save(entity);
}
+
+ public List<ErrorModel> getTaskError(String taskId) throws RegistryException {
+ List<TaskErrorEntity> entities = taskErrorRepository.findByTaskId(taskId);
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ List<ErrorModel> result = new ArrayList<>();
+ entities.forEach(e -> result.add(mapper.map(e, ErrorModel.class)));
+ return result;
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/TaskStatusService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/TaskStatusService.java
index c2a18da21e..53d166835d 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/TaskStatusService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/TaskStatusService.java
@@ -20,6 +20,7 @@
package org.apache.airavata.registry.services;
import com.github.dozermapper.core.Mapper;
+import java.util.List;
import org.apache.airavata.common.utils.AiravataUtils;
import org.apache.airavata.model.status.TaskStatus;
import org.apache.airavata.registry.entities.expcatalog.TaskStatusEntity;
@@ -47,4 +48,24 @@ public class TaskStatusService {
entity.setTaskId(taskId);
taskStatusRepository.save(entity);
}
+
+ public void updateTaskStatus(TaskStatus taskStatus, String taskId) throws RegistryException {
+ if (taskStatus.getStatusId() == null) {
+ taskStatus.setStatusId(ExpCatalogUtils.getID("TASK_STATE"));
+ }
+ if (taskStatus.getTimeOfStateChange() == 0) {
+ taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
+ }
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ TaskStatusEntity entity = mapper.map(taskStatus, TaskStatusEntity.class);
+ entity.setTaskId(taskId);
+ taskStatusRepository.save(entity);
+ }
+
+ public TaskStatus getTaskStatus(String taskId) throws RegistryException {
+ List<TaskStatusEntity> entities = taskStatusRepository.findByTaskIdOrderByTimeOfStateChangeDesc(taskId);
+ if (entities.isEmpty()) return null;
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ return mapper.map(entities.get(0), TaskStatus.class);
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/UserService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/UserService.java
index 181d60b088..f6d5e9951c 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/UserService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/UserService.java
@@ -56,4 +56,15 @@ public class UserService {
UserEntity saved = userRepository.save(entity);
return mapper.map(saved, UserProfile.class);
}
+
+ public UserProfile get(UserPK userPK) throws RegistryException {
+ UserEntity entity = userRepository.findById(userPK).orElse(null);
+ if (entity == null) return null;
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ return mapper.map(entity, UserProfile.class);
+ }
+
+ public void delete(UserPK userPK) throws RegistryException {
+ userRepository.deleteById(userPK);
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/registry/services/WorkflowService.java b/airavata-api/src/main/java/org/apache/airavata/registry/services/WorkflowService.java
index 6eab035345..a50586ff51 100644
--- a/airavata-api/src/main/java/org/apache/airavata/registry/services/WorkflowService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/registry/services/WorkflowService.java
@@ -20,6 +20,7 @@
package org.apache.airavata.registry.services;
import com.github.dozermapper.core.Mapper;
+import java.util.List;
import org.apache.airavata.model.workflow.AiravataWorkflow;
import org.apache.airavata.registry.entities.airavataworkflowcatalog.AiravataWorkflowEntity;
import org.apache.airavata.registry.exceptions.WorkflowCatalogException;
@@ -41,4 +42,17 @@ public class WorkflowService {
entity.setExperimentId(experimentId);
workflowRepository.save(entity);
}
+
+ public String getWorkflowId(String experimentId) throws WorkflowCatalogException {
+ List<AiravataWorkflowEntity> entities = workflowRepository.findByExperimentId(experimentId);
+ if (entities.isEmpty()) return null;
+ return entities.get(0).getId();
+ }
+
+ public AiravataWorkflow getWorkflow(String workflowId) throws WorkflowCatalogException {
+ AiravataWorkflowEntity entity = workflowRepository.findById(workflowId).orElse(null);
+ if (entity == null) return null;
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ return mapper.map(entity, AiravataWorkflow.class);
+ }
}
diff --git a/airavata-api/src/main/java/org/apache/airavata/security/GatewayGroupsInitializer.java b/airavata-api/src/main/java/org/apache/airavata/security/GatewayGroupsInitializer.java
index 7f7655f017..e6ded58955 100644
--- a/airavata-api/src/main/java/org/apache/airavata/security/GatewayGroupsInitializer.java
+++ b/airavata-api/src/main/java/org/apache/airavata/security/GatewayGroupsInitializer.java
@@ -20,7 +20,7 @@
package org.apache.airavata.security;
import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.credential.exception.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.airavata.model.appcatalog.gatewaygroups.GatewayGroups;
import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
import org.apache.airavata.model.credential.store.PasswordCredential;
diff --git a/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java b/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java
index 06ee06f015..5afa468ebb 100644
--- a/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java
@@ -42,7 +42,7 @@ import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.AiravataUtils;
import org.apache.airavata.common.utils.Constants;
import org.apache.airavata.config.AiravataServerProperties;
-import org.apache.airavata.credential.exception.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.airavata.helix.core.support.adaptor.AdaptorSupportImpl;
import org.apache.airavata.messaging.core.MessageContext;
import org.apache.airavata.messaging.core.MessagingFactory;
diff --git a/airavata-api/src/main/java/org/apache/airavata/service/CredentialStoreService.java b/airavata-api/src/main/java/org/apache/airavata/service/CredentialStoreService.java
index d43ef92f84..03430377ce 100644
--- a/airavata-api/src/main/java/org/apache/airavata/service/CredentialStoreService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/service/CredentialStoreService.java
@@ -23,23 +23,29 @@ import java.io.ByteArrayInputStream;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
import java.util.stream.Collectors;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.DBInitializer;
-import org.apache.airavata.common.utils.DBUtil;
import org.apache.airavata.config.AiravataServerProperties;
import org.apache.airavata.credential.CommunityUser;
import org.apache.airavata.credential.Credential;
import org.apache.airavata.credential.CredentialOwnerType;
-import org.apache.airavata.credential.exception.CredentialStoreException;
-import org.apache.airavata.credential.store.impl.CertificateCredentialWriter;
-import org.apache.airavata.credential.store.impl.CredentialReaderImpl;
-import org.apache.airavata.credential.store.impl.SSHCredentialWriter;
-import org.apache.airavata.credential.store.impl.util.CredentialStoreDBInitConfig;
-import org.apache.airavata.credential.util.TokenGenerator;
-import org.apache.airavata.credential.util.Utility;
-import org.apache.airavata.model.credential.store.*;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
+import org.apache.airavata.credential.impl.store.CertificateCredentialWriter;
+import org.apache.airavata.credential.impl.store.CredentialReaderImpl;
+import org.apache.airavata.credential.impl.store.SSHCredentialWriter;
+import org.apache.airavata.credential.utils.CredentialStoreDBInitConfig;
+import org.apache.airavata.credential.utils.TokenGenerator;
+import org.apache.airavata.credential.utils.Utility;
+import org.apache.airavata.model.credential.store.CertificateCredential;
+import org.apache.airavata.model.credential.store.CredentialSummary;
+import org.apache.airavata.model.credential.store.PasswordCredential;
+import org.apache.airavata.model.credential.store.SSHCredential;
+import org.apache.airavata.model.credential.store.SummaryType;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,9 +59,13 @@ public class CredentialStoreService {
@Autowired
private AiravataServerProperties properties;
- private DBUtil dbUtil;
+ @Autowired
private SSHCredentialWriter sshCredentialWriter;
+
+ @Autowired
private CertificateCredentialWriter certificateCredentialWriter;
+
+ @Autowired
private CredentialReaderImpl credentialReader;
@jakarta.annotation.PostConstruct
@@ -81,15 +91,6 @@ public class CredentialStoreService {
logger.debug("Starting credential store, connecting to database - " + jdbcUrl + " DB user - " + userName
+ " driver name - " + driverName);
DBInitializer.initializeDB(new CredentialStoreDBInitConfig());
-
- try {
- dbUtil = new DBUtil(jdbcUrl, userName, password, driverName);
- sshCredentialWriter = new SSHCredentialWriter(dbUtil);
- certificateCredentialWriter = new CertificateCredentialWriter(dbUtil);
- credentialReader = new CredentialReaderImpl(dbUtil);
- } catch (ApplicationSettingsException e) {
- throw new RuntimeException("Failed to initialize CredentialStoreService", e);
- }
}
public String addSSHCredential(SSHCredential sshCredential) throws CredentialStoreException {
@@ -117,22 +118,16 @@ public class CredentialStoreService {
} catch (Exception ex) {
String message = "Error occurred while generating key pair: " + ex.getMessage();
logger.error(message, ex);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(message);
- exception.initCause(ex);
- throw exception;
+ throw new CredentialStoreException(message, ex);
}
}
credential.setCredentialOwnerType(CredentialOwnerType.GATEWAY);
try {
sshCredentialWriter.writeCredentials(credential);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
+ } catch (CredentialStoreException e) {
String message = "Error occurred while saving SSH Credentials: " + e.getMessage();
logger.error(message, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(message);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(message, e);
}
return token;
} catch (CredentialStoreException e) {
@@ -166,13 +161,10 @@ public class CredentialStoreService {
credential.setCertificates(certificates);
try {
certificateCredentialWriter.writeCredentials(credential);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
+ } catch (CredentialStoreException e) {
String message = "Error occurred while saving Certificate Credentials: " + e.getMessage();
logger.error(message, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(message);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(message, e);
}
return token;
} catch (CredentialStoreException e) {
@@ -180,10 +172,7 @@ public class CredentialStoreService {
} catch (CertificateException e) {
String message = "Error occurred while processing certificate: " + e.getMessage();
logger.error(message, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(message);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(message, e);
}
}
@@ -200,13 +189,10 @@ public class CredentialStoreService {
credential.setToken(token);
try {
sshCredentialWriter.writeCredentials(credential);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
+ } catch (CredentialStoreException e) {
String message = "Error occurred while saving PWD Credentials: " + e.getMessage();
logger.error(message, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(message);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(message, e);
}
return token;
} catch (CredentialStoreException e) {
@@ -219,14 +205,12 @@ public class CredentialStoreService {
Credential credential;
try {
credential = credentialReader.getCredential(gatewayId, tokenId);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String msg = "Error occurred while retrieving SSH credential for token - " + tokenId
- + " and gateway id - " + gatewayId;
+ } catch (CredentialStoreException e) {
+ String msg = String.format(
+ "Error occurred while retrieving SSH credential for token - %s and gateway id - %s",
+ tokenId, gatewayId);
logger.error(msg, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(msg);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(msg, e);
}
if (credential instanceof org.apache.airavata.credential.impl.ssh.SSHCredential
&& !(credential instanceof org.apache.airavata.credential.impl.password.PasswordCredential)) {
@@ -258,14 +242,12 @@ public class CredentialStoreService {
Credential credential;
try {
credential = credentialReader.getCredential(gatewayId, tokenId);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String msg = "Error occurred while retrieving credential for token - " + tokenId + " and gateway id - "
- + gatewayId;
+ } catch (CredentialStoreException e) {
+ String msg = String.format(
+ "Error occurred while retrieving credential for token - %s and gateway id - %s",
+ tokenId, gatewayId);
logger.error(msg, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(msg);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(msg, e);
}
if (isSSHCredential(credential)) {
return convertToCredentialSummary((org.apache.airavata.credential.impl.ssh.SSHCredential) credential);
@@ -276,12 +258,15 @@ public class CredentialStoreService {
return convertToCredentialSummary(
(org.apache.airavata.credential.impl.password.PasswordCredential) credential);
}
- String msg = "Unrecognized type of credential for token: " + tokenId;
+ String msg = String.format("Unrecognized type of credential for token: %s", tokenId);
logger.error(msg);
- CredentialStoreException exception = new CredentialStoreException(msg);
- throw exception;
+ throw new CredentialStoreException(msg);
} catch (CredentialStoreException e) {
- throw e;
+ String msg = String.format(
+ "Error occurred while retrieving credential for token - %s and gateway id - %s",
+ tokenId, gatewayId);
+ logger.error(msg, e);
+ throw new CredentialStoreException(msg, e);
}
}
@@ -291,13 +276,10 @@ public class CredentialStoreService {
List<Credential> credentials;
try {
credentials = credentialReader.getAllAccessibleCredentialsPerGateway(gatewayId, accessibleTokenIds);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String msg = "Error occurred while retrieving credentials for gateway - " + gatewayId;
+ } catch (CredentialStoreException e) {
+ String msg = String.format("Error occurred while retrieving credentials for gateway - %s", gatewayId);
logger.error(msg, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(msg);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(msg, e);
}
if (type.equals(SummaryType.SSH)) {
return credentials.stream()
@@ -360,8 +342,9 @@ public class CredentialStoreService {
credentialSummary.setUsername(cred.getPortalUserName());
// FIXME: need to get gatewayId for CertificateCredentials
credentialSummary.setGatewayId("");
- // FIXME: get the public key? Or what would be appropriate for a summary of a CertificateCredential?
- // credentialSummary.setPublicKey(new String(cred.getPublicKey()));
+ // FIXME: get the public key? Or what would be appropriate for a summary of a
+ // CertificateCredential?
+ // credentialSummary.setPublicKey(new String(cred.getPublicKey()));
credentialSummary.setToken(cred.getToken());
credentialSummary.setPersistedTime(cred.getCertificateRequestedTime().getTime());
credentialSummary.setDescription(cred.getDescription());
@@ -383,18 +366,7 @@ public class CredentialStoreService {
public CertificateCredential getCertificateCredential(String tokenId, String gatewayId)
throws CredentialStoreException {
try {
- Credential credential;
- try {
- credential = credentialReader.getCredential(gatewayId, tokenId);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String msg = "Error occurred while retrieving Certificate credential for token - " + tokenId
- + " and gateway id - " + gatewayId;
- logger.error(msg, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(msg);
- exception.initCause(e);
- throw exception;
- }
+ Credential credential = credentialReader.getCredential(gatewayId, tokenId);
if (credential instanceof org.apache.airavata.credential.impl.certificate.CertificateCredential) {
org.apache.airavata.credential.impl.certificate.CertificateCredential credential1 =
(org.apache.airavata.credential.impl.certificate.CertificateCredential) credential;
@@ -418,8 +390,7 @@ public class CredentialStoreService {
certificateCredential.setX509Cert(credential1.getCertificates()[0].toString());
return certificateCredential;
} else {
- logger.info("Could not find Certificate credentials for token - " + tokenId + " and " + "gateway id - "
- + gatewayId);
+ logger.info("certificateCredential not found for token=%s and gateway_id=%s", tokenId, gatewayId);
return null;
}
} catch (CredentialStoreException e) {
@@ -432,14 +403,12 @@ public class CredentialStoreService {
Credential credential;
try {
credential = credentialReader.getCredential(gatewayId, tokenId);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String msg = "Error occurred while retrieving PWD credential for token - " + tokenId
- + " and gateway id - " + gatewayId;
+ } catch (CredentialStoreException e) {
+ String msg = String.format(
+ "Error occurred while retrieving PWD credential for token %s and gateway_id=%s",
+ tokenId, gatewayId);
logger.error(msg, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(msg);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(msg, e);
}
if (credential instanceof org.apache.airavata.credential.impl.password.PasswordCredential) {
org.apache.airavata.credential.impl.password.PasswordCredential credential1 =
@@ -455,8 +424,7 @@ public class CredentialStoreService {
credential1.getCertificateRequestedTime().getTime());
return pwdCredential;
} else {
- logger.info("Could not find PWD credentials for token - " + tokenId + " and " + "gateway id - "
- + gatewayId);
+ logger.info("Could not find PWD credentials for token %s and gateway_id=%s", tokenId, gatewayId);
return null;
}
} catch (CredentialStoreException e) {
@@ -468,19 +436,16 @@ public class CredentialStoreService {
public List<CredentialSummary> getAllCredentialSummaryForGateway(SummaryType type, String gatewayId)
throws CredentialStoreException {
if (type.equals(SummaryType.SSH)) {
- Map<String, String> sshKeyMap = new HashMap<>();
List<CredentialSummary> summaryList = new ArrayList<>();
try {
List<Credential> allCredentials;
try {
allCredentials = credentialReader.getAllCredentialsPerGateway(gatewayId);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String message = "Error occurred while retrieving credential Summary: " + e.getMessage();
+ } catch (CredentialStoreException e) {
+ String message = String.format(
+ "Error occurred while retrieving credential Summary for gateway_id=%s", gatewayId);
logger.error(message, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(message);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(message, e);
}
if (allCredentials != null && !allCredentials.isEmpty()) {
for (Credential credential : allCredentials) {
@@ -506,8 +471,9 @@ public class CredentialStoreService {
}
return summaryList;
} else {
- logger.info("Summay Type" + type.toString() + " not supported for gateway id - " + gatewayId);
- return null;
+ String msg = String.format("Summary type=%s not supported for gateway_id=%s", type.name(), gatewayId);
+ logger.error(msg);
+ throw new CredentialStoreException(msg);
}
}
@@ -515,19 +481,17 @@ public class CredentialStoreService {
public List<CredentialSummary> getAllCredentialSummaryForUserInGateway(
SummaryType type, String gatewayId, String userId) throws CredentialStoreException {
if (type.equals(SummaryType.SSH)) {
- Map<String, String> sshKeyMap = new HashMap<>();
List<CredentialSummary> summaryList = new ArrayList<>();
try {
List<Credential> allCredentials;
try {
allCredentials = credentialReader.getAllCredentials();
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String message = "Error occurred while retrieving credential Summary: " + e.getMessage();
+ } catch (CredentialStoreException e) {
+ String message = String.format(
+ "Error retrieving credential summaries for user_id=%s and gateway_id=%s",
+ userId, gatewayId);
logger.error(message, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(message);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(message, e);
}
if (allCredentials != null && !allCredentials.isEmpty()) {
for (Credential credential : allCredentials) {
@@ -575,13 +539,10 @@ public class CredentialStoreService {
List<Credential> allCredentials;
try {
allCredentials = credentialReader.getAllCredentialsPerGateway(gatewayId);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String message = "Error occurred while retrieving credentials: " + e.getMessage();
+ } catch (CredentialStoreException e) {
+ String message = String.format("Error retrieving credentials for gateway_id=%s", gatewayId);
logger.error(message, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(message);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(message, e);
}
if (allCredentials != null && !allCredentials.isEmpty()) {
for (Credential credential : allCredentials) {
@@ -604,14 +565,11 @@ public class CredentialStoreService {
try {
try {
credentialReader.removeCredentials(gatewayId, tokenId);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String msg = "Error occurred while deleting SSH credential for token - " + tokenId
- + " and gateway id - " + gatewayId;
+ } catch (CredentialStoreException e) {
+ String msg = String.format(
+ "Error deleting SSH credential for token=%s and gateway_id=%s", tokenId, gatewayId);
logger.error(msg, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(msg);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(msg, e);
}
return true;
} catch (CredentialStoreException e) {
@@ -623,14 +581,11 @@ public class CredentialStoreService {
try {
try {
credentialReader.removeCredentials(gatewayId, tokenId);
- } catch (org.apache.airavata.credential.store.CredentialStoreException e) {
- String msg = "Error occurred while deleting PWD credential for token - " + tokenId
- + " and gateway id - " + gatewayId;
+ } catch (CredentialStoreException e) {
+ String msg = String.format(
+ "Error deleting PWD credential for token=%s and gateway_id=%s", tokenId, gatewayId);
logger.error(msg, e);
- CredentialStoreException exception = new CredentialStoreException();
- exception.setMessage(msg);
- exception.initCause(e);
- throw exception;
+ throw new CredentialStoreException(msg, e);
}
return true;
} catch (CredentialStoreException e) {
diff --git a/airavata-api/src/main/java/org/apache/airavata/service/IamAdminService.java b/airavata-api/src/main/java/org/apache/airavata/service/IamAdminService.java
index 386b74a250..6907ee33da 100644
--- a/airavata-api/src/main/java/org/apache/airavata/service/IamAdminService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/service/IamAdminService.java
@@ -25,7 +25,7 @@ import org.apache.airavata.common.utils.AiravataUtils;
import org.apache.airavata.common.utils.Constants;
import org.apache.airavata.common.utils.DBEventService;
import org.apache.airavata.config.AiravataServerProperties;
-import org.apache.airavata.credential.exception.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.airavata.messaging.core.util.DBEventPublisherUtils;
import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
import org.apache.airavata.model.credential.store.PasswordCredential;
diff --git a/airavata-api/src/main/java/org/apache/airavata/service/OrchestratorService.java b/airavata-api/src/main/java/org/apache/airavata/service/OrchestratorService.java
index deff83d854..3087fb5451 100644
--- a/airavata-api/src/main/java/org/apache/airavata/service/OrchestratorService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/service/OrchestratorService.java
@@ -66,9 +66,9 @@ import org.apache.airavata.model.status.QueueStatusModel;
import org.apache.airavata.model.task.TaskTypes;
import org.apache.airavata.model.util.ExperimentModelUtil;
import org.apache.airavata.orchestrator.exception.OrchestratorException;
+import org.apache.airavata.orchestrator.impl.SimpleOrchestratorImpl;
import org.apache.airavata.orchestrator.schedule.HostScheduler;
import org.apache.airavata.orchestrator.utils.OrchestratorConstants;
-import org.apache.airavata.orchestrator.impl.SimpleOrchestratorImpl;
import org.apache.airavata.registry.api.exception.RegistryServiceException;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.RetryPolicy;
diff --git a/airavata-api/src/main/java/org/apache/airavata/service/TenantProfileService.java b/airavata-api/src/main/java/org/apache/airavata/service/TenantProfileService.java
index 82928a6bbf..66415163f9 100644
--- a/airavata-api/src/main/java/org/apache/airavata/service/TenantProfileService.java
+++ b/airavata-api/src/main/java/org/apache/airavata/service/TenantProfileService.java
@@ -30,7 +30,7 @@ import org.apache.airavata.common.exception.AiravataException;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.Constants;
import org.apache.airavata.common.utils.DBEventService;
-import org.apache.airavata.credential.exception.CredentialStoreException;
+import org.apache.airavata.credential.exceptions.CredentialStoreException;
import org.apache.airavata.messaging.core.util.DBEventPublisherUtils;
import org.apache.airavata.model.credential.store.PasswordCredential;
import org.apache.airavata.model.dbevent.CrudType;
diff --git a/airavata-api/src/main/resources/airavata-server.properties b/airavata-api/src/main/resources/airavata.properties
similarity index 100%
rename from airavata-api/src/main/resources/airavata-server.properties
rename to airavata-api/src/main/resources/airavata.properties
diff --git a/airavata-api/src/main/resources/migrations-util/derby/airavata-server.properties b/airavata-api/src/main/resources/migrations-util/derby/airavata.properties
similarity index 100%
rename from airavata-api/src/main/resources/migrations-util/derby/airavata-server.properties
rename to airavata-api/src/main/resources/migrations-util/derby/airavata.properties
diff --git a/airavata-api/src/main/resources/migrations-util/mysql/airavata-server.properties b/airavata-api/src/main/resources/migrations-util/mysql/airavata.properties
similarity index 100%
rename from airavata-api/src/main/resources/migrations-util/mysql/airavata-server.properties
rename to airavata-api/src/main/resources/migrations-util/mysql/airavata.properties
diff --git a/airavata-api/src/test/java/org/apache/airavata/api/thrift/client/TestSSLClient.java b/airavata-api/src/test/java/org/apache/airavata/api/thrift/client/TestSSLClient.java
index 1b8e7eef5c..866aa179f5 100644
--- a/airavata-api/src/test/java/org/apache/airavata/api/thrift/client/TestSSLClient.java
+++ b/airavata-api/src/test/java/org/apache/airavata/api/thrift/client/TestSSLClient.java
@@ -27,28 +27,30 @@ import org.apache.airavata.model.credential.store.CertificateCredential;
import org.apache.airavata.model.credential.store.CommunityUser;
import org.apache.airavata.model.credential.store.SSHCredential;
import org.apache.airavata.service.CredentialStoreService;
-import org.apache.airavata.service.ServiceFactory;
-import org.apache.airavata.service.ServiceFactoryException;
import org.apache.commons.codec.binary.Base64;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class TestSSLClient {
private static final Logger logger = LoggerFactory.getLogger(TestSSLClient.class);
- private void invoke() {
- try {
- CredentialStoreService credentialService =
- ServiceFactory.getInstance().getCredentialStoreService();
- testSSHCredential(credentialService);
- testCertificateCredential(credentialService);
- } catch (ServiceFactoryException e) {
- logger.error("Error getting credential store service", e);
- }
+ @Autowired
+ private CredentialStoreService credentialService;
+
+ @Test
+ public void invoke() {
+ testSSHCredential(credentialService);
+ testCertificateCredential(credentialService);
}
- public static void testSSHCredential(CredentialStoreService credentialService) {
+ public void testSSHCredential(CredentialStoreService credentialService) {
try {
SSHCredential sshCredential = new SSHCredential();
sshCredential.setUsername("test");
@@ -64,7 +66,7 @@ public class TestSSLClient {
}
}
- public static void testCertificateCredential(CredentialStoreService credentialService) {
+ public void testCertificateCredential(CredentialStoreService credentialService) {
try {
CertificateCredential certificateCredential = new CertificateCredential();
CommunityUser communityUser = new CommunityUser("testGateway", "test", "test@ddsd");
@@ -93,9 +95,4 @@ public class TestSSLClient {
logger.error("Error adding certificate credential", e);
}
}
-
- public static void main(String[] args) {
- TestSSLClient c = new TestSSLClient();
- c.invoke();
- }
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/api/thrift/handler/TestSharingRegistryHandler.java b/airavata-api/src/test/java/org/apache/airavata/api/thrift/handler/TestSharingRegistryHandler.java
index 56983dd2ba..5dacfb318d 100644
--- a/airavata-api/src/test/java/org/apache/airavata/api/thrift/handler/TestSharingRegistryHandler.java
+++ b/airavata-api/src/test/java/org/apache/airavata/api/thrift/handler/TestSharingRegistryHandler.java
@@ -27,13 +27,20 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class TestSharingRegistryHandler {
private static final Logger logger = LoggerFactory.getLogger(TestSharingRegistryHandler.class);
+ @Autowired
+ private SharingRegistryServerHandler sharingRegistryServerHandler;
+
@Test
public void test() throws Exception {
- SharingRegistryServerHandler sharingRegistryServerHandler = new SharingRegistryServerHandler();
// Creating domain
Domain domain = new Domain();
diff --git a/airavata-api/src/test/java/org/apache/airavata/api/thrift/server/TestOrchestratorServiceServer.java b/airavata-api/src/test/java/org/apache/airavata/api/thrift/server/TestOrchestratorServiceServer.java
index aed9c69d80..1b8fccc745 100644
--- a/airavata-api/src/test/java/org/apache/airavata/api/thrift/server/TestOrchestratorServiceServer.java
+++ b/airavata-api/src/test/java/org/apache/airavata/api/thrift/server/TestOrchestratorServiceServer.java
@@ -19,11 +19,6 @@
*/
package org.apache.airavata.api.thrift.server;
-// import org.apache.airavata.client.AiravataAPIFactory;
-// import org.apache.airavata.client.api.AiravataAPI;
-// import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
-// import org.apache.airavata.client.tools.DocumentCreator;
-
import java.util.ArrayList;
import java.util.List;
import org.apache.airavata.model.application.io.DataType;
@@ -33,53 +28,32 @@ import org.apache.airavata.model.experiment.ExperimentModel;
import org.apache.airavata.model.experiment.UserConfigurationDataModel;
import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
import org.apache.airavata.model.util.ExperimentModelUtil;
-import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
+import org.apache.airavata.orchestrator.exception.OrchestratorException;
+import org.apache.airavata.registry.api.exception.RegistryServiceException;
import org.apache.airavata.service.OrchestratorService;
-import org.apache.airavata.service.ServiceFactory;
+import org.apache.airavata.service.RegistryService;
import org.apache.airavata.service.ServiceFactoryException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class TestOrchestratorServiceServer {
- // private static DocumentCreator documentCreator;
- private static OrchestratorService orchestratorService;
- // private static Registry registry;
- private static int NUM_CONCURRENT_REQUESTS = 1;
- private static final String DEFAULT_GATEWAY = "default.registry.gateway";
- private static final Logger logger = LoggerFactory.getLogger(TestOrchestratorServiceServer.class);
- /*
- public static void main(String[] args) {
- try {
- AiravataUtils.setExecutionAsClient();
- sysUser = ClientSettings.getSetting(DEFAULT_USER);
- sysUserPwd = ClientSettings.getSetting(DEFAULT_USER_PASSWORD);
- gateway = ClientSettings.getSetting(DEFAULT_GATEWAY);
- orchestratorClient = OrchestratorClientFactory.createOrchestratorClient("localhost", 8940);
- registry = RegistryFactory.getRegistry(gateway, sysUser, sysUserPwd);
- documentCreator = new DocumentCreator(getAiravataAPI());
- documentCreator.createLocalHostDocs();
- documentCreator.createGramDocs();
- documentCreator.createPBSDocsForOGCE();
- storeExperimentDetail();
- } catch (ApplicationSettingsException e) {
- e.printStackTrace();
- } catch (RegistryException e) {
- e.printStackTrace();
- }
+ @Autowired
+ private OrchestratorService orchestratorService;
- }
+ @Autowired
+ private RegistryService registryService;
- private static AiravataAPI getAiravataAPI() {
- AiravataAPI airavataAPI = null;
- try {
- airavataAPI = AiravataAPIFactory.getAPI(gateway, sysUser);
- } catch (AiravataAPIInvocationException e) {
- e.printStackTrace();
- }
- return airavataAPI;
- }
- */
+ private static int NUM_CONCURRENT_REQUESTS = 1;
+ private static final String DEFAULT_GATEWAY = "default.registry.gateway";
+ private static final Logger logger = LoggerFactory.getLogger(TestOrchestratorServiceServer.class);
public static void main(String[] args) {
try {
@@ -89,7 +63,8 @@ public class TestOrchestratorServiceServer {
}
}
- public static void storeExperimentDetail() {
+ @Test
+ public void testStoreExperimentDetail() {
for (int i = 0; i < NUM_CONCURRENT_REQUESTS; i++) {
Thread thread = new Thread() {
public void run() {
@@ -124,22 +99,21 @@ public class TestOrchestratorServiceServer {
UserConfigurationDataModel userConfigurationDataModel = new UserConfigurationDataModel();
userConfigurationDataModel.setComputationalResourceScheduling(scheduling);
simpleExperiment.setUserConfigurationData(userConfigurationDataModel);
+
String expId = null;
try {
- // expId = (String) registry.add(ParentDataType.EXPERIMENT,
- // simpleExperiment);
- } catch (Exception e) {
- e.printStackTrace();
+ expId = registryService.createExperiment(DEFAULT_GATEWAY, simpleExperiment);
+ } catch (RegistryServiceException e) {
+ logger.error("Error while creating experiment", e);
+ Assertions.fail("Error while creating experiment");
}
+ Assertions.assertNotNull(expId, "Experiment ID should not be null");
try {
- if (orchestratorService == null) {
- orchestratorService = ServiceFactory.getInstance().getOrchestratorService();
- }
orchestratorService.launchExperiment(expId, DEFAULT_GATEWAY, null);
} catch (OrchestratorException | ServiceFactoryException e) {
- e.printStackTrace();
- throw new RuntimeException("Error while launching experiment", e);
+ logger.error("Error while launching experiment", e);
+ Assertions.fail("Error while launching experiment");
}
}
};
@@ -147,7 +121,8 @@ public class TestOrchestratorServiceServer {
try {
thread.join();
} catch (InterruptedException e) {
- e.printStackTrace();
+ logger.error("Error while joining thread", e);
+ Assertions.fail("Error while joining thread");
}
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/api/thrift/server/TestSharingRegistryServer.java b/airavata-api/src/test/java/org/apache/airavata/api/thrift/server/TestSharingRegistryServer.java
index 78e05834ea..a2508c660e 100644
--- a/airavata-api/src/test/java/org/apache/airavata/api/thrift/server/TestSharingRegistryServer.java
+++ b/airavata-api/src/test/java/org/apache/airavata/api/thrift/server/TestSharingRegistryServer.java
@@ -22,30 +22,37 @@ package org.apache.airavata.api.thrift.server;
import java.util.ArrayList;
import java.util.List;
import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.service.ServiceFactory;
-import org.apache.airavata.service.ServiceFactoryException;
import org.apache.airavata.service.SharingRegistryService;
-import org.apache.airavata.sharing.models.*;
+import org.apache.airavata.sharing.models.Domain;
+import org.apache.airavata.sharing.models.DuplicateEntryException;
+import org.apache.airavata.sharing.models.Entity;
+import org.apache.airavata.sharing.models.EntitySearchField;
+import org.apache.airavata.sharing.models.EntityType;
+import org.apache.airavata.sharing.models.GroupCardinality;
+import org.apache.airavata.sharing.models.GroupType;
+import org.apache.airavata.sharing.models.PermissionType;
+import org.apache.airavata.sharing.models.SearchCondition;
+import org.apache.airavata.sharing.models.SearchCriteria;
+import org.apache.airavata.sharing.models.SharingRegistryException;
+import org.apache.airavata.sharing.models.User;
+import org.apache.airavata.sharing.models.UserGroup;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class TestSharingRegistryServer {
- @BeforeAll
- public static void setUp() throws Exception {
- SharingRegistryServer server = new SharingRegistryServer();
- server.setTestMode(true);
- server.start();
- Thread.sleep(1000 * 2);
- }
+ @Autowired
+ private SharingRegistryService sharingService;
@Test
public void test()
throws InterruptedException, ApplicationSettingsException, SharingRegistryException,
- DuplicateEntryException, ServiceFactoryException {
- SharingRegistryService sharingService = ServiceFactory.getInstance().getSharingRegistryService();
-
+ DuplicateEntryException {
Domain domain = new Domain();
// has to be one word
domain.setName("test-domain" + Math.random());
diff --git a/airavata-api/src/test/java/org/apache/airavata/credential/cpi/SSHSummaryTest/SSHSummaryTest.java b/airavata-api/src/test/java/org/apache/airavata/credential/cpi/SSHSummaryTest/SSHSummaryTest.java
index 8397959e58..87e3d6ee65 100644
--- a/airavata-api/src/test/java/org/apache/airavata/credential/cpi/SSHSummaryTest/SSHSummaryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/credential/cpi/SSHSummaryTest/SSHSummaryTest.java
@@ -32,9 +32,8 @@ import org.apache.airavata.common.utils.DatabaseTestCases;
import org.apache.airavata.common.utils.DerbyUtil;
import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.credential.impl.ssh.SSHCredential;
-import org.apache.airavata.credential.store.impl.SSHCredentialWriter;
-import org.apache.airavata.credential.store.impl.db.CredentialsDAO;
-import org.apache.airavata.credential.util.TokenGenerator;
+import org.apache.airavata.credential.impl.store.SSHCredentialWriter;
+import org.apache.airavata.credential.utils.TokenGenerator;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -47,8 +46,6 @@ import org.slf4j.LoggerFactory;
public class SSHSummaryTest extends DatabaseTestCases {
private static final Logger logger = LoggerFactory.getLogger(SSHSummaryTest.class);
- private CredentialsDAO credentialsDAO;
-
private X509Certificate[] x509Certificates;
private PrivateKey privateKey;
@@ -95,9 +92,6 @@ public class SSHSummaryTest extends DatabaseTestCases {
@BeforeEach
public void setUp() throws Exception {
-
- credentialsDAO = new CredentialsDAO();
-
x509Certificates = new X509Certificate[1];
// Cleanup tables;
@@ -157,8 +151,9 @@ public class SSHSummaryTest extends DatabaseTestCases {
String gatewayId = "phasta";
String privateKeyPath = "/home/abhandar/Documents/Airavata/keys/id_rsa_airavata";
String pubKeyPath = "/home/abhandar/Documents/Airavata/keys/id_rsa_airavata.pub";
- DBUtil dbUtil = new DBUtil(jdbcURL, userName, password, jdbcDriver);
- SSHCredentialWriter writer = new SSHCredentialWriter(dbUtil);
+ // Note: SSHCredentialWriter is now a Spring component and should be autowired
+ // This test needs to be updated to use Spring Boot test context
+ SSHCredentialWriter writer = new SSHCredentialWriter();
SSHCredential sshCredential = new SSHCredential();
sshCredential.setGateway(gatewayId);
String token = TokenGenerator.generateToken(gatewayId, null);
diff --git a/airavata-api/src/test/java/org/apache/airavata/credential/notifier/impl/EmailNotifierTest.java b/airavata-api/src/test/java/org/apache/airavata/credential/notifier/impl/EmailNotifierTest.java
index b74fc2db32..987315eb33 100644
--- a/airavata-api/src/test/java/org/apache/airavata/credential/notifier/impl/EmailNotifierTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/credential/notifier/impl/EmailNotifierTest.java
@@ -19,6 +19,9 @@
*/
package org.apache.airavata.credential.notifier.impl;
+import org.apache.airavata.credential.impl.notifier.EmailNotificationMessage;
+import org.apache.airavata.credential.impl.notifier.EmailNotifier;
+import org.apache.airavata.credential.impl.notifier.EmailNotifierConfiguration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/CommunityUserDAOTest.java b/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/CommunityUserDAOTest.java
deleted file mode 100644
index 24fe3cd5ad..0000000000
--- a/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/CommunityUserDAOTest.java
+++ /dev/null
@@ -1,192 +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.credential.store.impl.db;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import java.sql.Connection;
-import java.util.List;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.DatabaseTestCases;
-import org.apache.airavata.common.utils.DerbyUtil;
-import org.apache.airavata.credential.CommunityUser;
-import org.junit.jupiter.api.*;
-
-/**
- * Test for community user DAO.
- */
-public class CommunityUserDAOTest extends DatabaseTestCases {
-
- private CommunityUserDAO communityUserDAO;
-
- @BeforeAll
- public static void setUpDatabase() throws Exception {
- DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
- waitTillServerStarts();
- String createTable = "CREATE TABLE COMMUNITY_USER\n" + " (\n"
- + " GATEWAY_ID VARCHAR(256) NOT NULL,\n"
- + " COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,\n"
- + " TOKEN_ID VARCHAR(256) NOT NULL,\n"
- + " COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,\n"
- + " PRIMARY KEY (GATEWAY_ID, COMMUNITY_USER_NAME, TOKEN_ID)\n"
- + " )";
- String dropTable = "drop table COMMUNITY_USER";
- try {
- executeSQL(dropTable);
- } catch (Exception e) {
- }
- executeSQL(createTable);
- }
-
- @AfterAll
- public static void shutDownDatabase() throws Exception {
- DerbyUtil.stopDerbyServer();
- }
-
- @BeforeEach
- public void setUp() throws Exception {
- communityUserDAO = new CommunityUserDAO();
- Connection connection = getDbUtil().getConnection();
- try {
- DBUtil.truncate("community_user", connection);
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testAddCommunityUser() throws Exception {
-
- Connection connection = getConnection();
-
- try {
-
- CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
- communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
- communityUser = new CommunityUser("gw1", "ogce2", "ogce@sciencegateway.org");
- communityUserDAO.addCommunityUser(communityUser, "Token2", connection);
-
- CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
- assertNotNull(user);
- assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
- user = communityUserDAO.getCommunityUser("gw1", "ogce2", connection);
- assertNotNull(user);
- assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
- user = communityUserDAO.getCommunityUserByToken("gw1", "Token1", connection);
- assertNotNull(user);
- assertEquals("ogce", user.getUserName());
- assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
- user = communityUserDAO.getCommunityUserByToken("gw1", "Token2", connection);
- assertNotNull(user);
- assertEquals("ogce2", user.getUserName());
- assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testDeleteCommunityUser() throws Exception {
-
- Connection connection = getConnection();
-
- try {
- CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
- communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
- CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
- assertNotNull(user);
-
- communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
- communityUserDAO.deleteCommunityUser(communityUser, connection);
-
- user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
- assertNull(user);
-
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testDeleteCommunityUserByToken() throws Exception {
-
- Connection connection = getConnection();
-
- try {
- CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
- communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
- CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
- assertNotNull(user);
-
- communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
- communityUserDAO.deleteCommunityUserByToken(communityUser, "Token1", connection);
-
- user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
- assertNull(user);
-
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testGetCommunityUsers() throws Exception {
-
- Connection connection = getConnection();
-
- try {
- CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
- communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
- CommunityUser user = communityUserDAO.getCommunityUser("gw1", "ogce", connection);
- assertNotNull(user);
- assertEquals("ogce@sciencegateway.org", user.getUserEmail());
-
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testGetCommunityUsersForGateway() throws Exception {
-
- Connection connection = getConnection();
-
- CommunityUser communityUser = new CommunityUser("gw1", "ogce", "ogce@sciencegateway.org");
- communityUserDAO.addCommunityUser(communityUser, "Token1", connection);
-
- communityUser = new CommunityUser("gw1", "ogce2", "ogce@sciencegateway.org");
- communityUserDAO.addCommunityUser(communityUser, "Token2", connection);
-
- List<CommunityUser> users = communityUserDAO.getCommunityUsers("gw1", connection);
- assertNotNull(users);
- assertEquals(2, users.size());
-
- assertEquals(users.get(0).getUserName(), "ogce");
- assertEquals(users.get(1).getUserName(), "ogce2");
- }
-}
diff --git a/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/CredentialsDAOTest.java b/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/CredentialsDAOTest.java
deleted file mode 100644
index 63378903e3..0000000000
--- a/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/CredentialsDAOTest.java
+++ /dev/null
@@ -1,464 +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.credential.store.impl.db;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-import java.sql.Connection;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.airavata.common.utils.DBUtil;
-import org.apache.airavata.common.utils.DatabaseTestCases;
-import org.apache.airavata.common.utils.DerbyUtil;
-import org.apache.airavata.common.utils.KeyStorePasswordCallback;
-import org.apache.airavata.credential.CommunityUser;
-import org.apache.airavata.credential.Credential;
-import org.apache.airavata.credential.CredentialOwnerType;
-import org.apache.airavata.credential.impl.certificate.CertificateCredential;
-import org.apache.airavata.credential.store.CredentialStoreException;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test class for credential class
- */
-public class CredentialsDAOTest extends DatabaseTestCases {
-
- private static final Logger logger = LoggerFactory.getLogger(CredentialsDAOTest.class);
-
- private CredentialsDAO credentialsDAO;
-
- private X509Certificate[] x509Certificates;
- private PrivateKey privateKey;
-
- @BeforeAll
- public static void setUpDatabase() throws Exception {
- DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
-
- waitTillServerStarts();
-
- /*
- * String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n" + " GATEWAY_NAME VARCHAR(256) NOT NULL,\n" +
- * " COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,\n" + " CREDENTIAL BLOB NOT NULL,\n" +
- * " PRIVATE_KEY BLOB NOT NULL,\n" + " NOT_BEFORE VARCHAR(256) NOT NULL,\n" +
- * " NOT_AFTER VARCHAR(256) NOT NULL,\n" + " LIFETIME INTEGER NOT NULL,\n" +
- * " REQUESTING_PORTAL_USER_NAME VARCHAR(256) NOT NULL,\n" +
- * " REQUESTED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',\n" +
- * " PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME)\n" + ")";
- */
- // Adding description field as per pull request https://github.com/apache/airavata/pull/54
- String createTable = "CREATE TABLE CREDENTIALS\n" + "(\n"
- + " GATEWAY_ID VARCHAR(256) NOT NULL,\n"
- + " TOKEN_ID VARCHAR(256) NOT NULL,\n"
- + // Actual token used to identify the credential
- " CREDENTIAL BLOB NOT NULL,\n"
- + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n"
- + " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
- + " DESCRIPTION VARCHAR(500),\n"
- + " CREDENTIAL_OWNER_TYPE VARCHAR(10) DEFAULT 'GATEWAY' NOT NULL,\n"
- + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n" + ")";
-
- String dropTable = "drop table CREDENTIALS";
-
- try {
- executeSQL(dropTable);
- } catch (Exception e) {
- }
-
- executeSQL(createTable);
- }
-
- @AfterAll
- public static void shutDownDatabase() throws Exception {
- DerbyUtil.stopDerbyServer();
- }
-
- @BeforeEach
- public void setUp() throws Exception {
-
- credentialsDAO = new CredentialsDAO();
-
- x509Certificates = new X509Certificate[1];
-
- // Cleanup tables;
- Connection connection = getConnection();
-
- try {
- DBUtil.truncate("credentials", connection);
- } finally {
- connection.close();
- }
-
- initializeKeys();
- }
-
- private void initializeKeys() throws Exception {
- KeyStore ks = KeyStore.getInstance("JKS");
- char[] password = "password".toCharArray();
-
- String baseDirectory = System.getProperty("credential.module.directory");
-
- String keyStorePath =
- "src" + File.separator + "test" + File.separator + "resources" + File.separator + "airavata.p12";
-
- if (baseDirectory != null) {
- keyStorePath = baseDirectory + File.separator + keyStorePath;
- } else {
- keyStorePath = "modules" + File.separator + "credential-store" + File.separator + keyStorePath;
- }
-
- File keyStoreFile = new File(keyStorePath);
- if (!keyStoreFile.exists()) {
- logger.error("Unable to read keystore file " + keyStoreFile);
- throw new RuntimeException("Unable to read keystore file " + keyStoreFile);
- }
-
- java.io.FileInputStream fis = null;
- try {
- fis = new java.io.FileInputStream(keyStorePath);
- ks.load(fis, password);
- } finally {
- if (fis != null) {
- fis.close();
- }
- }
-
- privateKey = (PrivateKey) ks.getKey("selfsigned", password);
- x509Certificates[0] = (X509Certificate) ks.getCertificate("selfsigned");
- }
-
- @Test
- public void testKeyReading() throws Exception {
- initializeKeys();
- logger.info("privateKey algorithm: {}", privateKey.getAlgorithm());
- logger.info("x509Certificates issuerDN: {}", x509Certificates[0].getIssuerDN());
-
- assertNotNull(privateKey);
- assertNotNull(x509Certificates);
- }
-
- private CommunityUser getCommunityUser(String gateway, String name) {
- return new CommunityUser(gateway, name, "amila@sciencegateway.org");
- }
-
- private void addTestCredentials() throws Exception {
-
- Connection connection = getConnection();
-
- try {
- CertificateCredential certificateCredential = getTestCredentialObject();
- credentialsDAO.addCredentials(
- certificateCredential.getCommunityUser().getGatewayName(), certificateCredential, connection);
- certificateCredential.setToken("tom2");
- credentialsDAO.addCredentials(
- certificateCredential.getCommunityUser().getGatewayName(), certificateCredential, connection);
-
- } finally {
- connection.close();
- }
- }
-
- public CertificateCredential getTestCredentialObject() {
-
- CertificateCredential certificateCredential = new CertificateCredential();
- certificateCredential.setToken("tom");
- certificateCredential.setCertificates(x509Certificates);
- certificateCredential.setPrivateKey(privateKey);
- certificateCredential.setCommunityUser(getCommunityUser("gw1", "tom"));
- certificateCredential.setLifeTime(1000);
- certificateCredential.setPortalUserName("jerry");
- certificateCredential.setNotBefore("13 OCT 2012 5:34:23");
- certificateCredential.setNotAfter("14 OCT 2012 5:34:23");
- certificateCredential.setCredentialOwnerType(CredentialOwnerType.GATEWAY);
-
- return certificateCredential;
- }
-
- @Test
- public void testSerialization() throws CredentialStoreException {
-
- CertificateCredential certificateCredential = getTestCredentialObject();
-
- CredentialsDAO credentialsDAO1 = new CredentialsDAO();
-
- byte[] array = credentialsDAO1.convertObjectToByteArray(certificateCredential);
- CertificateCredential readCertificateCredential =
- (CertificateCredential) credentialsDAO1.convertByteArrayToObject(array);
-
- checkEquality(certificateCredential.getCertificates(), readCertificateCredential.getCertificates());
- assertEquals(
- certificateCredential.getCertificateRequestedTime(),
- readCertificateCredential.getCertificateRequestedTime());
- assertEquals(
- certificateCredential.getCommunityUser().getGatewayName(),
- readCertificateCredential.getCommunityUser().getGatewayName());
- assertEquals(
- certificateCredential.getCommunityUser().getUserEmail(),
- readCertificateCredential.getCommunityUser().getUserEmail());
- assertEquals(
- certificateCredential.getCommunityUser().getUserName(),
- readCertificateCredential.getCommunityUser().getUserName());
- assertEquals(certificateCredential.getLifeTime(), readCertificateCredential.getLifeTime());
- assertEquals(certificateCredential.getNotAfter(), readCertificateCredential.getNotAfter());
- assertEquals(certificateCredential.getNotBefore(), readCertificateCredential.getNotBefore());
- assertEquals(certificateCredential.getPortalUserName(), readCertificateCredential.getPortalUserName());
- assertEquals(
- certificateCredential.getCredentialOwnerType(), readCertificateCredential.getCredentialOwnerType());
-
- PrivateKey newKey = readCertificateCredential.getPrivateKey();
-
- assertNotNull(newKey);
- assertEquals(privateKey.getClass(), newKey.getClass());
-
- assertEquals(privateKey.getFormat(), newKey.getFormat());
- assertEquals(privateKey.getAlgorithm(), newKey.getAlgorithm());
- assertTrue(Arrays.equals(privateKey.getEncoded(), newKey.getEncoded()));
- }
-
- @Test
- public void testSerializationWithEncryption() throws CredentialStoreException, URISyntaxException {
-
- URI uri = this.getClass().getClassLoader().getResource("airavata.p12").toURI();
- String secretKeyAlias = "mykey";
-
- assert uri != null;
-
- CertificateCredential certificateCredential = getTestCredentialObject();
-
- CredentialsDAO credentialsDAO1 =
- new CredentialsDAO(uri.getPath(), secretKeyAlias, new TestACSKeyStoreCallback());
-
- byte[] array = credentialsDAO1.convertObjectToByteArray(certificateCredential);
- CertificateCredential readCertificateCredential =
- (CertificateCredential) credentialsDAO1.convertByteArrayToObject(array);
-
- checkEquality(certificateCredential.getCertificates(), readCertificateCredential.getCertificates());
- assertEquals(
- certificateCredential.getCertificateRequestedTime(),
- readCertificateCredential.getCertificateRequestedTime());
- assertEquals(
- certificateCredential.getCommunityUser().getGatewayName(),
- readCertificateCredential.getCommunityUser().getGatewayName());
- assertEquals(
- certificateCredential.getCommunityUser().getUserEmail(),
- readCertificateCredential.getCommunityUser().getUserEmail());
- assertEquals(
- certificateCredential.getCommunityUser().getUserName(),
- readCertificateCredential.getCommunityUser().getUserName());
- assertEquals(certificateCredential.getLifeTime(), readCertificateCredential.getLifeTime());
- assertEquals(certificateCredential.getNotAfter(), readCertificateCredential.getNotAfter());
- assertEquals(certificateCredential.getNotBefore(), readCertificateCredential.getNotBefore());
- assertEquals(certificateCredential.getPortalUserName(), readCertificateCredential.getPortalUserName());
- assertEquals(
- certificateCredential.getCredentialOwnerType(), readCertificateCredential.getCredentialOwnerType());
-
- PrivateKey newKey = readCertificateCredential.getPrivateKey();
-
- assertNotNull(newKey);
- assertEquals(privateKey.getClass(), newKey.getClass());
-
- assertEquals(privateKey.getFormat(), newKey.getFormat());
- assertEquals(privateKey.getAlgorithm(), newKey.getAlgorithm());
- assertTrue(Arrays.equals(privateKey.getEncoded(), newKey.getEncoded()));
- }
-
- private class TestACSKeyStoreCallback implements KeyStorePasswordCallback {
-
- @Override
- public char[] getStorePassword() {
- return "airavata".toCharArray();
- }
-
- @Override
- public char[] getSecretKeyPassPhrase(String keyAlias) {
- if (keyAlias.equals("mykey")) {
- return "airavatasecretkey".toCharArray();
- }
-
- return null;
- }
- }
-
- private void checkEquality(X509Certificate[] certificates1, X509Certificate[] certificates2) {
-
- int i = 0;
-
- for (X509Certificate certificate : certificates1) {
- assertEquals(certificate, certificates2[i]);
- }
-
- assertEquals(certificates1.length, certificates2.length);
- }
-
- @Test
- public void testAddCredentials() throws Exception {
-
- addTestCredentials();
-
- Connection connection = getConnection();
-
- try {
- CertificateCredential certificateCredential =
- (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
- // Test get gateway name
- String gateway = credentialsDAO.getGatewayID("tom", connection);
- assertNotNull(certificateCredential);
- assertEquals("jerry", certificateCredential.getPortalUserName());
- assertEquals("gw1", gateway);
- checkEquality(x509Certificates, certificateCredential.getCertificates());
- assertEquals(
- privateKey.getFormat(),
- certificateCredential.getPrivateKey().getFormat());
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testDeleteCredentials() throws Exception {
-
- addTestCredentials();
-
- Connection connection = getConnection();
-
- try {
- CertificateCredential certificateCredential =
- (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
- assertNotNull(certificateCredential);
-
- credentialsDAO.deleteCredentials("gw1", "tom", connection);
-
- certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
- assertNull(certificateCredential);
-
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testUpdateCredentials() throws Exception {
-
- addTestCredentials();
-
- Connection connection = getConnection();
-
- try {
- CommunityUser communityUser = getCommunityUser("gw1", "tom");
- CertificateCredential certificateCredential = new CertificateCredential();
- certificateCredential.setToken("tom");
- certificateCredential.setCommunityUser(communityUser);
- certificateCredential.setCertificates(x509Certificates);
- // certificateCredential.setPrivateKey(privateKey);
- certificateCredential.setPortalUserName("test2");
- certificateCredential.setLifeTime(50);
- certificateCredential.setNotBefore("15 OCT 2012 5:34:23");
- certificateCredential.setNotAfter("16 OCT 2012 5:34:23");
- certificateCredential.setCredentialOwnerType(CredentialOwnerType.USER);
-
- credentialsDAO.updateCredentials(communityUser.getGatewayName(), certificateCredential, connection);
-
- certificateCredential = (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
-
- assertEquals(
- "CN=Airavata Project, OU=IU, O=Indiana University, L=Bloomington, ST=IN, C=US",
- certificateCredential.getCertificates()[0].getIssuerDN().toString());
- // Assertions.assertNotNull(certificateCredential.getPrivateKey());
- assertEquals("test2", certificateCredential.getPortalUserName());
- assertEquals(CredentialOwnerType.USER, certificateCredential.getCredentialOwnerType());
-
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testGetCredentials() throws Exception {
-
- addTestCredentials();
-
- Connection connection = getConnection();
-
- try {
-
- CertificateCredential certificateCredential =
- (CertificateCredential) credentialsDAO.getCredential("gw1", "tom", connection);
- assertEquals(
- "CN=Airavata Project, OU=IU, O=Indiana University, L=Bloomington, ST=IN, C=US",
- certificateCredential.getCertificates()[0].getIssuerDN().toString());
- // Assertions.assertNotNull(certificateCredential.getPrivateKey());
-
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testGetGatewayCredentials() throws Exception {
-
- addTestCredentials();
-
- Connection connection = getConnection();
-
- try {
- List<Credential> list = credentialsDAO.getCredentials("gw1", connection);
-
- assertEquals(2, list.size());
- } finally {
- connection.close();
- }
- }
-
- @Test
- public void testGetGatewayCredentialsForAccessibleTokenIds() throws Exception {
-
- addTestCredentials();
-
- Connection connection = getConnection();
-
- try {
- List<Credential> list = credentialsDAO.getCredentials("gw1", Arrays.asList("tom"), connection);
-
- assertEquals(1, list.size());
- list = credentialsDAO.getCredentials("gw1", Arrays.asList("tom", "tom2"), connection);
- assertEquals(2, list.size());
- list = credentialsDAO.getCredentials("gw1", Arrays.asList("tom2"), connection);
- assertEquals(1, list.size());
- list = credentialsDAO.getCredentials("gw1", Arrays.asList("non-existent-token-id"), connection);
- assertEquals(0, list.size());
- list = credentialsDAO.getCredentials("gw1", Arrays.asList(), connection);
- assertEquals(0, list.size());
- list = credentialsDAO.getCredentials("gw1", null, connection);
- assertEquals(0, list.size());
- } finally {
- connection.close();
- }
- }
-}
diff --git a/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/SSHCredentialTest.java b/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/SSHCredentialTest.java
index bfb1f5c869..ca54b44f57 100644
--- a/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/SSHCredentialTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/credential/store/impl/db/SSHCredentialTest.java
@@ -21,10 +21,9 @@ package org.apache.airavata.credential.store.impl.db;
import java.io.File;
import java.io.FileInputStream;
-import org.apache.airavata.common.utils.DBUtil;
import org.apache.airavata.credential.impl.ssh.SSHCredential;
-import org.apache.airavata.credential.store.impl.SSHCredentialWriter;
-import org.apache.airavata.credential.util.TokenGenerator;
+import org.apache.airavata.credential.impl.store.SSHCredentialWriter;
+import org.apache.airavata.credential.utils.TokenGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,17 +32,14 @@ public class SSHCredentialTest {
private static final Logger logger = LoggerFactory.getLogger(SSHCredentialTest.class);
public static void main(String[] args) {
- String jdbcURL = "jdbc:mysql://gw85.iu.xsede.org:3306/airavata_gw119";
- String jdbcDriver = "com.mysql.jdbc.Driver";
- String userName = "gtaDevUser";
- String password = "gtaDevPWD";
String gatewayId = "phasta";
String privateKeyPath = "/Users/chathuri/Desktop/ssh_gw111/id_rsa";
String pubKeyPath = "/Users/chathuri/Desktop/ssh_gw111/id_rsa.pub";
try {
- DBUtil dbUtil = new DBUtil(jdbcURL, userName, password, jdbcDriver);
- SSHCredentialWriter writer = new SSHCredentialWriter(dbUtil);
+ // Note: SSHCredentialWriter is now a Spring component and should be autowired
+ // This test needs to be updated to use Spring Boot test context
+ SSHCredentialWriter writer = new SSHCredentialWriter();
SSHCredential sshCredential = new SSHCredential();
sshCredential.setGateway(gatewayId);
String token = TokenGenerator.generateToken(gatewayId, null);
diff --git a/airavata-api/src/test/java/org/apache/airavata/credential/util/ConfigurationReaderTest.java b/airavata-api/src/test/java/org/apache/airavata/credential/utils/ConfigurationReaderTest.java
similarity index 97%
rename from airavata-api/src/test/java/org/apache/airavata/credential/util/ConfigurationReaderTest.java
rename to airavata-api/src/test/java/org/apache/airavata/credential/utils/ConfigurationReaderTest.java
index 39ef9c547d..f589d85d08 100644
--- a/airavata-api/src/test/java/org/apache/airavata/credential/util/ConfigurationReaderTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/credential/utils/ConfigurationReaderTest.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.util;
+package org.apache.airavata.credential.utils;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/airavata-api/src/test/java/org/apache/airavata/credential/util/TokenGeneratorTest.java b/airavata-api/src/test/java/org/apache/airavata/credential/utils/TokenGeneratorTest.java
similarity index 96%
rename from airavata-api/src/test/java/org/apache/airavata/credential/util/TokenGeneratorTest.java
rename to airavata-api/src/test/java/org/apache/airavata/credential/utils/TokenGeneratorTest.java
index 25ed63aa4f..091101d40c 100644
--- a/airavata-api/src/test/java/org/apache/airavata/credential/util/TokenGeneratorTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/credential/utils/TokenGeneratorTest.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.credential.util;
+package org.apache.airavata.credential.utils;
import static org.junit.jupiter.api.Assertions.assertNotNull;
diff --git a/airavata-api/src/test/java/org/apache/airavata/profile/iam/admin/services/core/SetupNewGateway.java b/airavata-api/src/test/java/org/apache/airavata/profile/entities/SetupNewGateway.java
similarity index 98%
rename from airavata-api/src/test/java/org/apache/airavata/profile/iam/admin/services/core/SetupNewGateway.java
rename to airavata-api/src/test/java/org/apache/airavata/profile/entities/SetupNewGateway.java
index 2fdc70b5ce..3e5571e80a 100644
--- a/airavata-api/src/test/java/org/apache/airavata/profile/iam/admin/services/core/SetupNewGateway.java
+++ b/airavata-api/src/test/java/org/apache/airavata/profile/entities/SetupNewGateway.java
@@ -17,7 +17,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.airavata.profile.iam.admin.services.core;
+package org.apache.airavata.profile.entities;
import java.util.ArrayList;
import java.util.List;
@@ -159,6 +159,8 @@ public class SetupNewGateway {
}
}
+ // Unused method - commented out
+ /*
private static PasswordCredential createTenantAdminCreds(String tenantId, String username, String password) {
PasswordCredential tenantAdminCreds = new PasswordCredential();
tenantAdminCreds.setGatewayId(tenantId);
@@ -166,4 +168,5 @@ public class SetupNewGateway {
tenantAdminCreds.setPassword(password);
return tenantAdminCreds;
}
+ */
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java
index bb6d91c3c2..5108b59559 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java
@@ -38,18 +38,14 @@ import org.apache.airavata.registry.utils.DBConstants;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
-@TestPropertySource(locations = "classpath:application-test.properties")
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ApplicationDeploymentRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ApplicationDeploymentRepositoryTest.class);
-
@Autowired
private ComputeResourceService computeResourceService;
@@ -192,7 +188,7 @@ public class ApplicationDeploymentRepositoryTest extends TestBase {
String computeResource = addSampleComputeResource("1");
ApplicationDeploymentDescription deployment = prepareSampleDeployment("1", applicationModule, computeResource);
- String deploymentId = applicationDeploymentService.addApplicationDeployment(deployment, gatewayId);
+ applicationDeploymentService.addApplicationDeployment(deployment, gatewayId);
ApplicationDeploymentDescription savedDeployment =
applicationDeploymentService.getApplicationDeployement("appDep1");
Assertions.assertNotNull(savedDeployment);
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
index 3530d8459d..5c336099d3 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
@@ -33,27 +33,34 @@ import org.apache.airavata.model.application.io.OutputDataObjectType;
import org.apache.airavata.model.parallelism.ApplicationParallelismType;
import org.apache.airavata.registry.exceptions.AppCatalogException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ApplicationDeploymentService;
+import org.apache.airavata.registry.services.ApplicationInterfaceService;
+import org.apache.airavata.registry.services.ComputeResourceService;
import org.apache.airavata.registry.utils.DBConstants;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ApplicationInterfaceRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ApplicationInterfaceRepositoryTest.class);
+ @Autowired
+ private ApplicationInterfaceService applicationInterfaceService;
+
+ @Autowired
+ private ComputeResourceService computeResourceService;
+
+ @Autowired
+ private ApplicationDeploymentService applicationDeploymentService;
- private ApplicationInterfaceRepository applicationInterfaceRepository;
- private ComputeResourceRepository computeResourceRepository;
- private ApplicationDeploymentRepository applicationDeploymentRepository;
private String gatewayId = "testGateway";
public ApplicationInterfaceRepositoryTest() {
super(TestBase.Database.APP_CATALOG);
- computeResourceRepository = new ComputeResourceRepository();
- applicationInterfaceRepository = new ApplicationInterfaceRepository();
- applicationDeploymentRepository = new ApplicationDeploymentRepository();
}
@Test
@@ -63,9 +70,9 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationModule.setAppModuleName("appMod1Name");
applicationModule.setAppModuleDescription("Description");
applicationModule.setAppModuleVersion("Version1");
- String moduleId = applicationInterfaceRepository.addApplicationModule(applicationModule, gatewayId);
+ String moduleId = applicationInterfaceService.addApplicationModule(applicationModule, gatewayId);
- ApplicationModule savedAppModule = applicationInterfaceRepository.getApplicationModule(moduleId);
+ ApplicationModule savedAppModule = applicationInterfaceService.getApplicationModule(moduleId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(applicationModule, savedAppModule));
}
@@ -75,9 +82,9 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationModule.setAppModuleName("appMod1Name");
applicationModule.setAppModuleDescription("Description");
applicationModule.setAppModuleVersion("Version1");
- String moduleId = applicationInterfaceRepository.addApplicationModule(applicationModule, gatewayId);
+ String moduleId = applicationInterfaceService.addApplicationModule(applicationModule, gatewayId);
- ApplicationModule savedAppModule = applicationInterfaceRepository.getApplicationModule(moduleId);
+ ApplicationModule savedAppModule = applicationInterfaceService.getApplicationModule(moduleId);
Assertions.assertNotEquals(applicationModule.getAppModuleName(), savedAppModule.getAppModuleId());
Assertions.assertTrue(savedAppModule.getAppModuleId().startsWith(applicationModule.getAppModuleName()));
}
@@ -85,17 +92,17 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
@Test
public void deleteApplicationModuleTest() throws AppCatalogException {
- Assertions.assertNull(applicationInterfaceRepository.getApplicationModule("appMod1"));
+ Assertions.assertNull(applicationInterfaceService.getApplicationModule("appMod1"));
ApplicationModule applicationModule = new ApplicationModule();
applicationModule.setAppModuleId("appMod1");
applicationModule.setAppModuleName("appMod1Name");
- String moduleId = applicationInterfaceRepository.addApplicationModule(applicationModule, gatewayId);
- Assertions.assertNotNull(applicationInterfaceRepository.getApplicationModule(moduleId));
+ String moduleId = applicationInterfaceService.addApplicationModule(applicationModule, gatewayId);
+ Assertions.assertNotNull(applicationInterfaceService.getApplicationModule(moduleId));
- Assertions.assertTrue(applicationInterfaceRepository.removeApplicationModule("appMod1"));
+ Assertions.assertTrue(applicationInterfaceService.removeApplicationModule("appMod1"));
- Assertions.assertNull(applicationInterfaceRepository.getApplicationModule("appMod1"));
+ Assertions.assertNull(applicationInterfaceService.getApplicationModule("appMod1"));
}
@Test
@@ -105,18 +112,18 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationModule.setAppModuleName("appMod1Name");
applicationModule.setAppModuleDescription("Description");
applicationModule.setAppModuleVersion("Version1");
- String moduleId = applicationInterfaceRepository.addApplicationModule(applicationModule, gatewayId);
+ String moduleId = applicationInterfaceService.addApplicationModule(applicationModule, gatewayId);
- ApplicationModule savedAppModule = applicationInterfaceRepository.getApplicationModule(moduleId);
+ ApplicationModule savedAppModule = applicationInterfaceService.getApplicationModule(moduleId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(applicationModule, savedAppModule));
savedAppModule.setAppModuleName("Updated Name");
savedAppModule.setAppModuleDescription("Updated Description");
savedAppModule.setAppModuleVersion("new version");
- applicationInterfaceRepository.updateApplicationModule("appMod1", savedAppModule);
+ applicationInterfaceService.updateApplicationModule("appMod1", savedAppModule);
- ApplicationModule updatedAppModule = applicationInterfaceRepository.getApplicationModule(moduleId);
+ ApplicationModule updatedAppModule = applicationInterfaceService.getApplicationModule(moduleId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(savedAppModule, updatedAppModule));
}
@@ -130,11 +137,11 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationOutputs(new ArrayList<>());
String interfaceId =
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gatewayId);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gatewayId);
assertEquals(applicationInterfaceDescription.getApplicationInterfaceId(), interfaceId);
ApplicationInterfaceDescription savedInterface =
- applicationInterfaceRepository.getApplicationInterface(interfaceId);
+ applicationInterfaceService.getApplicationInterface(interfaceId);
Assertions.assertTrue(
EqualsBuilder.reflectionEquals(applicationInterfaceDescription, savedInterface, "__isset_bitfield"));
}
@@ -164,7 +171,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationOutputs(new ArrayList<>());
String interfaceId =
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gatewayId);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gatewayId);
Assertions.assertTrue(
interfaceId.startsWith("app_interface_1"),
MessageFormat.format("{0} does not start with {1}", interfaceId, "app_interface_1"));
@@ -173,7 +180,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
@Test
public void deleteApplicationInterfaceTest() throws AppCatalogException {
- Assertions.assertNull(applicationInterfaceRepository.getApplicationModule("interface1"));
+ Assertions.assertNull(applicationInterfaceService.getApplicationModule("interface1"));
ApplicationInterfaceDescription applicationInterfaceDescription = new ApplicationInterfaceDescription();
applicationInterfaceDescription.setApplicationInterfaceId("interface1");
@@ -211,11 +218,11 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.addToApplicationOutputs(output);
String interfaceId =
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gatewayId);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gatewayId);
- Assertions.assertNotNull(applicationInterfaceRepository.getApplicationInterface(interfaceId));
- Assertions.assertTrue(applicationInterfaceRepository.removeApplicationInterface(interfaceId));
- Assertions.assertNull(applicationInterfaceRepository.getApplicationInterface(interfaceId));
+ Assertions.assertNotNull(applicationInterfaceService.getApplicationInterface(interfaceId));
+ Assertions.assertTrue(applicationInterfaceService.removeApplicationInterface(interfaceId));
+ Assertions.assertNull(applicationInterfaceService.getApplicationInterface(interfaceId));
}
@Test
@@ -223,25 +230,25 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
ApplicationModule applicationModule1 = new ApplicationModule();
applicationModule1.setAppModuleId("appMod1");
applicationModule1.setAppModuleName("appMod1Name");
- String moduleId1 = applicationInterfaceRepository.addApplicationModule(applicationModule1, gatewayId);
+ String moduleId1 = applicationInterfaceService.addApplicationModule(applicationModule1, gatewayId);
ApplicationModule applicationModule2 = new ApplicationModule();
applicationModule2.setAppModuleId("appMod2");
applicationModule2.setAppModuleName("appMod2Name");
- String moduleId2 = applicationInterfaceRepository.addApplicationModule(applicationModule2, gatewayId);
+ String moduleId2 = applicationInterfaceService.addApplicationModule(applicationModule2, gatewayId);
ApplicationInterfaceDescription applicationInterfaceDescription = new ApplicationInterfaceDescription();
applicationInterfaceDescription.setApplicationInterfaceId("interface1");
applicationInterfaceDescription.setApplicationName("app interface 1");
String interfaceId =
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gatewayId);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gatewayId);
- applicationInterfaceRepository.addApplicationModuleMapping(moduleId1, interfaceId);
- applicationInterfaceRepository.addApplicationModuleMapping(moduleId2, interfaceId);
+ applicationInterfaceService.addApplicationModuleMapping(moduleId1, interfaceId);
+ applicationInterfaceService.addApplicationModuleMapping(moduleId2, interfaceId);
ApplicationInterfaceDescription savedInterface =
- applicationInterfaceRepository.getApplicationInterface(interfaceId);
+ applicationInterfaceService.getApplicationInterface(interfaceId);
Assertions.assertEquals(savedInterface.getApplicationModules().get(0), applicationModule1.getAppModuleId());
Assertions.assertEquals(savedInterface.getApplicationModules().get(1), applicationModule2.getAppModuleId());
@@ -255,7 +262,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationName("app interface 1");
String interfaceId =
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gatewayId);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gatewayId);
InputDataObjectType input = new InputDataObjectType();
input.setName("input1");
@@ -291,10 +298,10 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationInputs(Collections.singletonList(input));
applicationInterfaceDescription.setApplicationOutputs(Collections.singletonList(output));
- applicationInterfaceRepository.updateApplicationInterface(interfaceId, applicationInterfaceDescription);
+ applicationInterfaceService.updateApplicationInterface(interfaceId, applicationInterfaceDescription);
ApplicationInterfaceDescription savedInterface =
- applicationInterfaceRepository.getApplicationInterface(interfaceId);
+ applicationInterfaceService.getApplicationInterface(interfaceId);
Assertions.assertEquals(1, savedInterface.getApplicationInputsSize());
Assertions.assertEquals(1, savedInterface.getApplicationOutputsSize());
@@ -303,8 +310,8 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
Assertions.assertTrue(EqualsBuilder.reflectionEquals(
output, savedInterface.getApplicationOutputs().get(0), "__isset_bitfield"));
- List<InputDataObjectType> savedInputs = applicationInterfaceRepository.getApplicationInputs(interfaceId);
- List<OutputDataObjectType> savedOutputs = applicationInterfaceRepository.getApplicationOutputs(interfaceId);
+ List<InputDataObjectType> savedInputs = applicationInterfaceService.getApplicationInputs(interfaceId);
+ List<OutputDataObjectType> savedOutputs = applicationInterfaceService.getApplicationOutputs(interfaceId);
Assertions.assertEquals(1, savedInputs.size());
Assertions.assertEquals(1, savedOutputs.size());
@@ -321,7 +328,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationName("app interface 1");
String interfaceId =
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gatewayId);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gatewayId);
InputDataObjectType input = new InputDataObjectType();
input.setName("input1");
@@ -359,19 +366,19 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationInputs(Arrays.asList(input, input2));
applicationInterfaceDescription.setApplicationOutputs(Arrays.asList(output, output2));
- applicationInterfaceRepository.updateApplicationInterface(interfaceId, applicationInterfaceDescription);
+ applicationInterfaceService.updateApplicationInterface(interfaceId, applicationInterfaceDescription);
ApplicationInterfaceDescription savedInterface =
- applicationInterfaceRepository.getApplicationInterface(interfaceId);
+ applicationInterfaceService.getApplicationInterface(interfaceId);
Assertions.assertEquals(2, savedInterface.getApplicationInputsSize());
Assertions.assertEquals(2, savedInterface.getApplicationOutputsSize());
savedInterface.setApplicationInputs(Arrays.asList(input));
savedInterface.setApplicationOutputs(Arrays.asList(output));
- applicationInterfaceRepository.updateApplicationInterface(interfaceId, savedInterface);
+ applicationInterfaceService.updateApplicationInterface(interfaceId, savedInterface);
ApplicationInterfaceDescription updatedInterface =
- applicationInterfaceRepository.getApplicationInterface(interfaceId);
+ applicationInterfaceService.getApplicationInterface(interfaceId);
Assertions.assertEquals(1, updatedInterface.getApplicationInputsSize());
Assertions.assertEquals(1, updatedInterface.getApplicationOutputsSize());
}
@@ -385,7 +392,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationInterfaceId("interface" + i);
applicationInterfaceDescription.setApplicationName("app interface " + i);
interfaces.add(applicationInterfaceDescription);
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gatewayId);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gatewayId);
}
for (ApplicationInterfaceDescription iface : interfaces) {
@@ -393,7 +400,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
filters.put(DBConstants.ApplicationInterface.APPLICATION_NAME, iface.getApplicationName());
assertEquals(
iface.getApplicationName(),
- applicationInterfaceRepository
+ applicationInterfaceService
.getApplicationInterfaces(filters)
.get(0)
.getApplicationName());
@@ -410,7 +417,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationModule.setAppModuleDescription("Description");
applicationModule.setAppModuleVersion("Version1");
modules.add(applicationModule);
- applicationInterfaceRepository.addApplicationModule(applicationModule, gatewayId);
+ applicationInterfaceService.addApplicationModule(applicationModule, gatewayId);
}
for (ApplicationModule module : modules) {
@@ -418,7 +425,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
filters.put(DBConstants.ApplicationModule.APPLICATION_MODULE_NAME, module.getAppModuleName());
assertEquals(
module.getAppModuleName(),
- applicationInterfaceRepository
+ applicationInterfaceService
.getApplicationModules(filters)
.get(0)
.getAppModuleName());
@@ -433,12 +440,12 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationModule.setAppModuleName("appMod1Name");
applicationModule.setAppModuleDescription("Description");
applicationModule.setAppModuleVersion("Version1");
- applicationInterfaceRepository.addApplicationModule(applicationModule, gatewayId);
+ applicationInterfaceService.addApplicationModule(applicationModule, gatewayId);
Map<String, String> filters = new HashMap<>();
filters.put("INVALID KEY", applicationModule.getAppModuleName());
try {
- applicationInterfaceRepository.getApplicationModules(filters).get(0).getAppModuleName();
+ applicationInterfaceService.getApplicationModules(filters).get(0).getAppModuleName();
Assertions.fail("Expected to throw an exception");
} catch (IllegalArgumentException e) {
// ignore
@@ -451,15 +458,12 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
ApplicationInterfaceDescription applicationInterfaceDescription = new ApplicationInterfaceDescription();
applicationInterfaceDescription.setApplicationInterfaceId("interface1");
applicationInterfaceDescription.setApplicationName("app interface");
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gatewayId);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gatewayId);
Map<String, String> filters = new HashMap<>();
filters.put("INVALID KEY", applicationInterfaceDescription.getApplicationName());
try {
- applicationInterfaceRepository
- .getApplicationInterfaces(filters)
- .get(0)
- .getApplicationName();
+ applicationInterfaceService.getApplicationInterfaces(filters).get(0).getApplicationName();
Assertions.fail("Expected to throw an exception");
} catch (IllegalArgumentException e) {
// ignore
@@ -472,22 +476,22 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
ComputeResourceDescription computeResourceDescription1 = new ComputeResourceDescription();
computeResourceDescription1.setComputeResourceId("compHost1");
computeResourceDescription1.setHostName("compHost1Name");
- String computeResourceId1 = computeResourceRepository.addComputeResource(computeResourceDescription1);
+ String computeResourceId1 = computeResourceService.addComputeResource(computeResourceDescription1);
ComputeResourceDescription computeResourceDescription2 = new ComputeResourceDescription();
computeResourceDescription2.setComputeResourceId("compHost2");
computeResourceDescription2.setHostName("compHost2Name");
- String computeResourceId2 = computeResourceRepository.addComputeResource(computeResourceDescription2);
+ String computeResourceId2 = computeResourceService.addComputeResource(computeResourceDescription2);
ApplicationModule applicationModule1 = new ApplicationModule();
applicationModule1.setAppModuleId("appMod1");
applicationModule1.setAppModuleName("appMod1Name");
- String moduleId1 = applicationInterfaceRepository.addApplicationModule(applicationModule1, gatewayId);
+ String moduleId1 = applicationInterfaceService.addApplicationModule(applicationModule1, gatewayId);
ApplicationModule applicationModule2 = new ApplicationModule();
applicationModule2.setAppModuleId("appMod2");
applicationModule2.setAppModuleName("appMod2Name");
- String moduleId2 = applicationInterfaceRepository.addApplicationModule(applicationModule2, gatewayId);
+ applicationInterfaceService.addApplicationModule(applicationModule2, gatewayId);
ApplicationDeploymentDescription applicationDeploymentDescription1 = new ApplicationDeploymentDescription();
applicationDeploymentDescription1.setAppDeploymentId("appDep1");
@@ -496,10 +500,9 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationDeploymentDescription1.setExecutablePath("executablePath");
applicationDeploymentDescription1.setParallelism(ApplicationParallelismType.SERIAL);
String deploymentId1 =
- applicationDeploymentRepository.addApplicationDeployment(applicationDeploymentDescription1, gatewayId);
+ applicationDeploymentService.addApplicationDeployment(applicationDeploymentDescription1, gatewayId);
- ApplicationDeploymentDescription applicationDeployement =
- applicationDeploymentRepository.getApplicationDeployement(deploymentId1);
+ applicationDeploymentService.getApplicationDeployement(deploymentId1);
ApplicationDeploymentDescription applicationDeploymentDescription2 = new ApplicationDeploymentDescription();
applicationDeploymentDescription2.setAppDeploymentId("appDep2");
@@ -508,14 +511,14 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationDeploymentDescription2.setExecutablePath("executablePath");
applicationDeploymentDescription2.setParallelism(ApplicationParallelismType.SERIAL);
String deploymentId2 =
- applicationDeploymentRepository.addApplicationDeployment(applicationDeploymentDescription2, gatewayId);
+ applicationDeploymentService.addApplicationDeployment(applicationDeploymentDescription2, gatewayId);
List<String> deploymentIds = new ArrayList<>();
deploymentIds.add(deploymentId1);
List<String> compHostIds = new ArrayList<>();
compHostIds.add(computeResourceId1);
List<ApplicationModule> appModuleList =
- applicationInterfaceRepository.getAccessibleApplicationModules(gatewayId, deploymentIds, compHostIds);
+ applicationInterfaceService.getAccessibleApplicationModules(gatewayId, deploymentIds, compHostIds);
assertEquals(1, appModuleList.size());
assertEquals(moduleId1, appModuleList.get(0).getAppModuleId());
@@ -525,7 +528,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
compHostIds = new ArrayList<>();
compHostIds.add(computeResourceId2);
appModuleList =
- applicationInterfaceRepository.getAccessibleApplicationModules(gatewayId, deploymentIds, compHostIds);
+ applicationInterfaceService.getAccessibleApplicationModules(gatewayId, deploymentIds, compHostIds);
assertEquals(0, appModuleList.size());
deploymentIds = new ArrayList<>();
@@ -533,7 +536,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
compHostIds = new ArrayList<>();
compHostIds.add(computeResourceId2);
appModuleList =
- applicationInterfaceRepository.getAccessibleApplicationModules(gatewayId, deploymentIds, compHostIds);
+ applicationInterfaceService.getAccessibleApplicationModules(gatewayId, deploymentIds, compHostIds);
assertEquals(1, appModuleList.size());
assertEquals(moduleId1, appModuleList.get(0).getAppModuleId());
@@ -544,7 +547,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
compHostIds.add(computeResourceId1);
compHostIds.add(computeResourceId2);
appModuleList =
- applicationInterfaceRepository.getAccessibleApplicationModules(gatewayId, deploymentIds, compHostIds);
+ applicationInterfaceService.getAccessibleApplicationModules(gatewayId, deploymentIds, compHostIds);
assertEquals(1, appModuleList.size());
assertEquals(moduleId1, appModuleList.get(0).getAppModuleId());
}
@@ -563,7 +566,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationModule.setAppModuleDescription(gateway + "Description");
applicationModule.setAppModuleVersion(gateway + "Version1");
modules.add(applicationModule);
- applicationInterfaceRepository.addApplicationModule(applicationModule, gateway);
+ applicationInterfaceService.addApplicationModule(applicationModule, gateway);
}
moduleStore.put(gateway, modules);
}
@@ -571,7 +574,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
for (int j = 0; j < 5; j++) {
String gateway = "gateway" + j;
List<ApplicationModule> allApplicationModules =
- applicationInterfaceRepository.getAllApplicationModules(gateway);
+ applicationInterfaceService.getAllApplicationModules(gateway);
Assertions.assertEquals(moduleStore.get(gateway).size(), allApplicationModules.size());
for (int i = 0; i < allApplicationModules.size(); i++) {
@@ -596,7 +599,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationInputs(new ArrayList<>());
applicationInterfaceDescription.setApplicationOutputs(new ArrayList<>());
interfaces.add(applicationInterfaceDescription);
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gateway);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gateway);
}
interfaceStore.put(gateway, interfaces);
}
@@ -604,7 +607,7 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
for (int j = 0; j < 5; j++) {
String gateway = "gateway" + j;
List<ApplicationInterfaceDescription> allApplicationInterfaces =
- applicationInterfaceRepository.getAllApplicationInterfaces(gateway);
+ applicationInterfaceService.getAllApplicationInterfaces(gateway);
Assertions.assertEquals(interfaceStore.get(gateway).size(), allApplicationInterfaces.size());
for (int i = 0; i < allApplicationInterfaces.size(); i++) {
@@ -628,11 +631,11 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
applicationInterfaceDescription.setApplicationInputs(new ArrayList<>());
applicationInterfaceDescription.setApplicationOutputs(new ArrayList<>());
interfaces.add(applicationInterfaceDescription);
- applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription, gateway);
+ applicationInterfaceService.addApplicationInterface(applicationInterfaceDescription, gateway);
}
}
- List<String> allApplicationInterfaceIds = applicationInterfaceRepository.getAllApplicationInterfaceIds();
+ List<String> allApplicationInterfaceIds = applicationInterfaceService.getAllApplicationInterfaceIds();
Assertions.assertEquals(interfaces.size(), allApplicationInterfaceIds.size());
for (int i = 0; i < interfaces.size(); i++) {
Assertions.assertEquals(interfaces.get(i).getApplicationInterfaceId(), allApplicationInterfaceIds.get(i));
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ComputeResourceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ComputeResourceRepositoryTest.java
index 2604644ec2..11412a0ca9 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ComputeResourceRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ComputeResourceRepositoryTest.java
@@ -25,50 +25,52 @@ import org.apache.airavata.model.data.movement.*;
import org.apache.airavata.model.parallelism.ApplicationParallelismType;
import org.apache.airavata.registry.exceptions.AppCatalogException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ComputeResourceService;
import org.apache.airavata.registry.utils.DBConstants;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ComputeResourceRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ComputeResourceRepositoryTest.class);
-
- private ComputeResourceRepository computeResourceRepository;
+ @Autowired
+ private ComputeResourceService computeResourceService;
public ComputeResourceRepositoryTest() {
super(Database.APP_CATALOG);
- computeResourceRepository = new ComputeResourceRepository();
}
@Test
public void removeBatchQueueTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(resourceJobManager);
+ computeResourceService.addResourceJobManager(resourceJobManager);
SSHJobSubmission sshJobSubmission = prepareSSHJobSubmission(resourceJobManager);
- String sshSubmissionId = computeResourceRepository.addSSHJobSubmission(sshJobSubmission);
+ String sshSubmissionId = computeResourceService.addSSHJobSubmission(sshJobSubmission);
SCPDataMovement scpDataMovement = prepareScpDataMovement();
- String scpDataMovementId = computeResourceRepository.addScpDataMovement(scpDataMovement);
+ String scpDataMovementId = computeResourceService.addScpDataMovement(scpDataMovement);
GridFTPDataMovement gridFTPDataMovement = prepareGridFTPDataMovement("192.156.33.44");
- String gridFTPDataMovementId = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement);
+ String gridFTPDataMovementId = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement);
ComputeResourceDescription computeResourceDescription =
prepareComputeResource(sshSubmissionId, scpDataMovementId, gridFTPDataMovementId, 4);
- String savedComputeResourceId = computeResourceRepository.addComputeResource(computeResourceDescription);
+ String savedComputeResourceId = computeResourceService.addComputeResource(computeResourceDescription);
List<BatchQueue> batchQueues = computeResourceDescription.getBatchQueues();
Assertions.assertTrue(batchQueues.size() > 0);
- computeResourceRepository.removeBatchQueue(
+ computeResourceService.removeBatchQueue(
savedComputeResourceId, batchQueues.get(0).getQueueName());
ComputeResourceDescription updatedComputeResource =
- computeResourceRepository.getComputeResource(savedComputeResourceId);
+ computeResourceService.getComputeResource(savedComputeResourceId);
List<BatchQueue> updatedBatchQueues = updatedComputeResource.getBatchQueues();
@@ -83,29 +85,29 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void removeDataMovementInterfaceTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(resourceJobManager);
+ computeResourceService.addResourceJobManager(resourceJobManager);
SSHJobSubmission sshJobSubmission = prepareSSHJobSubmission(resourceJobManager);
- String sshSubmissionId = computeResourceRepository.addSSHJobSubmission(sshJobSubmission);
+ String sshSubmissionId = computeResourceService.addSSHJobSubmission(sshJobSubmission);
SCPDataMovement scpDataMovement = prepareScpDataMovement();
- String scpDataMovementId = computeResourceRepository.addScpDataMovement(scpDataMovement);
+ String scpDataMovementId = computeResourceService.addScpDataMovement(scpDataMovement);
GridFTPDataMovement gridFTPDataMovement = prepareGridFTPDataMovement("192.156.33.44");
- String gridFTPDataMovementId = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement);
+ String gridFTPDataMovementId = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement);
ComputeResourceDescription computeResourceDescription =
prepareComputeResource(sshSubmissionId, scpDataMovementId, gridFTPDataMovementId, 4);
- String savedComputeResourceId = computeResourceRepository.addComputeResource(computeResourceDescription);
+ String savedComputeResourceId = computeResourceService.addComputeResource(computeResourceDescription);
List<DataMovementInterface> dataMovementInterfaces = computeResourceDescription.getDataMovementInterfaces();
Assertions.assertTrue(dataMovementInterfaces.size() > 0);
- computeResourceRepository.removeDataMovementInterface(
+ computeResourceService.removeDataMovementInterface(
savedComputeResourceId, dataMovementInterfaces.get(0).getDataMovementInterfaceId());
ComputeResourceDescription updatedComputeResource =
- computeResourceRepository.getComputeResource(savedComputeResourceId);
+ computeResourceService.getComputeResource(savedComputeResourceId);
List<DataMovementInterface> updatedDataMovementInterfaces = updatedComputeResource.getDataMovementInterfaces();
@@ -121,29 +123,29 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void removeJobSubmissionInterfaceTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(resourceJobManager);
+ computeResourceService.addResourceJobManager(resourceJobManager);
SSHJobSubmission sshJobSubmission = prepareSSHJobSubmission(resourceJobManager);
- String sshSubmissionId = computeResourceRepository.addSSHJobSubmission(sshJobSubmission);
+ String sshSubmissionId = computeResourceService.addSSHJobSubmission(sshJobSubmission);
SCPDataMovement scpDataMovement = prepareScpDataMovement();
- String scpDataMovementId = computeResourceRepository.addScpDataMovement(scpDataMovement);
+ String scpDataMovementId = computeResourceService.addScpDataMovement(scpDataMovement);
GridFTPDataMovement gridFTPDataMovement = prepareGridFTPDataMovement("192.156.33.44");
- String gridFTPDataMovementId = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement);
+ String gridFTPDataMovementId = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement);
ComputeResourceDescription computeResourceDescription =
prepareComputeResource(sshSubmissionId, scpDataMovementId, gridFTPDataMovementId, 4);
- String savedComputeResourceId = computeResourceRepository.addComputeResource(computeResourceDescription);
+ String savedComputeResourceId = computeResourceService.addComputeResource(computeResourceDescription);
List<JobSubmissionInterface> jobSubmissionInterfaces = computeResourceDescription.getJobSubmissionInterfaces();
Assertions.assertTrue(jobSubmissionInterfaces.size() > 0);
- computeResourceRepository.removeJobSubmissionInterface(
+ computeResourceService.removeJobSubmissionInterface(
savedComputeResourceId, jobSubmissionInterfaces.get(0).getJobSubmissionInterfaceId());
ComputeResourceDescription updatedComputeResource =
- computeResourceRepository.getComputeResource(savedComputeResourceId);
+ computeResourceService.getComputeResource(savedComputeResourceId);
List<JobSubmissionInterface> updatedJobSubmissionInterfaces =
updatedComputeResource.getJobSubmissionInterfaces();
@@ -160,15 +162,15 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void listComputeResourcesTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(resourceJobManager);
+ computeResourceService.addResourceJobManager(resourceJobManager);
SSHJobSubmission sshJobSubmission = prepareSSHJobSubmission(resourceJobManager);
- String sshSubmissionId = computeResourceRepository.addSSHJobSubmission(sshJobSubmission);
+ String sshSubmissionId = computeResourceService.addSSHJobSubmission(sshJobSubmission);
SCPDataMovement scpDataMovement = prepareScpDataMovement();
- String scpDataMovementId = computeResourceRepository.addScpDataMovement(scpDataMovement);
+ String scpDataMovementId = computeResourceService.addScpDataMovement(scpDataMovement);
GridFTPDataMovement gridFTPDataMovement = prepareGridFTPDataMovement("192.156.33.44");
- String gridFTPDataMovementId = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement);
+ String gridFTPDataMovementId = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement);
List<String> allIds = new ArrayList<>();
List<ComputeResourceDescription> allComputeResources = new ArrayList<>();
@@ -178,14 +180,13 @@ public class ComputeResourceRepositoryTest extends TestBase {
prepareComputeResource(sshSubmissionId, scpDataMovementId, gridFTPDataMovementId, 4);
computeResourceDescription.setHostName("Host" + i);
computeResourceDescription.setEnabled((i % 2 == 0));
- String savedId = computeResourceRepository.addComputeResource(computeResourceDescription);
+ String savedId = computeResourceService.addComputeResource(computeResourceDescription);
allIds.add(savedId);
allComputeResources.add(computeResourceDescription);
allComputeResourceMap.put(savedId, computeResourceDescription.getHostName());
}
- List<ComputeResourceDescription> allSavedComputeResources =
- computeResourceRepository.getAllComputeResourceList();
+ List<ComputeResourceDescription> allSavedComputeResources = computeResourceService.getAllComputeResourceList();
Assertions.assertEquals(5, allSavedComputeResources.size());
for (int i = 0; i < 5; i++) {
@@ -193,7 +194,7 @@ public class ComputeResourceRepositoryTest extends TestBase {
deepCompareComputeResourceDescription(allComputeResources.get(i), allSavedComputeResources.get(i)));
}
- Map<String, String> allSavedComputeResourceIds = computeResourceRepository.getAllComputeResourceIdList();
+ Map<String, String> allSavedComputeResourceIds = computeResourceService.getAllComputeResourceIdList();
Assertions.assertEquals(5, allSavedComputeResourceIds.size());
@@ -203,7 +204,7 @@ public class ComputeResourceRepositoryTest extends TestBase {
Assertions.assertEquals(allComputeResourceMap.get(id), host);
}
- Map<String, String> allAvailableIds = computeResourceRepository.getAvailableComputeResourceIdList();
+ Map<String, String> allAvailableIds = computeResourceService.getAvailableComputeResourceIdList();
Assertions.assertEquals(3, allAvailableIds.size());
Assertions.assertNotNull(allAvailableIds.get(allIds.get(0)));
@@ -215,27 +216,26 @@ public class ComputeResourceRepositoryTest extends TestBase {
public void filterComputeResourcesTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(resourceJobManager);
+ computeResourceService.addResourceJobManager(resourceJobManager);
SSHJobSubmission sshJobSubmission = prepareSSHJobSubmission(resourceJobManager);
- String sshSubmissionId = computeResourceRepository.addSSHJobSubmission(sshJobSubmission);
+ String sshSubmissionId = computeResourceService.addSSHJobSubmission(sshJobSubmission);
SCPDataMovement scpDataMovement = prepareScpDataMovement();
- String scpDataMovementId = computeResourceRepository.addScpDataMovement(scpDataMovement);
+ String scpDataMovementId = computeResourceService.addScpDataMovement(scpDataMovement);
GridFTPDataMovement gridFTPDataMovement = prepareGridFTPDataMovement("192.156.33.44");
- String gridFTPDataMovementId = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement);
+ String gridFTPDataMovementId = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement);
ComputeResourceDescription computeResourceDescription =
prepareComputeResource(sshSubmissionId, scpDataMovementId, gridFTPDataMovementId, 4);
Map<String, String> cfilters = new HashMap<String, String>();
cfilters.put(DBConstants.ComputeResource.HOST_NAME, "localhost");
- List<ComputeResourceDescription> computeResourceList =
- computeResourceRepository.getComputeResourceList(cfilters);
+ List<ComputeResourceDescription> computeResourceList = computeResourceService.getComputeResourceList(cfilters);
Assertions.assertEquals(0, computeResourceList.size());
- String computeResourceId = computeResourceRepository.addComputeResource(computeResourceDescription);
- computeResourceList = computeResourceRepository.getComputeResourceList(cfilters);
+ String computeResourceId = computeResourceService.addComputeResource(computeResourceDescription);
+ computeResourceList = computeResourceService.getComputeResourceList(cfilters);
Assertions.assertEquals(1, computeResourceList.size());
@@ -244,7 +244,7 @@ public class ComputeResourceRepositoryTest extends TestBase {
try {
cfilters = new HashMap<String, String>();
cfilters.put("Invalid_filter", "localhost");
- computeResourceRepository.getComputeResourceList(cfilters);
+ computeResourceService.getComputeResourceList(cfilters);
Assertions.fail();
} catch (Exception e) {
// ignore
@@ -254,22 +254,21 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void updateComputeResourceTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(resourceJobManager);
+ computeResourceService.addResourceJobManager(resourceJobManager);
SSHJobSubmission sshJobSubmission = prepareSSHJobSubmission(resourceJobManager);
- String sshSubmissionId = computeResourceRepository.addSSHJobSubmission(sshJobSubmission);
+ String sshSubmissionId = computeResourceService.addSSHJobSubmission(sshJobSubmission);
SCPDataMovement scpDataMovement = prepareScpDataMovement();
- String scpDataMovementId = computeResourceRepository.addScpDataMovement(scpDataMovement);
+ String scpDataMovementId = computeResourceService.addScpDataMovement(scpDataMovement);
GridFTPDataMovement gridFTPDataMovement = prepareGridFTPDataMovement("192.156.33.44");
- String gridFTPDataMovementId = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement);
+ String gridFTPDataMovementId = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement);
ComputeResourceDescription computeResourceDescription =
prepareComputeResource(sshSubmissionId, scpDataMovementId, gridFTPDataMovementId, 4);
- String computeResourceId = computeResourceRepository.addComputeResource(computeResourceDescription);
+ String computeResourceId = computeResourceService.addComputeResource(computeResourceDescription);
- ComputeResourceDescription savedComputeResource =
- computeResourceRepository.getComputeResource(computeResourceId);
+ ComputeResourceDescription savedComputeResource = computeResourceService.getComputeResource(computeResourceId);
savedComputeResource.getHostAliases().add("New Alias");
BatchQueue batchQueue = new BatchQueue();
@@ -291,10 +290,10 @@ public class ComputeResourceRepositoryTest extends TestBase {
savedComputeResource.setCpusPerNode(43);
savedComputeResource.setDefaultWalltime(4343);
- computeResourceRepository.updateComputeResource(computeResourceId, savedComputeResource);
+ computeResourceService.updateComputeResource(computeResourceId, savedComputeResource);
ComputeResourceDescription updatedComputeResource =
- computeResourceRepository.getComputeResource(computeResourceId);
+ computeResourceService.getComputeResource(computeResourceId);
Assertions.assertTrue(deepCompareComputeResourceDescription(savedComputeResource, updatedComputeResource));
}
@@ -302,26 +301,26 @@ public class ComputeResourceRepositoryTest extends TestBase {
public void addComputeResourceTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(resourceJobManager);
+ computeResourceService.addResourceJobManager(resourceJobManager);
SSHJobSubmission sshJobSubmission = prepareSSHJobSubmission(resourceJobManager);
- String sshSubmissionId = computeResourceRepository.addSSHJobSubmission(sshJobSubmission);
+ String sshSubmissionId = computeResourceService.addSSHJobSubmission(sshJobSubmission);
SCPDataMovement scpDataMovement = prepareScpDataMovement();
- String scpDataMovementId = computeResourceRepository.addScpDataMovement(scpDataMovement);
+ String scpDataMovementId = computeResourceService.addScpDataMovement(scpDataMovement);
GridFTPDataMovement gridFTPDataMovement = prepareGridFTPDataMovement("192.156.33.44");
- String gridFTPDataMovementId = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement);
+ String gridFTPDataMovementId = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement);
ComputeResourceDescription computeResourceDescription =
prepareComputeResource(sshSubmissionId, scpDataMovementId, gridFTPDataMovementId, 4);
computeResourceDescription.setComputeResourceId("manually-entered-id");
- Assertions.assertNull(computeResourceRepository.getComputeResource("manually-entered-id"));
- String computeResourceId = computeResourceRepository.addComputeResource(computeResourceDescription);
+ Assertions.assertNull(computeResourceService.getComputeResource("manually-entered-id"));
+ String computeResourceId = computeResourceService.addComputeResource(computeResourceDescription);
Assertions.assertEquals("manually-entered-id", computeResourceId);
- Assertions.assertTrue(computeResourceRepository.isComputeResourceExists(computeResourceId));
+ Assertions.assertTrue(computeResourceService.isComputeResourceExists(computeResourceId));
ComputeResourceDescription savedComputeResource =
- computeResourceRepository.getComputeResource("manually-entered-id");
+ computeResourceService.getComputeResource("manually-entered-id");
Assertions.assertNotNull(savedComputeResource);
Assertions.assertTrue(deepCompareComputeResourceDescription(computeResourceDescription, savedComputeResource));
@@ -330,34 +329,34 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void addResourceJobManagerTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- String jobManagerId = computeResourceRepository.addResourceJobManager(resourceJobManager);
- ResourceJobManager savedJobManager = computeResourceRepository.getResourceJobManager(jobManagerId);
+ String jobManagerId = computeResourceService.addResourceJobManager(resourceJobManager);
+ ResourceJobManager savedJobManager = computeResourceService.getResourceJobManager(jobManagerId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(resourceJobManager, savedJobManager, "__isset_bitfield"));
}
@Test
public void deleteResourceJobManagerTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- String jobManagerId = computeResourceRepository.addResourceJobManager(resourceJobManager);
+ String jobManagerId = computeResourceService.addResourceJobManager(resourceJobManager);
- Assertions.assertNotNull(computeResourceRepository.getResourceJobManager(jobManagerId));
- computeResourceRepository.deleteResourceJobManager(jobManagerId);
- Assertions.assertNull(computeResourceRepository.getResourceJobManager(jobManagerId));
+ Assertions.assertNotNull(computeResourceService.getResourceJobManager(jobManagerId));
+ computeResourceService.deleteResourceJobManager(jobManagerId);
+ Assertions.assertNull(computeResourceService.getResourceJobManager(jobManagerId));
}
@Test
public void updateResourceJobManagerTest() throws AppCatalogException {
ResourceJobManager resourceJobManager = prepareResourceJobManager();
- String jobManagerId = computeResourceRepository.addResourceJobManager(resourceJobManager);
- ResourceJobManager savedJobManager = computeResourceRepository.getResourceJobManager(jobManagerId);
+ String jobManagerId = computeResourceService.addResourceJobManager(resourceJobManager);
+ ResourceJobManager savedJobManager = computeResourceService.getResourceJobManager(jobManagerId);
savedJobManager.setJobManagerBinPath("/new bin");
savedJobManager.getJobManagerCommands().put(JobManagerCommand.SHOW_START, "New Command Value");
savedJobManager.getParallelismPrefix().put(ApplicationParallelismType.MPI, "MPI Type");
- computeResourceRepository.updateResourceJobManager(jobManagerId, savedJobManager);
+ computeResourceService.updateResourceJobManager(jobManagerId, savedJobManager);
- ResourceJobManager updatedJobManager = computeResourceRepository.getResourceJobManager(jobManagerId);
+ ResourceJobManager updatedJobManager = computeResourceService.getResourceJobManager(jobManagerId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(savedJobManager, updatedJobManager, "__isset_bitfield"));
}
@@ -365,8 +364,8 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void addUnicoreJobSubmissionTest() throws AppCatalogException {
UnicoreJobSubmission unicoreJobSubmission = prepareUnicoreJobSubmission();
- String savedSubmissionId = computeResourceRepository.addUNICOREJobSubmission(unicoreJobSubmission);
- UnicoreJobSubmission savedSubmission = computeResourceRepository.getUNICOREJobSubmission(savedSubmissionId);
+ String savedSubmissionId = computeResourceService.addUNICOREJobSubmission(unicoreJobSubmission);
+ UnicoreJobSubmission savedSubmission = computeResourceService.getUNICOREJobSubmission(savedSubmissionId);
Assertions.assertTrue(
EqualsBuilder.reflectionEquals(unicoreJobSubmission, savedSubmission, "__isset_bitfield"));
@@ -375,8 +374,8 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void addCloudJobSubmissionTest() throws AppCatalogException {
CloudJobSubmission cloudJobSubmission = prepareCloudJobSubmission();
- String savedSubmissionId = computeResourceRepository.addCloudJobSubmission(cloudJobSubmission);
- CloudJobSubmission savedSubmission = computeResourceRepository.getCloudJobSubmission(savedSubmissionId);
+ String savedSubmissionId = computeResourceService.addCloudJobSubmission(cloudJobSubmission);
+ CloudJobSubmission savedSubmission = computeResourceService.getCloudJobSubmission(savedSubmissionId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(cloudJobSubmission, savedSubmission, "__isset_bitfield"));
}
@@ -384,11 +383,11 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void addLocalJobSubmissionTest() throws AppCatalogException {
ResourceJobManager jobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(jobManager);
+ computeResourceService.addResourceJobManager(jobManager);
LOCALSubmission localSubmission = prepareLocalJobSubmission(jobManager);
- String savedSubmissionId = computeResourceRepository.addLocalJobSubmission(localSubmission);
- LOCALSubmission savedSubmission = computeResourceRepository.getLocalJobSubmission(savedSubmissionId);
+ String savedSubmissionId = computeResourceService.addLocalJobSubmission(localSubmission);
+ LOCALSubmission savedSubmission = computeResourceService.getLocalJobSubmission(savedSubmissionId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(localSubmission, savedSubmission, "__isset_bitfield"));
}
@@ -396,11 +395,11 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void addSSHJobSubmissionTest() throws AppCatalogException {
ResourceJobManager jobManager = prepareResourceJobManager();
- computeResourceRepository.addResourceJobManager(jobManager);
+ computeResourceService.addResourceJobManager(jobManager);
SSHJobSubmission sshJobSubmission = prepareSSHJobSubmission(jobManager);
- String jobSubmissionId = computeResourceRepository.addSSHJobSubmission(sshJobSubmission);
- SSHJobSubmission savedJobSubmission = computeResourceRepository.getSSHJobSubmission(jobSubmissionId);
+ String jobSubmissionId = computeResourceService.addSSHJobSubmission(sshJobSubmission);
+ SSHJobSubmission savedJobSubmission = computeResourceService.getSSHJobSubmission(jobSubmissionId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(sshJobSubmission, savedJobSubmission, "__isset_bitfield"));
}
@@ -408,27 +407,27 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void addSCPDataMovementTest() throws AppCatalogException {
SCPDataMovement scpDataMovement = prepareScpDataMovement();
- String dataMovementId = computeResourceRepository.addScpDataMovement(scpDataMovement);
+ String dataMovementId = computeResourceService.addScpDataMovement(scpDataMovement);
- SCPDataMovement savedDataMovement = computeResourceRepository.getSCPDataMovement(dataMovementId);
+ SCPDataMovement savedDataMovement = computeResourceService.getSCPDataMovement(dataMovementId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(scpDataMovement, savedDataMovement, "__isset_bitfield"));
}
@Test
public void addLocalDataMovementTest() throws AppCatalogException {
LOCALDataMovement localDataMovement = prepareLocalDataMovement();
- String dataMovementId = computeResourceRepository.addLocalDataMovement(localDataMovement);
+ String dataMovementId = computeResourceService.addLocalDataMovement(localDataMovement);
- LOCALDataMovement savedDataMovement = computeResourceRepository.getLocalDataMovement(dataMovementId);
+ LOCALDataMovement savedDataMovement = computeResourceService.getLocalDataMovement(dataMovementId);
Assertions.assertTrue(EqualsBuilder.reflectionEquals(localDataMovement, savedDataMovement, "__isset_bitfield"));
}
@Test
public void addUnicoreDataMovementTest() throws AppCatalogException {
UnicoreDataMovement unicoreDataMovement = prepareUnicoreDataMovement();
- String dataMovementId = computeResourceRepository.addUnicoreDataMovement(unicoreDataMovement);
+ String dataMovementId = computeResourceService.addUnicoreDataMovement(unicoreDataMovement);
- UnicoreDataMovement savedDataMovement = computeResourceRepository.getUNICOREDataMovement(dataMovementId);
+ UnicoreDataMovement savedDataMovement = computeResourceService.getUNICOREDataMovement(dataMovementId);
Assertions.assertTrue(
EqualsBuilder.reflectionEquals(unicoreDataMovement, savedDataMovement, "__isset_bitfield"));
}
@@ -436,30 +435,30 @@ public class ComputeResourceRepositoryTest extends TestBase {
@Test
public void addGridFTPDataMovementTest() throws AppCatalogException {
GridFTPDataMovement gridFTPDataMovement1 = prepareGridFTPDataMovement("222.33.43.444", "23.344.44.454");
- String dataMovementId1 = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement1);
- GridFTPDataMovement savedDataMovement1 = computeResourceRepository.getGridFTPDataMovement(dataMovementId1);
+ String dataMovementId1 = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement1);
+ GridFTPDataMovement savedDataMovement1 = computeResourceService.getGridFTPDataMovement(dataMovementId1);
Assertions.assertTrue(
EqualsBuilder.reflectionEquals(gridFTPDataMovement1, savedDataMovement1, "__isset_bitfield"));
GridFTPDataMovement gridFTPDataMovement2 = prepareGridFTPDataMovement("222.33.43.445", "23.344.44.400");
- String dataMovementId2 = computeResourceRepository.addGridFTPDataMovement(gridFTPDataMovement2);
- GridFTPDataMovement savedDataMovement2 = computeResourceRepository.getGridFTPDataMovement(dataMovementId2);
+ String dataMovementId2 = computeResourceService.addGridFTPDataMovement(gridFTPDataMovement2);
+ GridFTPDataMovement savedDataMovement2 = computeResourceService.getGridFTPDataMovement(dataMovementId2);
Assertions.assertTrue(
EqualsBuilder.reflectionEquals(gridFTPDataMovement2, savedDataMovement2, "__isset_bitfield"));
}
@Test
public void fetchNotAvailableResourceTest() throws AppCatalogException {
- Assertions.assertNull(computeResourceRepository.getResourceJobManager("INVALID ID"));
- Assertions.assertNull(computeResourceRepository.getComputeResource("INVALID ID"));
- Assertions.assertNull(computeResourceRepository.getCloudJobSubmission("INVALID ID"));
+ Assertions.assertNull(computeResourceService.getResourceJobManager("INVALID ID"));
+ Assertions.assertNull(computeResourceService.getComputeResource("INVALID ID"));
+ Assertions.assertNull(computeResourceService.getCloudJobSubmission("INVALID ID"));
Assertions.assertEquals(
- 0, computeResourceRepository.getFileSystems("INVALID ID").size());
- Assertions.assertNull(computeResourceRepository.getGridFTPDataMovement("INVALID ID"));
- Assertions.assertNull(computeResourceRepository.getLocalDataMovement("INVALID ID"));
- Assertions.assertNull(computeResourceRepository.getLocalJobSubmission("INVALID ID"));
- Assertions.assertNull(computeResourceRepository.getSCPDataMovement("INVALID ID"));
- Assertions.assertNull(computeResourceRepository.getUNICOREDataMovement("INVALID ID"));
+ 0, computeResourceService.getFileSystems("INVALID ID").size());
+ Assertions.assertNull(computeResourceService.getGridFTPDataMovement("INVALID ID"));
+ Assertions.assertNull(computeResourceService.getLocalDataMovement("INVALID ID"));
+ Assertions.assertNull(computeResourceService.getLocalJobSubmission("INVALID ID"));
+ Assertions.assertNull(computeResourceService.getSCPDataMovement("INVALID ID"));
+ Assertions.assertNull(computeResourceService.getUNICOREDataMovement("INVALID ID"));
}
private ComputeResourceDescription prepareComputeResource(
@@ -630,7 +629,7 @@ public class ComputeResourceRepositoryTest extends TestBase {
return equals;
}
- private boolean deepCompareArrayList(List expected, List actual, boolean preferOrder) {
+ private boolean deepCompareArrayList(List<?> expected, List<?> actual, boolean preferOrder) {
if ((expected == null) == (actual == null)) {
if (expected == null) {
return true;
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayGroupsRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayGroupsRepositoryTest.java
index 6844a6bca4..b536ccb2d0 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayGroupsRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayGroupsRepositoryTest.java
@@ -21,11 +21,15 @@ package org.apache.airavata.registry.repositories.appcatalog;
import org.apache.airavata.model.appcatalog.gatewaygroups.GatewayGroups;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.GatewayGroupsService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class GatewayGroupsRepositoryTest extends TestBase {
private static final String GATEWAY_ID = "gateway-id";
@@ -33,12 +37,11 @@ public class GatewayGroupsRepositoryTest extends TestBase {
private static final String READ_ONLY_ADMINS_GROUP_ID = "read-only-admins-group-id";
private static final String DEFAULT_GATEWAY_USERS_GROUP_ID = "default-gateway-users-group-id";
- private GatewayGroupsRepository gatewayGroupsRepository;
- private static final Logger logger = LoggerFactory.getLogger(GatewayProfileRepositoryTest.class);
+ @Autowired
+ private GatewayGroupsService gatewayGroupsService;
public GatewayGroupsRepositoryTest() {
super(Database.APP_CATALOG);
- gatewayGroupsRepository = new GatewayGroupsRepository();
}
@Test
@@ -50,16 +53,16 @@ public class GatewayGroupsRepositoryTest extends TestBase {
gatewayGroups.setReadOnlyAdminsGroupId(READ_ONLY_ADMINS_GROUP_ID);
gatewayGroups.setDefaultGatewayUsersGroupId(DEFAULT_GATEWAY_USERS_GROUP_ID);
- gatewayGroupsRepository.create(gatewayGroups);
+ gatewayGroupsService.create(gatewayGroups);
- GatewayGroups retrievedGatewayGroups = gatewayGroupsRepository.get(GATEWAY_ID);
+ GatewayGroups retrievedGatewayGroups = gatewayGroupsService.get(GATEWAY_ID);
Assertions.assertEquals(ADMIN_GROUPS_ID, retrievedGatewayGroups.getAdminsGroupId());
Assertions.assertEquals(READ_ONLY_ADMINS_GROUP_ID, retrievedGatewayGroups.getReadOnlyAdminsGroupId());
Assertions.assertEquals(DEFAULT_GATEWAY_USERS_GROUP_ID, retrievedGatewayGroups.getDefaultGatewayUsersGroupId());
Assertions.assertEquals(gatewayGroups, retrievedGatewayGroups);
- gatewayGroupsRepository.delete(GATEWAY_ID);
+ gatewayGroupsService.delete(GATEWAY_ID);
}
@Test
@@ -71,20 +74,20 @@ public class GatewayGroupsRepositoryTest extends TestBase {
gatewayGroups.setReadOnlyAdminsGroupId(READ_ONLY_ADMINS_GROUP_ID);
gatewayGroups.setDefaultGatewayUsersGroupId(DEFAULT_GATEWAY_USERS_GROUP_ID);
- gatewayGroupsRepository.create(gatewayGroups);
+ gatewayGroupsService.create(gatewayGroups);
final String defaultGatewayUsersGroupId = "some-other-group-id";
gatewayGroups.setDefaultGatewayUsersGroupId(defaultGatewayUsersGroupId);
- gatewayGroupsRepository.update(gatewayGroups);
+ gatewayGroupsService.update(gatewayGroups);
- GatewayGroups retrievedGatewayGroups = gatewayGroupsRepository.get(GATEWAY_ID);
+ GatewayGroups retrievedGatewayGroups = gatewayGroupsService.get(GATEWAY_ID);
Assertions.assertEquals(ADMIN_GROUPS_ID, retrievedGatewayGroups.getAdminsGroupId());
Assertions.assertEquals(READ_ONLY_ADMINS_GROUP_ID, retrievedGatewayGroups.getReadOnlyAdminsGroupId());
Assertions.assertEquals(defaultGatewayUsersGroupId, retrievedGatewayGroups.getDefaultGatewayUsersGroupId());
Assertions.assertEquals(gatewayGroups, retrievedGatewayGroups);
- gatewayGroupsRepository.delete(GATEWAY_ID);
+ gatewayGroupsService.delete(GATEWAY_ID);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayProfileRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayProfileRepositoryTest.java
index b563a2c991..90cf4d858d 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayProfileRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayProfileRepositoryTest.java
@@ -36,19 +36,29 @@ import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfil
import org.apache.airavata.model.data.movement.DataMovementProtocol;
import org.apache.airavata.registry.exceptions.AppCatalogException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ComputeResourceService;
+import org.apache.airavata.registry.services.GwyResourceProfileService;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class GatewayProfileRepositoryTest extends TestBase {
private static final Logger logger = LoggerFactory.getLogger(GatewayProfileRepositoryTest.class);
- private GwyResourceProfileRepository gwyResourceProfileRepository;
+ @Autowired
+ private GwyResourceProfileService gwyResourceProfileService;
+
+ @Autowired
+ private ComputeResourceService computeResourceService;
public GatewayProfileRepositoryTest() {
super(Database.APP_CATALOG);
- gwyResourceProfileRepository = new GwyResourceProfileRepository();
}
@Test
@@ -56,23 +66,22 @@ public class GatewayProfileRepositoryTest extends TestBase {
// Verify that the default Gateway Resource Profile exists already
List<GatewayResourceProfile> defaultGatewayResourceProfileList =
- this.gwyResourceProfileRepository.getAllGatewayProfiles();
+ this.gwyResourceProfileService.getAllGatewayProfiles();
assertEquals(1, defaultGatewayResourceProfileList.size());
assertEquals(
ServerSettings.getDefaultUserGateway(),
defaultGatewayResourceProfileList.get(0).getGatewayID());
GatewayResourceProfile gf = new GatewayResourceProfile();
- ComputeResourceRepository computeResourceRepository = new ComputeResourceRepository();
ComputeResourceDescription cm1 = new ComputeResourceDescription();
cm1.setHostName("localhost");
cm1.setResourceDescription("test compute host");
- String hostId1 = computeResourceRepository.addComputeResource(cm1);
+ String hostId1 = computeResourceService.addComputeResource(cm1);
ComputeResourceDescription cm2 = new ComputeResourceDescription();
cm2.setHostName("localhost");
cm2.setResourceDescription("test compute host");
- String hostId2 = computeResourceRepository.addComputeResource(cm2);
+ String hostId2 = computeResourceService.addComputeResource(cm2);
ComputeResourcePreference preference1 = new ComputeResourcePreference();
preference1.setComputeResourceId(hostId1);
@@ -112,10 +121,10 @@ public class GatewayProfileRepositoryTest extends TestBase {
gf1.setIdentityServerPwdCredToken("pwdCredential");
gf1.setIdentityServerTenant("testTenant");
- String gwId = gwyResourceProfileRepository.addGatewayResourceProfile(gf);
+ String gwId = gwyResourceProfileService.addGatewayResourceProfile(gf);
GatewayResourceProfile retrievedProfile = null;
- if (gwyResourceProfileRepository.isExists(gwId)) {
- retrievedProfile = gwyResourceProfileRepository.getGatewayProfile(gwId);
+ if (gwyResourceProfileService.isGatewayResourceProfileExists(gwId)) {
+ retrievedProfile = gwyResourceProfileService.getGatewayProfile(gwId);
logger.info("************ gateway id ************** :{}", retrievedProfile.getGatewayID());
assertTrue(retrievedProfile.getGatewayID().equals("testGateway"), "Retrieved gateway id matched");
assertTrue(retrievedProfile.getCredentialStoreToken().equals("testCredential"));
@@ -123,12 +132,11 @@ public class GatewayProfileRepositoryTest extends TestBase {
assertTrue(retrievedProfile.getIdentityServerTenant().equals("testTenant"));
}
- gwyResourceProfileRepository.addGatewayResourceProfile(gf1);
- List<GatewayResourceProfile> getGatewayResourceList = gwyResourceProfileRepository.getAllGatewayProfiles();
+ gwyResourceProfileService.addGatewayResourceProfile(gf1);
+ List<GatewayResourceProfile> getGatewayResourceList = gwyResourceProfileService.getAllGatewayProfiles();
assertEquals(3, getGatewayResourceList.size(), "should be 3 gateway profiles (1 default and 2 just added)");
- List<ComputeResourcePreference> preferences =
- gwyResourceProfileRepository.getAllComputeResourcePreferences(gwId);
+ List<ComputeResourcePreference> preferences = gwyResourceProfileService.getAllComputeResourcePreferences(gwId);
logger.info("compute preferences size : {}", preferences.size());
assertTrue(preferences.size() == 2);
if (preferences != null && !preferences.isEmpty()) {
@@ -149,9 +157,9 @@ public class GatewayProfileRepositoryTest extends TestBase {
logger.info("Preferred Job Submission Protocol: {}", cm.getPreferredJobSubmissionProtocol());
}
}
- computeResourceRepository.removeComputeResource(hostId1);
- computeResourceRepository.removeComputeResource(hostId2);
- gwyResourceProfileRepository.delete("testGateway");
- gwyResourceProfileRepository.delete("testGateway1");
+ computeResourceService.removeComputeResource(hostId1);
+ computeResourceService.removeComputeResource(hostId2);
+ gwyResourceProfileService.removeGatewayResourceProfile("testGateway");
+ gwyResourceProfileService.removeGatewayResourceProfile("testGateway1");
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GroupResourceProfileRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GroupResourceProfileRepositoryTest.java
index 9b33db3c42..1de6f7c069 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GroupResourceProfileRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GroupResourceProfileRepositoryTest.java
@@ -32,19 +32,26 @@ import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescr
import org.apache.airavata.model.appcatalog.groupresourceprofile.*;
import org.apache.airavata.registry.exceptions.AppCatalogException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ComputeResourceService;
+import org.apache.airavata.registry.services.GroupResourceProfileService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
// FIXME - update the codes changed by GroupComputeResourcePreference -> abstract GroupComputeResourcePreference +
// SlurmGroupComputeResourcePreference
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class GroupResourceProfileRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ComputeResourceRepository.class);
+ @Autowired
+ private ComputeResourceService computeResourceService;
+
+ @Autowired
+ private GroupResourceProfileService groupResourceProfileService;
- private ComputeResourceRepository computeResourceRepository;
- private GroupResourceProfileRepository groupResourceProfileRepository;
private String gatewayId = "TEST_GATEWAY";
private String groupResourceProfileId = null;
private String resourceId1 = null;
@@ -55,8 +62,6 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
public GroupResourceProfileRepositoryTest() {
super(Database.APP_CATALOG);
- computeResourceRepository = new ComputeResourceRepository();
- groupResourceProfileRepository = new GroupResourceProfileRepository();
}
@Override
@@ -91,7 +96,7 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
batchQueueList.add(batchQueue2);
description.setBatchQueues(batchQueueList);
- this.resourceId1 = computeResourceRepository.addComputeResource(description);
+ this.resourceId1 = computeResourceService.addComputeResource(description);
ComputeResourceDescription cm2 = new ComputeResourceDescription();
cm2.setHostName("localhost2");
@@ -116,7 +121,7 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
cmbatchQueueList.add(cm_batchQueue2);
cm2.setBatchQueues(cmbatchQueueList);
- this.resourceId2 = computeResourceRepository.addComputeResource(cm2);
+ this.resourceId2 = computeResourceService.addComputeResource(cm2);
}
@Test
@@ -193,13 +198,13 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
groupResourceProfile.setBatchQueueResourcePolicies(batchQueueResourcePolicyList);
- groupResourceProfileId = groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
+ groupResourceProfileId = groupResourceProfileService.addGroupResourceProfile(groupResourceProfile);
String computeResourcePolicyId1 = null;
String batchQueueResourcePolicyId2 = null;
- if (groupResourceProfileRepository.isGroupResourceProfileExists(groupResourceProfileId)) {
+ if (groupResourceProfileService.isGroupResourceProfileExists(groupResourceProfileId)) {
GroupResourceProfile getGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
assertTrue(getGroupResourceProfile.getGatewayId().equals(gatewayId));
assertTrue(getGroupResourceProfile.getGroupResourceProfileId().equals(groupResourceProfileId));
@@ -220,9 +225,9 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
.get();
}
- assertTrue(groupResourceProfileRepository.getGroupComputeResourcePreference(resourceId1, groupResourceProfileId)
+ assertTrue(groupResourceProfileService.getGroupComputeResourcePreference(resourceId1, groupResourceProfileId)
!= null);
- // assertTrue(groupResourceProfileRepository
+ // assertTrue(groupResourceProfileService
// .getGroupComputeResourcePreference(resourceId1, groupResourceProfileId)
// .getGroupSSHAccountProvisionerConfigs()
// .size()
@@ -230,11 +235,11 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
// verify reservation1
// assertEquals(
// 2,
- // groupResourceProfileRepository
+ // groupResourceProfileService
// .getGroupComputeResourcePreference(resourceId1, groupResourceProfileId)
// .getReservations()
// .size());
- // ComputeResourceReservation retrievedReservation1 = groupResourceProfileRepository
+ // ComputeResourceReservation retrievedReservation1 = groupResourceProfileService
// .getGroupComputeResourcePreference(resourceId1, groupResourceProfileId)
// .getReservations()
// .get(0);
@@ -243,39 +248,39 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
// assertEquals(reservation1.getEndTime(), retrievedReservation1.getEndTime());
ComputeResourcePolicy getComputeResourcePolicy =
- groupResourceProfileRepository.getComputeResourcePolicy(computeResourcePolicyId1);
+ groupResourceProfileService.getComputeResourcePolicy(computeResourcePolicyId1);
assertTrue(getComputeResourcePolicy.getAllowedBatchQueues().get(0).equals("queue1"));
BatchQueueResourcePolicy getBatchQueuePolicy =
- groupResourceProfileRepository.getBatchQueueResourcePolicy(batchQueueResourcePolicyId2);
+ groupResourceProfileService.getBatchQueueResourcePolicy(batchQueueResourcePolicyId2);
assertTrue(getBatchQueuePolicy != null);
assertTrue(getBatchQueuePolicy.getMaxAllowedCores() == 3);
assertTrue(getBatchQueuePolicy.getMaxAllowedWalltime() == 12);
- assertTrue(groupResourceProfileRepository
+ assertTrue(groupResourceProfileService
.getAllGroupResourceProfiles(gatewayId, null)
.size()
== 0);
- assertTrue(groupResourceProfileRepository
+ assertTrue(groupResourceProfileService
.getAllGroupResourceProfiles(gatewayId, Collections.emptyList())
.size()
== 0);
- assertTrue(groupResourceProfileRepository
+ assertTrue(groupResourceProfileService
.getAllGroupComputeResourcePreferences(groupResourceProfileId)
.size()
== 2);
- assertTrue(groupResourceProfileRepository
+ assertTrue(groupResourceProfileService
.getAllGroupComputeResourcePolicies(groupResourceProfileId)
.size()
== 2);
- assertTrue(groupResourceProfileRepository
+ assertTrue(groupResourceProfileService
.getAllGroupBatchQueueResourcePolicies(groupResourceProfileId)
.size()
== 2);
// AIRAVATA-2872 Test setting resourceSpecificCredentialStoreToken to a value and then changing it to null
GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
GroupComputeResourcePreference retrievedGroupComputeResourcePreference =
retrievedGroupResourceProfile.getComputePreferences().stream()
.filter(pref -> pref.getComputeResourceId().equals(resourceId1))
@@ -283,10 +288,10 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
.get();
assertNull(retrievedGroupComputeResourcePreference.getResourceSpecificCredentialStoreToken());
retrievedGroupComputeResourcePreference.setResourceSpecificCredentialStoreToken("abc123");
- groupResourceProfileRepository.updateGroupResourceProfile(retrievedGroupResourceProfile);
+ groupResourceProfileService.updateGroupResourceProfile(retrievedGroupResourceProfile);
GroupResourceProfile retrievedGroupResourceProfile2 =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
GroupComputeResourcePreference retrievedGroupComputeResourcePreference2 =
retrievedGroupResourceProfile2.getComputePreferences().stream()
.filter(pref -> pref.getComputeResourceId().equals(resourceId1))
@@ -295,10 +300,10 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
assertEquals("abc123", retrievedGroupComputeResourcePreference2.getResourceSpecificCredentialStoreToken());
retrievedGroupComputeResourcePreference2.setResourceSpecificCredentialStoreToken(null);
assertNull(retrievedGroupComputeResourcePreference2.getResourceSpecificCredentialStoreToken());
- groupResourceProfileRepository.updateGroupResourceProfile(retrievedGroupResourceProfile2);
+ groupResourceProfileService.updateGroupResourceProfile(retrievedGroupResourceProfile2);
GroupResourceProfile retrievedGroupResourceProfile3 =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
GroupComputeResourcePreference retrievedGroupComputeResourcePreference3 =
retrievedGroupResourceProfile3.getComputePreferences().stream()
.filter(pref -> pref.getComputeResourceId().equals(resourceId1))
@@ -310,12 +315,12 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
assertEquals(2, retrievedGroupResourceProfile3.getComputePreferencesSize());
retrievedGroupResourceProfile3.setComputePreferences(
retrievedGroupResourceProfile3.getComputePreferences().subList(0, 1));
- groupResourceProfileRepository.updateGroupResourceProfile(retrievedGroupResourceProfile3);
+ groupResourceProfileService.updateGroupResourceProfile(retrievedGroupResourceProfile3);
GroupResourceProfile retrievedGroupResourceProfile4 =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
assertEquals(1, retrievedGroupResourceProfile4.getComputePreferencesSize());
- groupResourceProfileRepository.removeGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.removeGroupResourceProfile(groupResourceProfileId);
}
@Test
@@ -329,13 +334,13 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
// the create operation but not any fields, like creation time, that are
// populated by the create operation
GroupResourceProfile cloneGroupResourceProfile = groupResourceProfile.deepCopy();
- String groupResourceProfileId = groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
- long creationTime = groupResourceProfileRepository
+ String groupResourceProfileId = groupResourceProfileService.addGroupResourceProfile(groupResourceProfile);
+ long creationTime = groupResourceProfileService
.getGroupResourceProfile(groupResourceProfileId)
.getCreationTime();
cloneGroupResourceProfile.setGroupResourceProfileId(groupResourceProfileId);
- groupResourceProfileRepository.updateGroupResourceProfile(cloneGroupResourceProfile);
- long creationTimeAfterUpdate = groupResourceProfileRepository
+ groupResourceProfileService.updateGroupResourceProfile(cloneGroupResourceProfile);
+ long creationTimeAfterUpdate = groupResourceProfileService
.getGroupResourceProfile(groupResourceProfileId)
.getCreationTime();
Assertions.assertEquals(creationTime, creationTimeAfterUpdate, "creationTime should be the same after update");
@@ -368,23 +373,22 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
groupResourceProfile.addToComputePreferences(groupComputeResourcePreference1);
- String groupResourceProfileId = groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
+ String groupResourceProfileId = groupResourceProfileService.addGroupResourceProfile(groupResourceProfile);
// Remove one of the reservations
{
GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
// List<ComputeResourceReservation> retrievedReservations =
// retrievedGroupResourceProfile.getComputePreferences().get(0).getReservations();
// assertEquals(2, retrievedReservations.size());
// retrievedReservations.remove(1);
- groupResourceProfileRepository.updateGroupResourceProfile(retrievedGroupResourceProfile);
+ groupResourceProfileService.updateGroupResourceProfile(retrievedGroupResourceProfile);
}
{
- GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
// List<ComputeResourceReservation> retrievedReservations =
// retrievedGroupResourceProfile.getComputePreferences().get(0).getReservations();
// assertEquals(1, retrievedReservations.size());
@@ -421,27 +425,23 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
groupResourceProfile.addToComputePreferences(groupComputeResourcePreference1);
- String groupResourceProfileId = groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
+ String groupResourceProfileId = groupResourceProfileService.addGroupResourceProfile(groupResourceProfile);
// Update one of the reservations
- long newStartTime = AiravataUtils.getCurrentTimestamp().getTime() + 1000 * 1000;
- long newEndTime = AiravataUtils.getCurrentTimestamp().getTime() + 2 * 1000 * 1000;
{
GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
// List<ComputeResourceReservation> retrievedReservations =
// retrievedGroupResourceProfile.getComputePreferences().get(0).getReservations();
// assertEquals(2, retrievedReservations.size());
// push into future, should sort second on next retrieval
// retrievedReservations.get(0).setStartTime(newStartTime);
// retrievedReservations.get(0).setEndTime(newEndTime);
-
- groupResourceProfileRepository.updateGroupResourceProfile(retrievedGroupResourceProfile);
+ groupResourceProfileService.updateGroupResourceProfile(retrievedGroupResourceProfile);
}
{
- GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
// List<ComputeResourceReservation> retrievedReservations =
// retrievedGroupResourceProfile.getComputePreferences().get(0).getReservations();
// assertEquals(2, retrievedReservations.size());
@@ -472,12 +472,12 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
groupResourceProfile.addToComputePreferences(groupComputeResourcePreference1);
- String groupResourceProfileId = groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
+ String groupResourceProfileId = groupResourceProfileService.addGroupResourceProfile(groupResourceProfile);
// add queue to the reservation
{
GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
// List<ComputeResourceReservation> retrievedReservations =
// retrievedGroupResourceProfile.getComputePreferences().get(0).getReservations();
// assertEquals(1, retrievedReservations.size());
@@ -485,12 +485,11 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
// assertEquals(1, reservation.getQueueNamesSize());
// reservation.addToQueueNames(QUEUE2_NAME);
- groupResourceProfileRepository.updateGroupResourceProfile(retrievedGroupResourceProfile);
+ groupResourceProfileService.updateGroupResourceProfile(retrievedGroupResourceProfile);
}
{
- GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
// List<ComputeResourceReservation> retrievedReservations =
// retrievedGroupResourceProfile.getComputePreferences().get(0).getReservations();
// assertEquals(1, retrievedReservations.size());
@@ -521,12 +520,12 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
groupResourceProfile.addToComputePreferences(groupComputeResourcePreference1);
- String groupResourceProfileId = groupResourceProfileRepository.addGroupResourceProfile(groupResourceProfile);
+ String groupResourceProfileId = groupResourceProfileService.addGroupResourceProfile(groupResourceProfile);
// add queue to the reservation
{
GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
// List<ComputeResourceReservation> retrievedReservations =
// retrievedGroupResourceProfile.getComputePreferences().get(0).getReservations();
// assertEquals(1, retrievedReservations.size());
@@ -537,12 +536,11 @@ public class GroupResourceProfileRepositoryTest extends TestBase {
// reservation.unsetQueueNames();
// reservation.addToQueueNames(QUEUE1_NAME);
- groupResourceProfileRepository.updateGroupResourceProfile(retrievedGroupResourceProfile);
+ groupResourceProfileService.updateGroupResourceProfile(retrievedGroupResourceProfile);
}
{
- GroupResourceProfile retrievedGroupResourceProfile =
- groupResourceProfileRepository.getGroupResourceProfile(groupResourceProfileId);
+ groupResourceProfileService.getGroupResourceProfile(groupResourceProfileId);
// List<ComputeResourceReservation> retrievedReservations =
// retrievedGroupResourceProfile.getComputePreferences().get(0).getReservations();
// assertEquals(1, retrievedReservations.size());
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/JobSubmissionInterfaceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/JobSubmissionInterfaceRepositoryTest.java
index fa43dfd669..63f33692ec 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/JobSubmissionInterfaceRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/JobSubmissionInterfaceRepositoryTest.java
@@ -19,31 +19,39 @@
*/
package org.apache.airavata.registry.repositories.appcatalog;
+import com.github.dozermapper.core.Mapper;
import org.apache.airavata.model.appcatalog.computeresource.BatchQueue;
import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface;
import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol;
+import org.apache.airavata.registry.entities.appcatalog.JobSubmissionInterfaceEntity;
import org.apache.airavata.registry.entities.appcatalog.JobSubmissionInterfacePK;
import org.apache.airavata.registry.exceptions.AppCatalogException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ComputeResourceService;
+import org.apache.airavata.registry.utils.ObjectMapperSingleton;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class JobSubmissionInterfaceRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ComputeResourceRepositoryTest.class);
+ @Autowired
+ private ComputeResourceService computeResourceService;
+
+ @Autowired
private JobSubmissionInterfaceRepository jobSubmissionInterfaceRepository;
- private ComputeResourceRepository computeResourceRepository;
+
private String computeResourceId;
public JobSubmissionInterfaceRepositoryTest() {
super(Database.APP_CATALOG);
- jobSubmissionInterfaceRepository = new JobSubmissionInterfaceRepository();
- computeResourceRepository = new ComputeResourceRepository();
}
@BeforeEach
@@ -53,13 +61,13 @@ public class JobSubmissionInterfaceRepositoryTest extends TestBase {
description.setHostName("localhost");
description.addToBatchQueues(new BatchQueue("queue1"));
description.addToBatchQueues(new BatchQueue("queue2"));
- computeResourceId = computeResourceRepository.addComputeResource(description);
+ computeResourceId = computeResourceService.addComputeResource(description);
}
@AfterEach
public void removeTestComputeResource() throws AppCatalogException {
- computeResourceRepository.removeComputeResource(computeResourceId);
+ computeResourceService.removeComputeResource(computeResourceId);
}
@Test
@@ -71,17 +79,21 @@ public class JobSubmissionInterfaceRepositoryTest extends TestBase {
jobSubmissionInterface.setJobSubmissionProtocol(JobSubmissionProtocol.SSH);
String jobSubmissionInterfaceId =
- jobSubmissionInterfaceRepository.addJobSubmission(computeResourceId, jobSubmissionInterface);
+ computeResourceService.addJobSubmissionProtocol(computeResourceId, jobSubmissionInterface);
JobSubmissionInterfacePK pk = new JobSubmissionInterfacePK();
pk.setComputeResourceId(computeResourceId);
pk.setJobSubmissionInterfaceId(jobSubmissionInterfaceId);
- JobSubmissionInterface retrievedJobSubmissionInterface = jobSubmissionInterfaceRepository.get(pk);
+ JobSubmissionInterfaceEntity entity =
+ jobSubmissionInterfaceRepository.findById(pk).orElse(null);
+ Assertions.assertNotNull(entity);
+ Mapper mapper = ObjectMapperSingleton.getInstance();
+ JobSubmissionInterface retrievedJobSubmissionInterface = mapper.map(entity, JobSubmissionInterface.class);
Assertions.assertEquals("test", retrievedJobSubmissionInterface.getJobSubmissionInterfaceId());
Assertions.assertEquals(1, retrievedJobSubmissionInterface.getPriorityOrder());
Assertions.assertEquals(JobSubmissionProtocol.SSH, retrievedJobSubmissionInterface.getJobSubmissionProtocol());
- jobSubmissionInterfaceRepository.delete(pk);
+ computeResourceService.removeJobSubmissionInterface(computeResourceId, jobSubmissionInterfaceId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/StorageResourceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/StorageResourceRepositoryTest.java
index f5613f9681..9fe8feb255 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/StorageResourceRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/StorageResourceRepositoryTest.java
@@ -32,22 +32,32 @@ import org.apache.airavata.model.data.movement.SCPDataMovement;
import org.apache.airavata.model.data.movement.SecurityProtocol;
import org.apache.airavata.registry.exceptions.AppCatalogException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ComputeResourceService;
+import org.apache.airavata.registry.services.StorageResourceService;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
/**
* Created by skariyat on 3/13/18.
*/
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class StorageResourceRepositoryTest extends TestBase {
private static final Logger logger = LoggerFactory.getLogger(StorageResourceRepository.class);
- private StorageResourceRepository storageResourceRepository;
+ @Autowired
+ private StorageResourceService storageResourceService;
+
+ @Autowired
+ private ComputeResourceService computeResourceService;
public StorageResourceRepositoryTest() {
super(Database.APP_CATALOG);
- storageResourceRepository = new StorageResourceRepository();
}
@Test
@@ -79,11 +89,11 @@ public class StorageResourceRepositoryTest extends TestBase {
dataMovementInterfaces.add(gridFTPMv);
description.setDataMovementInterfaces(dataMovementInterfaces);
- String resourceId = storageResourceRepository.addStorageResource(description);
+ String resourceId = storageResourceService.addStorageResource(description);
StorageResourceDescription storageResourceDescription = null;
- if (storageResourceRepository.isExists(resourceId)) {
- storageResourceDescription = storageResourceRepository.getStorageResource(resourceId);
+ if (storageResourceService.isStorageResourceExists(resourceId)) {
+ storageResourceDescription = storageResourceService.getStorageResource(resourceId);
assertTrue(storageResourceDescription.getHostName().equals("localhost"));
assertTrue(
storageResourceDescription.getStorageResourceDescription().equals("testDescription"));
@@ -102,9 +112,9 @@ public class StorageResourceRepositoryTest extends TestBase {
}
description.setHostName("localhost2");
- storageResourceRepository.updateStorageResource(resourceId, description);
- if (storageResourceRepository.isStorageResourceExists(resourceId)) {
- storageResourceDescription = storageResourceRepository.getStorageResource(resourceId);
+ storageResourceService.updateStorageResource(resourceId, description);
+ if (storageResourceService.isStorageResourceExists(resourceId)) {
+ storageResourceDescription = storageResourceService.getStorageResource(resourceId);
logger.info("**********Updated Resource name ************* : {}", storageResourceDescription.getHostName());
assertTrue(storageResourceDescription.getHostName().equals("localhost2"));
}
@@ -116,7 +126,7 @@ public class StorageResourceRepositoryTest extends TestBase {
SCPDataMovement dataMovement = new SCPDataMovement();
dataMovement.setSshPort(22);
dataMovement.setSecurityProtocol(SecurityProtocol.SSH_KEYS);
- return new ComputeResourceRepository().addScpDataMovement(dataMovement);
+ return computeResourceService.addScpDataMovement(dataMovement);
} catch (AppCatalogException e) {
logger.error(e.getMessage(), e);
}
@@ -131,7 +141,7 @@ public class StorageResourceRepositoryTest extends TestBase {
endPoints.add("222.33.43.444");
endPoints.add("23.344.44.454");
dataMovement.setGridFTPEndPoints(endPoints);
- return new ComputeResourceRepository().addGridFTPDataMovement(dataMovement);
+ return computeResourceService.addGridFTPDataMovement(dataMovement);
} catch (AppCatalogException e) {
logger.error(e.getMessage(), e);
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/UserResourceProfileRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/UserResourceProfileRepositoryTest.java
index 89531005f1..049c667a0f 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/UserResourceProfileRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/UserResourceProfileRepositoryTest.java
@@ -28,21 +28,24 @@ import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProf
import org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference;
import org.apache.airavata.registry.exceptions.AppCatalogException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.UserResourceProfileService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class UserResourceProfileRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(UserResourceProfileRepositoryTest.class);
+ @Autowired
+ private UserResourceProfileService userResourceProfileService;
- private UserResourceProfileRepository userResourceProfileRepository;
private String userId = "testUser";
private String gatewayId = "testGateway";
public UserResourceProfileRepositoryTest() {
super(Database.APP_CATALOG);
- userResourceProfileRepository = new UserResourceProfileRepository();
}
@Test
@@ -67,48 +70,48 @@ public class UserResourceProfileRepositoryTest extends TestBase {
userResourceProfile.setUserStoragePreferences(Arrays.asList(userStoragePreference));
userResourceProfile.setIdentityServerTenant("tenant1");
userResourceProfile.setIdentityServerPwdCredToken("password");
- if (!userResourceProfileRepository.isUserResourceProfileExists(userId, gatewayId))
- userResourceProfileRepository.addUserResourceProfile(userResourceProfile);
+ if (!userResourceProfileService.isUserResourceProfileExists(userId, gatewayId))
+ userResourceProfileService.addUserResourceProfile(userResourceProfile);
assertEquals(userId, userResourceProfile.getUserId());
userResourceProfile.setIdentityServerTenant("tenant2");
- userResourceProfileRepository.updateUserResourceProfile(userId, gatewayId, userResourceProfile);
+ userResourceProfileService.updateUserResourceProfile(userId, gatewayId, userResourceProfile);
UserResourceProfile retrievedUserResourceProfile =
- userResourceProfileRepository.getUserResourceProfile(userId, gatewayId);
+ userResourceProfileService.getUserResourceProfile(userId, gatewayId);
assertTrue(retrievedUserResourceProfile.getUserStoragePreferences().size() == 1);
assertEquals(
userResourceProfile.getIdentityServerTenant(), retrievedUserResourceProfile.getIdentityServerTenant());
UserComputeResourcePreference retrievedUserComputeResourcePreference =
- userResourceProfileRepository.getUserComputeResourcePreference(
+ userResourceProfileService.getUserComputeResourcePreference(
userId, gatewayId, userComputeResourcePreference.getComputeResourceId());
assertEquals(
userComputeResourcePreference.getLoginUserName(),
retrievedUserComputeResourcePreference.getLoginUserName());
- UserStoragePreference retrievedUserStoragePreference = userResourceProfileRepository.getUserStoragePreference(
+ UserStoragePreference retrievedUserStoragePreference = userResourceProfileService.getUserStoragePreference(
userId, gatewayId, userStoragePreference.getStorageResourceId());
assertEquals(
userStoragePreference.getFileSystemRootLocation(),
retrievedUserStoragePreference.getFileSystemRootLocation());
- assertTrue(userResourceProfileRepository.getAllUserResourceProfiles().size() == 1);
- assertTrue(userResourceProfileRepository
+ assertTrue(userResourceProfileService.getAllUserResourceProfiles().size() == 1);
+ assertTrue(userResourceProfileService
.getAllUserComputeResourcePreferences(userId, gatewayId)
.size()
== 1);
- assertTrue(userResourceProfileRepository
+ assertTrue(userResourceProfileService
.getAllUserStoragePreferences(userId, gatewayId)
.size()
== 1);
- assertTrue(userResourceProfileRepository.getGatewayProfileIds(gatewayId).size() == 1);
- assertEquals(userId, userResourceProfileRepository.getUserNamefromID(userId, gatewayId));
+ assertTrue(userResourceProfileService.getGatewayProfileIds(gatewayId).size() == 1);
+ assertEquals(userId, userResourceProfileService.getUserNamefromID(userId, gatewayId));
- userResourceProfileRepository.removeUserComputeResourcePreferenceFromGateway(
+ userResourceProfileService.removeUserComputeResourcePreferenceFromGateway(
userId, gatewayId, userComputeResourcePreference.getComputeResourceId());
- userResourceProfileRepository.removeUserDataStoragePreferenceFromGateway(
+ userResourceProfileService.removeUserDataStoragePreferenceFromGateway(
userId, gatewayId, userStoragePreference.getStorageResourceId());
- userResourceProfileRepository.removeUserResourceProfile(userId, gatewayId);
+ userResourceProfileService.removeUserResourceProfile(userId, gatewayId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentErrorRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentErrorRepositoryTest.java
index e5f99eb027..229329167a 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentErrorRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentErrorRepositoryTest.java
@@ -30,25 +30,33 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentErrorService;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ExperimentErrorRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentErrorRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ExperimentErrorRepository experimentErrorRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ExperimentErrorService experimentErrorService;
public ExperimentErrorRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- experimentErrorRepository = new ExperimentErrorRepository();
}
@Test
@@ -57,14 +65,14 @@ public class ExperimentErrorRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -73,25 +81,25 @@ public class ExperimentErrorRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
assertTrue(experimentId != null);
ErrorModel errorModel = new ErrorModel();
errorModel.setErrorId("error");
- String experimentErrorId = experimentErrorRepository.addExperimentError(errorModel, experimentId);
+ String experimentErrorId = experimentErrorService.addExperimentError(errorModel, experimentId);
assertTrue(experimentErrorId != null);
- assertTrue(experimentRepository.getExperiment(experimentId).getErrors().size() == 1);
+ assertTrue(experimentService.getExperiment(experimentId).getErrors().size() == 1);
errorModel.setActualErrorMessage("message");
- experimentErrorRepository.updateExperimentError(errorModel, experimentId);
+ experimentErrorService.updateExperimentError(errorModel, experimentId);
- List<ErrorModel> retrievedErrorList = experimentErrorRepository.getExperimentErrors(experimentId);
+ List<ErrorModel> retrievedErrorList = experimentErrorService.getExperimentErrors(experimentId);
assertTrue(retrievedErrorList.size() == 1);
assertEquals("message", retrievedErrorList.get(0).getActualErrorMessage());
- experimentRepository.removeExperiment(experimentId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentInputRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentInputRepositoryTest.java
index 4428e40c8e..dae10a36ca 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentInputRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentInputRepositoryTest.java
@@ -32,25 +32,33 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentInputService;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ExperimentInputRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentInputRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ExperimentInputRepository experimentInputRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ExperimentInputService experimentInputService;
public ExperimentInputRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- experimentInputRepository = new ExperimentInputRepository();
}
@Test
@@ -59,14 +67,14 @@ public class ExperimentInputRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -75,7 +83,7 @@ public class ExperimentInputRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
assertTrue(experimentId != null);
InputDataObjectType inputDataObjectTypeExp = new InputDataObjectType();
@@ -86,23 +94,23 @@ public class ExperimentInputRepositoryTest extends TestBase {
inputDataObjectTypeExpList.add(inputDataObjectTypeExp);
assertEquals(
- experimentId, experimentInputRepository.addExperimentInputs(inputDataObjectTypeExpList, experimentId));
- assertTrue(experimentRepository
+ experimentId, experimentInputService.addExperimentInputs(inputDataObjectTypeExpList, experimentId));
+ assertTrue(experimentService
.getExperiment(experimentId)
.getExperimentInputs()
.size()
== 1);
inputDataObjectTypeExp.setValue("iValueE");
- experimentInputRepository.updateExperimentInputs(inputDataObjectTypeExpList, experimentId);
+ experimentInputService.updateExperimentInputs(inputDataObjectTypeExpList, experimentId);
- List<InputDataObjectType> retrievedExpInputsList = experimentInputRepository.getExperimentInputs(experimentId);
+ List<InputDataObjectType> retrievedExpInputsList = experimentInputService.getExperimentInputs(experimentId);
assertTrue(retrievedExpInputsList.size() == 1);
assertEquals("iValueE", retrievedExpInputsList.get(0).getValue());
assertEquals(DataType.STRING, retrievedExpInputsList.get(0).getType());
- experimentRepository.removeExperiment(experimentId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentOutputRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentOutputRepositoryTest.java
index 1d5084c2ca..c4553d4704 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentOutputRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentOutputRepositoryTest.java
@@ -32,25 +32,33 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentOutputService;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ExperimentOutputRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentOutputRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ExperimentOutputRepository experimentOutputRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ExperimentOutputService experimentOutputService;
public ExperimentOutputRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- experimentOutputRepository = new ExperimentOutputRepository();
}
@Test
@@ -59,14 +67,14 @@ public class ExperimentOutputRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -75,7 +83,7 @@ public class ExperimentOutputRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
assertTrue(experimentId != null);
OutputDataObjectType outputDataObjectTypeExp = new OutputDataObjectType();
@@ -85,26 +93,23 @@ public class ExperimentOutputRepositoryTest extends TestBase {
List<OutputDataObjectType> outputDataObjectTypeExpList = new ArrayList<>();
outputDataObjectTypeExpList.add(outputDataObjectTypeExp);
- assertEquals(
- experimentId,
- experimentOutputRepository.addExperimentOutputs(outputDataObjectTypeExpList, experimentId));
- assertTrue(experimentRepository
+ experimentOutputService.addExperimentOutputs(outputDataObjectTypeExpList, experimentId);
+ assertTrue(experimentService
.getExperiment(experimentId)
.getExperimentOutputs()
.size()
== 1);
outputDataObjectTypeExp.setValue("oValueE");
- experimentOutputRepository.updateExperimentOutputs(outputDataObjectTypeExpList, experimentId);
+ experimentOutputService.updateExperimentOutputs(outputDataObjectTypeExpList, experimentId);
- List<OutputDataObjectType> retrievedExpOutputList =
- experimentOutputRepository.getExperimentOutputs(experimentId);
+ List<OutputDataObjectType> retrievedExpOutputList = experimentOutputService.getExperimentOutputs(experimentId);
assertTrue(retrievedExpOutputList.size() == 1);
assertEquals("oValueE", retrievedExpOutputList.get(0).getValue());
assertEquals(DataType.STRING, retrievedExpOutputList.get(0).getType());
- experimentRepository.removeExperiment(experimentId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentRepositoryTest.java
index a6bb52d871..3e1f067cf9 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentRepositoryTest.java
@@ -32,17 +32,26 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ExperimentRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
private String gatewayId;
@@ -50,9 +59,6 @@ public class ExperimentRepositoryTest extends TestBase {
public ExperimentRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
}
@Override
@@ -63,14 +69,14 @@ public class ExperimentRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- gatewayId = gatewayRepository.addGateway(gateway);
+ gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- projectId = projectRepository.addProject(project, gatewayId);
+ projectId = projectService.addProject(project, gatewayId);
}
@Test
@@ -84,16 +90,16 @@ public class ExperimentRepositoryTest extends TestBase {
experimentModel.setExperimentName("name");
experimentModel.setGatewayInstanceId("gateway-instance-id");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
assertTrue(experimentId != null);
- assertEquals(0, experimentRepository.getExperiment(experimentId).getEmailAddressesSize());
+ assertEquals(0, experimentService.getExperiment(experimentId).getEmailAddressesSize());
experimentModel.setDescription("description");
experimentModel.addToEmailAddresses("notify@example.com");
experimentModel.addToEmailAddresses("notify2@example.com");
- experimentRepository.updateExperiment(experimentModel, experimentId);
+ experimentService.updateExperiment(experimentModel, experimentId);
- ExperimentModel retrievedExperimentModel = experimentRepository.getExperiment(experimentId);
+ ExperimentModel retrievedExperimentModel = experimentService.getExperiment(experimentId);
assertEquals("description", retrievedExperimentModel.getDescription());
assertEquals(ExperimentType.SINGLE_APPLICATION, retrievedExperimentModel.getExperimentType());
assertEquals("gateway-instance-id", retrievedExperimentModel.getGatewayInstanceId());
@@ -127,14 +133,14 @@ public class ExperimentRepositoryTest extends TestBase {
computationalResourceSchedulingModel.setWallTimeLimit(77);
userConfigurationDataModel.setComputationalResourceScheduling(computationalResourceSchedulingModel);
assertEquals(
- experimentId, experimentRepository.addUserConfigurationData(userConfigurationDataModel, experimentId));
+ experimentId, experimentService.addUserConfigurationData(userConfigurationDataModel, experimentId));
userConfigurationDataModel.setInputStorageResourceId("storage2");
userConfigurationDataModel.setOutputStorageResourceId("storage2");
- experimentRepository.updateUserConfigurationData(userConfigurationDataModel, experimentId);
+ experimentService.updateUserConfigurationData(userConfigurationDataModel, experimentId);
final UserConfigurationDataModel retrievedUserConfigurationDataModel =
- experimentRepository.getUserConfigurationData(experimentId);
+ experimentService.getUserConfigurationData(experimentId);
assertEquals("storage2", retrievedUserConfigurationDataModel.getInputStorageResourceId());
assertEquals("storage2", retrievedUserConfigurationDataModel.getOutputStorageResourceId());
final ComputationalResourceSchedulingModel retrievedComputationalResourceScheduling =
@@ -154,8 +160,8 @@ public class ExperimentRepositoryTest extends TestBase {
assertEquals(1333, retrievedComputationalResourceScheduling.getTotalPhysicalMemory());
assertEquals(77, retrievedComputationalResourceScheduling.getWallTimeLimit());
- experimentRepository.removeExperiment(experimentId);
- assertFalse(experimentRepository.isExperimentExist(experimentId));
+ experimentService.removeExperiment(experimentId);
+ assertFalse(experimentService.isExperimentExist(experimentId));
}
@Test
@@ -186,10 +192,10 @@ public class ExperimentRepositoryTest extends TestBase {
input1.setOverrideFilename("gaussian.com");
experimentModel.addToExperimentInputs(input1);
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
assertTrue(experimentId != null);
- ExperimentModel retrievedExperimentModel = experimentRepository.getExperiment(experimentId);
+ ExperimentModel retrievedExperimentModel = experimentService.getExperiment(experimentId);
assertEquals(1, retrievedExperimentModel.getExperimentInputsSize());
InputDataObjectType retrievedInput1 =
retrievedExperimentModel.getExperimentInputs().get(0);
@@ -223,9 +229,9 @@ public class ExperimentRepositoryTest extends TestBase {
retrievedInput1.setValue("value1a");
retrievedInput1.setOverrideFilename("gaussian.com-updated");
- experimentRepository.updateExperiment(retrievedExperimentModel, experimentId);
+ experimentService.updateExperiment(retrievedExperimentModel, experimentId);
- retrievedExperimentModel = experimentRepository.getExperiment(experimentId);
+ retrievedExperimentModel = experimentService.getExperiment(experimentId);
assertEquals(1, retrievedExperimentModel.getExperimentInputsSize());
retrievedInput1 = retrievedExperimentModel.getExperimentInputs().get(0);
assertFalse(retrievedInput1.isIsRequired());
@@ -242,8 +248,8 @@ public class ExperimentRepositoryTest extends TestBase {
assertEquals("value1a", retrievedInput1.getValue());
assertEquals("gaussian.com-updated", retrievedInput1.getOverrideFilename());
- experimentRepository.removeExperiment(experimentId);
- assertFalse(experimentRepository.isExperimentExist(experimentId));
+ experimentService.removeExperiment(experimentId);
+ assertFalse(experimentService.isExperimentExist(experimentId));
}
/**
@@ -260,7 +266,7 @@ public class ExperimentRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name/forward-slash//a");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
assertTrue(experimentId.startsWith("name_forward-slash__a"));
// Backward slashes
@@ -271,7 +277,7 @@ public class ExperimentRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name\\backward-slash\\\\a");
- experimentId = experimentRepository.addExperiment(experimentModel);
+ experimentId = experimentService.addExperiment(experimentModel);
assertTrue(experimentId.startsWith("name_backward-slash__a"));
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentStatusRepositoryTest.java
index 772e88daa2..c18dc87b5e 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentStatusRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentStatusRepositoryTest.java
@@ -30,25 +30,33 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.ExperimentStatusService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ExperimentStatusRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentStatusRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ExperimentStatusRepository experimentStatusRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ExperimentStatusService experimentStatusService;
public ExperimentStatusRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- experimentStatusRepository = new ExperimentStatusRepository();
}
@Test
@@ -57,14 +65,14 @@ public class ExperimentStatusRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -73,41 +81,40 @@ public class ExperimentStatusRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
assertTrue(experimentId != null);
// addExperiment adds the CREATED experiment status
assertEquals(
1,
- experimentRepository
+ experimentService
.getExperiment(experimentId)
.getExperimentStatus()
.size());
ExperimentStatus experimentStatus = new ExperimentStatus(ExperimentState.VALIDATED);
- String experimentStatusId = experimentStatusRepository.addExperimentStatus(experimentStatus, experimentId);
+ String experimentStatusId = experimentStatusService.addExperimentStatus(experimentStatus, experimentId);
assertTrue(experimentStatusId != null);
assertEquals(
2,
- experimentRepository
+ experimentService
.getExperiment(experimentId)
.getExperimentStatus()
.size());
experimentStatus.setState(ExperimentState.EXECUTING);
- experimentStatusRepository.updateExperimentStatus(experimentStatus, experimentId);
+ experimentStatusService.updateExperimentStatus(experimentStatus, experimentId);
ExperimentStatus updatedExecutingStatus = new ExperimentStatus(ExperimentState.EXECUTING);
updatedExecutingStatus.setReason("updated reason");
updatedExecutingStatus.setTimeOfStateChange(experimentStatus.getTimeOfStateChange());
- String updatedExperimentStatusId =
- experimentStatusRepository.updateExperimentStatus(updatedExecutingStatus, experimentId);
+ experimentStatusService.updateExperimentStatus(updatedExecutingStatus, experimentId);
- ExperimentStatus retrievedExpStatus = experimentStatusRepository.getExperimentStatus(experimentId);
+ ExperimentStatus retrievedExpStatus = experimentStatusService.getExperimentStatus(experimentId);
assertEquals(ExperimentState.EXECUTING, retrievedExpStatus.getState());
assertEquals("updated reason", updatedExecutingStatus.getReason());
- experimentRepository.removeExperiment(experimentId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentSummaryRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentSummaryRepositoryTest.java
index 480827337a..cf17393bbc 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentSummaryRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentSummaryRepositoryTest.java
@@ -35,28 +35,38 @@ import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.cpi.ResultOrderType;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.ExperimentStatusService;
+import org.apache.airavata.registry.services.ExperimentSummaryService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProjectService;
import org.apache.airavata.registry.utils.DBConstants;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ExperimentSummaryRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentSummaryRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ExperimentStatusRepository experimentStatusRepository;
- ExperimentSummaryRepository experimentSummaryRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ExperimentStatusService experimentStatusService;
+
+ @Autowired
+ ExperimentSummaryService experimentSummaryService;
public ExperimentSummaryRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- experimentStatusRepository = new ExperimentStatusRepository();
- experimentSummaryRepository = new ExperimentSummaryRepository();
}
@Test
@@ -65,13 +75,13 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModelOne = new ExperimentModel();
experimentModelOne.setProjectId(projectId);
@@ -100,32 +110,32 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
experimentModelThree.setDescription("descriptionThree");
experimentModelThree.setExecutionId("executionIdThree");
- String experimentIdOne = experimentRepository.addExperiment(experimentModelOne);
+ String experimentIdOne = experimentService.addExperiment(experimentModelOne);
assertTrue(experimentIdOne != null);
// Reload experiment to get its status' identifier
- experimentModelOne = experimentRepository.getExperiment(experimentIdOne);
+ experimentModelOne = experimentService.getExperiment(experimentIdOne);
- String experimentIdTwo = experimentRepository.addExperiment(experimentModelTwo);
+ String experimentIdTwo = experimentService.addExperiment(experimentModelTwo);
assertTrue(experimentIdTwo != null);
// Reload experiment to get its status' identifier
- experimentModelTwo = experimentRepository.getExperiment(experimentIdTwo);
+ experimentModelTwo = experimentService.getExperiment(experimentIdTwo);
- String experimentIdThree = experimentRepository.addExperiment(experimentModelThree);
+ String experimentIdThree = experimentService.addExperiment(experimentModelThree);
assertTrue(experimentIdThree != null);
// Reload experiment to get its status' identifier
- experimentModelThree = experimentRepository.getExperiment(experimentIdThree);
+ experimentModelThree = experimentService.getExperiment(experimentIdThree);
Timestamp timeOne = Timestamp.valueOf("2010-01-01 09:00:00");
experimentModelOne.setCreationTime(timeOne.getTime());
- experimentRepository.updateExperiment(experimentModelOne, experimentIdOne);
+ experimentService.updateExperiment(experimentModelOne, experimentIdOne);
Timestamp timeTwo = Timestamp.valueOf("2018-01-01 09:00:00");
experimentModelTwo.setCreationTime(timeTwo.getTime());
- experimentRepository.updateExperiment(experimentModelTwo, experimentIdTwo);
+ experimentService.updateExperiment(experimentModelTwo, experimentIdTwo);
Timestamp timeThree = Timestamp.valueOf("2020-01-01 09:00:00");
experimentModelThree.setCreationTime(timeThree.getTime());
- experimentRepository.updateExperiment(experimentModelThree, experimentIdThree);
+ experimentService.updateExperiment(experimentModelThree, experimentIdThree);
Map<String, String> filters = new HashMap<>();
filters.put(DBConstants.Experiment.GATEWAY_ID, gatewayId);
@@ -133,14 +143,13 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
List<String> allExperimentIds = Arrays.asList(experimentIdOne, experimentIdTwo, experimentIdThree);
List<ExperimentSummaryModel> experimentSummaryModelList =
- experimentSummaryRepository.searchAllAccessibleExperiments(
- allExperimentIds, filters, -1, 0, null, null);
+ experimentSummaryService.searchAllAccessibleExperiments(allExperimentIds, filters, -1, 0, null, null);
assertEquals(3, experimentSummaryModelList.size());
filters.put(DBConstants.Experiment.EXECUTION_ID, "executionIdTwo");
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
- allExperimentIds, filters, -1, 0, null, null);
+ experimentSummaryModelList =
+ experimentSummaryService.searchAllAccessibleExperiments(allExperimentIds, filters, -1, 0, null, null);
assertTrue(experimentSummaryModelList.size() == 1);
assertEquals(experimentIdTwo, experimentSummaryModelList.get(0).getExperimentId());
@@ -150,8 +159,8 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
filters.put(DBConstants.ExperimentSummary.FROM_DATE, fromDate);
filters.put(DBConstants.ExperimentSummary.TO_DATE, toDate);
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
- allExperimentIds, filters, -1, 0, null, null);
+ experimentSummaryModelList =
+ experimentSummaryService.searchAllAccessibleExperiments(allExperimentIds, filters, -1, 0, null, null);
assertTrue(experimentSummaryModelList.size() == 1);
assertEquals(experimentIdTwo, experimentSummaryModelList.get(0).getExperimentId());
@@ -162,13 +171,13 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
accessibleExperimentIds.add(experimentIdOne);
filters.put(DBConstants.Experiment.EXECUTION_ID, "executionIdOne");
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
accessibleExperimentIds, filters, -1, 0, DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC);
assertTrue(experimentSummaryModelList.size() == 1);
assertEquals(experimentIdOne, experimentSummaryModelList.get(0).getExperimentId());
// Test with empty accessibleExperimentIds
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
Collections.emptyList(),
Collections.singletonMap(DBConstants.Experiment.GATEWAY_ID, gatewayId),
-1,
@@ -181,7 +190,7 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
filters.clear();
filters.put(DBConstants.Experiment.GATEWAY_ID, gatewayId);
filters.put(DBConstants.Experiment.USER_NAME, "userOne");
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
allExperimentIds, filters, -1, 0, DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC);
assertEquals(1, experimentSummaryModelList.size(), "should return only userOne's exp");
assertEquals("userOne", experimentSummaryModelList.get(0).getUserName());
@@ -189,13 +198,13 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
// Test with pagination
filters.clear();
filters.put(DBConstants.Experiment.GATEWAY_ID, gatewayId);
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
allExperimentIds, filters, 2, 0, DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC);
assertEquals(2, experimentSummaryModelList.size(), "should only return 2 experiments since limit=2");
assertEquals(experimentIdOne, experimentSummaryModelList.get(0).getExperimentId());
assertEquals(experimentIdTwo, experimentSummaryModelList.get(1).getExperimentId());
// page 2
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
allExperimentIds, filters, 2, 2, DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC);
assertEquals(
1,
@@ -203,14 +212,14 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
"should only return 1 experiment since limit=2 but partial last page");
assertEquals(experimentIdThree, experimentSummaryModelList.get(0).getExperimentId());
// Test with offset at the end (should return empty list)
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
allExperimentIds, filters, 3, 3, DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC);
assertEquals(
0,
experimentSummaryModelList.size(),
"should return 0 since we're just past the last page (page size of 3)");
// Test with offset past the end (should return empty list)
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
allExperimentIds, filters, 3, 10, DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC);
assertEquals(
0,
@@ -226,13 +235,13 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
filters.put(DBConstants.ExperimentSummary.TO_DATE, toDate);
ExperimentStatistics experimentStatistics =
- experimentSummaryRepository.getAccessibleExperimentStatistics(allExperimentIds, filters, 10, 0);
+ experimentSummaryService.getAccessibleExperimentStatistics(allExperimentIds, filters, 10, 0);
assertTrue(experimentStatistics.getAllExperimentCount() == 0);
filters.remove(DBConstants.Experiment.RESOURCE_HOST_ID);
experimentStatistics =
- experimentSummaryRepository.getAccessibleExperimentStatistics(allExperimentIds, filters, 10, 0);
+ experimentSummaryService.getAccessibleExperimentStatistics(allExperimentIds, filters, 10, 0);
assertTrue(experimentStatistics.getAllExperimentCount() == 1);
assertEquals(experimentStatistics.getAllExperiments().get(0).getExperimentId(), experimentIdTwo);
@@ -240,19 +249,19 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
filters.remove(DBConstants.Experiment.EXECUTION_ID);
ExperimentStatus experimentStatusOne = new ExperimentStatus(ExperimentState.CREATED);
- String statusIdOne = experimentStatusRepository.addExperimentStatus(experimentStatusOne, experimentIdOne);
+ String statusIdOne = experimentStatusService.addExperimentStatus(experimentStatusOne, experimentIdOne);
assertTrue(statusIdOne != null);
ExperimentStatus experimentStatusTwo = new ExperimentStatus(ExperimentState.EXECUTING);
- String statusIdTwo = experimentStatusRepository.addExperimentStatus(experimentStatusTwo, experimentIdTwo);
+ String statusIdTwo = experimentStatusService.addExperimentStatus(experimentStatusTwo, experimentIdTwo);
assertTrue(statusIdTwo != null);
ExperimentStatus experimentStatusThree = new ExperimentStatus(ExperimentState.CANCELED);
- String statusIdThree = experimentStatusRepository.addExperimentStatus(experimentStatusThree, experimentIdThree);
+ String statusIdThree = experimentStatusService.addExperimentStatus(experimentStatusThree, experimentIdThree);
assertTrue(statusIdThree != null);
experimentStatistics =
- experimentSummaryRepository.getAccessibleExperimentStatistics(allExperimentIds, filters, 10, 0);
+ experimentSummaryService.getAccessibleExperimentStatistics(allExperimentIds, filters, 10, 0);
assertEquals(2, experimentStatistics.getAllExperimentCount());
assertTrue(experimentStatistics.getRunningExperimentCount() == 1);
// Experiment 3 is most recent
@@ -264,7 +273,7 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
filters.remove(DBConstants.ExperimentSummary.TO_DATE);
experimentStatistics =
- experimentSummaryRepository.getAccessibleExperimentStatistics(allExperimentIds, filters, 10, 0);
+ experimentSummaryService.getAccessibleExperimentStatistics(allExperimentIds, filters, 10, 0);
assertTrue(experimentStatistics.getAllExperimentCount() == 3);
assertTrue(experimentStatistics.getCreatedExperimentCount() == 1);
assertTrue(experimentStatistics.getRunningExperimentCount() == 1);
@@ -274,19 +283,19 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
filters = new HashMap<>();
filters.put(DBConstants.Experiment.GATEWAY_ID, gatewayId);
filters.put(DBConstants.ExperimentSummary.EXPERIMENT_STATUS, ExperimentState.CREATED.name());
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
allExperimentIds, filters, -1, 0, DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC);
assertEquals(1, experimentSummaryModelList.size(), "should return only one CREATED exp");
assertEquals(experimentIdOne, experimentSummaryModelList.get(0).getExperimentId());
// Only EXECUTING status
filters.put(DBConstants.ExperimentSummary.EXPERIMENT_STATUS, ExperimentState.EXECUTING.name());
- experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments(
+ experimentSummaryModelList = experimentSummaryService.searchAllAccessibleExperiments(
allExperimentIds, filters, -1, 0, DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC);
assertEquals(1, experimentSummaryModelList.size(), "should return only one EXECUTING exp");
assertEquals(experimentIdTwo, experimentSummaryModelList.get(0).getExperimentId());
// Experiment 2 is EXECUTING and should be the only one returned
- experimentStatistics = experimentSummaryRepository.getAccessibleExperimentStatistics(
+ experimentStatistics = experimentSummaryService.getAccessibleExperimentStatistics(
Collections.singletonList(experimentIdTwo), filters, 10, 0);
assertTrue(experimentStatistics.getAllExperimentCount() == 1);
assertTrue(experimentStatistics.getCreatedExperimentCount() == 0);
@@ -297,7 +306,7 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
filters.put(DBConstants.Experiment.GATEWAY_ID, gatewayId);
// First page
experimentStatistics =
- experimentSummaryRepository.getAccessibleExperimentStatistics(allExperimentIds, filters, 1, 0);
+ experimentSummaryService.getAccessibleExperimentStatistics(allExperimentIds, filters, 1, 0);
// Should still return total count even when only returning the first page of experiment summaries
assertEquals(3, experimentStatistics.getAllExperimentCount());
// experiment 3 is most recent
@@ -307,7 +316,7 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
experimentStatistics.getAllExperiments().get(0).getExperimentId());
// Second page
experimentStatistics =
- experimentSummaryRepository.getAccessibleExperimentStatistics(allExperimentIds, filters, 1, 1);
+ experimentSummaryService.getAccessibleExperimentStatistics(allExperimentIds, filters, 1, 1);
// Should still return total count even when only returning the first page of experiment summaries
assertEquals(3, experimentStatistics.getAllExperimentCount());
// experiment 2 is less recent
@@ -315,11 +324,11 @@ public class ExperimentSummaryRepositoryTest extends TestBase {
assertEquals(
experimentIdTwo, experimentStatistics.getAllExperiments().get(0).getExperimentId());
- experimentRepository.removeExperiment(experimentIdOne);
- experimentRepository.removeExperiment(experimentIdTwo);
- experimentRepository.removeExperiment(experimentIdThree);
+ experimentService.removeExperiment(experimentIdOne);
+ experimentService.removeExperiment(experimentIdTwo);
+ experimentService.removeExperiment(experimentIdThree);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/GatewayRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/GatewayRepositoryTest.java
index c239d5601b..7bad01a998 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/GatewayRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/GatewayRepositoryTest.java
@@ -36,7 +36,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
-@TestPropertySource(locations = "classpath:application-test.properties")
+@TestPropertySource(locations = "classpath:airavata.properties")
public class GatewayRepositoryTest extends TestBase {
private String testGatewayId = "testGateway";
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobRepositoryTest.java
index 7e05576b4c..d629f7ff62 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobRepositoryTest.java
@@ -45,18 +45,14 @@ import org.apache.airavata.registry.services.ProjectService;
import org.apache.airavata.registry.services.TaskService;
import org.apache.airavata.registry.utils.DBConstants;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
-@TestPropertySource(locations = "classpath:application-test.properties")
+@TestPropertySource(locations = "classpath:airavata.properties")
public class JobRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(JobRepositoryTest.class);
-
@Autowired
GatewayService gatewayService;
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobStatusRepositoryTest.java
index 4fc1fe99c7..e82aec09b5 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobStatusRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobStatusRepositoryTest.java
@@ -35,31 +35,45 @@ import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.entities.expcatalog.JobPK;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.JobService;
+import org.apache.airavata.registry.services.JobStatusService;
+import org.apache.airavata.registry.services.ProcessService;
+import org.apache.airavata.registry.services.ProjectService;
+import org.apache.airavata.registry.services.TaskService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class JobStatusRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(JobStatusRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ProcessRepository processRepository;
- TaskRepository taskRepository;
- JobRepository jobRepository;
- JobStatusRepository jobStatusRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ProcessService processService;
+
+ @Autowired
+ TaskService taskService;
+
+ @Autowired
+ JobService jobService;
+
+ @Autowired
+ JobStatusService jobStatusService;
public JobStatusRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- jobRepository = new JobRepository();
- taskRepository = new TaskRepository(jobRepository);
- processRepository = new ProcessRepository(taskRepository);
- jobStatusRepository = new JobStatusRepository();
}
@Test
@@ -68,14 +82,14 @@ public class JobStatusRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -84,20 +98,20 @@ public class JobStatusRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
ProcessModel processModel = new ProcessModel(null, experimentId);
- String processId = processRepository.addProcess(processModel, experimentId);
+ String processId = processService.addProcess(processModel, experimentId);
TaskModel taskModel = new TaskModel();
taskModel.setTaskType(TaskTypes.JOB_SUBMISSION);
taskModel.setParentProcessId(processId);
- String taskId = taskRepository.addTask(taskModel, processId);
+ String taskId = taskService.addTask(taskModel, processId);
assertTrue(taskId != null);
taskModel.setTaskType(TaskTypes.MONITORING);
- taskRepository.updateTask(taskModel, taskId);
+ taskService.updateTask(taskModel, taskId);
JobPK jobPK = new JobPK();
jobPK.setJobId("job");
@@ -108,25 +122,24 @@ public class JobStatusRepositoryTest extends TestBase {
jobModel.setTaskId(jobPK.getTaskId());
jobModel.setJobDescription("jobDescription");
- String jobId = jobRepository.addJob(jobModel, processId);
+ String jobId = jobService.addJob(jobModel, processId);
assertTrue(jobId != null);
JobStatus jobStatus = new JobStatus(JobState.QUEUED);
- String jobStatusId = jobStatusRepository.addJobStatus(jobStatus, jobPK);
- assertTrue(jobStatusId != null);
- assertTrue(jobRepository.getJob(jobPK).getJobStatuses().size() == 1);
+ jobStatusService.addJobStatus(jobStatus, jobPK);
+ assertTrue(jobService.getJob(jobPK).getJobStatuses().size() == 1);
jobStatus.setJobState(JobState.ACTIVE);
- jobStatusRepository.updateJobStatus(jobStatus, jobPK);
+ jobStatusService.updateJobStatus(jobStatus, jobPK);
- JobStatus retrievedJobStatus = jobStatusRepository.getJobStatus(jobPK);
+ JobStatus retrievedJobStatus = jobStatusService.getJobStatus(jobPK);
assertEquals(JobState.ACTIVE, retrievedJobStatus.getJobState());
- experimentRepository.removeExperiment(experimentId);
- processRepository.removeProcess(processId);
- taskRepository.removeTask(taskId);
- jobRepository.removeJob(jobPK);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ processService.removeProcess(processId);
+ taskService.removeTask(taskId);
+ jobService.removeJob(jobPK);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/NotificationRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/NotificationRepositoryTest.java
index 19909fc599..334549203d 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/NotificationRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/NotificationRepositoryTest.java
@@ -26,20 +26,23 @@ import org.apache.airavata.model.workspace.Notification;
import org.apache.airavata.model.workspace.NotificationPriority;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.NotificationService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class NotificationRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(NotificationRepositoryTest.class);
-
private String testGateway = "testGateway";
- NotificationRepository notificationRepository;
+
+ @Autowired
+ NotificationService notificationService;
public NotificationRepositoryTest() {
super(Database.EXP_CATALOG);
- notificationRepository = new NotificationRepository();
}
@Test
@@ -50,18 +53,17 @@ public class NotificationRepositoryTest extends TestBase {
notification.setTitle("notificationTitle");
notification.setNotificationMessage("notificationMessage");
- String notificationId = notificationRepository.createNotification(notification);
+ String notificationId = notificationService.createNotification(notification);
assertEquals(notification.getNotificationId(), notificationId);
notification.setPriority(NotificationPriority.NORMAL);
- notificationRepository.updateNotification(notification);
+ notificationService.updateNotification(notification);
- Notification retrievedNotification = notificationRepository.getNotification(notificationId);
+ Notification retrievedNotification = notificationService.getNotification(notificationId);
assertEquals(NotificationPriority.NORMAL, retrievedNotification.getPriority());
- assertTrue(
- notificationRepository.getAllGatewayNotifications(testGateway).size() == 1);
+ assertTrue(notificationService.getAllGatewayNotifications(testGateway).size() == 1);
- notificationRepository.deleteNotification(notificationId);
+ notificationService.deleteNotification(notificationId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessErrorRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessErrorRepositoryTest.java
index 8af7a3bc04..b65f302f1c 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessErrorRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessErrorRepositoryTest.java
@@ -31,29 +31,37 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProcessErrorService;
+import org.apache.airavata.registry.services.ProcessService;
+import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ProcessErrorRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ProcessErrorRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ProcessRepository processRepository;
- ProcessErrorRepository processErrorRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ProcessService processService;
+
+ @Autowired
+ ProcessErrorService processErrorService;
public ProcessErrorRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- JobRepository jobRepository = new JobRepository();
- TaskRepository taskRepository = new TaskRepository(jobRepository);
- processRepository = new ProcessRepository(taskRepository);
- processErrorRepository = new ProcessErrorRepository(processRepository);
}
@Test
@@ -62,14 +70,14 @@ public class ProcessErrorRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -78,29 +86,29 @@ public class ProcessErrorRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
ProcessModel processModel = new ProcessModel(null, experimentId);
- String processId = processRepository.addProcess(processModel, experimentId);
+ String processId = processService.addProcess(processModel, experimentId);
assertTrue(processId != null);
ErrorModel errorModel = new ErrorModel();
errorModel.setErrorId("error");
- String processErrorId = processErrorRepository.addProcessError(errorModel, processId);
+ String processErrorId = processErrorService.addProcessError(errorModel, processId);
assertTrue(processErrorId != null);
- assertTrue(processRepository.getProcess(processId).getProcessErrors().size() == 1);
+ assertTrue(processService.getProcess(processId).getProcessErrors().size() == 1);
errorModel.setActualErrorMessage("message");
- processErrorRepository.updateProcessError(errorModel, processId);
+ processErrorService.updateProcessError(errorModel, processId);
- List<ErrorModel> retrievedErrorList = processErrorRepository.getProcessError(processId);
+ List<ErrorModel> retrievedErrorList = processErrorService.getProcessError(processId);
assertTrue(retrievedErrorList.size() == 1);
assertEquals("message", retrievedErrorList.get(0).getActualErrorMessage());
- experimentRepository.removeExperiment(experimentId);
- processRepository.removeProcess(processId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ processService.removeProcess(processId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessInputRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessInputRepositoryTest.java
index 971218f48e..98a770f2e2 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessInputRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessInputRepositoryTest.java
@@ -33,29 +33,37 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProcessInputService;
+import org.apache.airavata.registry.services.ProcessService;
+import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ProcessInputRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ProcessInputRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ProcessRepository processRepository;
- ProcessInputRepository processInputRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ProcessService processService;
+
+ @Autowired
+ ProcessInputService processInputService;
public ProcessInputRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- JobRepository jobRepository = new JobRepository();
- TaskRepository taskRepository = new TaskRepository(jobRepository);
- processRepository = new ProcessRepository(taskRepository);
- processInputRepository = new ProcessInputRepository(processRepository);
}
@Test
@@ -64,14 +72,14 @@ public class ProcessInputRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -80,10 +88,10 @@ public class ProcessInputRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
ProcessModel processModel = new ProcessModel(null, experimentId);
- String processId = processRepository.addProcess(processModel, experimentId);
+ String processId = processService.addProcess(processModel, experimentId);
assertTrue(processId != null);
InputDataObjectType inputDataObjectProType = new InputDataObjectType();
@@ -93,20 +101,20 @@ public class ProcessInputRepositoryTest extends TestBase {
List<InputDataObjectType> inputDataObjectTypeProList = new ArrayList<>();
inputDataObjectTypeProList.add(inputDataObjectProType);
- assertEquals(processId, processInputRepository.addProcessInputs(inputDataObjectTypeProList, processId));
- assertTrue(processRepository.getProcess(processId).getProcessInputs().size() == 1);
+ assertEquals(processId, processInputService.addProcessInputs(inputDataObjectTypeProList, processId));
+ assertTrue(processService.getProcess(processId).getProcessInputs().size() == 1);
inputDataObjectProType.setValue("iValueP");
- processInputRepository.updateProcessInputs(inputDataObjectTypeProList, processId);
+ processInputService.updateProcessInputs(inputDataObjectTypeProList, processId);
- List<InputDataObjectType> retrievedProInputsList = processInputRepository.getProcessInputs(processId);
+ List<InputDataObjectType> retrievedProInputsList = processInputService.getProcessInputs(processId);
assertTrue(retrievedProInputsList.size() == 1);
assertEquals("iValueP", retrievedProInputsList.get(0).getValue());
assertEquals(DataType.STDOUT, retrievedProInputsList.get(0).getType());
- experimentRepository.removeExperiment(experimentId);
- processRepository.removeProcess(processId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ processService.removeProcess(processId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessOutputRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessOutputRepositoryTest.java
index bf3bc1f944..d69100d204 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessOutputRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessOutputRepositoryTest.java
@@ -33,29 +33,37 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProcessOutputService;
+import org.apache.airavata.registry.services.ProcessService;
+import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ProcessOutputRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ProcessOutputRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ProcessRepository processRepository;
- ProcessOutputRepository processOutputRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ProcessService processService;
+
+ @Autowired
+ ProcessOutputService processOutputService;
public ProcessOutputRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- JobRepository jobRepository = new JobRepository();
- TaskRepository taskRepository = new TaskRepository(jobRepository);
- processRepository = new ProcessRepository(taskRepository);
- processOutputRepository = new ProcessOutputRepository(processRepository);
}
@Test
@@ -64,14 +72,14 @@ public class ProcessOutputRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -80,10 +88,10 @@ public class ProcessOutputRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
ProcessModel processModel = new ProcessModel(null, experimentId);
- String processId = processRepository.addProcess(processModel, experimentId);
+ String processId = processService.addProcess(processModel, experimentId);
assertTrue(processId != null);
OutputDataObjectType outputDataObjectProType = new OutputDataObjectType();
@@ -93,20 +101,20 @@ public class ProcessOutputRepositoryTest extends TestBase {
List<OutputDataObjectType> outputDataObjectTypeProList = new ArrayList<>();
outputDataObjectTypeProList.add(outputDataObjectProType);
- assertEquals(processId, processOutputRepository.addProcessOutputs(outputDataObjectTypeProList, processId));
- assertTrue(processRepository.getProcess(processId).getProcessOutputs().size() == 1);
+ processOutputService.addProcessOutputs(outputDataObjectTypeProList, processId);
+ assertTrue(processService.getProcess(processId).getProcessOutputs().size() == 1);
outputDataObjectProType.setValue("oValueP");
- processOutputRepository.updateProcessOutputs(outputDataObjectTypeProList, processId);
+ processOutputService.updateProcessOutputs(outputDataObjectTypeProList, processId);
- List<OutputDataObjectType> retrievedProOutputList = processOutputRepository.getProcessOutputs(processId);
+ List<OutputDataObjectType> retrievedProOutputList = processOutputService.getProcessOutputs(processId);
assertTrue(retrievedProOutputList.size() == 1);
assertEquals("oValueP", retrievedProOutputList.get(0).getValue());
assertEquals(DataType.STDERR, retrievedProOutputList.get(0).getType());
- experimentRepository.removeExperiment(experimentId);
- processRepository.removeProcess(processId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ processService.removeProcess(processId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessRepositoryTest.java
index 35fb3d9c3b..8686991143 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessRepositoryTest.java
@@ -34,28 +34,34 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProcessService;
+import org.apache.airavata.registry.services.ProjectService;
import org.apache.airavata.registry.utils.DBConstants;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ProcessRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ProcessRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ProcessRepository processRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ProcessService processService;
public ProcessRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- JobRepository jobRepository = new JobRepository();
- TaskRepository taskRepository = new TaskRepository(jobRepository);
- processRepository = new ProcessRepository(taskRepository);
}
@Test
@@ -64,14 +70,14 @@ public class ProcessRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -80,7 +86,7 @@ public class ProcessRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
ProcessModel processModel = new ProcessModel(null, experimentId);
@@ -93,10 +99,9 @@ public class ProcessRepositoryTest extends TestBase {
taskStatus.setStatusId("task-status-id");
task.addToTaskStatuses(taskStatus);
- String processId = processRepository.addProcess(processModel, experimentId);
+ String processId = processService.addProcess(processModel, experimentId);
assertTrue(processId != null);
- assertTrue(
- experimentRepository.getExperiment(experimentId).getProcesses().size() == 1);
+ assertTrue(experimentService.getExperiment(experimentId).getProcesses().size() == 1);
processModel.setProcessDetail("detail");
processModel.setUseUserCRPref(true);
@@ -115,9 +120,9 @@ public class ProcessRepositoryTest extends TestBase {
job.addToJobStatuses(jobStatus);
jobSubmissionTask.addToJobs(job);
processModel.addToTasks(jobSubmissionTask);
- processRepository.updateProcess(processModel, processId);
+ processService.updateProcess(processModel, processId);
- ProcessModel retrievedProcess = processRepository.getProcess(processId);
+ ProcessModel retrievedProcess = processService.getProcess(processId);
assertEquals(experimentId, retrievedProcess.getExperimentId());
assertEquals("detail", retrievedProcess.getProcessDetail());
assertTrue(retrievedProcess.isUseUserCRPref());
@@ -134,17 +139,16 @@ public class ProcessRepositoryTest extends TestBase {
ComputationalResourceSchedulingModel computationalResourceSchedulingModel =
new ComputationalResourceSchedulingModel();
assertEquals(
- processId,
- processRepository.addProcessResourceSchedule(computationalResourceSchedulingModel, processId));
+ processId, processService.addProcessResourceSchedule(computationalResourceSchedulingModel, processId));
computationalResourceSchedulingModel.setQueueName("queue");
computationalResourceSchedulingModel.setStaticWorkingDir("staticWorkingDir");
computationalResourceSchedulingModel.setOverrideAllocationProjectNumber("overrideAllocationProjectNumber");
computationalResourceSchedulingModel.setOverrideLoginUserName("overrideLoginUserName");
computationalResourceSchedulingModel.setOverrideScratchLocation("overrideScratchLocation");
- processRepository.updateProcessResourceSchedule(computationalResourceSchedulingModel, processId);
+ processService.updateProcessResourceSchedule(computationalResourceSchedulingModel, processId);
ComputationalResourceSchedulingModel updatedComputationalResourceSchedulingModel =
- processRepository.getProcessResourceSchedule(processId);
+ processService.getProcessResourceSchedule(processId);
assertEquals("queue", updatedComputationalResourceSchedulingModel.getQueueName());
assertEquals("staticWorkingDir", updatedComputationalResourceSchedulingModel.getStaticWorkingDir());
assertEquals(
@@ -154,15 +158,15 @@ public class ProcessRepositoryTest extends TestBase {
assertEquals(
"overrideScratchLocation", updatedComputationalResourceSchedulingModel.getOverrideScratchLocation());
- List<String> processIdList = processRepository.getProcessIds(DBConstants.Process.EXPERIMENT_ID, experimentId);
+ List<String> processIdList = processService.getProcessIds(DBConstants.Process.EXPERIMENT_ID, experimentId);
assertTrue(processIdList.size() == 1);
assertTrue(processIdList.get(0).equals(processId));
- experimentRepository.removeExperiment(experimentId);
- processRepository.removeProcess(processId);
- assertFalse(processRepository.isProcessExist(processId));
+ experimentService.removeExperiment(experimentId);
+ processService.removeProcess(processId);
+ assertFalse(processService.isProcessExist(processId));
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessStatusRepositoryTest.java
index 051468e667..afc7ef52bc 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessStatusRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessStatusRepositoryTest.java
@@ -38,18 +38,14 @@ import org.apache.airavata.registry.services.ProcessService;
import org.apache.airavata.registry.services.ProcessStatusService;
import org.apache.airavata.registry.services.ProjectService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
-@TestPropertySource(locations = "classpath:application-test.properties")
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ProcessStatusRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ProcessStatusRepositoryTest.class);
-
@Autowired
GatewayService gatewayService;
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProjectRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProjectRepositoryTest.java
index 0e6cfd0b8c..a4c3b9b177 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProjectRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProjectRepositoryTest.java
@@ -29,17 +29,18 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProjectService;
import org.apache.airavata.registry.utils.Constants;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class ProjectRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(ProjectRepositoryTest.class);
-
- private String testGateway = "testGateway";
-
@Autowired
GatewayService gatewayService;
@@ -52,6 +53,7 @@ public class ProjectRepositoryTest extends TestBase {
@Test
public void testProjectRepository() throws RegistryException {
+ String testGateway = "testGateway";
Gateway gateway = new Gateway();
gateway.setGatewayId(testGateway);
gateway.setDomain("SEAGRID");
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/QueueStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/QueueStatusRepositoryTest.java
index eb3bbea3ab..a21777908b 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/QueueStatusRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/QueueStatusRepositoryTest.java
@@ -27,18 +27,21 @@ import java.util.List;
import org.apache.airavata.model.status.QueueStatusModel;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.QueueStatusService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class QueueStatusRepositoryTest extends TestBase {
- QueueStatusRepository queueStatusRepository;
- private static final Logger logger = LoggerFactory.getLogger(QueueStatusRepositoryTest.class);
+ @Autowired
+ QueueStatusService queueStatusService;
public QueueStatusRepositoryTest() {
super(Database.EXP_CATALOG);
- queueStatusRepository = new QueueStatusRepository();
}
@Test
@@ -51,10 +54,10 @@ public class QueueStatusRepositoryTest extends TestBase {
queueStatusModel.setQueuedJobs(2);
queueStatusModel.setTime(System.currentTimeMillis());
- boolean returnValue = queueStatusRepository.createQueueStatuses(Arrays.asList(queueStatusModel));
+ boolean returnValue = queueStatusService.createQueueStatuses(Arrays.asList(queueStatusModel));
assertTrue(returnValue);
- List<QueueStatusModel> queueStatusModelList = queueStatusRepository.getLatestQueueStatuses();
+ List<QueueStatusModel> queueStatusModelList = queueStatusService.getLatestQueueStatuses();
assertTrue(queueStatusModelList.size() == 1);
assertEquals(queueStatusModel.getHostName(), queueStatusModelList.get(0).getHostName());
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskErrorRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskErrorRepositoryTest.java
index 80f0544123..c75aacfce5 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskErrorRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskErrorRepositoryTest.java
@@ -33,30 +33,41 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProcessService;
+import org.apache.airavata.registry.services.ProjectService;
+import org.apache.airavata.registry.services.TaskErrorService;
+import org.apache.airavata.registry.services.TaskService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class TaskErrorRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(TaskErrorRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ProcessRepository processRepository;
- TaskRepository taskRepository;
- TaskErrorRepository taskErrorRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ProcessService processService;
+
+ @Autowired
+ TaskService taskService;
+
+ @Autowired
+ TaskErrorService taskErrorService;
public TaskErrorRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- JobRepository jobRepository = new JobRepository();
- taskRepository = new TaskRepository(jobRepository);
- processRepository = new ProcessRepository(taskRepository);
- taskErrorRepository = new TaskErrorRepository(taskRepository);
}
@Test
@@ -65,14 +76,14 @@ public class TaskErrorRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -81,36 +92,36 @@ public class TaskErrorRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
ProcessModel processModel = new ProcessModel(null, experimentId);
- String processId = processRepository.addProcess(processModel, experimentId);
+ String processId = processService.addProcess(processModel, experimentId);
TaskModel taskModel = new TaskModel();
taskModel.setTaskType(TaskTypes.JOB_SUBMISSION);
taskModel.setParentProcessId(processId);
- String taskId = taskRepository.addTask(taskModel, processId);
+ String taskId = taskService.addTask(taskModel, processId);
assertTrue(taskId != null);
ErrorModel errorModel = new ErrorModel();
errorModel.setErrorId("error");
- String taskErrorId = taskErrorRepository.addTaskError(errorModel, taskId);
+ String taskErrorId = taskErrorService.addTaskError(errorModel, taskId);
assertTrue(taskErrorId != null);
- assertTrue(taskRepository.getTask(taskId).getTaskErrors().size() == 1);
+ assertTrue(taskService.getTask(taskId).getTaskErrors().size() == 1);
errorModel.setActualErrorMessage("message");
- taskErrorRepository.updateTaskError(errorModel, taskId);
+ taskErrorService.updateTaskError(errorModel, taskId);
- List<ErrorModel> retrievedErrorList = taskErrorRepository.getTaskError(taskId);
+ List<ErrorModel> retrievedErrorList = taskErrorService.getTaskError(taskId);
assertTrue(retrievedErrorList.size() == 1);
assertEquals("message", retrievedErrorList.get(0).getActualErrorMessage());
- experimentRepository.removeExperiment(experimentId);
- processRepository.removeProcess(processId);
- taskRepository.removeTask(taskId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ processService.removeProcess(processId);
+ taskService.removeTask(taskId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskRepositoryTest.java
index fe47de6c84..092547a90f 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskRepositoryTest.java
@@ -35,29 +35,38 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProcessService;
+import org.apache.airavata.registry.services.ProjectService;
+import org.apache.airavata.registry.services.TaskService;
import org.apache.airavata.registry.utils.DBConstants;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class TaskRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(TaskRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ProcessRepository processRepository;
- TaskRepository taskRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ProcessService processService;
+
+ @Autowired
+ TaskService taskService;
public TaskRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- JobRepository jobRepository = new JobRepository();
- taskRepository = new TaskRepository(jobRepository);
- processRepository = new ProcessRepository(taskRepository);
}
@Test
@@ -66,14 +75,14 @@ public class TaskRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -82,10 +91,10 @@ public class TaskRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
ProcessModel processModel = new ProcessModel(null, experimentId);
- String processId = processRepository.addProcess(processModel, experimentId);
+ String processId = processService.addProcess(processModel, experimentId);
TaskModel taskModel = new TaskModel();
taskModel.setTaskType(TaskTypes.JOB_SUBMISSION);
@@ -96,28 +105,28 @@ public class TaskRepositoryTest extends TestBase {
taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
taskModel.addToTaskStatuses(taskStatus);
- String taskId = taskRepository.addTask(taskModel, processId);
+ String taskId = taskService.addTask(taskModel, processId);
assertTrue(taskId != null);
- assertTrue(processRepository.getProcess(processId).getTasks().size() == 1);
+ assertTrue(processService.getProcess(processId).getTasks().size() == 1);
taskModel.setTaskType(TaskTypes.MONITORING);
- taskRepository.updateTask(taskModel, taskId);
- TaskModel retrievedTask = taskRepository.getTask(taskId);
+ taskService.updateTask(taskModel, taskId);
+ TaskModel retrievedTask = taskService.getTask(taskId);
assertEquals(TaskTypes.MONITORING, retrievedTask.getTaskType());
assertArrayEquals("subtask model".getBytes(StandardCharsets.UTF_8), retrievedTask.getSubTaskModel());
assertEquals(1, retrievedTask.getTaskStatusesSize());
assertEquals(TaskState.CREATED, retrievedTask.getTaskStatuses().get(0).getState());
- List<String> taskIdList = taskRepository.getTaskIds(DBConstants.Task.PARENT_PROCESS_ID, processId);
+ List<String> taskIdList = taskService.getTaskIds(DBConstants.Task.PARENT_PROCESS_ID, processId);
assertTrue(taskIdList.size() == 1);
assertTrue(taskIdList.get(0).equals(taskId));
- experimentRepository.removeExperiment(experimentId);
- processRepository.removeProcess(processId);
- taskRepository.removeTask(taskId);
- assertFalse(taskRepository.isTaskExist(taskId));
+ experimentService.removeExperiment(experimentId);
+ processService.removeProcess(processId);
+ taskService.removeTask(taskId);
+ assertFalse(taskService.isTaskExist(taskId));
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskStatusRepositoryTest.java
index 3150176f02..8f443336bb 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskStatusRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskStatusRepositoryTest.java
@@ -33,30 +33,41 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.ExperimentService;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.ProcessService;
+import org.apache.airavata.registry.services.ProjectService;
+import org.apache.airavata.registry.services.TaskService;
+import org.apache.airavata.registry.services.TaskStatusService;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class TaskStatusRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(TaskStatusRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
- GatewayRepository gatewayRepository;
- ProjectRepository projectRepository;
- ExperimentRepository experimentRepository;
- ProcessRepository processRepository;
- TaskRepository taskRepository;
- TaskStatusRepository taskStatusRepository;
+ @Autowired
+ ProjectService projectService;
+
+ @Autowired
+ ExperimentService experimentService;
+
+ @Autowired
+ ProcessService processService;
+
+ @Autowired
+ TaskService taskService;
+
+ @Autowired
+ TaskStatusService taskStatusService;
public TaskStatusRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- projectRepository = new ProjectRepository();
- experimentRepository = new ExperimentRepository();
- JobRepository jobRepository = new JobRepository();
- taskRepository = new TaskRepository(jobRepository);
- processRepository = new ProcessRepository(taskRepository);
- taskStatusRepository = new TaskStatusRepository(taskRepository);
}
@Test
@@ -65,14 +76,14 @@ public class TaskStatusRepositoryTest extends TestBase {
gateway.setGatewayId("gateway");
gateway.setDomain("SEAGRID");
gateway.setEmailAddress("abc@d.com");
- String gatewayId = gatewayRepository.addGateway(gateway);
+ String gatewayId = gatewayService.addGateway(gateway);
Project project = new Project();
project.setName("projectName");
project.setOwner("user");
project.setGatewayId(gatewayId);
- String projectId = projectRepository.addProject(project, gatewayId);
+ String projectId = projectService.addProject(project, gatewayId);
ExperimentModel experimentModel = new ExperimentModel();
experimentModel.setProjectId(projectId);
@@ -81,33 +92,32 @@ public class TaskStatusRepositoryTest extends TestBase {
experimentModel.setUserName("user");
experimentModel.setExperimentName("name");
- String experimentId = experimentRepository.addExperiment(experimentModel);
+ String experimentId = experimentService.addExperiment(experimentModel);
ProcessModel processModel = new ProcessModel(null, experimentId);
- String processId = processRepository.addProcess(processModel, experimentId);
+ String processId = processService.addProcess(processModel, experimentId);
TaskModel taskModel = new TaskModel();
taskModel.setTaskType(TaskTypes.JOB_SUBMISSION);
taskModel.setParentProcessId(processId);
- String taskId = taskRepository.addTask(taskModel, processId);
+ String taskId = taskService.addTask(taskModel, processId);
assertTrue(taskId != null);
TaskStatus taskStatus = new TaskStatus(TaskState.EXECUTING);
- String taskStatusId = taskStatusRepository.addTaskStatus(taskStatus, taskId);
- assertTrue(taskStatusId != null);
- assertTrue(taskRepository.getTask(taskId).getTaskStatuses().size() == 1);
+ taskStatusService.addTaskStatus(taskStatus, taskId);
+ assertTrue(taskService.getTask(taskId).getTaskStatuses().size() == 1);
taskStatus.setState(TaskState.CREATED);
- taskStatusRepository.updateTaskStatus(taskStatus, taskId);
+ taskStatusService.updateTaskStatus(taskStatus, taskId);
- TaskStatus retrievedTaskStatus = taskStatusRepository.getTaskStatus(taskId);
+ TaskStatus retrievedTaskStatus = taskStatusService.getTaskStatus(taskId);
assertEquals(TaskState.CREATED, retrievedTaskStatus.getState());
- experimentRepository.removeExperiment(experimentId);
- processRepository.removeProcess(processId);
- taskRepository.removeTask(taskId);
- gatewayRepository.removeGateway(gatewayId);
- projectRepository.removeProject(projectId);
+ experimentService.removeExperiment(experimentId);
+ processService.removeProcess(processId);
+ taskService.removeTask(taskId);
+ gatewayService.removeGateway(gatewayId);
+ projectService.removeProject(projectId);
}
}
diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/UserRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/UserRepositoryTest.java
index d2b466b7cf..9fa80625d7 100644
--- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/UserRepositoryTest.java
+++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/UserRepositoryTest.java
@@ -30,25 +30,30 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.registry.entities.expcatalog.UserPK;
import org.apache.airavata.registry.exceptions.RegistryException;
import org.apache.airavata.registry.repositories.common.TestBase;
+import org.apache.airavata.registry.services.GatewayService;
+import org.apache.airavata.registry.services.UserService;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class})
+@TestPropertySource(locations = "classpath:airavata.properties")
public class UserRepositoryTest extends TestBase {
- private static final Logger logger = LoggerFactory.getLogger(UserRepositoryTest.class);
+ @Autowired
+ GatewayService gatewayService;
+
+ @Autowired
+ UserService userService;
- GatewayRepository gatewayRepository;
- UserRepository userRepository;
private String gatewayId;
private String gatewayId2;
public UserRepositoryTest() {
super(Database.EXP_CATALOG);
- gatewayRepository = new GatewayRepository();
- userRepository = new UserRepository();
}
@BeforeEach
@@ -56,18 +61,18 @@ public class UserRepositoryTest extends TestBase {
Gateway gateway = new Gateway();
gateway.setGatewayId("gateway");
- gatewayId = gatewayRepository.addGateway(gateway);
+ gatewayId = gatewayService.addGateway(gateway);
Gateway gateway2 = new Gateway();
gateway2.setGatewayId("gateway2");
- gatewayId2 = gatewayRepository.addGateway(gateway2);
+ gatewayId2 = gatewayService.addGateway(gateway2);
}
@AfterEach
public void deleteTestData() throws RegistryException {
- gatewayRepository.removeGateway(gatewayId);
- gatewayRepository.removeGateway(gatewayId2);
+ gatewayService.removeGateway(gatewayId);
+ gatewayService.removeGateway(gatewayId2);
}
@Test
@@ -78,13 +83,13 @@ public class UserRepositoryTest extends TestBase {
userProfile.setAiravataInternalUserId("username@" + gatewayId);
userProfile.setGatewayId(gatewayId);
- userRepository.addUser(userProfile);
- UserProfile retrievedUserProfile = userRepository.get(new UserPK(gatewayId, "username"));
+ userService.addUser(userProfile);
+ UserProfile retrievedUserProfile = userService.get(new UserPK(gatewayId, "username"));
assertEquals("username", retrievedUserProfile.getUserId());
assertEquals("username@" + gatewayId, retrievedUserProfile.getAiravataInternalUserId());
assertEquals(gatewayId, retrievedUserProfile.getGatewayId());
- userRepository.delete(new UserPK(gatewayId, "username"));
+ userService.delete(new UserPK(gatewayId, "username"));
}
@Test
@@ -96,32 +101,32 @@ public class UserRepositoryTest extends TestBase {
userProfile.setUserId(username1);
userProfile.setAiravataInternalUserId(username1 + "@" + gatewayId);
userProfile.setGatewayId(gatewayId);
- userRepository.addUser(userProfile);
+ userService.addUser(userProfile);
String username2 = "username2";
UserProfile userProfile2 = new UserProfile();
userProfile2.setUserId(username2);
userProfile2.setAiravataInternalUserId(username2 + "@" + gatewayId);
userProfile2.setGatewayId(gatewayId);
- userRepository.addUser(userProfile2);
+ userService.addUser(userProfile2);
String username3 = "username3";
UserProfile userProfile3 = new UserProfile();
userProfile3.setUserId(username3);
userProfile3.setAiravataInternalUserId(username3 + "@" + gatewayId2);
userProfile3.setGatewayId(gatewayId2);
- userRepository.addUser(userProfile3);
+ userService.addUser(userProfile3);
- List<String> gateway1Usernames = userRepository.getAllUsernamesInGateway(gatewayId);
+ List<String> gateway1Usernames = userService.getAllUsernamesInGateway(gatewayId);
assertEquals(2, gateway1Usernames.size());
assertEquals(new HashSet<>(Arrays.asList(username1, username2)), new HashSet<>(gateway1Usernames));
- List<String> gateway2Usernames = userRepository.getAllUsernamesInGateway(gatewayId2);
+ List<String> gateway2Usernames = userService.getAllUsernamesInGateway(gatewayId2);
assertEquals(1, gateway2Usernames.size());
assertEquals(Collections.singleton(username3), new HashSet<>(gateway2Usernames));
- userRepository.delete(new UserPK(gatewayId, username1));
- userRepository.delete(new UserPK(gatewayId, username2));
- userRepository.delete(new UserPK(gatewayId2, username3));
... 865 lines suppressed ...