Source Code Cross Referenced for ProducerManagerImpl.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.iplanet.am.util.Debug;
004:
005:        import java.util.ArrayList;
006:        import java.util.Collections;
007:        import java.util.HashMap;
008:        import java.util.Iterator;
009:        import java.util.Map;
010:        import java.util.Set;
011:
012:        import javax.servlet.http.HttpServletRequest;
013:        import javax.servlet.ServletContext;
014:
015:        import com.sun.portal.wsrp.common.stubs.OperationFailedFault;
016:
017:        import com.iplanet.am.sdk.AMConstants;
018:        import com.iplanet.am.sdk.AMException;
019:        import com.iplanet.am.sdk.AMOrganization;
020:        import com.iplanet.am.sdk.AMRole;
021:        import com.iplanet.am.sdk.AMOrganizationalUnit;
022:        import com.iplanet.am.sdk.AMStoreConnection;
023:        import com.iplanet.sso.SSOException;
024:        import com.iplanet.sso.SSOToken;
025:        import com.iplanet.sso.SSOTokenManager;
026:        import com.sun.identity.sm.SMSException;
027:        import com.sun.identity.sm.ServiceSchema;
028:        import com.sun.identity.sm.ServiceSchemaManager;
029:        import com.sun.portal.desktop.context.DSAMEConstants;
030:        import com.sun.portal.wsrp.WSRPException;
031:        import com.sun.portal.wsrp.common.WSRPFactory;
032:        import com.sun.portal.wsrp.common.stubs.ModelDescription;
033:        import com.sun.portal.wsrp.producer.Producer;
034:        import com.sun.portal.wsrp.producer.ISConstants;
035:        import com.sun.portal.wsrp.producer.ISConnection;
036:        import com.sun.portal.wsrp.producer.ProducerDN;
037:        import com.sun.portal.wsrp.producer.ProducerException;
038:        import com.sun.portal.wsrp.producer.ProducerManager;
039:        import com.sun.portal.wsrp.producer.ProducerRegistryManager;
040:        import com.sun.portal.wsrp.producer.impl.ProducerImpl;
041:        import com.sun.portal.desktop.context.DSAMEMultiPortalConstants;
042:        import com.sun.portal.wsrp.producer.ISMultiPortalConstants;
043:
044:        public class ProducerManagerImpl implements  ProducerManager,
045:                ISConstants {
046:            private SSOToken token = null;
047:            private HttpServletRequest request = null;
048:            private ServletContext ctx = null;
049:            private ISConnection isConnection = null;
050:            private ProducerRegistryManager producerRegistryManager = null;
051:            private String portalId = null;
052:
053:            public ProducerManagerImpl(HttpServletRequest req,
054:                    ServletContext ctx, SSOToken token)
055:                    throws ProducerException {
056:                this .token = token;
057:                this .request = req;
058:                this .ctx = ctx;
059:                this .isConnection = new ISConnection(token);
060:                this .producerRegistryManager = ProducerRegistryManager
061:                        .getRegistryManager();
062:            }
063:
064:            public ProducerManagerImpl(SSOToken token, String portalId)
065:                    throws ProducerException {
066:                this .portalId = portalId;
067:                this .token = token;
068:                this .isConnection = new ISConnection(token, portalId);
069:                this .producerRegistryManager = ProducerRegistryManager
070:                        .getRegistryManager(portalId);
071:            }
072:
073:            public boolean areAllProducersDisabled() throws ProducerException {
074:                String areAllDisabled = isConnection
075:                        .getGlobalStringAttribute(ATTR_ALL_DISABLED);
076:
077:                return Boolean.valueOf(areAllDisabled).booleanValue();
078:            }
079:
080:            public Producer getProducer(String orgDN, String instanceName)
081:                    throws ProducerException {
082:                return new ProducerImpl(request, ctx, token, orgDN,
083:                        instanceName);
084:            }
085:
086:            public Producer getProducer(String key) throws ProducerException {
087:                if (request != null) {
088:                    return new ProducerImpl(request, ctx, token, key);
089:                }
090:                return new ProducerImpl(token, key, portalId);
091:
092:            }
093:
094:            public Producer[] getAllProducers(String orgDN)
095:                    throws ProducerException {
096:                //AMOrganizationalUnit producerOU = getProducerOU(orgDN);
097:                //String producerOUDN = ProducerDN.getProducersDN(orgDN);
098:                //Set producerDNs = isConnection.getSubOUNames(producerOUDN);
099:                //Iterator iterator = producerDNs.iterator();
100:                //Producer[] producers = new Producer[producerDNs.size()];
101:                // Ask the Producer Registry for the definite list of producer
102:                // instances of an organization now.  Note that this is
103:                // potentially very dangerous because, if the Producer
104:                // Registry is ever corrupted for any reason, no producer
105:                // instances will be visible and manageable from the admin
106:                // console even if the actual producer data are intact.
107:                Set keys = producerRegistryManager.getKeys(orgDN);
108:                Iterator iterator = keys.iterator();
109:                Producer[] producers = new Producer[keys.size()];
110:
111:                for (int i = 0; i < producers.length; i++) {
112:                    //String name = getProducerName((String)iterator.next());
113:                    //producers[i] = getProducer(orgDN, name);
114:                    producers[i] = getProducer((String) iterator.next());
115:                }
116:
117:                return producers;
118:            }
119:
120:            public void addProducer(String orgDN, String instanceName,
121:                    boolean status, boolean requiresRegistration,
122:                    boolean supportsInBandRegistration,
123:                    ModelDescription registrationPropertyDescription)
124:                    throws ProducerException {
125:
126:                AMOrganizationalUnit producerOU = getProducerOU(orgDN);
127:                String producerOUDN = ProducerDN
128:                        .getProducersDN(orgDN, portalId);
129:                Set objectClasses = Collections
130:                        .singleton(OBJECT_CLASS_PRODUCER);
131:                Set services = Collections.singleton("iPlanetAMAuthService");
132:                Map attributes = new HashMap();
133:
134:                attributes.put(ATTR_STATUS, Collections.singleton(Boolean
135:                        .toString(status)));
136:
137:                attributes.put(ATTR_REQUIRES_REGISTRATION, Collections
138:                        .singleton(Boolean.toString(requiresRegistration)));
139:
140:                if (requiresRegistration) {
141:                    attributes.put(ATTR_SUPPORTS_IN_BAND_REGISTRATION,
142:                            Collections.singleton(Boolean
143:                                    .toString(supportsInBandRegistration)));
144:                }
145:
146:                if (requiresRegistration
147:                        && (registrationPropertyDescription != null)) {
148:                    try {
149:                        WSRPFactory factory = WSRPFactory.getInstance();
150:
151:                        String xmlString = factory
152:                                .getJAXBXML(
153:                                        factory
154:                                                .getJAXBModelDescription(registrationPropertyDescription),
155:                                        true);
156:
157:                        attributes.put(ATTR_REGISTRATION_PROPERTY_DESCRIPTION,
158:                                Collections.singleton(xmlString));
159:                    } catch (WSRPException e) {
160:                        throw new ProducerException(e);
161:                    }
162:                }
163:
164:                attributes
165:                        .put(
166:                                ATTR_REGISTRATION_VALIDATOR_CLASSNAME,
167:                                Collections
168:                                        .singleton("com.sun.portal.wsrp.producer.registration.validator.impl.DefaultRegistrationValidator"));
169:
170:                isConnection.createOUUnderOU(producerOUDN, instanceName,
171:                        objectClasses, services, attributes);
172:
173:                String peopleDN = ProducerDN.getDefaultPeopleDN(orgDN,
174:                        instanceName, portalId);
175:                String defaultUserDN = ProducerDN.getDefaultUserDN(orgDN,
176:                        instanceName, portalId);
177:
178:                DSAMEMultiPortalConstants dmc = null;
179:
180:                if (portalId == null) {
181:                    dmc = DSAMEMultiPortalConstants.getInstance();
182:                } else {
183:                    DSAMEMultiPortalConstants.createInstance(portalId);
184:                    dmc = DSAMEMultiPortalConstants.getInstance(portalId);
185:                }
186:
187:                objectClasses = Collections
188:                        .singleton(dmc.MP_SUN_DESKTOP_OBJECT_CLASS);
189:
190:                attributes.clear();
191:                attributes.put("userPassword", Collections
192:                        .singleton(defaultUserDN));
193:                String regHandle = getRegistrationHandle(peopleDN);
194:                try {
195:                    isConnection.createRole(orgDN, regHandle, instanceName,
196:                            objectClasses, null);
197:                    isConnection.createUser(peopleDN, "default", objectClasses,
198:                            attributes, instanceName);
199:                    producerRegistryManager.add(instanceName, orgDN,
200:                            instanceName);
201:                } catch (ProducerException e) {
202:                    removeProducers(orgDN, new String[] { instanceName });
203:                    throw e;
204:                }
205:            }
206:
207:            public void removeProducers(String orgDN, String[] names)
208:                    throws ProducerException {
209:                AMOrganizationalUnit producerOU = getProducerOU(orgDN);
210:
211:                for (int i = 0; i < names.length; i++) {
212:
213:                    String producerDN = ProducerDN.getProducerDN(orgDN,
214:                            names[i], portalId);
215:
216:                    try {
217:                        AMOrganizationalUnit producer = producerOU
218:                                .getSubOrganizationalUnit(producerDN);
219:
220:                        if (producer.isExists()) {
221:                            producer.delete(true);
222:                        } else {
223:                            throw new ProducerException(1,
224:                                    "Producer Name does not exist.");
225:                        }
226:                        deleteProducerRoles(orgDN, names[i]);
227:
228:                    } catch (AMException e) {
229:                        throw new ProducerException(e.getMessage(), e);
230:                    } catch (SSOException e) {
231:                        throw new ProducerException(e.getMessage(), e);
232:                    }
233:
234:                    producerRegistryManager.remove(names[i]);
235:                }
236:            }
237:
238:            private AMOrganizationalUnit getProducerOU(String orgDN)
239:                    throws ProducerException {
240:                try {
241:                    AMStoreConnection storeConnection = new AMStoreConnection(
242:                            token);
243:                    AMOrganization org = storeConnection.getOrganization(orgDN);
244:                    String producerOUDN = ProducerDN.getProducersDN(orgDN,
245:                            portalId);
246:                    AMOrganizationalUnit producerOU = null;
247:
248:                    synchronized (getClass()) {
249:                        producerOU = org.getOrganizationalUnit(producerOUDN);
250:
251:                        if (!producerOU.isExists()) {
252:                            ISMultiPortalConstants ismpc = null;
253:                            if (portalId == null) {
254:                                ismpc = ISMultiPortalConstants.getInstance();
255:                            } else {
256:                                ismpc = ISMultiPortalConstants
257:                                        .getInstance(portalId);
258:                            }
259:                            Set producerOUName = Collections
260:                                    .singleton(ismpc.MP_RDN_PRODUCER);
261:
262:                            Set producerOUs = org
263:                                    .createOrganizationalUnits(producerOUName);
264:
265:                            Iterator iterator = producerOUs.iterator();
266:
267:                            if (iterator.hasNext()) {
268:                                producerOU = (AMOrganizationalUnit) iterator
269:                                        .next();
270:                            } else {
271:                                // FIXME: should localized
272:                                throw new ProducerException("Cannot create ou="
273:                                        + ismpc.MP_RDN_PRODUCER);
274:                            }
275:                        }
276:                    }
277:
278:                    return producerOU;
279:                } catch (AMException e) {
280:                    throw new ProducerException(e.getMessage(), e);
281:                } catch (SSOException e) {
282:                    throw new ProducerException(e.getMessage(), e);
283:                }
284:
285:            }
286:
287:            // Gets the producer name from the producer's DN.
288:            /* This method is commented out due to the change of
289:             * getAllProducers() to use the Producer Registry to obtain the
290:             * list of producer instances of an org.  The original code used
291:             * this method.  This method is intentionally not removed so that
292:             * when the Producer Registry is fixed completely in the future,
293:             * we can revert back easily...
294:            private String getProducerName(String aDN) {
295:                // A DN of the form ou=producerInstance,ou=WSRPProducers,...
296:                int i = aDN.indexOf(",");
297:                String rdn = (i < 0) ? aDN : aDN.substring(0, i);
298:                return rdn.startsWith("ou=") ? rdn.substring(3) : rdn;
299:            }
300:             */
301:
302:            private void deleteProducerRoles(String orgDN, String instance)
303:                    throws AMException, SSOException {
304:
305:                AMStoreConnection storeConnection = new AMStoreConnection(token);
306:                AMOrganization org = storeConnection.getOrganization(orgDN);
307:                Set roles = org.searchRoles(ProducerDN.WSRP_ROLE_PREFIX + "*"
308:                        + instance + "*", AMConstants.SCOPE_ONE);
309:                Iterator it = roles.iterator();
310:                AMRole wsrpRole = null;
311:                while (it.hasNext()) {
312:                    wsrpRole = storeConnection.getRole(it.next().toString());
313:                    wsrpRole.delete();
314:                }
315:            }
316:
317:            private String getRegistrationHandle(String peopleDN) {
318:                String lowercaseDN = peopleDN.toLowerCase();
319:                int index = lowercaseDN.indexOf("ou=people,");
320:                if (index != -1) {
321:                    String parseDN = peopleDN.substring(index + 10, lowercaseDN
322:                            .length());
323:                    index = parseDN.indexOf(",");
324:                    if (index != -1)
325:                        return parseDN.substring(3, index);
326:                }
327:                return peopleDN;
328:            }
329:
330:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.