Source Code Cross Referenced for XMLPersonAttributesConfiguration.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » groups » pags » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.groups.pags 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2004 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.groups.pags;
007:
008:        import java.lang.reflect.Constructor;
009:        import java.util.HashMap;
010:        import java.util.Map;
011:
012:        import org.jasig.portal.groups.pags.PersonAttributesGroupStore.GroupDefinition;
013:        import org.jasig.portal.groups.pags.PersonAttributesGroupStore.TestGroup;
014:        import org.jasig.portal.utils.ResourceLoader;
015:        import org.w3c.dom.Document;
016:        import org.w3c.dom.Element;
017:        import org.w3c.dom.Node;
018:        import org.w3c.dom.NodeList;
019:        import org.w3c.dom.Text;
020:
021:        /**
022:         * Read in the configuration for the Person Attributes group store using
023:         * an XML file.  See the example file in /properties/groups/PAGSGroupStoreConfig.xml
024:         * and the DTD in /webpages/dtd/PAGSGroupStore.dtd for information on the
025:         * file format.
026:         *
027:         * @author Al Wold
028:         * @version $Revision: 36683 $
029:         */
030:        public class XMLPersonAttributesConfiguration implements 
031:                IPersonAttributesConfiguration {
032:
033:            public Map getConfig() {
034:                Map groupDefinitions;
035:                Document config = null;
036:                try {
037:                    config = ResourceLoader.getResourceAsDocument(this 
038:                            .getClass(),
039:                            "/properties/groups/PAGSGroupStoreConfig.xml");
040:                } catch (Exception rme) {
041:                    throw new RuntimeException(
042:                            "PersonAttributesGroupStore: Unable to find configuration document");
043:                }
044:                groupDefinitions = new HashMap();
045:                config.normalize();
046:                Element groupStoreElement = config.getDocumentElement();
047:                NodeList groupElements = groupStoreElement.getChildNodes();
048:                for (int i = 0; i < groupElements.getLength(); i++) {
049:                    if (groupElements.item(i) instanceof  Element) {
050:                        GroupDefinition groupDef = initGroupDef((Element) groupElements
051:                                .item(i));
052:                        groupDefinitions.put(groupDef.getKey(), groupDef);
053:                    }
054:                }
055:                return groupDefinitions;
056:            }
057:
058:            private GroupDefinition initGroupDef(Element groupElement) {
059:                GroupDefinition groupDef = new GroupDefinition();
060:                NodeList children = groupElement.getChildNodes();
061:                for (int i = 0; i < children.getLength(); i++) {
062:                    if (children.item(i) instanceof  Element) {
063:                        Element element = (Element) children.item(i);
064:                        String tagName = element.getTagName();
065:                        element.normalize();
066:                        String text = null;
067:                        if (element.getFirstChild() instanceof  Text) {
068:                            text = ((Text) element.getFirstChild()).getData()
069:                                    .trim();
070:                        }
071:                        if (tagName.equals("group-key")) {
072:                            groupDef.setKey(text);
073:                        } else if (tagName.equals("group-name")) {
074:                            groupDef.setName(text);
075:                        } else if (tagName.equals("group-description")) {
076:                            groupDef.setDescription(text);
077:                        } else if (tagName.equals("selection-test")) {
078:                            NodeList testGroups = element.getChildNodes();
079:                            for (int j = 0; j < testGroups.getLength(); j++) {
080:                                Node testGroup = testGroups.item(j);
081:                                if (testGroup instanceof  Element
082:                                        && ((Element) testGroup).getTagName()
083:                                                .equals("test-group")) {
084:                                    TestGroup tg = new TestGroup();
085:                                    NodeList tests = testGroup.getChildNodes();
086:                                    for (int k = 0; k < tests.getLength(); k++) {
087:                                        Node test = tests.item(k);
088:                                        if (test instanceof  Element
089:                                                && ((Element) test)
090:                                                        .getTagName().equals(
091:                                                                "test")) {
092:                                            String attribute = null;
093:                                            String tester = null;
094:                                            String value = null;
095:                                            NodeList parameters = test
096:                                                    .getChildNodes();
097:                                            for (int l = 0; l < parameters
098:                                                    .getLength(); l++) {
099:                                                Node parameter = parameters
100:                                                        .item(l);
101:                                                text = null;
102:                                                String nodeName = parameter
103:                                                        .getNodeName();
104:                                                if (parameter.getFirstChild() != null
105:                                                        && parameter
106:                                                                .getFirstChild() instanceof  Text) {
107:                                                    text = ((Text) parameter
108:                                                            .getFirstChild())
109:                                                            .getData();
110:                                                }
111:                                                if (nodeName
112:                                                        .equals("attribute-name")) {
113:                                                    attribute = text;
114:                                                } else if (nodeName
115:                                                        .equals("tester-class")) {
116:                                                    tester = text;
117:                                                } else if (nodeName
118:                                                        .equals("test-value")) {
119:                                                    value = text;
120:                                                }
121:                                            }
122:                                            IPersonTester testerInst = initializeTester(
123:                                                    tester, attribute, value);
124:                                            tg.addTest(testerInst);
125:                                        }
126:                                        groupDef.addTestGroup(tg);
127:                                    }
128:                                }
129:                            }
130:                        } else if (tagName.equals("members")) {
131:                            addMemberKeys(groupDef, element);
132:                        }
133:                    }
134:                }
135:                return groupDef;
136:            }
137:
138:            private void addMemberKeys(GroupDefinition groupDef, Element members) {
139:                NodeList children = members.getChildNodes();
140:                for (int i = 0; i < children.getLength(); i++) {
141:                    Node node = children.item(i);
142:                    if (node instanceof  Element
143:                            && node.getNodeName().equals("member-key")) {
144:                        Element member = (Element) node;
145:                        member.normalize();
146:                        if (member.getFirstChild() instanceof  Text) {
147:                            groupDef.addMember(((Text) member.getFirstChild())
148:                                    .getData());
149:                        }
150:                    }
151:                }
152:            }
153:
154:            private IPersonTester initializeTester(String tester,
155:                    String attribute, String value) {
156:                try {
157:                    Class testerClass = Class.forName(tester);
158:                    Constructor c = testerClass.getConstructor(new Class[] {
159:                            String.class, String.class });
160:                    Object o = c.newInstance(new Object[] { attribute, value });
161:                    return (IPersonTester) o;
162:                } catch (Exception e) {
163:                    e.printStackTrace();
164:                    return null;
165:                }
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.