[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/common ErrorCode.java,1.2,1.3 Fra
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-06 04:36:33
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30574 Modified Files: ErrorCode.java FrameworkUtil.java Log Message: no message Index: FrameworkUtil.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/FrameworkUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FrameworkUtil.java 4 Mar 2006 04:40:28 -0000 1.3 --- FrameworkUtil.java 6 Mar 2006 04:36:30 -0000 1.4 *************** *** 1,4 **** --- 1,9 ---- package org.jmonks.batchserver.framework.common; + import java.util.Map; + import org.w3c.dom.Element; + import org.w3c.dom.Node; + import org.w3c.dom.NodeList; + /** *************** *** 27,29 **** --- 32,79 ---- */ } + + /** + * <p> + * Loads the property elements exists in the given element to the given map. + * This looks for the <property> elements in the given element and looks + * for the value of "key" attribute and the values of <property> element + * and load them as key values pairs. + * </p> + * <p> + * Property elements should be in the following format.<br><br> + * <property key="some-config-key1">some-config-value1</property> + * </p> + * + * @param configElement DOM Element consists of <property> elements. + * @param propertyMap Map to be loaded with property key values. + * + * @throws IllegalArgumentException If either configElement or propertyMap is null. + */ + public static void loadPropertiesFromElementToMap(Element configElement,Map propertyMap) + { + if(configElement==null) + throw new IllegalArgumentException("Input configuration element configElement cannot be null"); + + if(propertyMap==null) + throw new IllegalArgumentException("Input properties map propertyMap cannot be null"); + + NodeList propertyElements=configElement.getElementsByTagName("property"); + for(int i=0;i<propertyElements.getLength();i++) + { + Element propertyElement=(Element)propertyElements.item(i); + String key=propertyElement.getAttribute("key"); + String value=""; + NodeList propertyValueNodes=propertyElement.getChildNodes(); + for(int j=0;j<propertyValueNodes.getLength();j++) + { + Node propertyValueNode=propertyValueNodes.item(j); + if(propertyValueNode.getNodeType()==Node.TEXT_NODE) + { + value=propertyValueNode.getNodeValue(); + break; + } + } + propertyMap.put(key,value); + } + } } \ No newline at end of file Index: ErrorCode.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/common/ErrorCode.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ErrorCode.java 4 Mar 2006 04:40:28 -0000 1.2 --- ErrorCode.java 6 Mar 2006 04:36:30 -0000 1.3 *************** *** 15,26 **** public final class ErrorCode { - - public final static ErrorCode JOBNAME_KEY_NOT_FOUND = new ErrorCode(1001,"job-name key not found in the startup properties"); - public final static ErrorCode JOB_NOT_CONFIGURED = new ErrorCode(1002,"job is not configured in the job configuration file"); - public final static ErrorCode INVALID_CONFIG_FACTORY = new ErrorCode(1003,"not a valid configuration factory"); - public final static ErrorCode MISSING_PROPS_XML_CONFIG_FACTORY = new ErrorCode(1004,"required properties are missing in xml config factory configuration"); - public final static ErrorCode UNABLE_TO_LOAD_XML_JOB_CONFIG_FILE = new ErrorCode(1005,"configured xml job configuration file cannot be loaded"); - public final static ErrorCode INVALID_JOB_CONFIG_FILE_FORMAT = new ErrorCode(1006,"xml job configuration file is not in a valid format"); - /** * Code represents the error. --- 15,18 ---- *************** *** 85,87 **** --- 77,99 ---- return stringValue.toString(); } + + /** + * Framework Configuration Error Codes. + */ + public final static ErrorCode JOBNAME_KEY_NOT_FOUND = new ErrorCode(1001,"job-name key not found in the startup properties"); + public final static ErrorCode FRAMEWORK_CONFIG_FILE_NOT_FOUND = new ErrorCode(1002,"framework configuration file framework-config.xml is not found in the classpath"); + public final static ErrorCode NONE_OR_MULITPLE_JOB_CONFIG_FACTORY_CONFIG_TAGS = new ErrorCode(1003,"None or multiple job-config-factory-config tag(s) in framework configuration"); + public final static ErrorCode NONE_OR_MULITPLE_LOGGING_CONFIG_TAGS = new ErrorCode(1004,"None or multiple logging-config tag(s) in framework configuration"); + public final static ErrorCode NONE_OR_MULITPLE_MGMT_MNTR_CONFIG_TAGS = new ErrorCode(1005,"None or multiple mgmt-mntr-config tag(s) in framework configuration"); + public final static ErrorCode NONE_OR_MULITPLE_REPOSITORY_CONFIG_TAGS = new ErrorCode(1006,"None or multiple repository-config tag(s) in framework configuration"); + public static final ErrorCode JOB_CONFIG_FACTORY_CLASS_NAME_ATTRIB_NOT_FOUND = new ErrorCode(1007,"Attribute job-config-factory-class-name not found in job-config-factory-config element"); + /** + * Job Configuration Error Codes. + */ + public final static ErrorCode JOB_NOT_CONFIGURED = new ErrorCode(2001,"job is not configured in the job configuration source"); + public final static ErrorCode INVALID_JOB_CONFIG_FACTORY = new ErrorCode(2002,"not a valid configuration factory"); + public final static ErrorCode MISSING_PROPS_XML_CONFIG_FACTORY = new ErrorCode(2003,"required properties are missing in xml config factory configuration"); + public final static ErrorCode UNABLE_TO_LOAD_XML_JOB_CONFIG_FILE = new ErrorCode(2004,"configured xml job configuration file cannot be loaded"); + public final static ErrorCode INVALID_JOB_CONFIG_FILE_FORMAT = new ErrorCode(2005,"xml job configuration file is not in a valid format"); + } |