Source Code Cross Referenced for DPRegister.java in  » Portal » Open-Portal » com » sun » portal » portlet » admin » mbeans » tasks » 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.portlet.admin.mbeans.tasks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: DPRegister.java,v 1.3 2006/08/22 10:50:11 nk137934 Exp $
003:         * Copyright 2004 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.portlet.admin.mbeans.tasks;
014:
015:        import java.util.Properties;
016:        import java.util.List;
017:        import java.util.ArrayList;
018:        import java.util.StringTokenizer;
019:        import java.io.File;
020:        import java.io.FileInputStream;
021:        import java.io.IOException;
022:        import com.sun.portal.desktop.context.AdminDPContext;
023:        import java.util.logging.Level;
024:        import java.util.logging.Logger;
025:        import com.sun.portal.portlet.admin.mbeans.tasks.*;
026:
027:        // This class is used to create provider def in the DP
028:
029:        public class DPRegister {
030:
031:            private static final String WEB_XML = "web.xml";
032:            private static final String PORTLET_XML = "portlet.xml";
033:            private static final String EXT_XML = "sun-portlet.xml";
034:            private static final String WEB_INF_PREFIX = "WEB-INF" + "/";
035:            private static final String DD_LOCATION = "DDFileLocation";
036:            private static final String DD_SUFFIX = "_portlet.xml";
037:            private static final String WAR_SUFFIX = ".war";
038:
039:            private Properties configProps = null;
040:
041:            public DPRegister(Properties pdconfigProp)
042:                    throws PortletDeployerException {
043:                this .configProps = pdconfigProp;
044:            }
045:
046:            public void process(AdminDPContext dadc, String dn, boolean global,
047:                    File earFile, Properties rolesProperties,
048:                    Properties userinfoProperties, boolean verbose,
049:                    Logger logger) throws PortletDeployerException {
050:
051:                if (verbose) {
052:                    logger.log(Level.INFO, "PSPL_CSPPAMT0021",
053:                            new Object[] { earFile });
054:                }
055:
056:                WebAppExtractor extractor = null;
057:                List allProviderElements = new ArrayList();
058:
059:                try {
060:
061:                    extractor = new WebAppExtractor(earFile, configProps,
062:                            verbose, logger);
063:                    if (extractor.isArchiveRegistered()) {
064:                        throw new PortletDeployerException("alreadyRegistered");
065:
066:                    }
067:                    if (verbose) {
068:                        logger.log(Level.INFO, "PSPL_CSPPAMT0022");
069:                    }
070:                    List listOfDescriptors = extractor.extractPortletWars();
071:                    if (verbose) {
072:                        logger.log(Level.INFO, "PSPL_CSPPAMT0023",
073:                                new Object[] { new Integer(listOfDescriptors
074:                                        .size()) });
075:
076:                    }
077:                    if (rolesProperties == null) {
078:                        rolesProperties = new Properties();
079:                    }
080:
081:                    if (userinfoProperties == null) {
082:                        userinfoProperties = new Properties();
083:                    }
084:
085:                    // iterate through all descriptors
086:                    // Create a DP entry for each portlet applications
087:
088:                    for (int i = 0; i < listOfDescriptors.size(); i++) {
089:                        File[] fileArray = (File[]) listOfDescriptors.get(i);
090:                        File portletXMLDesc = fileArray[0];
091:                        File extensionXMLDesc = fileArray[1];
092:                        File webXMLDesc = fileArray[2];
093:
094:                        String webAppName = getWebAppNameFromFileName(portletXMLDesc
095:                                .getName());
096:                        FileInputStream portletXMLStream = new FileInputStream(
097:                                portletXMLDesc);
098:                        FileInputStream extensionXMLStream = null;
099:                        if (extensionXMLDesc != null) {
100:                            extensionXMLStream = new FileInputStream(
101:                                    extensionXMLDesc);
102:                        }
103:                        FileInputStream webXMLStream = new FileInputStream(
104:                                webXMLDesc);
105:                        if (verbose) {
106:                            logger
107:                                    .log(
108:                                            Level.INFO,
109:                                            "PSPL_CSPPAMT0023",
110:                                            new Object[] { getWebAppNameFromFileName(portletXMLDesc
111:                                                    .getName()) });
112:                        }
113:                        // Read roles declared in the web.xml
114:                        List roles = new ArrayList();
115:                        try {
116:                            roles = PDWebAppUpdater.getRoles(webXMLStream);
117:
118:                        } catch (Exception ioe) {
119:                            // No roles in web.xml so ignore
120:                            logger.log(Level.WARNING, "PSPL_CSPPAMT0033", ioe
121:                                    .getMessage());
122:                        }
123:                        if (verbose) {
124:                            logger.log(Level.INFO, "PSPL_CSPPAMT0026",
125:                                    new Object[] { roles });
126:                        }
127:                        PDProviderEntryGenerator providerGen = new PDProviderEntryGenerator(
128:                                portletXMLStream, extensionXMLStream,
129:                                configProps, webAppName);
130:                        List providerElements = providerGen
131:                                .createProviderElements(rolesProperties,
132:                                        userinfoProperties, roles);
133:                        allProviderElements.add(providerElements);
134:                        // close all open input streams
135:                        webXMLStream.close();
136:                        if (extensionXMLStream != null) {
137:                            extensionXMLStream.close();
138:                        }
139:                    }
140:
141:                } catch (IOException excp) {
142:                    logger.log(Level.SEVERE, "PSPL_CSPPAMT0025", excp);
143:                    abortRegistration(extractor);
144:                    throw new PortletDeployerException(excp);
145:                } catch (PortletDeployerException pdExcp) {
146:                    // In case of any failures, no DP updates are done.
147:                    logger.log(Level.SEVERE, "PSPL_CSPPAMT0025", pdExcp);
148:                    abortRegistration(extractor);
149:                    throw new PortletDeployerException(pdExcp.getKey(), pdExcp
150:                            .getTokens());
151:                }
152:
153:                // No failure have been encountered. Do all DP updates
154:                try {
155:                    PDDPUpdater dpUpdater = new PDDPUpdater(dadc, dn, global,
156:                            verbose, logger);
157:                    // iterate through the list of all provider elements and add them.
158:                    for (int i = 0; i < allProviderElements.size(); i++) {
159:                        dpUpdater.addProviders((List) allProviderElements
160:                                .get(i));
161:                    }
162:                } catch (PortletDeployerException pdExcp) {
163:                    // In case of any failures, no DP updates are done.
164:                    logger.log(Level.SEVERE, "PSPL_CSPPAMT0025", pdExcp);
165:                    abortRegistration(extractor);
166:                    throw pdExcp;
167:                }
168:
169:                // Everything went fine   
170:                //delete the extracted web.xml and sun-portlet.xml from file system
171:                extractor.deleteAdditionalDescriptors();
172:            }
173:
174:            private String getWebAppNameFromFileName(String descriptorFileName) {
175:                StringTokenizer tokenizer = new StringTokenizer(
176:                        descriptorFileName, "_");
177:                tokenizer.nextToken(); // Ear name -ignore
178:                return tokenizer.nextToken();
179:            }
180:
181:            private void abortRegistration(WebAppExtractor extractor) {
182:
183:                if (extractor != null) {
184:                    extractor.deleteExtractedWars();
185:                }
186:            }
187:
188:        }
w___w__w.___j__a__va2___s__.___c__o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.