Source Code Cross Referenced for ExtendedPortletMetadata.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » util » descriptor » 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 » jetspeed 2.1.3 » org.apache.jetspeed.util.descriptor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
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 org.apache.jetspeed.util.descriptor;
018:
019:        import java.io.Reader;
020:        import java.util.ArrayList;
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:
024:        import org.apache.commons.digester.Digester;
025:        import org.apache.commons.digester.Rule;
026:        import org.apache.commons.logging.Log;
027:        import org.apache.commons.logging.LogFactory;
028:        import org.apache.jetspeed.om.common.portlet.CustomPortletMode;
029:        import org.apache.jetspeed.om.common.portlet.CustomWindowState;
030:        import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
031:        import org.apache.jetspeed.om.portlet.impl.CustomPortletModeImpl;
032:        import org.apache.jetspeed.om.portlet.impl.CustomWindowStateImpl;
033:        import org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl;
034:        import org.apache.jetspeed.tools.pamanager.rules.JetspeedServicesRuleSet;
035:        import org.apache.jetspeed.tools.pamanager.rules.MetadataRuleSet;
036:        import org.apache.jetspeed.tools.pamanager.rules.PortletRule;
037:        import org.apache.jetspeed.tools.pamanager.rules.SecurityConstraintRefRule;
038:        import org.apache.jetspeed.tools.pamanager.rules.UserAttributeRefRuleSet;
039:        import org.xml.sax.Attributes;
040:
041:        /**
042:         * This class is used to load extended MetaData, like that of the Dublin Core, 
043:         * into an exsting PortletApplicationDefinition's object graph.
044:         * 
045:         * @author <a href="mailto:jford@apache.org">Jeremy Ford </a>
046:         * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
047:         * @version $Id: JetspeedDescriptorUtilities.java,v 1.10 2004/06/08 01:35:01
048:         *                dlestrat Exp $
049:         */
050:        public class ExtendedPortletMetadata {
051:            private static class CollectionRule extends Rule {
052:                private Collection collection;
053:
054:                public CollectionRule(Collection collection) {
055:                    this .collection = collection;
056:                }
057:
058:                public void begin(String arg0, String arg1, Attributes arg2)
059:                        throws Exception {
060:                    digester.push(collection);
061:                }
062:
063:                public void end(String arg0, String arg1) throws Exception {
064:                    digester.pop();
065:                }
066:            }
067:
068:            protected final static Log log = LogFactory
069:                    .getLog(ExtendedPortletMetadata.class);
070:
071:            protected Reader extendedMetaData;
072:            protected MutablePortletApplication portletApp;
073:
074:            /**
075:             * 
076:             * @param extendedMetaData Reader that contains the extended metadata, usually jetspeed-portlet.xml
077:             * @param portletApp the MutablePortletApplication we are adding the extended metadata to.
078:             */
079:            public ExtendedPortletMetadata(Reader extendedMetaData,
080:                    MutablePortletApplication portletApp) {
081:                this .extendedMetaData = extendedMetaData;
082:                this .portletApp = portletApp;
083:            }
084:
085:            /**
086:             * Performs the actual loading and mapping of the metadata into the PortletApplicationDefinition.
087:             * 
088:             */
089:            public void load() throws MetaDataException {
090:                try {
091:                    Digester digester = new Digester();
092:                    digester.setClassLoader(this .getClass().getClassLoader());
093:                    digester.setValidating(false);
094:                    digester.setNamespaceAware(true);
095:                    digester.push(portletApp);
096:
097:                    digester.addRuleSet(new MetadataRuleSet("portlet-app/"));
098:                    digester
099:                            .addRuleSet(new JetspeedServicesRuleSet(portletApp));
100:                    digester.addRule("portlet-app/security-constraint-ref",
101:                            new SecurityConstraintRefRule(portletApp));
102:
103:                    digester.addRule("portlet-app/portlet/portlet-name",
104:                            new PortletRule(portletApp));
105:                    digester.addRuleSet(new MetadataRuleSet(
106:                            "portlet-app/portlet/"));
107:
108:                    digester.addRule(
109:                            "portlet-app/portlet/security-constraint-ref",
110:                            new SecurityConstraintRefRule(portletApp));
111:
112:                    digester
113:                            .addRuleSet(new UserAttributeRefRuleSet(portletApp));
114:
115:                    ArrayList mappedPortletModes = new ArrayList();
116:                    digester.addRule("portlet-app/custom-portlet-mode",
117:                            new CollectionRule(mappedPortletModes));
118:                    digester.addObjectCreate("portlet-app/custom-portlet-mode",
119:                            CustomPortletModeImpl.class);
120:
121:                    digester.addBeanPropertySetter(
122:                            "portlet-app/custom-portlet-mode/name",
123:                            "customName");
124:                    digester.addBeanPropertySetter(
125:                            "portlet-app/custom-portlet-mode/mapped-name",
126:                            "mappedName");
127:                    digester.addSetNext("portlet-app/custom-portlet-mode",
128:                            "add");
129:
130:                    ArrayList mappedWindowStates = new ArrayList();
131:                    digester.addRule("portlet-app/custom-window-state",
132:                            new CollectionRule(mappedWindowStates));
133:                    digester.addObjectCreate("portlet-app/custom-window-state",
134:                            CustomWindowStateImpl.class);
135:
136:                    digester.addBeanPropertySetter(
137:                            "portlet-app/custom-window-state/name",
138:                            "customName");
139:                    digester.addBeanPropertySetter(
140:                            "portlet-app/custom-window-state/mapped-name",
141:                            "mappedName");
142:                    digester.addSetNext("portlet-app/custom-window-state",
143:                            "add");
144:
145:                    digester.parse(extendedMetaData);
146:
147:                    if (mappedPortletModes.size() > 0) {
148:                        PortletApplicationDefinitionImpl pa = (PortletApplicationDefinitionImpl) portletApp;
149:                        ArrayList customModes = new ArrayList(pa
150:                                .getCustomPortletModes());
151:                        Iterator mappedModesIter = mappedPortletModes
152:                                .iterator();
153:                        while (mappedModesIter.hasNext()) {
154:                            CustomPortletModeImpl mappedMode = (CustomPortletModeImpl) mappedModesIter
155:                                    .next();
156:                            if (!mappedMode.getMappedMode().equals(
157:                                    mappedMode.getCustomMode())) {
158:                                int index = customModes.indexOf(mappedMode);
159:                                if (index > -1) {
160:                                    CustomPortletMode customMode = (CustomPortletMode) customModes
161:                                            .get(index);
162:                                    mappedMode.setDescription(customMode
163:                                            .getDescription());
164:                                    customModes.set(index, mappedMode);
165:                                }
166:                            }
167:                        }
168:                        pa.setCustomPortletModes(customModes);
169:                    }
170:                    if (mappedWindowStates.size() > 0) {
171:                        PortletApplicationDefinitionImpl pa = (PortletApplicationDefinitionImpl) portletApp;
172:                        ArrayList customStates = new ArrayList(pa
173:                                .getCustomWindowStates());
174:                        Iterator mappedStatesIter = mappedWindowStates
175:                                .iterator();
176:                        while (mappedStatesIter.hasNext()) {
177:                            CustomWindowStateImpl mappedState = (CustomWindowStateImpl) mappedStatesIter
178:                                    .next();
179:                            if (!mappedState.getMappedState().equals(
180:                                    mappedState.getCustomState())) {
181:                                int index = customStates.indexOf(mappedState);
182:                                if (index > -1) {
183:                                    CustomWindowState customState = (CustomWindowState) customStates
184:                                            .get(index);
185:                                    mappedState.setDescription(customState
186:                                            .getDescription());
187:                                    customStates.set(index, mappedState);
188:                                }
189:                            }
190:                        }
191:                        pa.setCustomWindowStates(customStates);
192:                    }
193:                } catch (Throwable t) {
194:                    throw new MetaDataException(
195:                            "Unable to marshall extended metadata.  "
196:                                    + t.toString(), t);
197:                }
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.