Source Code Cross Referenced for DPFilter.java in  » Portal » Open-Portal » com » sun » portal » wsrp » producer » impl » 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 » Open Portal » com.sun.portal.wsrp.producer.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.wsrp.producer.impl;
002:
003:        import com.sun.portal.desktop.dp.DPChannel;
004:        import com.sun.portal.desktop.dp.DPContainerChannel;
005:        import com.sun.portal.desktop.dp.DPNode;
006:        import com.sun.portal.desktop.dp.DPRoot;
007:        import com.sun.portal.log.common.PortalLogger;
008:        import com.sun.portal.wsrp.producer.DPConnection;
009:        import com.sun.portal.wsrp.producer.ProducerException;
010:        import java.util.HashSet;
011:        import java.util.Iterator;
012:        import java.util.Set;
013:        import java.util.TreeSet;
014:        import java.util.logging.Level;
015:        import java.util.logging.Logger;
016:        import javax.servlet.http.HttpServletRequest;
017:
018:        public class DPFilter {
019:
020:            private static Logger logger = PortalLogger
021:                    .getLogger(ProducerImpl.class);
022:            private String portalId = null;
023:            private String organization = null;
024:            private HttpServletRequest req = null;
025:
026:            private DPRoot dpRoot = null;
027:            private static final Object dpLock = new Object();
028:
029:            private static String CHANNEL_NAME_SEPARATOR = String
030:                    .valueOf(DPNode.CHANNEL_NAME_SEPARATOR);
031:
032:            public DPFilter(String portalId, String organization) {
033:                this .portalId = portalId;
034:                this .organization = organization;
035:            }
036:
037:            public DPFilter(HttpServletRequest req, String organization) {
038:                this .req = req;
039:                this .organization = organization;
040:            }
041:
042:            public Set getExistingChannels() throws ProducerException {
043:                DPConnection dpc = null;
044:                if (req != null) {
045:                    dpc = new DPConnection(req);
046:                } else {
047:                    dpc = new DPConnection(portalId);
048:                }
049:                dpRoot = dpc.getDPRoot(organization);
050:
051:                DPNode currentNode = dpRoot;
052:                Set result = new TreeSet();
053:                Set channelNames = getChannelNames(currentNode);
054:                Iterator iterator = channelNames.iterator();
055:
056:                while (iterator.hasNext()) {
057:                    String channelName = (String) iterator.next();
058:                    logger.log(Level.FINEST, "PSDT_CSPT0019", channelName);
059:                    if (!isDisplayable(channelName)) {
060:                        continue;
061:                    }
062:                    DPChannel channel = getDPChannel(channelName);
063:                    //check if this channel is a container and if it is get
064:                    // the list of channels defined in the container
065:                    if (channel instanceof  DPContainerChannel) {
066:                        // get the list for this container baseDN.
067:                        result.addAll(getChannelsInContainer(channel, false));
068:                    } else {
069:                        result.add(channelName);
070:                    }
071:                }
072:
073:                return filterResults(result);
074:
075:            }
076:
077:            private Set filterResults(Set channels) {
078:                Set portletChannels = new TreeSet();
079:
080:                for (Iterator i = channels.iterator(); i.hasNext();) {
081:                    String name = (String) i.next();
082:                    DPChannel dpch = dpRoot.getChannel(name);
083:                    String providerName = dpch.getProviderName();
084:
085:                    if (providerName.indexOf("__Portlet__") != -1
086:                            && (!providerName.equals("_WSRPWindowProvider"))) {
087:                        portletChannels.add(name);
088:                    }
089:                }
090:                return portletChannels;
091:            }
092:
093:            private String toFullyQualifiedName(DPNode container,
094:                    String shortName) {
095:                return ((container instanceof  DPRoot) ? "" : container
096:                        .getName()
097:                        + DPNode.CHANNEL_NAME_SEPARATOR)
098:                        + shortName;
099:            }
100:
101:            private Set getChannelsInContainer(DPChannel container,
102:                    boolean onlyContainers) throws ProducerException {
103:                DPNode currentNode = container;
104:                Set result = new TreeSet();
105:                Set channelNames = getChannelNames(currentNode);
106:                Iterator iterator = channelNames.iterator();
107:
108:                while (iterator.hasNext()) {
109:                    String channelName = (String) iterator.next();
110:                    logger.log(Level.FINEST, "PSDT_CSPT0023", channelName);
111:                    String fQCN = toFullyQualifiedName(currentNode, channelName);
112:
113:                    if (!isDisplayable(fQCN)) {
114:                        continue;
115:                    }
116:                    DPChannel channel = null;
117:                    synchronized (dpLock) {
118:                        channel = currentNode.getChannel(channelName);
119:                    }
120:                    //check if this channel is a container and if it is get
121:                    // the list of channels defined in the container
122:                    if (channel instanceof  DPContainerChannel) {
123:                        if (onlyContainers) {
124:                            result.add(fQCN);
125:                        }
126:                        // get the list for this container baseDN.
127:                        result.addAll(getChannelsInContainer(channel,
128:                                onlyContainers));
129:                    } else if (!onlyContainers) {
130:                        result.add(fQCN);
131:                    }
132:                }
133:                return result;
134:
135:            }
136:
137:            private Set getChannelNames(DPNode node) {
138:                Set channelNames = null;
139:                synchronized (dpLock) {
140:                    channelNames = node.getChannelNames();
141:                }
142:
143:                Set portletChannelNames = new HashSet();
144:
145:                for (Iterator i = channelNames.iterator(); i.hasNext();) {
146:                    String name = (String) i.next();
147:                    DPChannel dpch = node.getChannel(name);
148:                    String providerName = dpch.getProviderName();
149:                    portletChannelNames.add(name);
150:                }
151:                return portletChannelNames;
152:            }
153:
154:            private DPChannel getDPChannel(String channelName)
155:                    throws ProducerException {
156:                DPChannel channel = null;
157:                synchronized (dpLock) {
158:                    if (!existsChannel(channelName)) {
159:                        // error key non-existent channel.
160:                        logger.log(Level.FINE, "PSDT_CSPT0035", new Object[] {
161:                                channelName, dpRoot.getName() });
162:                        throw new ProducerException("Channel does not exists: "
163:                                + channelName);
164:                    }
165:                    channel = dpRoot.getChannel(channelName);
166:                }
167:                return channel;
168:            }
169:
170:            private boolean existsChannel(String channel) {
171:                boolean exists = dpRoot.channelExists(channel);
172:                return exists;
173:            }
174:
175:            private boolean isDisplayable(String fqcn) {
176:
177:                boolean isDisplayable = true;
178:                if (fqcn == null || fqcn.length() == 0) {
179:                    isDisplayable = false;
180:                    return isDisplayable;
181:                }
182:                DPChannel channel = null;
183:                try {
184:                    channel = getDPChannel(fqcn);
185:                } catch (ProducerException tae) {
186:                    isDisplayable = false;
187:                    return isDisplayable;
188:                }
189:                String shortName = getTail(fqcn, CHANNEL_NAME_SEPARATOR);
190:
191:                // Filter out all channels/containers that are defined advanced or
192:                // if the name starts with "_"
193:                if (channel == null || channel.isAdvanced()
194:                        || shortName.startsWith("_")) {
195:
196:                    isDisplayable = false;
197:                }
198:
199:                return isDisplayable;
200:            }
201:
202:            private String getTail(String rpn, String nameSeparator) {
203:                String tail = null;
204:                if (rpn != null && rpn.length() != 0) {
205:                    int index = rpn.lastIndexOf(nameSeparator);
206:                    if (index == -1) {
207:                        tail = rpn;
208:                    } else {
209:                        tail = rpn.substring(index + 1, rpn.length());
210:                    }
211:                }
212:                return tail;
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.