airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: fixing AIRAVATA-1244
Date Tue, 20 May 2014 16:26:14 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 054093f36 -> ddf262d3d


fixing AIRAVATA-1244


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

Branch: refs/heads/master
Commit: ddf262d3d344696707f1fb7a83597709736454d1
Parents: 054093f
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Tue May 20 12:26:09 2014 -0400
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Tue May 20 12:26:09 2014 -0400

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   | 45 +++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/ddf262d3/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index f1cdaaa..d123446 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -28,6 +28,7 @@ import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.orchestrator.client.OrchestratorClientFactory;
 import org.apache.airavata.orchestrator.cpi.OrchestratorService;
 import org.apache.airavata.orchestrator.cpi.OrchestratorService.Client;
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
 import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
 import org.apache.airavata.model.workspace.experiment.*;
 import org.apache.airavata.registry.cpi.*;
@@ -137,6 +138,20 @@ public class AiravataServerHandler implements Airavata.Iface {
      */
     @Override
     public List<Project> getAllUserProjects(String userName) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
+        if (userName == null || userName.equals("")){
+            logger.error("Username cannot be empty. Please provide a valid user..");
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Username cannot be empty. Please provide a valid user..");
+            throw exception;
+        }
+        if (!ResourceUtils.isUserExist(userName)){
+            logger.error("User does not exist in the system. Please provide a valid user..");
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("User does not exist in the system. Please provide a valid
user..");
+            throw exception;
+        }
         List<Project> projects = new ArrayList<Project>();
         try {
             registry = RegistryFactory.getDefaultRegistry();
@@ -163,9 +178,23 @@ public class AiravataServerHandler implements Airavata.Iface {
      */
     @Override
     public List<Experiment> getAllExperimentsInProject(String projectId) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
+        if (projectId == null || projectId.equals("")){
+            logger.error("Project id cannot be empty. Please provide a valid project ID...");
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Project id cannot be empty. Please provide a valid project
ID...");
+            throw exception;
+        }
         try {
-            List<Experiment> experiments = new ArrayList<Experiment>();
             registry = RegistryFactory.getDefaultRegistry();
+            if (!registry.isExist(RegistryModelType.PROJECT, projectId)){
+                logger.error("Project does not exist in the system. Please provide a valid
project ID...");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("Project does not exist in the system. Please provide
a valid project ID...");
+                throw exception;
+            }
+            List<Experiment> experiments = new ArrayList<Experiment>();
             if (registry.isExist(RegistryModelType.PROJECT, projectId)){
 	            List<Object> list = registry.get(RegistryModelType.EXPERIMENT, Constants.FieldConstants.ExperimentConstants.PROJECT_ID,
projectId);
 	            if (list != null && !list.isEmpty()){
@@ -191,6 +220,20 @@ public class AiravataServerHandler implements Airavata.Iface {
      */
     @Override
     public List<Experiment> getAllUserExperiments(String userName) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
+        if (userName == null || userName.equals("")){
+            logger.error("Username cannot be empty. Please provide a valid user..");
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Username cannot be empty. Please provide a valid user..");
+            throw exception;
+        }
+        if (!ResourceUtils.isUserExist(userName)){
+            logger.error("User does not exist in the system. Please provide a valid user..");
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("User does not exist in the system. Please provide a valid
user..");
+            throw exception;
+        }
         try {
             List<Experiment> experiments = new ArrayList<Experiment>();
             registry = RegistryFactory.getDefaultRegistry();


Mime
View raw message