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


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.desktop.context;
006:
007:        import java.util.Set;
008:        import java.util.Iterator;
009:        import java.util.Locale;
010:        import java.util.Map;
011:        import java.util.HashMap;
012:
013:        import javax.servlet.http.HttpServletRequest;
014:
015:        import com.iplanet.sso.SSOToken;
016:        import com.iplanet.sso.SSOException;
017:
018:        import com.sun.portal.util.ResourceLoader;
019:        import com.sun.portal.util.SSOUtil;
020:
021:        public class DSAMEAdminDPContext implements  AdminDPContext,
022:                DSAMEConstants {
023:
024:            protected DSAMEConnection dsameConn = null;
025:
026:            protected Map dpDocumentsLastRead = new HashMap();
027:            protected Map dpDocumentsLastReadPerPortal = new HashMap();
028:
029:            private static DSAMEMultiPortalConstants dmpc = null;
030:            private String portalId = null;
031:
032:            public DSAMEAdminDPContext() {
033:            }
034:
035:            /**
036:             * Initializes DSAMEAdminDPContext from a servlet.
037:             *
038:             * @param req Request object
039:             */
040:            public void init(HttpServletRequest req) {
041:                // create dsame connection
042:                SSOToken ssoToken = DSAMEConnection.getSSOToken(req);
043:                dsameConn = new DSAMEConnection(ssoToken);
044:                dmpc = DSAMEMultiPortalConstants.getInstance();
045:
046:                portalId = ResourceLoader.getInstance(System.getProperties())
047:                        .getPortalId();
048:            }
049:
050:            public void init(HttpServletRequest req, SSOToken ssoToken) {
051:                // create dsame connection        
052:                dsameConn = new DSAMEConnection(ssoToken);
053:                dmpc = DSAMEMultiPortalConstants.getInstance();
054:                portalId = ResourceLoader.getInstance(System.getProperties())
055:                        .getPortalId();
056:            }
057:
058:            public void init(HttpServletRequest req, String uid, String pw) {
059:                // create dsame connection
060:                dsameConn = new DSAMEConnection(uid, pw);
061:                dmpc = DSAMEMultiPortalConstants.getInstance();
062:                portalId = ResourceLoader.getInstance(System.getProperties())
063:                        .getPortalId();
064:            }
065:
066:            /**
067:             * Initializes DSAMEAdminDPContext from a stand-alone app. (CLI)
068:             *
069:             * @param uid user DN
070:             * @param password user password
071:             * @param propertiesFile Name of the file containig server-specific
072:             * settings.
073:             * @param portalId
074:             */
075:            public void init(final String uid, String password,
076:                    String propertiesFile, String portalId) {
077:
078:                //Instance must be created earliest as it is used in DSAMEConnection
079:                DSAMEMultiPortalConstants.createInstance(portalId);
080:                dmpc = DSAMEMultiPortalConstants.getInstance(portalId);
081:                this .portalId = portalId;
082:
083:                // create SSOToken
084:                SSOToken ssoToken = null;
085:                try {
086:
087:                    //FOLLOWING IS COMMENTED TO FIX CR 6273650
088:                    /*
089:                    SSOTokenManager ssom = DSAMEConnection.getSSOTokenManager();
090:                    ssoToken = ssom.createSSOToken(
091:                        new java.security.Principal() {
092:                            public String getName() { return uid; }
093:                        },
094:                        password);
095:                     */
096:                    //FOLLOWING IS REPLACEMENT OF ABOVE CALL
097:                    ssoToken = SSOUtil.createSSOToken(uid, password);
098:
099:                } catch (SSOException se) {
100:                    throw new ContextError("DSAMEAdminContext.init(): "
101:                            + "Failed to create SSOToken.  ", se);
102:                }
103:
104:                // create dsame connection
105:                dsameConn = new DSAMEConnection(ssoToken, portalId);
106:            }
107:
108:            /**
109:             * Initializes DSAMEAdminDPContext from a MBean.
110:             *
111:             * @param ssoToken SSOToken
112:             * @param propertiesFile Name of the file containig server-specific
113:             * settings.
114:             * @param portalId
115:             */
116:            public void init(SSOToken ssoToken, String propertiesFile,
117:                    String portalId) {
118:
119:                //Instance must be created earliest as it is used in DSAMEConnection
120:                DSAMEMultiPortalConstants.createInstance(portalId);
121:                dmpc = DSAMEMultiPortalConstants.getInstance(portalId);
122:                this .portalId = portalId;
123:
124:                // create dsame connection
125:                dsameConn = new DSAMEConnection(ssoToken, portalId);
126:            }
127:
128:            public boolean isValidating() {
129:
130:                //
131:                // Always validate
132:                //
133:                return true;
134:            }
135:
136:            public String getNameSpaceURI() {
137:
138:                return dsameConn.getGlobalAttribute(
139:                        dmpc.MP_SUN_DESKTOP_SERVICE, ATTR_DP_NAMESPACEURI);
140:            }
141:
142:            public synchronized Locale getLocale() {
143:
144:                //
145:                // FIXME(susu): what's the implication of this locale?
146:                //
147:                return Locale.getDefault();
148:            }
149:
150:            /*
151:             * Get all the nodes that are children of the base node, includes 
152:             * the base itself. If the includeParent option is set to true,
153:             * then include all the parent nodes of the base node.
154:             *
155:             * @param base The base dn.
156:             * @param level The level to be searched downwards.
157:             * @param includeParent If true, then include all the parent nodes.
158:             * @return Set A <code>Set</code> of the node names from the
159:             * search result.
160:             */
161:            public Set getAllNamesFromBase(String base, int level,
162:                    boolean includeParent) {
163:                Set allNodeNames = dsameConn.getChildrenNodeNames(base, level);
164:                if (includeParent) {
165:                    Set allParentNodeNames = getDPDocumentNames(base);
166:                    allNodeNames.addAll(allParentNodeNames);
167:                }
168:
169:                return allNodeNames;
170:            }
171:
172:            /*
173:             * Get all the children nodes from the root dn. Search up to the
174:             * level that is given.
175:             *
176:             * @param level The level to be searched downwards.
177:             * @return Set A <code>Set</code> of node names that contains all
178:             * the children node names.
179:             */
180:            public Set getAllNames(int level) {
181:                Set childrenNodeNames = dsameConn.getChildrenNodeNames(level);
182:                Set allNodeNames = getDPDocumentNames();
183:                for (Iterator i = childrenNodeNames.iterator(); i.hasNext();) {
184:                    allNodeNames.add((String) i.next());
185:                }
186:
187:                return allNodeNames;
188:            }
189:
190:            public Set getDPDocumentNames() {
191:                return dsameConn.getNodeNames();
192:            }
193:
194:            public Set getDPDocumentNames(String name) {
195:                return dsameConn.getNodeNames(name);
196:            }
197:
198:            public String getDPDocument(String name) {
199:                if (!isGlobal(name)) {
200:                    boolean isDesktopServiceAssigned = dsameConn
201:                            .isServiceAssigned(name,
202:                                    dmpc.MP_SUN_DESKTOP_SERVICE);
203:                    if (!isDesktopServiceAssigned) {
204:                        throw new ContextError(
205:                                "DSAMEAdminDPContext.getDPDocument(): "
206:                                        + "DesktopService not assigned to this dn : "
207:                                        + name);
208:                    }
209:                }
210:                String dp = dsameConn.getAttributeByDN(name, ATTR_DP_DOCUMENT);
211:
212:                if (dp != null) {
213:                    setDPDocumentLastRead(name);
214:                }
215:
216:                return dp;
217:            }
218:
219:            public String getGlobalDPDocument() {
220:                String dp = dsameConn.getGlobalAttribute(
221:                        dmpc.MP_SUN_DESKTOP_SERVICE, ATTR_DP_DOCUMENT);
222:
223:                if (dp != null) {
224:                    setDPDocumentLastRead(DSAMEConnection.GLOBAL_KEY);
225:                }
226:
227:                return dp;
228:            }
229:
230:            /*
231:             * Check if the pased base is the global dn.
232:             */
233:            public boolean isGlobal(String base) {
234:                return dsameConn.isGlobal(base);
235:            }
236:
237:            public String getDPDocumentByDN(String dn) {
238:                return getDPDocument(dn);
239:            }
240:
241:            protected void setDPDocumentLastModified(String name) {
242:                dsameConn.setAttributeByDN(name, ATTR_DP_LAST_MODIFIED, Long
243:                        .toString(System.currentTimeMillis()));
244:            }
245:
246:            public void storeDPDocument(String name, String dp) {
247:
248:                if (dp == null) {
249:                    throw new ContextError(
250:                            "DSAMEAdminDPContext.storeDPDocumentByDN(): "
251:                                    + "Passed in DP doc is null. ");
252:                }
253:
254:                dsameConn.setAttributeByDN(name, ATTR_DP_DOCUMENT, dp);
255:
256:                setDPDocumentLastModified(name);
257:                setDPDocumentLastRead(name);
258:            }
259:
260:            public void storeDPDocumentByDN(String dn, String dp) {
261:                storeDPDocument(dn, dp);
262:            }
263:
264:            public void storeGlobalDPDocument(String dp) {
265:                dsameConn.setGlobalAttribute(dmpc.MP_SUN_DESKTOP_SERVICE,
266:                        ATTR_DP_DOCUMENT, dp);
267:
268:                setDPDocumentLastModified(DSAMEConnection.GLOBAL_KEY);
269:                setDPDocumentLastRead(DSAMEConnection.GLOBAL_KEY);
270:            }
271:
272:            public void removeDPDocument(String name) {
273:                dsameConn.removeAttributeByDN(name, ATTR_DP_DOCUMENT);
274:
275:                setDPDocumentLastModified(name);
276:                setDPDocumentLastRead(name);
277:            }
278:
279:            public void removeDPDocumentByDN(String dn) {
280:                removeDPDocument(dn);
281:            }
282:
283:            public void removeGlobalDPDocument() {
284:                dsameConn.removeGlobalAttribute(dmpc.MP_SUN_DESKTOP_SERVICE,
285:                        ATTR_DP_DOCUMENT);
286:
287:                setDPDocumentLastModified(DSAMEConnection.GLOBAL_KEY);
288:                setDPDocumentLastRead(DSAMEConnection.GLOBAL_KEY);
289:            }
290:
291:            protected void setDPDocumentLastRead(String name) {
292:                Long l = new Long(System.currentTimeMillis());
293:                dpDocumentsLastRead.put(name, l);
294:                dpDocumentsLastReadPerPortal.put(portalId, dpDocumentsLastRead);
295:            }
296:
297:            public long getDPDocumentLastModified(String name) {
298:                String lm = dsameConn.getAttributeByDN(name,
299:                        ATTR_DP_LAST_MODIFIED);
300:                long lastModified;
301:
302:                if (lm == null) {
303:                    //
304:                    // TBD(jtb): is this an error?
305:                    //
306:                    lastModified = -1;
307:                } else {
308:                    try {
309:                        lastModified = Long.parseLong(lm);
310:                    } catch (NumberFormatException nfe) {
311:                        lastModified = -1;
312:                    }
313:                }
314:
315:                return lastModified;
316:            }
317:
318:            public long getDPDocumentLastRead(String name) {
319:                Long l = null;
320:                if (dpDocumentsLastReadPerPortal.containsKey(portalId)) {
321:                    dpDocumentsLastRead = (Map) dpDocumentsLastReadPerPortal
322:                            .get(portalId);
323:                    l = (Long) dpDocumentsLastRead.get(name);
324:                }
325:                long lastRead = -1;
326:                if (l != null) {
327:                    lastRead = l.longValue();
328:                }
329:                return lastRead;
330:            }
331:
332:            public String getDTAttribute(String baseName, String name) {
333:                return dsameConn.getAttributeByDN(baseName, name);
334:            }
335:
336:            public void setDTAttribute(String baseName, String name, String val) {
337:                dsameConn.setAttributeByDN(baseName, name, val);
338:            }
339:
340:            public Set getGlobalAttributeMultiVal(String serviceName,
341:                    String name) {
342:                return dsameConn.getGlobalAttributeMultiVal(serviceName, name);
343:            }
344:
345:            public Set getAttributeMultiVal(String baseName,
346:                    String serviceName, String name) {
347:                return dsameConn.getTemplateAttributeMultiVal(baseName,
348:                        serviceName, name);
349:            }
350:
351:            public void setGlobalAttributeMultiVal(String serviceName,
352:                    String name, Set vals) {
353:                dsameConn.setGlobalAttributes(serviceName, name, vals);
354:            }
355:
356:            public void setAttributeMultiVal(String baseName,
357:                    String serviceName, String name, Set vals) {
358:                dsameConn.setAttributesByDN(baseName, serviceName, name, vals);
359:            }
360:
361:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.