Source Code Cross Referenced for ApplicationConstantsXmlParser.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » applicationconstants » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » edu.iu.uis.eden.applicationconstants.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.applicationconstants.xml;
018:
019:        import java.io.IOException;
020:        import java.io.InputStream;
021:        import java.util.ArrayList;
022:        import java.util.Iterator;
023:        import java.util.List;
024:
025:        import javax.xml.parsers.DocumentBuilderFactory;
026:        import javax.xml.parsers.FactoryConfigurationError;
027:        import javax.xml.parsers.ParserConfigurationException;
028:
029:        import org.apache.log4j.Logger;
030:        import org.jdom.Document;
031:        import org.jdom.Element;
032:        import org.jdom.JDOMException;
033:        import org.jdom.Namespace;
034:        import org.jdom.input.DOMBuilder;
035:        import org.xml.sax.SAXException;
036:
037:        import edu.iu.uis.eden.KEWServiceLocator;
038:        import edu.iu.uis.eden.applicationconstants.ApplicationConstant;
039:
040:        /*
041:         * A parser for application constant data.  Schema is ApplicationConstants.xsd
042:         * 
043:         * @author ewestfal
044:         * @author ahamid
045:         */
046:        public class ApplicationConstantsXmlParser {
047:
048:            private static final Logger LOG = Logger
049:                    .getLogger(ApplicationConstantsXmlParser.class);
050:
051:            private static final Namespace NAMESPACE = Namespace.getNamespace(
052:                    "", "ns:workflow/ApplicationConstants");
053:            private static final String APP_CONSTANTS_ELEMENT = "ApplicationConstants";
054:            private static final String APP_CONSTANT_ELEMENT = "ApplicationConstant";
055:            private static final String CONSTANT_NAME_ELEMENT = "ConstantName";
056:            private static final String CONSTANT_VALUE_ELEMENT = "ConstantValue";
057:
058:            public List parseAppConstEntries(InputStream file)
059:                    throws JDOMException, SAXException, IOException,
060:                    ParserConfigurationException, FactoryConfigurationError {
061:                List constEntries = new ArrayList();
062:
063:                org.w3c.dom.Document w3cDocument = DocumentBuilderFactory
064:                        .newInstance().newDocumentBuilder().parse(file);
065:                Document document = new DOMBuilder().build(w3cDocument);
066:                Element root = document.getRootElement();
067:
068:                for (Iterator constantsIt = root.getChildren(
069:                        APP_CONSTANTS_ELEMENT, NAMESPACE).iterator(); constantsIt
070:                        .hasNext();) {
071:                    Element constantsElement = (Element) constantsIt.next();
072:                    for (Iterator iterator = constantsElement.getChildren(
073:                            APP_CONSTANT_ELEMENT, NAMESPACE).iterator(); iterator
074:                            .hasNext();) {
075:                        Element constElement = (Element) iterator.next();
076:
077:                        String name = constElement.getChildTextTrim(
078:                                CONSTANT_NAME_ELEMENT, NAMESPACE);
079:                        String value = constElement.getChildTextTrim(
080:                                CONSTANT_VALUE_ELEMENT, NAMESPACE);
081:
082:                        LOG.info("Processing constant: " + name);
083:
084:                        ApplicationConstant constant = null;
085:                        ;
086:                        try {
087:                            LOG.debug("Looking up Application Constant: "
088:                                    + name);
089:                            constant = KEWServiceLocator
090:                                    .getApplicationConstantsService()
091:                                    .findByName(name);
092:                            if (constant != null) {
093:                                LOG
094:                                        .debug("Found existing Application Constant: "
095:                                                + name);
096:                                constant.setApplicationConstantValue(value);
097:                            } else {
098:                                constant = new ApplicationConstant();
099:                                constant.setApplicationConstantName(name);
100:                                constant.setApplicationConstantValue(value);
101:                            }
102:                            LOG.debug("Saving Application Constant: "
103:                                    + constant.getApplicationConstantName());
104:                            // TODO we're not flusing the cache here to get around problem with testing, this
105:                            // is typically only used in a test situation but we need to fix this!
106:                            KEWServiceLocator.getApplicationConstantsService()
107:                                    .save(constant);
108:                        } catch (Exception e) {
109:                            LOG.error("error saving Application Constant", e);
110:                        }
111:
112:                        // NOTE: should we move this into the try/catch block, or do we want to preserve a constant
113:                        // in memory even when it has not been persisted successfully?
114:                        constEntries.add(constant);
115:                    }
116:                }
117:
118:                //        ((ApplicationConstantsCache) SpringServiceLocator.getCache().getCachedObjectById(ApplicationConstantsCache.APPLICATION_CONSTANTS_CACHE_ID)).reload();
119:                return constEntries;
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.