perfsonar-dev - [GEANT/SA2/ps-java-services] r5531 - in trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service: configuration registration requesthandler scheduler storage/xml
Subject: perfsonar development work
List archive
[GEANT/SA2/ps-java-services] r5531 - in trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service: configuration registration requesthandler scheduler storage/xml
Chronological Thread
- From:
- To:
- Subject: [GEANT/SA2/ps-java-services] r5531 - in trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service: configuration registration requesthandler scheduler storage/xml
- Date: Tue, 9 Mar 2010 09:04:55 GMT
Author: psnc.trzaszczka
Date: 2010-03-09 09:04:55 +0000 (Tue, 09 Mar 2010)
New Revision: 5531
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/Configuration.java
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/ConfigurationManager.java
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/registration/GenericLSRegistrator.java
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/RequestHandler.java
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulingComponent.java
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/storage/xml/XMLDBComponent.java
Log:
change result codes to dotted notation
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/Configuration.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/Configuration.java
2010-03-08 14:13:37 UTC (rev 5530)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/Configuration.java
2010-03-09 09:04:55 UTC (rev 5531)
@@ -3,211 +3,200 @@
* Project: perfSONAR
*/
package org.perfsonar.base2.service.configuration;
-
-import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
-
public class Configuration {
- public static final String MESSAGE_HANDLER = "MessageHandler";
- public static final String AUXILIARY_COMPONENTS = "AuxiliaryComponents";
- public static final String COMPONENT = "Component";
- public static final String LOOKUP_INFORMATION = "LookupInformation";
- public static final String PROTOCOL_MAPPINGS = "ProtocolMappings";
- public static final String SERVICE_ENGINE = "ServiceEngine";
+ public static final String MESSAGE_HANDLER = "MessageHandler";
+ public static final String AUXILIARY_COMPONENTS =
"AuxiliaryComponents";
+ public static final String COMPONENT = "Component";
+ public static final String LOOKUP_INFORMATION = "LookupInformation";
+ public static final String PROTOCOL_MAPPINGS = "ProtocolMappings";
+ public static final String SERVICE_ENGINE = "ServiceEngine";
- // ----------------------------------------------------------- Variables
+ // -----------------------------------------------------------
Variables
- private Map<String,Service> services = null;
+ private Map<String, Service> services = null;
+ // -----------------------------------------------------------
Constructor
- // -----------------------------------------------------------
Constructor
+ public Configuration() {
+ services = new HashMap<String, Service>();
+ }
+ // ----------------------------------------------------------- Methods
- public Configuration() {
- services = new HashMap<String,Service>();
- }
+ public void addService(Service service) {
+ services.put(service.getName(), service);
+ }
- // ----------------------------------------------------------- Methods
+ public Service getService(String name) throws PerfSONARException {
+ Service service = (Service) services.get(name);
+ if (service == null) {
+ // TODO: url event types
+ throw new PerfSONARException("error.configuration",
+ "Could not find a service " + name
+ + " in the
configuration");
+ }
+ return service;
+ }
+ public Map getServices() {
+ return services;
+ }
- public void addService(Service service) {
- services.put(service.getName(), service);
- }
+ public Service getService() throws PerfSONARException {
- public Service getService(String name) throws PerfSONARException {
- Service service = (Service)services.get(name);
- if (service == null)
- throw new PerfSONARException(
- "error/configuration",
- "Could not find a service " + name + " in the
configuration");
- return service;
- }
+ String serviceName =
System.getenv("PERFSONAR_CONF_SERVICE_NAME");
+ Service s = null;
+ if (serviceName != null) {
+ s = getService(serviceName);
+ }
- public Map getServices() {
- return services;
- }
+ if (s == null) {
+ for (String sname : services.keySet()) {
+ s = getService(sname);
+ break;
+ }
+ }
- public Service getService() throws PerfSONARException {
+ return s;
+ }
- String serviceName = System.getenv("PERFSONAR_CONF_SERVICE_NAME");
- Service s = null;
- if (serviceName != null) {
- s = getService(serviceName);
- }
+ // ----------------------------------------------------------- Facade
+ // methods
- if (s == null) {
- for (String sname : services.keySet()) {
- s = getService(sname);
- break;
- }
- }
+ public String getLookupInformationOption(String optionName)
+ throws PerfSONARException {
+ return ((LookupInformation) getService().getEntry(
+
Configuration.LOOKUP_INFORMATION)).getOption(optionName)
+ .getValue();
+ }
- return s;
- }
+ public String getLookupInformationOption(String serviceName,
+ String optioName) throws PerfSONARException {
+ return ((LookupInformation) getService(serviceName).getEntry(
+
Configuration.LOOKUP_INFORMATION)).getOption(optioName)
+ .getValue();
+ }
+ public Iterator getLookupInformationIterator() throws
PerfSONARException {
+ return ((LookupInformation) getService().getEntry(
+
Configuration.LOOKUP_INFORMATION)).getOptions().keySet()
+ .iterator();
+ }
- // ----------------------------------------------------------- Facade
methods
+ public Iterator getLookupInformationIterator(String serviceName)
+ throws PerfSONARException {
+ return ((LookupInformation) getService(serviceName).getEntry(
+
Configuration.LOOKUP_INFORMATION)).getOptions().keySet()
+ .iterator();
+ }
+ public String getMessageHandlerClassName(String messageType)
+ throws PerfSONARException {
+ return ((MessageHandler) getService().getEntry(
+
Configuration.MESSAGE_HANDLER)).getMessage(messageType)
+ .getHandler();
+ }
- public String getLookupInformationOption(String optionName)
- throws PerfSONARException {
- return ((LookupInformation)
- getService().getEntry(Configuration.LOOKUP_INFORMATION))
- .getOption(optionName).getValue();
- }
+ public String getMessageHandlerClassName(String serviceName,
+ String messageType) throws PerfSONARException {
+ return ((MessageHandler) getService(serviceName).getEntry(
+
Configuration.MESSAGE_HANDLER)).getMessage(messageType)
+ .getHandler();
+ }
- public String getLookupInformationOption(String serviceName, String
optioName)
- throws PerfSONARException {
- return ((LookupInformation)
-
getService(serviceName).getEntry(Configuration.LOOKUP_INFORMATION))
- .getOption(optioName).getValue();
- }
+ public Message getMessageHandler(String messageType)
+ throws PerfSONARException {
+ return ((MessageHandler) getService().getEntry(
+
Configuration.MESSAGE_HANDLER)).getMessage(messageType);
+ }
- public Iterator getLookupInformationIterator()
- throws PerfSONARException {
- return ((LookupInformation)
- getService().getEntry(Configuration.LOOKUP_INFORMATION))
- .getOptions().keySet().iterator();
- }
+ public Message getMessageHandler(String serviceName, String
messageType)
+ throws PerfSONARException {
+ return ((MessageHandler) getService(serviceName).getEntry(
+
Configuration.MESSAGE_HANDLER)).getMessage(messageType);
+ }
- public Iterator getLookupInformationIterator(String serviceName)
- throws PerfSONARException {
- return ((LookupInformation)
-
getService(serviceName).getEntry(Configuration.LOOKUP_INFORMATION))
- .getOptions().keySet().iterator();
- }
+ public String getProtocolMappingElement(String elementName)
+ throws PerfSONARException {
+ return ((ProtocolMappings) getService().getEntry(
+
Configuration.PROTOCOL_MAPPINGS)).getElement(elementName)
+ .getMapping();
+ }
- public String getMessageHandlerClassName(String messageType)
- throws PerfSONARException {
- return ((MessageHandler)
- getService().getEntry(Configuration.MESSAGE_HANDLER))
- .getMessage(messageType).getHandler();
- }
+ public String getProtocolMappingElement(String serviceName,
+ String elementName) throws PerfSONARException {
+ return ((ProtocolMappings) getService(serviceName).getEntry(
+
Configuration.PROTOCOL_MAPPINGS)).getElement(elementName)
+ .getMapping();
+ }
- public String getMessageHandlerClassName(String serviceName, String
messageType)
- throws PerfSONARException {
- return ((MessageHandler)
-
getService(serviceName).getEntry(Configuration.MESSAGE_HANDLER))
- .getMessage(messageType).getHandler();
- }
+ public Iterator getProtocolMappingsIterator() throws
PerfSONARException {
+ return ((ProtocolMappings) getService().getEntry(
+
Configuration.PROTOCOL_MAPPINGS)).getElements().keySet()
+ .iterator();
+ }
- public Message getMessageHandler(String messageType)
- throws PerfSONARException {
- return ((MessageHandler)
- getService().getEntry(Configuration.MESSAGE_HANDLER))
- .getMessage(messageType);
- }
+ public Iterator getProtocolMappingsIterator(String serviceName)
+ throws PerfSONARException {
+ return ((ProtocolMappings) getService(serviceName).getEntry(
+
Configuration.PROTOCOL_MAPPINGS)).getElements().keySet()
+ .iterator();
+ }
- public Message getMessageHandler(String serviceName, String messageType)
- throws PerfSONARException {
- return ((MessageHandler)
-
getService(serviceName).getEntry(Configuration.MESSAGE_HANDLER))
- .getMessage(messageType);
- }
+ public String getExtensionOption(String extensionName, String
optionName)
+ throws PerfSONARException {
+ return ((Extension)
getService().getEntry(extensionName)).getOption(
+ optionName).getValue();
+ }
- public String getProtocolMappingElement(String elementName)
- throws PerfSONARException {
- return ((ProtocolMappings)
- getService().getEntry(Configuration.PROTOCOL_MAPPINGS))
- .getElement(elementName).getMapping();
- }
+ public String getExtensionOption(String serviceName, String
extensionName,
+ String optionName) throws PerfSONARException {
+ return ((Extension)
getService(serviceName).getEntry(extensionName))
+ .getOption(optionName).getValue();
+ }
- public String getProtocolMappingElement(String serviceName, String
elementName)
- throws PerfSONARException {
- return ((ProtocolMappings)
-
getService(serviceName).getEntry(Configuration.PROTOCOL_MAPPINGS))
- .getElement(elementName).getMapping();
- }
+ public Iterator getExtensionOptionsIterator(String extensionName,
+ String optionName) throws PerfSONARException {
+ return ((Extension)
getService().getEntry(extensionName)).getOptions()
+ .keySet().iterator();
+ }
- public Iterator getProtocolMappingsIterator()
- throws PerfSONARException {
- return ((ProtocolMappings)
- getService().getEntry(Configuration.PROTOCOL_MAPPINGS))
- .getElements().keySet().iterator();
- }
+ public Iterator getExtensionOptionsIterator(String serviceName,
+ String extensionName, String optionName) throws
PerfSONARException {
+ return ((Extension)
getService(serviceName).getEntry(extensionName))
+ .getOptions().keySet().iterator();
+ }
- public Iterator getProtocolMappingsIterator(String serviceName)
- throws PerfSONARException {
- return ((ProtocolMappings)
-
getService(serviceName).getEntry(Configuration.PROTOCOL_MAPPINGS))
- .getElements().keySet().iterator();
- }
+ public String getServiceEngineOption(String serviceName, String
messageType)
+ throws PerfSONARException {
+ return getMessageHandler(serviceName, messageType).getOption(
+ SERVICE_ENGINE).getValue();
+ }
- public String getExtensionOption(String extensionName, String optionName)
- throws PerfSONARException {
- return ((Extension)
- getService().getEntry(extensionName))
- .getOption(optionName).getValue();
- }
+ public String getServiceEngineOption(String messageType)
+ throws PerfSONARException {
+ return
getMessageHandler(messageType).getOption(SERVICE_ENGINE)
+ .getValue();
+ }
- public String getExtensionOption(String serviceName, String
extensionName, String optionName)
- throws PerfSONARException {
- return ((Extension)
- getService(serviceName).getEntry(extensionName))
- .getOption(optionName).getValue();
- }
+ public AuxiliaryComponents getAuxiliaryComponents()
+ throws PerfSONARException {
+ return ((AuxiliaryComponents) getService().getEntry(
+ Configuration.AUXILIARY_COMPONENTS));
+ }
- public Iterator getExtensionOptionsIterator(String extensionName, String
optionName)
- throws PerfSONARException {
- return ((Extension)
- getService().getEntry(extensionName))
- .getOptions().keySet().iterator();
- }
+ public Component getAuxiliaryComponent(String name)
+ throws PerfSONARException {
+ return ((AuxiliaryComponents) getService().getEntry(
+
Configuration.AUXILIARY_COMPONENTS)).getComponent(name);
+ }
- public Iterator getExtensionOptionsIterator(String serviceName, String
extensionName, String optionName)
- throws PerfSONARException {
- return ((Extension)
- getService(serviceName).getEntry(extensionName))
- .getOptions().keySet().iterator();
- }
-
- public String getServiceEngineOption(String serviceName, String
messageType)
- throws PerfSONARException {
- return getMessageHandler(serviceName,
messageType).getOption(SERVICE_ENGINE).getValue();
- }
-
- public String getServiceEngineOption(String messageType)
- throws PerfSONARException {
- return
getMessageHandler(messageType).getOption(SERVICE_ENGINE).getValue();
- }
-
- public AuxiliaryComponents getAuxiliaryComponents()
- throws PerfSONARException {
- return ((AuxiliaryComponents)
-
getService().getEntry(Configuration.AUXILIARY_COMPONENTS));
- }
-
- public Component getAuxiliaryComponent(String name) throws
PerfSONARException {
- return ((AuxiliaryComponents)
- getService().getEntry(Configuration.AUXILIARY_COMPONENTS)).
- getComponent(name);
-}
-
-
-} //Configuration
+} // Configuration
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/ConfigurationManager.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/ConfigurationManager.java
2010-03-08 14:13:37 UTC (rev 5530)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/configuration/ConfigurationManager.java
2010-03-09 09:04:55 UTC (rev 5531)
@@ -131,8 +131,9 @@
logger.error(
"Can not parse " + digesterInput +", "
+ ex.toString());
+ //TODO: url event types
throw new PerfSONARException(
- "error/configuration",
+ "error.configuration",
"Can not parse " + digesterInput+". Nested exception
was: "+ex.toString());
}
@@ -189,8 +190,9 @@
}
if (digesterInputStream == null) {
+ //TODO: url event types
throw new PerfSONARException(
- "error/configuration",
+ "error.configuration",
"Can not create an input stream of xml config file "
+ digesterInput);
}
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/registration/GenericLSRegistrator.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/registration/GenericLSRegistrator.java
2010-03-08 14:13:37 UTC (rev 5530)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/registration/GenericLSRegistrator.java
2010-03-09 09:04:55 UTC (rev 5531)
@@ -40,17 +40,17 @@
public ServiceMessage deregister(Key key, URL lsUrl)
throws PerfSONARException {
+ //TODO: url event types
+ throw new
PerfSONARException("error.common.action_not_supported","Action deregister is
not implemented yet");
- throw new PerfSONARException("error/not_implemented","Action
deregister is not implemented yet");
-
}
public ServiceMessage update(Key key, URL lsUrl)
throws PerfSONARException {
+ //TODO: url event types
+ throw new
PerfSONARException("error.common.action_not_supported","Action update is not
implemented yet");
- throw new PerfSONARException("error/not_implemented","Action update
is not implemented yet");
-
}
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/RequestHandler.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/RequestHandler.java
2010-03-08 14:13:37 UTC (rev 5530)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/requesthandler/RequestHandler.java
2010-03-09 09:04:55 UTC (rev 5531)
@@ -77,8 +77,11 @@
throws PerfSONARException {
String type = e.getAttribute("type");
- if (type==null) throw new PerfSONARException(
- "error/no_message_type","No message type in request. Cannot
find MessageHandler");
+ if (type==null){
+ //TODO: url event types
+ throw new PerfSONARException("error.no_message_type","No
message type in request. Cannot find MessageHandler");
+ }
+
logger.debug("Message type is ["+type+"]");
@@ -117,8 +120,11 @@
logger.debug("Run service handler");
Element requestElement = request.getElement();
- if (requestElement == null) throw new PerfSONARException(
- "error/no_element_object_in_request","No element object in
request.");
+ if (requestElement == null){
+ //TODO : URL event types
+ throw new
PerfSONARException("error.no_element_object_in_request","No element object in
request.");
+ }
+
String className = getClassNameFromType(requestElement);
MessageHandler mh = getMessageHandler(className);
@@ -127,10 +133,11 @@
mh.execute(request, response);
- } else throw new PerfSONARException("parse",
- "Object ["+request.getClass()+"] is not a valid Message ["+
- Message.class+
- "] element. Check parser mapping in the configuration file");
+ } else{
+ //TODO : URL event types
+ throw new
PerfSONARException("error.common.parse_error","Object
["+request.getClass()+"] is not a valid Message ["+Message.class+"] element.
Check parser mapping in the configuration file");
+ }
+
}
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulingComponent.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulingComponent.java
2010-03-08 14:13:37 UTC (rev 5530)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/scheduler/SchedulingComponent.java
2010-03-09 09:04:55 UTC (rev 5531)
@@ -81,7 +81,8 @@
.newInstance();
registerActions();
} catch (Exception e) {
- throw new
PerfSONARException("error/scheduler/wrong_data_storage",
+ //TODO: url event types
+ throw new
PerfSONARException("error.scheduler.wrong_data_storage",
"\n Cannot instantiate Scheduler [" + e.getMessage());
}
Modified:
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/storage/xml/XMLDBComponent.java
===================================================================
---
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/storage/xml/XMLDBComponent.java
2010-03-08 14:13:37 UTC (rev 5530)
+++
trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service/storage/xml/XMLDBComponent.java
2010-03-09 09:04:55 UTC (rev 5531)
@@ -68,7 +68,8 @@
username = getOption("username").getValue();
password = getOption("password").getValue();
} catch (Exception ex) {
- throw new PerfSONARException("error/xmldb/no_settings", "Cannot
load XML DB settings from configuration file");
+ //TODO: url event types
+ throw new PerfSONARException("error.xmldb.no_settings", "Cannot
load XML DB settings from configuration file");
}
return true;
}
@@ -80,8 +81,9 @@
// get a new class for that classname
logger.debug(dataStorageClassName);
dataStorage =
(XMLDataStorage)Class.forName(dataStorageClassName).newInstance();
- } catch (Exception e) {
- throw new PerfSONARException("wrong_data_storage",
+ } catch (Exception e) {
+ //TODO: url event types
+ throw new PerfSONARException("error.wrong_data_storage",
"\n Cannot instantiate XMLDataStorage ["+
dataStorageClassName+"]:\n "+e.getMessage()); }
if (dataStorage == null) dataStorage = new ExistHTTPDataStorage();
- [GEANT/SA2/ps-java-services] r5531 - in trunk/perfsonar-java-base2/src/main/java/org/perfsonar/base2/service: configuration registration requesthandler scheduler storage/xml, svn-noreply, 03/09/2010
Archive powered by MHonArc 2.6.16.