Return-Path: X-Original-To: apmail-airavata-commits-archive@www.apache.org Delivered-To: apmail-airavata-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B3F111197A for ; Tue, 20 May 2014 16:26:14 +0000 (UTC) Received: (qmail 1781 invoked by uid 500); 20 May 2014 16:26:14 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 1739 invoked by uid 500); 20 May 2014 16:26:14 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 1732 invoked by uid 99); 20 May 2014 16:26:14 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 May 2014 16:26:14 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6FB639384E4; Tue, 20 May 2014 16:26:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: chathuri@apache.org To: commits@airavata.apache.org Message-Id: <34ac6a66d7aa4f89a53e44c58f47c156@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: fixing AIRAVATA-1244 Date: Tue, 20 May 2014 16:26:14 +0000 (UTC) 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 Authored: Tue May 20 12:26:09 2014 -0400 Committer: Chathuri Wimalasena 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 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 projects = new ArrayList(); try { registry = RegistryFactory.getDefaultRegistry(); @@ -163,9 +178,23 @@ public class AiravataServerHandler implements Airavata.Iface { */ @Override public List 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 experiments = new ArrayList(); 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 experiments = new ArrayList(); if (registry.isExist(RegistryModelType.PROJECT, projectId)){ List 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 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 experiments = new ArrayList(); registry = RegistryFactory.getDefaultRegistry();