You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2012/11/28 20:50:26 UTC
svn commit: r1414882 - in
/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common:
exception/ServerSettingsException.java
exception/ServerSettingsLoadException.java
exception/UnspecifiedServerSettings.java utils/ServerSettings.java
Author: samindaw
Date: Wed Nov 28 19:50:25 2012
New Revision: 1414882
URL: http://svn.apache.org/viewvc?rev=1414882&view=rev
Log:
ServerSettings for Airavata
Added:
airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsException.java (with props)
airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsLoadException.java (with props)
airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedServerSettings.java (with props)
airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java (with props)
Added: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsException.java?rev=1414882&view=auto
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsException.java (added)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsException.java Wed Nov 28 19:50:25 2012
@@ -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 ServerSettingsException extends AiravataException {
+
+ private static final long serialVersionUID = -4901850535475160411L;
+
+ public ServerSettingsException(String message) {
+ super(message);
+ }
+
+ public ServerSettingsException(String message, Throwable e) {
+ super(message, e);
+ }
+}
Propchange: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsLoadException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsLoadException.java?rev=1414882&view=auto
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsLoadException.java (added)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsLoadException.java Wed Nov 28 19:50:25 2012
@@ -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 ServerSettingsLoadException extends ServerSettingsException {
+
+ private static final long serialVersionUID = -5102090895499711299L;
+ public ServerSettingsLoadException(String message) {
+ super(message);
+ }
+
+ public ServerSettingsLoadException(Throwable e) {
+ this(e.getMessage(),e);
+ }
+
+ public ServerSettingsLoadException(String message, Throwable e) {
+ super(message,e);
+ }
+}
Propchange: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/ServerSettingsLoadException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedServerSettings.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedServerSettings.java?rev=1414882&view=auto
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedServerSettings.java (added)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedServerSettings.java Wed Nov 28 19:50:25 2012
@@ -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 UnspecifiedServerSettings extends ServerSettingsException {
+
+ private static final long serialVersionUID = -1159027432434546003L;
+ public UnspecifiedServerSettings(String key) {
+ super("The '"+key+"' is not configured in Server settings!!!");
+ }
+}
Propchange: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/exception/UnspecifiedServerSettings.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java?rev=1414882&view=auto
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java (added)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java Wed Nov 28 19:50:25 2012
@@ -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.common.utils;
+
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.airavata.common.exception.ServerSettingsException;
+import org.apache.airavata.common.exception.ServerSettingsLoadException;
+import org.apache.airavata.common.exception.UnspecifiedServerSettings;
+
+public class ServerSettings {
+ private static final String REPOSITORY_PROPERTIES = "airavata-server.properties";
+ private static Properties properties = new Properties();
+ private static Exception propertyLoadException;
+ private static final String DEFAULT_GATEWAY_ID="gateway.id";
+
+ static{
+ URL url = ServiceUtils.class.getClassLoader()
+ .getResource(REPOSITORY_PROPERTIES);
+ try {
+ properties.load(url.openStream());
+ } catch (Exception e) {
+ propertyLoadException=e;
+ }
+ }
+
+ private static void validateSuccessfulPropertyFileLoad() throws ServerSettingsException{
+ if (propertyLoadException!=null){
+ throw new ServerSettingsLoadException(propertyLoadException);
+ }
+ }
+
+ public static String getSetting(String key) throws ServerSettingsException{
+ validateSuccessfulPropertyFileLoad();
+ if (properties.containsKey(key)){
+ return properties.getProperty(key);
+ }
+ throw new UnspecifiedServerSettings(key);
+ }
+
+ public static String getDefaultGatewayId()throws ServerSettingsException{
+ return getSetting(DEFAULT_GATEWAY_ID);
+ }
+}
Propchange: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
------------------------------------------------------------------------------
svn:mime-type = text/plain