moved commons-utils to commons module
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/8d16d0ec Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/8d16d0ec Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/8d16d0ec Branch: refs/heads/master Commit: 8d16d0ec5da700f1b576fbcc582e584978d43e60 Parents: a5cb91f Author: Shameera Rathanyaka <[email protected]> Authored: Thu Jun 11 17:34:31 2015 -0400 Committer: Shameera Rathanyaka <[email protected]> Committed: Thu Jun 11 17:34:31 2015 -0400 ---------------------------------------------------------------------- airavata-api/airavata-api-server/pom.xml | 2 +- .../airavata/api/server/AiravataAPIServer.java | 5 - .../api/server/handler/utils/ExpCatInit.java | 4 - distribution/pom.xml | 2 +- modules/commons/pom.xml | 122 +++- .../airavata/common/context/RequestContext.java | 56 ++ .../common/context/WorkflowContext.java | 86 +++ .../AiravataConfigurationException.java | 37 + .../common/exception/AiravataException.java | 37 + .../exception/ApplicationSettingsException.java | 35 + .../ApplicationSettingsLoadException.java | 38 ++ .../ApplicationSettingsStoreException.java | 34 + .../exception/LazyLoadedDataException.java | 30 + ...UnspecifiedApplicationSettingsException.java | 30 + .../common/exception/UtilsException.java | 61 ++ .../airavata/common/logger/AiravataLogger.java | 677 +++++++++++++++++++ .../common/logger/AiravataLoggerFactory.java | 34 + .../common/logger/AiravataLoggerImpl.java | 323 +++++++++ .../airavata/common/utils/AiravataJobState.java | 117 ++++ .../airavata/common/utils/AiravataUtils.java | 47 ++ .../airavata/common/utils/AiravataZKUtils.java | 205 ++++++ .../common/utils/ApplicationSettings.java | 444 ++++++++++++ .../airavata/common/utils/BrowserLauncher.java | 98 +++ .../airavata/common/utils/ClientSettings.java | 27 + .../apache/airavata/common/utils/Constants.java | 66 ++ .../apache/airavata/common/utils/DBUtil.java | 334 +++++++++ .../common/utils/DatabaseTestCases.java | 123 ++++ .../utils/DefaultKeyStorePasswordCallback.java | 55 ++ .../apache/airavata/common/utils/DerbyUtil.java | 114 ++++ .../airavata/common/utils/ExecutionMode.java | 28 + .../apache/airavata/common/utils/IOUtil.java | 209 ++++++ .../apache/airavata/common/utils/IServer.java | 51 ++ .../apache/airavata/common/utils/JSONUtil.java | 158 +++++ .../common/utils/KeyStorePasswordCallback.java | 50 ++ .../airavata/common/utils/MonitorPublisher.java | 47 ++ .../airavata/common/utils/NameValidator.java | 70 ++ .../org/apache/airavata/common/utils/Pair.java | 79 +++ .../airavata/common/utils/SecurityUtil.java | 180 +++++ .../airavata/common/utils/ServerSettings.java | 270 ++++++++ .../airavata/common/utils/ServiceUtils.java | 93 +++ .../airavata/common/utils/StringUtil.java | 480 +++++++++++++ .../apache/airavata/common/utils/SwingUtil.java | 358 ++++++++++ .../airavata/common/utils/ThriftUtils.java | 37 + .../apache/airavata/common/utils/Version.java | 120 ++++ .../airavata/common/utils/WSConstants.java | 187 +++++ .../apache/airavata/common/utils/WSDLUtil.java | 546 +++++++++++++++ .../apache/airavata/common/utils/XMLUtil.java | 586 ++++++++++++++++ .../airavata/common/utils/XmlFormatter.java | 82 +++ .../listener/AbstractActivityListener.java | 27 + .../listener/AbstractStateChangeRequest.java | 27 + .../common/utils/listener/PublisherMessage.java | 26 + .../common/utils/ApplicationSettingsTest.java | 43 ++ .../airavata/common/utils/SecurityUtilTest.java | 104 +++ .../airavata/common/utils/XMLUtilTest.java | 56 ++ .../commons/src/test/resources/mykeystore.jks | Bin 0 -> 498 bytes modules/commons/utils/pom.xml | 150 ---- .../airavata/common/context/RequestContext.java | 56 -- .../common/context/WorkflowContext.java | 86 --- .../AiravataConfigurationException.java | 37 - .../common/exception/AiravataException.java | 37 - .../exception/ApplicationSettingsException.java | 35 - .../ApplicationSettingsLoadException.java | 38 -- .../ApplicationSettingsStoreException.java | 34 - .../exception/LazyLoadedDataException.java | 30 - ...UnspecifiedApplicationSettingsException.java | 30 - .../common/exception/UtilsException.java | 61 -- .../airavata/common/logger/AiravataLogger.java | 677 ------------------- .../common/logger/AiravataLoggerFactory.java | 34 - .../common/logger/AiravataLoggerImpl.java | 323 --------- .../airavata/common/utils/AiravataJobState.java | 117 ---- .../airavata/common/utils/AiravataUtils.java | 47 -- .../airavata/common/utils/AiravataZKUtils.java | 205 ------ .../common/utils/ApplicationSettings.java | 444 ------------ .../airavata/common/utils/BrowserLauncher.java | 98 --- .../airavata/common/utils/ClientSettings.java | 27 - .../apache/airavata/common/utils/Constants.java | 66 -- .../apache/airavata/common/utils/DBUtil.java | 334 --------- .../common/utils/DatabaseTestCases.java | 123 ---- .../utils/DefaultKeyStorePasswordCallback.java | 55 -- .../apache/airavata/common/utils/DerbyUtil.java | 114 ---- .../airavata/common/utils/ExecutionMode.java | 28 - .../apache/airavata/common/utils/IOUtil.java | 209 ------ .../apache/airavata/common/utils/IServer.java | 51 -- .../apache/airavata/common/utils/JSONUtil.java | 160 ----- .../common/utils/KeyStorePasswordCallback.java | 50 -- .../airavata/common/utils/MonitorPublisher.java | 47 -- .../airavata/common/utils/NameValidator.java | 70 -- .../org/apache/airavata/common/utils/Pair.java | 79 --- .../airavata/common/utils/SecurityUtil.java | 181 ----- .../airavata/common/utils/ServerSettings.java | 270 -------- .../airavata/common/utils/ServiceUtils.java | 93 --- .../airavata/common/utils/StringUtil.java | 480 ------------- .../apache/airavata/common/utils/SwingUtil.java | 361 ---------- .../airavata/common/utils/ThriftUtils.java | 37 - .../apache/airavata/common/utils/Version.java | 120 ---- .../airavata/common/utils/WSConstants.java | 187 ----- .../apache/airavata/common/utils/WSDLUtil.java | 553 --------------- .../apache/airavata/common/utils/XMLUtil.java | 586 ---------------- .../airavata/common/utils/XmlFormatter.java | 82 --- .../listener/AbstractActivityListener.java | 27 - .../listener/AbstractStateChangeRequest.java | 27 - .../common/utils/listener/PublisherMessage.java | 26 - .../common/utils/ApplicationSettingsTest.java | 43 -- .../airavata/common/utils/SecurityUtilTest.java | 104 --- .../airavata/common/utils/XMLUtilTest.java | 56 -- .../utils/src/test/resources/mykeystore.jks | Bin 498 -> 0 bytes .../credential-store-service/pom.xml | 2 +- .../store/notifier/NotifierBootstrap.java | 1 - .../store/server/CredentialStoreServer.java | 1 - .../credential-store-stubs/pom.xml | 2 +- .../credential-store-webapp/pom.xml | 2 +- .../apache/airavata/gfac/core/RequestData.java | 1 - .../apache/airavata/gfac/impl/OutputUtils.java | 1 - .../gfac/monitor/email/EmailMonitorFactory.java | 2 - .../gfac/ssh/provider/impl/SSHProvider.java | 1 - modules/gfac/gfac-service/pom.xml | 2 +- .../airavata/gfac/server/GfacServerHandler.java | 1 + modules/messaging/core/pom.xml | 2 +- .../airavata/messaging/core/Publisher.java | 1 - .../core/impl/RabbitMQTaskLaunchPublisher.java | 1 - modules/orchestrator/orchestrator-core/pom.xml | 2 +- modules/registry/registry-core/pom.xml | 2 +- modules/registry/registry-cpi/pom.xml | 2 +- modules/security/pom.xml | 2 +- .../userstore/SessionDBUserStoreTest.java | 2 - modules/server/pom.xml | 2 +- .../org/apache/airavata/server/ServerMain.java | 4 - .../test-suite/multi-tenanted-airavata/pom.xml | 2 +- modules/workflow-model/workflow-engine/pom.xml | 2 +- .../workflow/engine/invoker/SimpleInvoker.java | 3 - .../workflow/engine/util/InterpreterUtil.java | 10 - .../workflow/engine/util/XBayaUtil.java | 5 - .../workflow-model-component/pom.xml | 2 +- .../workflow-model/workflow-model-core/pom.xml | 2 +- .../amazon/InstanceComponentDataPort.java | 2 - .../component/dynamic/DynamicComponentPort.java | 2 - .../component/url/URLComponentRegistry.java | 1 - .../component/web/WebComponentRegistry.java | 1 - .../component/ws/WSComponentApplication.java | 2 - .../model/component/ws/WSComponentPort.java | 2 - .../model/component/ws/WSComponentRegistry.java | 2 - .../airavata/workflow/model/gpel/DSCUtil.java | 10 - .../workflow/model/gpel/script/BPELScript.java | 13 - .../model/gpel/script/WorkflowWSDL.java | 8 - .../workflow/model/graph/impl/EdgeImpl.java | 1 - .../workflow/model/graph/impl/PortImpl.java | 1 - .../model/graph/system/ConstantNode.java | 2 - .../model/graph/system/DifferedInputNode.java | 2 - .../model/graph/system/EndBlockNode.java | 2 - .../model/graph/system/EndDoWhileNode.java | 2 - .../model/graph/system/EndForEachNode.java | 2 - .../workflow/model/graph/system/EndifNode.java | 2 - .../model/graph/system/ForEachNode.java | 2 - .../workflow/model/graph/system/InputNode.java | 2 - .../model/graph/system/ParameterNode.java | 2 - .../model/graph/system/S3InputNode.java | 2 - .../model/graph/system/SystemDataPort.java | 2 - .../workflow/model/graph/system/SystemNode.java | 2 - .../workflow/model/graph/ws/WSGraphFactory.java | 1 - .../workflow/model/graph/ws/WSPort.java | 2 - .../workflow/model/wf/TridentTransformer.java | 6 - .../airavata/workflow/model/wf/Workflow.java | 5 - modules/xbaya-gui/pom.xml | 2 +- .../xbaya/core/generators/BPELFiler.java | 6 - .../xbaya/core/generators/ODEScriptFiler.java | 11 - .../StandaloneNotificationSender.java | 2 - .../airavata/xbaya/messaging/EventData.java | 3 - .../xbaya/modifier/WorkflowModifier.java | 4 - .../org/apache/airavata/xbaya/ui/XBayaGUI.java | 1 - .../system/ConstantConfigurationDialog.java | 1 - .../DifferedInputConfigurationDialog.java | 1 - .../graph/system/InputConfigurationDialog.java | 2 - .../graph/system/OutputConfigurationDialog.java | 1 - .../xbaya/ui/dialogs/graph/ws/WSNodeWindow.java | 2 - .../dialogs/workflow/WorkflowImportWindow.java | 2 - .../workflow/WorkflowPropertyWindow.java | 5 - .../RegistryWorkflowPublisherWindow.java | 7 - .../WorkflowInterpreterLaunchWindow.java | 1 - .../airavata/xbaya/ui/graph/GraphCanvas.java | 2 - .../airavata/xbaya/ui/widgets/XBayaToolBar.java | 4 - .../apache/airavata/xbaya/util/XBayaUtil.java | 15 - 181 files changed, 7149 insertions(+), 7410 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/airavata-api/airavata-api-server/pom.xml ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/pom.xml b/airavata-api/airavata-api-server/pom.xml index e0af0f8..d3d1fc5 100644 --- a/airavata-api/airavata-api-server/pom.xml +++ b/airavata-api/airavata-api-server/pom.xml @@ -43,7 +43,7 @@ </dependency> <dependency> <groupId>org.apache.airavata</groupId> - <artifactId>airavata-common-utils</artifactId> + <artifactId>airavata-commons</artifactId> <version>${project.version}</version> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java index 8402a6f..42f8c1a 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java @@ -21,10 +21,7 @@ package org.apache.airavata.api.server; -import java.io.File; -import java.io.IOException; import java.net.InetSocketAddress; -import java.util.Random; import org.apache.airavata.api.Airavata; import org.apache.airavata.api.server.handler.AiravataServerHandler; @@ -43,8 +40,6 @@ import org.apache.thrift.server.TThreadPoolServer; import org.apache.thrift.transport.TServerSocket; import org.apache.thrift.transport.TServerTransport; import org.apache.thrift.transport.TTransportException; -import org.apache.zookeeper.*; -import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java index 20643b5..7eabc62 100644 --- a/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java +++ b/airavata-api/airavata-api-server/src/test/java/org/apache/airavata/api/server/handler/utils/ExpCatInit.java @@ -23,17 +23,13 @@ package org.apache.airavata.api.server.handler.utils; import org.apache.airavata.common.exception.ApplicationSettingsException; import org.apache.airavata.common.utils.ServerSettings; -import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils; -import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils; import org.apache.airavata.registry.core.experiment.catalog.ResourceType; -import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory; import org.apache.airavata.registry.core.experiment.catalog.resources.*; import org.apache.airavata.registry.cpi.*; import org.apache.derby.drda.NetworkServerControl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.persistence.EntityManager; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/distribution/pom.xml ---------------------------------------------------------------------- diff --git a/distribution/pom.xml b/distribution/pom.xml index 8c94c71..9f0eb5d 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -228,7 +228,7 @@ </dependency> <dependency> <groupId>org.apache.airavata</groupId> - <artifactId>airavata-common-utils</artifactId> + <artifactId>airavata-commons</artifactId> <version>${project.version}</version> <exclusions> <exclusion> http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/pom.xml ---------------------------------------------------------------------- diff --git a/modules/commons/pom.xml b/modules/commons/pom.xml index c21d9a0..f6c34d4 100644 --- a/modules/commons/pom.xml +++ b/modules/commons/pom.xml @@ -18,22 +18,118 @@ </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>commons</artifactId> - <packaging>pom</packaging> + <artifactId>airavata-commons</artifactId> + <packaging>jar</packaging> <name>Airavata Commons</name> <url>http://airavata.apache.org/</url> - <profiles> - <profile> - <id>default</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - <modules> - <module>utils</module> - </modules> - </profile> - </profiles> + <dependencies> + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>2.9.1</version> + </dependency> + <dependency> + <groupId>org.apache.xmlbeans</groupId> + <artifactId>xmlbeans</artifactId> + <version>${xmlbeans.version}</version> + </dependency> + <dependency> + <groupId>org.ogce</groupId> + <artifactId>xpp3</artifactId> + <version>${xpp3.version}</version> + </dependency> + <dependency> + <groupId>org.ogce</groupId> + <artifactId>xpp5</artifactId> + <version>${xpp5.version}</version> + </dependency> + <dependency> + <groupId>commons-dbcp</groupId> + <artifactId>commons-dbcp</artifactId> + <version>1.4</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>12.0</version> + </dependency> + + <!-- Logging --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derby</artifactId> + <version>${derby.version}</version> + </dependency> + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derbyclient</artifactId> + <version>${derby.version}</version> + </dependency> + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derbynet</artifactId> + <version>${derby.version}</version> + </dependency> + <dependency> + <groupId>org.apache.derby</groupId> + <artifactId>derbytools</artifactId> + <version>${derby.version}</version> + </dependency> + <dependency> + <groupId>org.apache.tomcat.embed</groupId> + <artifactId>tomcat-embed-core</artifactId> + <version>7.0.22</version> + </dependency> + <dependency> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + <version>1.2</version> + </dependency> + <!-- Testing --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-server-configuration</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.curator</groupId> + <artifactId>curator-framework</artifactId> + <version>${curator.version}</version> + </dependency> + <dependency> + <groupId>org.apache.thrift</groupId> + <artifactId>libthrift</artifactId> + <version>${thrift.version}</version> + </dependency> + + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>${google.gson.version}</version> + </dependency> + </dependencies> + <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java b/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java new file mode 100644 index 0000000..724d3a3 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java @@ -0,0 +1,56 @@ +/* + * + * 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.context; + +/** + * The request context class. This will be local to a thread. User data that needs to propagate relevant to a request + * will be stored here. We use thread local globals to store request data. Currently we only store user identity. + */ +public class RequestContext { + + public String getUserIdentity() { + return userIdentity; + } + + public void setUserIdentity(String userIdentity) { + this.userIdentity = userIdentity; + } + + /** + * User associated with current request. + */ + private String userIdentity; + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + /** + * The gateway id. + */ + private String gatewayId; + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java b/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java new file mode 100644 index 0000000..59142e4 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java @@ -0,0 +1,86 @@ +/* + * + * 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.context; + +/** + * The workflow context class. This will be local to a thread. Workflow data that needs to propagate relevant to a + * request will be stored here. We use thread local globals to store request data. Currently we only store user + * identity. + */ +public class WorkflowContext { + + private static final ThreadLocal userThreadLocal = new InheritableThreadLocal(); + + /** + * Sets the context. + * + * @param context + * The context to be set. - Careful when calling this. Make sure other data relevant to context is + * preserved. + */ + public static void set(RequestContext context) { + userThreadLocal.set(context); + } + + /** + * Clears the context + */ + public static void unset() { + userThreadLocal.remove(); + } + + /** + * Gets the context associated with current context. + * + * @return The context associated with current thread. + */ + public static RequestContext get() { + return (RequestContext) userThreadLocal.get(); + } + + /** + * Gets the user associated with current user. + * + * @return User id associated with current request. + */ + public static synchronized String getRequestUser() { + + RequestContext requestContext = (RequestContext) userThreadLocal.get(); + + if (requestContext != null) { + return requestContext.getUserIdentity(); + } + + return null; + } + + public static synchronized String getGatewayId() { + + RequestContext requestContext = (RequestContext) userThreadLocal.get(); + + if (requestContext != null) { + return requestContext.getGatewayId(); + } + + return null; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java new file mode 100644 index 0000000..874e029 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java @@ -0,0 +1,37 @@ +/* + * + * 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.exception; + +public class AiravataConfigurationException extends AiravataException { + private static final long serialVersionUID = -9124231436834631249L; + + public AiravataConfigurationException() { + } + + public AiravataConfigurationException(String message){ + this(message, null); + } + + public AiravataConfigurationException(String message, Throwable e){ + super(message,e); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java new file mode 100644 index 0000000..a41b77d --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java @@ -0,0 +1,37 @@ +/* + * + * 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.exception; + +public class AiravataException extends Exception { + + private static final long serialVersionUID = -5665822765183116821L; + public AiravataException() { + } + + public AiravataException(String message, Throwable e) { + super(message,e); + } + + public AiravataException(String message) { + super(message); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java new file mode 100644 index 0000000..b669fe0 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java @@ -0,0 +1,35 @@ +/* + * + * 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.exception; + +public class ApplicationSettingsException extends AiravataException { + + private static final long serialVersionUID = -4901850535475160411L; + + public ApplicationSettingsException(String message) { + super(message); + } + + public ApplicationSettingsException(String message, Throwable e) { + super(message, e); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java new file mode 100644 index 0000000..2735cf3 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsLoadException.java @@ -0,0 +1,38 @@ +/* + * + * 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.exception; + +public class ApplicationSettingsLoadException extends ApplicationSettingsException { + + private static final long serialVersionUID = -5102090895499711299L; + public ApplicationSettingsLoadException(String message) { + super(message); + } + + public ApplicationSettingsLoadException(Throwable e) { + this(e.getMessage(),e); + } + + public ApplicationSettingsLoadException(String message, Throwable e) { + super(message,e); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java new file mode 100644 index 0000000..5f258bf --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsStoreException.java @@ -0,0 +1,34 @@ +/* + * + * 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.exception; + +public class ApplicationSettingsStoreException extends ApplicationSettingsException { + + private static final long serialVersionUID = -5102090895499711299L; + public ApplicationSettingsStoreException(String filePath) { + super("Error while attempting to store settings in "+filePath); + } + + public ApplicationSettingsStoreException(String filePath, Throwable e) { + super(filePath,e); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java new file mode 100644 index 0000000..4ba58d7 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/LazyLoadedDataException.java @@ -0,0 +1,30 @@ +/* + * + * 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.exception; + +public class LazyLoadedDataException extends AiravataException { + private static final long serialVersionUID = -3164776318582067936L; + public LazyLoadedDataException(String message) { + super(message); + } + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java new file mode 100644 index 0000000..c29ff24 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/UnspecifiedApplicationSettingsException.java @@ -0,0 +1,30 @@ +/* + * + * 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.exception; + +public class UnspecifiedApplicationSettingsException extends ApplicationSettingsException { + + private static final long serialVersionUID = -1159027432434546003L; + public UnspecifiedApplicationSettingsException(String key) { + super("The '"+key+"' is not configured in settings!!!"); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/exception/UtilsException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/UtilsException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/UtilsException.java new file mode 100644 index 0000000..a412fe1 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/exception/UtilsException.java @@ -0,0 +1,61 @@ +/* + * + * 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.exception; + +public class UtilsException extends Exception { + + /** + * Constructs a UtilsException. + * + */ + public UtilsException() { + super(); + } + + /** + * Constructs a UtilsException. + * + * @param message + */ + public UtilsException(String message) { + super(message); + } + + /** + * Constructs a UtilsException. + * + * @param cause + */ + public UtilsException(Throwable cause) { + super(cause); + } + + /** + * Constructs a UtilsException. + * + * @param message + * @param cause + */ + public UtilsException(String message, Throwable cause) { + super(message, cause); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java new file mode 100644 index 0000000..9477cc9 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLogger.java @@ -0,0 +1,677 @@ +/* + * + * 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.logger; + +public interface AiravataLogger{ + + /** + * Return the name of this <code>Logger</code> instance. + * + * @return name of this logger instance + */ + String getName(); + + /** + * Is the logger instance enabled for the TRACE level? + * + * @return True if this Logger is enabled for the TRACE level, + * false otherwise. + * @since 1.4 + */ + boolean isTraceEnabled(); + + /** + * Log a message at the TRACE level. + * + * @param msg the message string to be logged + * @since 1.4 + */ + void trace(String msg); + + /** + * Log a message at the TRACE level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + * @since 1.4 + */ + void traceId(String etjId, String msg); + + /** + * Log a message at the TRACE level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the TRACE level. </p> + * + * @param format the format string + * @param arg the argument + * @since 1.4 + */ + void trace(String format, Object arg); + + /** + * Log a message at the TRACE level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the TRACE level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + * @since 1.4 + */ + void traceId(String etjId, String format, Object arg); + + /** + * Log a message at the TRACE level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the TRACE level. </p> + * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + * @since 1.4 + */ + void trace(String format, Object arg1, Object arg2); + + /** + * Log a message at the TRACE level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the TRACE level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + * @since 1.4 + */ + void traceId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log a message at the TRACE level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the TRACE level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and + * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p> + * + * @param format the format string + * @param arguments a list of 3 or more arguments + * @since 1.4 + */ + void trace(String format, Object... arguments); + + /** + * Log a message at the TRACE level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the TRACE level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for TRACE. The variants taking {@link #trace(String, Object) one} and + * {@link #trace(String, Object, Object) two} arguments exist solely in order to avoid this hidden cost.</p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + * @since 1.4 + */ + void traceId(String etjId, String format, Object... arguments); + + /** + * Log an exception (throwable) at the TRACE level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + * @since 1.4 + */ + void trace(String msg, Throwable t); + + /** + * Log an exception (throwable) at the TRACE level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + * @since 1.4 + */ + void traceId(String etjId, String msg, Throwable t); + + /** + * Is the logger instance enabled for the DEBUG level? + * + * @return True if this Logger is enabled for the DEBUG level, + * false otherwise. + */ + boolean isDebugEnabled(); + + /** + * Log a message at the DEBUG level. + * + * @param msg the message string to be logged + */ + void debug(String msg); + + /** + * Log a message at the DEBUG level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + */ + void debugId(String etjId, String msg); + + /** + * Log a message at the DEBUG level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the DEBUG level. </p> + * + * @param format the format string + * @param arg the argument + */ + void debug(String format, Object arg); + + /** + * Log a message at the DEBUG level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the DEBUG level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + */ + void debugId(String etjId, String format, Object arg); + + /** + * Log a message at the DEBUG level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the DEBUG level. </p> + * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void debug(String format, Object arg1, Object arg2); + + /** + * Log a message at the DEBUG level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the DEBUG level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void debugId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log a message at the DEBUG level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the DEBUG level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for DEBUG. The variants taking + * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.</p> + * + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void debug(String format, Object... arguments); + + /** + * Log a message at the DEBUG level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the DEBUG level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for DEBUG. The variants taking + * {@link #debug(String, Object) one} and {@link #debug(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.</p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void debugId(String etjId, String format, Object... arguments); + + /** + * Log an exception (throwable) at the DEBUG level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void debug(String msg, Throwable t); + + /** + * Log an exception (throwable) at the DEBUG level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void debugId(String etjId, String msg, Throwable t); + + /** + * Is the logger instance enabled for the INFO level? + * + * @return True if this Logger is enabled for the INFO level, + * false otherwise. + */ + boolean isInfoEnabled(); + + /** + * Log a message at the INFO level. + * + * @param msg the message string to be logged + */ + void info(String msg); + + /** + * Log a message at the INFO level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + */ + void infoId(String etjId, String msg); + + /** + * Log a message at the INFO level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the INFO level. </p> + * + * @param format the format string + * @param arg the argument + */ + void info(String format, Object arg); + + /** + * Log a message at the INFO level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the INFO level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + */ + void infoId(String etjId, String format, Object arg); + + /** + * Log a message at the INFO level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the INFO level. </p> + * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void info(String format, Object arg1, Object arg2); + + /** + * Log a message at the INFO level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the INFO level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void infoId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log a message at the INFO level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the INFO level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for INFO. The variants taking + * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.</p> + * + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void info(String format, Object... arguments); + + /** + * Log a message at the INFO level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the INFO level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for INFO. The variants taking + * {@link #info(String, Object) one} and {@link #info(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.</p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void infoId(String etjId, String format, Object... arguments); + + /** + * Log an exception (throwable) at the INFO level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void info(String msg, Throwable t); + + /** + * Log an exception (throwable) at the INFO level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void infoId(String etjId, String msg, Throwable t); + + /** + * Is the logger instance enabled for the WARN level? + * + * @return True if this Logger is enabled for the WARN level, + * false otherwise. + */ + boolean isWarnEnabled(); + + /** + * Log a message at the WARN level. + * + * @param msg the message string to be logged + */ + void warn(String msg); + + /** + * Log a message at the WARN level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + */ + void warnId(String etjId, String msg); + + /** + * Log a message at the WARN level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the WARN level. </p> + * + * @param format the format string + * @param arg the argument + */ + void warn(String format, Object arg); + + /** + * Log a message at the WARN level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the WARN level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + */ + void warnId(String etjId, String format, Object arg); + + /** + * Log a message at the WARN level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the WARN level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for WARN. The variants taking + * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.</p> + * + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void warn(String format, Object... arguments); + + /** + * Log a message at the WARN level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the WARN level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for WARN. The variants taking + * {@link #warn(String, Object) one} and {@link #warn(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.</p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void warnId(String etjId, String format, Object... arguments); + + /** + * Log a message at the WARN level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the WARN level. </p> + * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void warn(String format, Object arg1, Object arg2); + + /** + * Log a message at the WARN level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the WARN level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void warnId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log an exception (throwable) at the WARN level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void warn(String msg, Throwable t); + + /** + * Log an exception (throwable) at the WARN level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void warnId(String etjId, String msg, Throwable t); + + /** + * Is the logger instance enabled for the ERROR level? + * + * @return True if this Logger is enabled for the ERROR level, + * false otherwise. + */ + boolean isErrorEnabled(); + + /** + * Log a message at the ERROR level. + * + * @param msg the message string to be logged + */ + void error(String msg); + + /** + * Log a message at the ERROR level. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message string to be logged + */ + void errorId(String etjId, String msg); + + /** + * Log a message at the ERROR level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the ERROR level. </p> + * + * @param format the format string + * @param arg the argument + */ + void error(String format, Object arg); + + /** + * Log a message at the ERROR level according to the specified format + * and argument. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the ERROR level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg the argument + */ + void errorId(String etjId, String format, Object arg); + + /** + * Log a message at the ERROR level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the ERROR level. </p> + * + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void error(String format, Object arg1, Object arg2); + + /** + * Log a message at the ERROR level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous object creation when the logger + * is disabled for the ERROR level. </p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arg1 the first argument + * @param arg2 the second argument + */ + void errorId(String etjId, String format, Object arg1, Object arg2); + + /** + * Log a message at the ERROR level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the ERROR level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for ERROR. The variants taking + * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.</p> + * + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void error(String format, Object... arguments); + + /** + * Log a message at the ERROR level according to the specified format + * and arguments. + * <p/> + * <p>This form avoids superfluous string concatenation when the logger + * is disabled for the ERROR level. However, this variant incurs the hidden + * (and relatively small) cost of creating an <code>Object[]</code> before invoking the method, + * even if this logger is disabled for ERROR. The variants taking + * {@link #error(String, Object) one} and {@link #error(String, Object, Object) two} + * arguments exist solely in order to avoid this hidden cost.</p> + * + * @param etjId - Experiment , Task or Job Id + * @param format the format string + * @param arguments a list of 3 or more arguments + */ + void errorId(String etjId, String format, Object... arguments); + + /** + * Log an exception (throwable) at the ERROR level with an + * accompanying message. + * + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void error(String msg, Throwable t); + + /** + * Log an exception (throwable) at the ERROR level with an + * accompanying message. + * + * @param etjId - Experiment , Task or Job Id + * @param msg the message accompanying the exception + * @param t the exception (throwable) to log + */ + void errorId(String etjId, String msg, Throwable t); + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java new file mode 100644 index 0000000..a1a9462 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerFactory.java @@ -0,0 +1,34 @@ +/* + * + * 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.logger; + +public class AiravataLoggerFactory { + + public static AiravataLogger getLogger(Class aClass) { + return new AiravataLoggerImpl(aClass); + } + + public static AiravataLogger getLogger(String className) { + return new AiravataLoggerImpl(className); + } + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java new file mode 100644 index 0000000..74ab401 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/logger/AiravataLoggerImpl.java @@ -0,0 +1,323 @@ +/* + * + * 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.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AiravataLoggerImpl implements AiravataLogger{ + + private Logger logger; + + public AiravataLoggerImpl(Class aClass) { + logger = LoggerFactory.getLogger(aClass); + } + + public AiravataLoggerImpl(String className) { + logger = LoggerFactory.getLogger(className); + } + + + @Override + public String getName() { + return logger.getName(); + } + + @Override + public boolean isTraceEnabled() { + return logger.isTraceEnabled(); + } + + @Override + public void trace(String msg) { + logger.trace(msg); + } + + @Override + public void traceId(String etjId, String msg) { + logger.trace(getAiravataLogMessage(etjId, msg)); + } + + @Override + public void trace(String format, Object arg) { + logger.trace(format, arg); + } + + @Override + public void traceId(String etjId, String format, Object arg) { + logger.trace(getAiravataLogMessage(etjId, format), arg); + } + + @Override + public void trace(String format, Object arg1, Object arg2) { + logger.trace(format, arg1, arg2); + } + + @Override + public void traceId(String etjId, String format, Object arg1, Object arg2) { + logger.trace(getAiravataLogMessage(etjId,format), arg1, arg2); + } + + @Override + public void trace(String format, Object... arguments) { + logger.trace(format, arguments); + } + + @Override + public void traceId(String etjId, String format, Object... arguments) { + logger.trace(getAiravataLogMessage(etjId, format), arguments); + } + + @Override + public void trace(String msg, Throwable t) { + logger.trace(msg, t); + } + + @Override + public void traceId(String etjId, String msg, Throwable t) { + logger.trace(getAiravataLogMessage(etjId, msg), t); + } + + @Override + public boolean isDebugEnabled() { + return logger.isDebugEnabled(); + } + + @Override + public void debug(String msg) { + logger.debug(msg); + } + + @Override + public void debugId(String etjId, String msg) { + logger.debug(getAiravataLogMessage(etjId, msg)); + } + + @Override + public void debug(String format, Object arg) { + logger.debug(format, arg); + } + + @Override + public void debugId(String etjId, String format, Object arg) { + logger.debug(getAiravataLogMessage(etjId, format), arg); + } + + @Override + public void debug(String format, Object arg1, Object arg2) { + logger.debug(format, arg1, arg2); + } + + @Override + public void debugId(String etjId, String format, Object arg1, Object arg2) { + logger.debug(getAiravataLogMessage(etjId, format), arg1, arg2); + } + + @Override + public void debug(String format, Object... arguments) { + logger.debug(format, arguments); + } + + @Override + public void debugId(String etjId, String format, Object... arguments) { + logger.debug(getAiravataLogMessage(etjId, format), arguments); + } + + @Override + public void debug(String msg, Throwable t) { + logger.debug(msg, t); + } + + @Override + public void debugId(String etjId, String msg, Throwable t) { + logger.debug(getAiravataLogMessage(etjId, msg), t); + } + + @Override + public boolean isInfoEnabled() { + return logger.isInfoEnabled(); + } + + @Override + public void info(String msg) { + logger.info(msg); + } + + @Override + public void infoId(String etjId, String msg) { + logger.info(getAiravataLogMessage(etjId, msg)); + } + + @Override + public void info(String format, Object arg) { + logger.info(format, arg); + } + + @Override + public void infoId(String etjId, String format, Object arg) { + logger.info(getAiravataLogMessage(etjId, format), arg); + } + + @Override + public void info(String format, Object arg1, Object arg2) { + logger.info(format, arg1, arg2); + } + + @Override + public void infoId(String etjId, String format, Object arg1, Object arg2) { + logger.info(getAiravataLogMessage(etjId, format), arg1, arg2); + } + + @Override + public void info(String format, Object... arguments) { + logger.info(format, arguments); + } + + @Override + public void infoId(String etjId, String format, Object... arguments) { + logger.info(getAiravataLogMessage(etjId, format), arguments); + } + + @Override + public void info(String msg, Throwable t) { + logger.info(msg, t); + } + + @Override + public void infoId(String etjId, String msg, Throwable t) { + logger.info(getAiravataLogMessage(etjId, msg), t); + } + + @Override + public boolean isWarnEnabled() { + return logger.isWarnEnabled(); + } + + @Override + public void warn(String msg) { + logger.warn(msg); + } + + @Override + public void warnId(String etjId, String msg) { + logger.warn(getAiravataLogMessage(etjId, msg)); + } + + @Override + public void warn(String format, Object arg) { + logger.warn(format, arg); + } + + @Override + public void warnId(String etjId, String format, Object arg) { + logger.warn(getAiravataLogMessage(etjId, format), arg); + } + + @Override + public void warn(String format, Object... arguments) { + logger.warn(format, arguments); + } + + @Override + public void warnId(String etjId, String format, Object... arguments) { + logger.warn(getAiravataLogMessage(etjId, format), arguments); + } + + @Override + public void warn(String format, Object arg1, Object arg2) { + logger.warn(format, arg1, arg2); + } + + @Override + public void warnId(String etjId, String format, Object arg1, Object arg2) { + logger.warn(getAiravataLogMessage(etjId, format), arg1, arg2); + } + + @Override + public void warn(String msg, Throwable t) { + logger.warn(msg, t); + } + + @Override + public void warnId(String etjId, String msg, Throwable t) { + logger.warn(getAiravataLogMessage(etjId, msg), t); + } + + @Override + public boolean isErrorEnabled() { + return logger.isErrorEnabled(); + } + + @Override + public void error(String msg) { + logger.error(msg); + } + + @Override + public void errorId(String etjId, String msg) { + logger.error(getAiravataLogMessage(etjId, msg)); + } + + @Override + public void error(String format, Object arg) { + logger.error(format, arg); + } + + @Override + public void errorId(String etjId, String format, Object arg) { + logger.error(getAiravataLogMessage(etjId, format), arg); + } + + @Override + public void error(String format, Object arg1, Object arg2) { + logger.error(format, arg1, arg2); + } + + @Override + public void errorId(String etjId, String format, Object arg1, Object arg2) { + logger.error(getAiravataLogMessage(etjId, format), arg1, arg2); + } + + @Override + public void error(String format, Object... arguments) { + logger.error(format, arguments); + } + + @Override + public void errorId(String etjId, String format, Object... arguments) { + logger.error(getAiravataLogMessage(etjId, format), arguments); + } + + @Override + public void error(String msg, Throwable t) { + logger.error(msg, t); + } + + @Override + public void errorId(String etjId, String msg, Throwable t) { + logger.error(getAiravataLogMessage(etjId, msg), t); + } + + private String getAiravataLogMessage(String etjId, String msg) { + return new StringBuilder("Id:").append(etjId).append(" : ").append(msg).toString(); + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java new file mode 100644 index 0000000..83e4218 --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java @@ -0,0 +1,117 @@ +/* + * + * 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; + +/* +These are the job statuses shared in database level between orchestrator and +gfac instances + */ +public class AiravataJobState { + + private State jobState; + + public State getJobState() { + return jobState; + } + + public void setJobState(State jobState) { + this.jobState = jobState; + } + + + public enum State { + CREATED { + public String toString() { + return "CREATED"; + } + }, + ACCEPTED { + public String toString() { + return "ACCEPTED"; + } + }, + FETCHED { + public String toString() { + return "FETCHED"; + } + }, + INHANDLERSDONE { + public String toString() { + return "INHANDLERSDONE"; + } + }, + SUBMITTED { + public String toString() { + return "SUBMITTED"; + } + }, + OUTHANDLERSDONE { + public String toString() { + return "OUTHANDLERSDONE"; + } + }, + RUNNING { + public String toString() { + return "RUNNING"; + } + }, + FAILED { + public String toString() { + return "FAILED"; + } + }, + PAUSED { + public String toString() { + return "PAUSED"; + } + }, + PENDING { + public String toString() { + return "PENDING"; + } + }, + ACTIVE { + public String toString() { + return "ACTIVE"; + } + }, + DONE { + public String toString() { + return "DONE"; + } + }, + CANCELLED { + public String toString() { + return "CANCELLED"; + } + }, + UNKNOWN { + public String toString() { + return "UNKNOWN"; + } + }, + HANGED { + public String toString() { + return "HANGED"; + } + } + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/8d16d0ec/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java new file mode 100644 index 0000000..52d114f --- /dev/null +++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java @@ -0,0 +1,47 @@ +/* + * + * 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; + +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.UUID; + +public class AiravataUtils { + + public static Timestamp getCurrentTimestamp() { + Calendar calender = Calendar.getInstance(); + java.util.Date d = calender.getTime(); + return new Timestamp(d.getTime()); + } + + public static Timestamp getTime(long time) { + if (time == 0 || time < 0){ + return getCurrentTimestamp(); + } + return new Timestamp(time); + } + + public static String getId (String name){ + String id = name.replaceAll("\\s", ""); + return id + "_" + UUID.randomUUID(); + } +}
