Source Code Cross Referenced for PortletLocalServiceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portal » service » 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 » liferay portal 4.4.2 » com.liferay.portal.service.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
0003:         *
0004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
0005:         * of this software and associated documentation files (the "Software"), to deal
0006:         * in the Software without restriction, including without limitation the rights
0007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0008:         * copies of the Software, and to permit persons to whom the Software is
0009:         * furnished to do so, subject to the following conditions:
0010:         *
0011:         * The above copyright notice and this permission notice shall be included in
0012:         * all copies or substantial portions of the Software.
0013:         *
0014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0020:         * SOFTWARE.
0021:         */package com.liferay.portal.service.impl;
0022:
0023:        import com.liferay.portal.PortalException;
0024:        import com.liferay.portal.SystemException;
0025:        import com.liferay.portal.kernel.plugin.PluginPackage;
0026:        import com.liferay.portal.kernel.portlet.FriendlyURLMapper;
0027:        import com.liferay.portal.kernel.util.GetterUtil;
0028:        import com.liferay.portal.kernel.util.LocaleUtil;
0029:        import com.liferay.portal.kernel.util.Validator;
0030:        import com.liferay.portal.model.Portlet;
0031:        import com.liferay.portal.model.PortletCategory;
0032:        import com.liferay.portal.model.PortletInfo;
0033:        import com.liferay.portal.model.impl.CompanyImpl;
0034:        import com.liferay.portal.model.impl.PortletImpl;
0035:        import com.liferay.portal.service.base.PortletLocalServiceBaseImpl;
0036:        import com.liferay.portal.util.ContentUtil;
0037:        import com.liferay.portal.util.PortalUtil;
0038:        import com.liferay.portal.util.PortletKeys;
0039:        import com.liferay.portal.util.PropsValues;
0040:        import com.liferay.portlet.PortletPreferencesSerializer;
0041:        import com.liferay.util.CollectionFactory;
0042:        import com.liferay.util.ListUtil;
0043:
0044:        import java.io.IOException;
0045:        import java.io.StringWriter;
0046:
0047:        import java.util.ArrayList;
0048:        import java.util.HashMap;
0049:        import java.util.HashSet;
0050:        import java.util.Iterator;
0051:        import java.util.List;
0052:        import java.util.Map;
0053:        import java.util.Set;
0054:
0055:        import javax.portlet.PortletMode;
0056:        import javax.portlet.PreferencesValidator;
0057:
0058:        import org.apache.commons.logging.Log;
0059:        import org.apache.commons.logging.LogFactory;
0060:
0061:        import org.dom4j.Document;
0062:        import org.dom4j.DocumentException;
0063:        import org.dom4j.Element;
0064:        import org.dom4j.io.OutputFormat;
0065:        import org.dom4j.io.XMLWriter;
0066:
0067:        /**
0068:         * <a href="PortletLocalServiceImpl.java.html"><b><i>View Source</i></b></a>
0069:         *
0070:         * @author Brian Wing Shun Chan
0071:         * @author Raymond Augé
0072:         *
0073:         */
0074:        public class PortletLocalServiceImpl extends
0075:                PortletLocalServiceBaseImpl {
0076:
0077:            public void destroyPortlet(Portlet portlet) {
0078:                Map portletsPool = _getPortletsPool();
0079:
0080:                portletsPool.remove(portlet.getRootPortletId());
0081:
0082:                _clearCaches();
0083:            }
0084:
0085:            public PortletCategory getEARDisplay(String xml)
0086:                    throws SystemException {
0087:                try {
0088:                    return _readLiferayDisplayXML(xml);
0089:                } catch (DocumentException de) {
0090:                    throw new SystemException(de);
0091:                } catch (IOException ioe) {
0092:                    throw new SystemException(ioe);
0093:                }
0094:            }
0095:
0096:            public PortletCategory getWARDisplay(String servletContextName,
0097:                    String xml) throws SystemException {
0098:
0099:                try {
0100:                    return _readLiferayDisplayXML(servletContextName, xml);
0101:                } catch (DocumentException de) {
0102:                    throw new SystemException(de);
0103:                } catch (IOException ioe) {
0104:                    throw new SystemException(ioe);
0105:                }
0106:            }
0107:
0108:            public List getFriendlyURLMappers() {
0109:                return _getFriendlyURLMappers();
0110:            }
0111:
0112:            public Portlet getPortletById(long companyId, String portletId)
0113:                    throws SystemException {
0114:
0115:                portletId = PortalUtil.getJsSafePortletId(portletId);
0116:
0117:                Portlet portlet = null;
0118:
0119:                Map companyPortletsPool = _getPortletsPool(companyId);
0120:
0121:                String rootPortletId = PortletImpl.getRootPortletId(portletId);
0122:
0123:                if (portletId.equals(rootPortletId)) {
0124:                    portlet = (Portlet) companyPortletsPool.get(portletId);
0125:                } else {
0126:                    portlet = (Portlet) companyPortletsPool.get(rootPortletId);
0127:
0128:                    if (portlet != null) {
0129:                        portlet = portlet.getClonedInstance(portletId);
0130:                    }
0131:                }
0132:
0133:                if ((portlet == null)
0134:                        && (!portletId.equals(PortletKeys.LIFERAY_PORTAL))) {
0135:
0136:                    if (_log.isWarnEnabled()) {
0137:                        _log.warn("Portlet not found for " + companyId + " "
0138:                                + portletId);
0139:                    }
0140:                }
0141:
0142:                return portlet;
0143:            }
0144:
0145:            public Portlet getPortletByStrutsPath(long companyId,
0146:                    String strutsPath) throws SystemException {
0147:
0148:                return getPortletById(companyId, _getPortletId(strutsPath));
0149:            }
0150:
0151:            public List getPortlets() {
0152:                Map portletsPool = _getPortletsPool();
0153:
0154:                return ListUtil.fromCollection(portletsPool.values());
0155:            }
0156:
0157:            public List getPortlets(long companyId) throws SystemException {
0158:                return getPortlets(companyId, true, true);
0159:            }
0160:
0161:            public List getPortlets(long companyId, boolean showSystem,
0162:                    boolean showPortal) throws SystemException {
0163:
0164:                Map portletsPool = _getPortletsPool(companyId);
0165:
0166:                List portlets = ListUtil.fromCollection(portletsPool.values());
0167:
0168:                if (!showSystem || !showPortal) {
0169:                    Iterator itr = portlets.iterator();
0170:
0171:                    while (itr.hasNext()) {
0172:                        Portlet portlet = (Portlet) itr.next();
0173:
0174:                        if (showPortal
0175:                                && portlet.getPortletId().equals(
0176:                                        PortletKeys.PORTAL)) {
0177:
0178:                        } else if (!showPortal
0179:                                && portlet.getPortletId().equals(
0180:                                        PortletKeys.PORTAL)) {
0181:
0182:                            itr.remove();
0183:                        } else if (!showSystem && portlet.isSystem()) {
0184:                            itr.remove();
0185:                        }
0186:                    }
0187:                }
0188:
0189:                return portlets;
0190:            }
0191:
0192:            public boolean hasPortlet(long companyId, String portletId)
0193:                    throws SystemException {
0194:
0195:                portletId = PortalUtil.getJsSafePortletId(portletId);
0196:
0197:                Portlet portlet = null;
0198:
0199:                Map companyPortletsPool = _getPortletsPool(companyId);
0200:
0201:                String rootPortletId = PortletImpl.getRootPortletId(portletId);
0202:
0203:                if (portletId.equals(rootPortletId)) {
0204:                    portlet = (Portlet) companyPortletsPool.get(portletId);
0205:                } else {
0206:                    portlet = (Portlet) companyPortletsPool.get(rootPortletId);
0207:                }
0208:
0209:                if (portlet == null) {
0210:                    return false;
0211:                } else {
0212:                    return true;
0213:                }
0214:            }
0215:
0216:            public void initEAR(String[] xmls, PluginPackage pluginPackage) {
0217:                Map portletsPool = _getPortletsPool();
0218:
0219:                try {
0220:                    List servletURLPatterns = _readWebXML(xmls[4]);
0221:
0222:                    Set portletIds = _readPortletXML(xmls[0], portletsPool,
0223:                            servletURLPatterns, pluginPackage);
0224:
0225:                    portletIds.addAll(_readPortletXML(xmls[1], portletsPool,
0226:                            servletURLPatterns, pluginPackage));
0227:
0228:                    Set liferayPortletIds = _readLiferayPortletXML(xmls[2],
0229:                            portletsPool);
0230:
0231:                    liferayPortletIds.addAll(_readLiferayPortletXML(xmls[3],
0232:                            portletsPool));
0233:
0234:                    // Check for missing entries in liferay-portlet.xml
0235:
0236:                    Iterator itr = portletIds.iterator();
0237:
0238:                    while (itr.hasNext()) {
0239:                        String portletId = (String) itr.next();
0240:
0241:                        if (_log.isWarnEnabled()
0242:                                && !liferayPortletIds.contains(portletId)) {
0243:
0244:                            _log
0245:                                    .warn("Portlet with the name "
0246:                                            + portletId
0247:                                            + " is described in portlet.xml but does not "
0248:                                            + "have a matching entry in liferay-portlet.xml");
0249:                        }
0250:                    }
0251:
0252:                    // Check for missing entries in portlet.xml
0253:
0254:                    itr = liferayPortletIds.iterator();
0255:
0256:                    while (itr.hasNext()) {
0257:                        String portletId = (String) itr.next();
0258:
0259:                        if (_log.isWarnEnabled()
0260:                                && !portletIds.contains(portletId)) {
0261:                            _log
0262:                                    .warn("Portlet with the name "
0263:                                            + portletId
0264:                                            + " is described in liferay-portlet.xml but does "
0265:                                            + "not have a matching entry in portlet.xml");
0266:                        }
0267:                    }
0268:
0269:                    // Remove portlets that should not be included
0270:
0271:                    itr = portletsPool.entrySet().iterator();
0272:
0273:                    while (itr.hasNext()) {
0274:                        Map.Entry entry = (Map.Entry) itr.next();
0275:
0276:                        Portlet portletModel = (Portlet) entry.getValue();
0277:
0278:                        if (!portletModel.getPortletId().equals(
0279:                                PortletKeys.ADMIN)
0280:                                && !portletModel.getPortletId().equals(
0281:                                        PortletKeys.MY_ACCOUNT)
0282:                                && !portletModel.isInclude()) {
0283:
0284:                            itr.remove();
0285:                        }
0286:                    }
0287:                } catch (Exception e) {
0288:                    _log.error(e, e);
0289:                }
0290:            }
0291:
0292:            public List initWAR(String servletContextName, String[] xmls,
0293:                    PluginPackage pluginPackage) {
0294:
0295:                List portlets = new ArrayList();
0296:
0297:                Map portletsPool = _getPortletsPool();
0298:
0299:                try {
0300:                    List servletURLPatterns = _readWebXML(xmls[3]);
0301:
0302:                    Set portletIds = _readPortletXML(servletContextName,
0303:                            xmls[0], portletsPool, servletURLPatterns,
0304:                            pluginPackage);
0305:
0306:                    portletIds.addAll(_readPortletXML(servletContextName,
0307:                            xmls[1], portletsPool, servletURLPatterns,
0308:                            pluginPackage));
0309:
0310:                    Set liferayPortletIds = _readLiferayPortletXML(
0311:                            servletContextName, xmls[2], portletsPool);
0312:
0313:                    // Check for missing entries in liferay-portlet.xml
0314:
0315:                    Iterator itr = portletIds.iterator();
0316:
0317:                    while (itr.hasNext()) {
0318:                        String portletId = (String) itr.next();
0319:
0320:                        if (_log.isWarnEnabled()
0321:                                && !liferayPortletIds.contains(portletId)) {
0322:
0323:                            _log
0324:                                    .warn("Portlet with the name "
0325:                                            + portletId
0326:                                            + " is described in portlet.xml but does not "
0327:                                            + "have a matching entry in liferay-portlet.xml");
0328:                        }
0329:                    }
0330:
0331:                    // Check for missing entries in portlet.xml
0332:
0333:                    itr = liferayPortletIds.iterator();
0334:
0335:                    while (itr.hasNext()) {
0336:                        String portletId = (String) itr.next();
0337:
0338:                        if (_log.isWarnEnabled()
0339:                                && !portletIds.contains(portletId)) {
0340:                            _log
0341:                                    .warn("Portlet with the name "
0342:                                            + portletId
0343:                                            + " is described in liferay-portlet.xml but does "
0344:                                            + "not have a matching entry in portlet.xml");
0345:                        }
0346:                    }
0347:
0348:                    // Return the new portlets
0349:
0350:                    itr = portletIds.iterator();
0351:
0352:                    while (itr.hasNext()) {
0353:                        String portletId = (String) itr.next();
0354:
0355:                        Portlet portlet = (Portlet) _getPortletsPool().get(
0356:                                portletId);
0357:
0358:                        portlets.add(portlet);
0359:                    }
0360:                } catch (Exception e) {
0361:                    _log.error(e, e);
0362:                }
0363:
0364:                _clearCaches();
0365:
0366:                return portlets;
0367:            }
0368:
0369:            public Portlet updatePortlet(long companyId, String portletId,
0370:                    String roles, boolean active) throws PortalException,
0371:                    SystemException {
0372:
0373:                portletId = PortalUtil.getJsSafePortletId(portletId);
0374:
0375:                Portlet portlet = portletPersistence.fetchByC_P(companyId,
0376:                        portletId);
0377:
0378:                if (portlet == null) {
0379:                    long id = counterLocalService.increment();
0380:
0381:                    portlet = portletPersistence.create(id);
0382:
0383:                    portlet.setCompanyId(companyId);
0384:                    portlet.setPortletId(portletId);
0385:                }
0386:
0387:                portlet.setRoles(roles);
0388:                portlet.setActive(active);
0389:
0390:                portletPersistence.update(portlet);
0391:
0392:                portlet = getPortletById(companyId, portletId);
0393:
0394:                portlet.setRoles(roles);
0395:                portlet.setActive(active);
0396:
0397:                return portlet;
0398:            }
0399:
0400:            private void _clearCaches() {
0401:
0402:                // Refresh security path to portlet id mapping for all portlets
0403:
0404:                _portletIdsByStrutsPath.clear();
0405:
0406:                // Refresh company portlets
0407:
0408:                _companyPortletsPool.clear();
0409:            }
0410:
0411:            private List _getFriendlyURLMappers() {
0412:                List friendlyURLMappers = new ArrayList(
0413:                        _friendlyURLMapperPortlets.size());
0414:
0415:                Iterator itr = _friendlyURLMapperPortlets.entrySet().iterator();
0416:
0417:                while (itr.hasNext()) {
0418:                    Map.Entry entry = (Map.Entry) itr.next();
0419:
0420:                    Portlet portlet = (Portlet) entry.getValue();
0421:
0422:                    FriendlyURLMapper friendlyURLMapper = portlet
0423:                            .getFriendlyURLMapperInstance();
0424:
0425:                    if (friendlyURLMapper != null) {
0426:                        friendlyURLMappers.add(friendlyURLMapper);
0427:                    }
0428:                }
0429:
0430:                return friendlyURLMappers;
0431:            }
0432:
0433:            private String _getPortletId(String securityPath)
0434:                    throws SystemException {
0435:                if (_portletIdsByStrutsPath.size() == 0) {
0436:                    Iterator itr = _getPortletsPool().values().iterator();
0437:
0438:                    while (itr.hasNext()) {
0439:                        Portlet portlet = (Portlet) itr.next();
0440:
0441:                        _portletIdsByStrutsPath.put(portlet.getStrutsPath(),
0442:                                portlet.getPortletId());
0443:                    }
0444:                }
0445:
0446:                String portletId = (String) _portletIdsByStrutsPath
0447:                        .get(securityPath);
0448:
0449:                if (Validator.isNull(portletId)) {
0450:                    _log.error("Struts path " + securityPath
0451:                            + " is not mapped to a portlet "
0452:                            + "in liferay-portlet.xml");
0453:                }
0454:
0455:                return portletId;
0456:            }
0457:
0458:            private Map _getPortletsPool() {
0459:                return _portletsPool;
0460:            }
0461:
0462:            private Map _getPortletsPool(long companyId) throws SystemException {
0463:                Long companyIdObj = new Long(companyId);
0464:
0465:                Map portletsPool = (Map) _companyPortletsPool.get(companyIdObj);
0466:
0467:                if (portletsPool == null) {
0468:                    portletsPool = CollectionFactory.getSyncHashMap();
0469:
0470:                    Map parentPortletsPool = _getPortletsPool();
0471:
0472:                    if (parentPortletsPool == null) {
0473:
0474:                        // The Upgrade scripts sometimes try to access portlet
0475:                        // preferences before the portal's been initialized. Return an
0476:                        // empty pool.
0477:
0478:                        return portletsPool;
0479:                    }
0480:
0481:                    Iterator itr = parentPortletsPool.values().iterator();
0482:
0483:                    while (itr.hasNext()) {
0484:                        Portlet portlet = (Portlet) ((Portlet) itr.next())
0485:                                .clone();
0486:
0487:                        portlet.setCompanyId(companyId);
0488:
0489:                        portletsPool.put(portlet.getPortletId(), portlet);
0490:                    }
0491:
0492:                    itr = portletPersistence.findByCompanyId(companyId)
0493:                            .iterator();
0494:
0495:                    while (itr.hasNext()) {
0496:                        Portlet portlet = (Portlet) itr.next();
0497:
0498:                        Portlet portletModel = (Portlet) portletsPool
0499:                                .get(portlet.getPortletId());
0500:
0501:                        // Portlet may be null if it exists in the database but its
0502:                        // portlet WAR is not yet loaded
0503:
0504:                        if (portletModel != null) {
0505:                            portletModel.setPluginPackage(portlet
0506:                                    .getPluginPackage());
0507:                            portletModel.setDefaultPluginSetting(portlet
0508:                                    .getDefaultPluginSetting());
0509:                            portletModel.setRoles(portlet.getRoles());
0510:                            portletModel.setActive(portlet.getActive());
0511:                        }
0512:                    }
0513:
0514:                    _companyPortletsPool.put(companyIdObj, portletsPool);
0515:                }
0516:
0517:                return portletsPool;
0518:            }
0519:
0520:            private Set _readPortletXML(String xml, Map portletsPool,
0521:                    List servletURLPatterns, PluginPackage pluginPackage)
0522:                    throws DocumentException, IOException {
0523:
0524:                return _readPortletXML(null, xml, portletsPool,
0525:                        servletURLPatterns, pluginPackage);
0526:            }
0527:
0528:            private Set _readPortletXML(String servletContextName, String xml,
0529:                    Map portletsPool, List servletURLPatterns,
0530:                    PluginPackage pluginPackage) throws DocumentException,
0531:                    IOException {
0532:
0533:                Set portletIds = new HashSet();
0534:
0535:                if (xml == null) {
0536:                    return portletIds;
0537:                }
0538:
0539:                Document doc = PortalUtil.readDocumentFromXML(xml);
0540:
0541:                Element root = doc.getRootElement();
0542:
0543:                Set userAttributes = new HashSet();
0544:
0545:                Iterator itr1 = root.elements("user-attribute").iterator();
0546:
0547:                while (itr1.hasNext()) {
0548:                    Element userAttribute = (Element) itr1.next();
0549:
0550:                    String name = userAttribute.elementText("name");
0551:
0552:                    userAttributes.add(name);
0553:                }
0554:
0555:                itr1 = root.elements("portlet").iterator();
0556:
0557:                while (itr1.hasNext()) {
0558:                    Element portlet = (Element) itr1.next();
0559:
0560:                    String portletId = portlet.elementText("portlet-name");
0561:
0562:                    if (servletContextName != null) {
0563:                        portletId = portletId + PortletImpl.WAR_SEPARATOR
0564:                                + servletContextName;
0565:                    }
0566:
0567:                    portletId = PortalUtil.getJsSafePortletId(portletId);
0568:
0569:                    if (_log.isDebugEnabled()) {
0570:                        _log.debug("Reading portlet " + portletId);
0571:                    }
0572:
0573:                    portletIds.add(portletId);
0574:
0575:                    Portlet portletModel = (Portlet) portletsPool
0576:                            .get(portletId);
0577:
0578:                    if (portletModel == null) {
0579:                        portletModel = new PortletImpl(CompanyImpl.SYSTEM,
0580:                                portletId);
0581:
0582:                        portletsPool.put(portletId, portletModel);
0583:                    }
0584:
0585:                    portletModel.setPluginPackage(pluginPackage);
0586:
0587:                    if (servletContextName != null) {
0588:                        portletModel.setServletContextName(servletContextName);
0589:                    }
0590:
0591:                    if (servletURLPatterns != null) {
0592:                        portletModel.setServletURLPatterns(servletURLPatterns);
0593:                    }
0594:
0595:                    portletModel.setDisplayName(GetterUtil.getString(portlet
0596:                            .elementText("display-name"), portletModel
0597:                            .getDisplayName()));
0598:                    portletModel.setPortletClass(GetterUtil.getString(portlet
0599:                            .elementText("portlet-class")));
0600:
0601:                    Iterator itr2 = portlet.elements("init-param").iterator();
0602:
0603:                    while (itr2.hasNext()) {
0604:                        Element initParam = (Element) itr2.next();
0605:
0606:                        portletModel.getInitParams().put(
0607:                                initParam.elementText("name"),
0608:                                initParam.elementText("value"));
0609:                    }
0610:
0611:                    Element expirationCache = portlet
0612:                            .element("expiration-cache");
0613:
0614:                    if (expirationCache != null) {
0615:                        portletModel.setExpCache(new Integer(GetterUtil
0616:                                .getInteger(expirationCache.getText())));
0617:                    }
0618:
0619:                    itr2 = portlet.elements("supports").iterator();
0620:
0621:                    while (itr2.hasNext()) {
0622:                        Element supports = (Element) itr2.next();
0623:
0624:                        String mimeType = supports.elementText("mime-type");
0625:
0626:                        Set mimeTypeModes = (Set) portletModel
0627:                                .getPortletModes().get(mimeType);
0628:
0629:                        if (mimeTypeModes == null) {
0630:                            mimeTypeModes = new HashSet();
0631:
0632:                            portletModel.getPortletModes().put(mimeType,
0633:                                    mimeTypeModes);
0634:                        }
0635:
0636:                        mimeTypeModes.add(PortletMode.VIEW.toString()
0637:                                .toLowerCase());
0638:
0639:                        Iterator itr3 = supports.elements("portlet-mode")
0640:                                .iterator();
0641:
0642:                        while (itr3.hasNext()) {
0643:                            Element portletMode = (Element) itr3.next();
0644:
0645:                            mimeTypeModes.add(portletMode.getTextTrim()
0646:                                    .toLowerCase());
0647:                        }
0648:                    }
0649:
0650:                    Set supportedLocales = portletModel.getSupportedLocales();
0651:
0652:                    supportedLocales.add(LocaleUtil.toLanguageId(LocaleUtil
0653:                            .getDefault()));
0654:
0655:                    itr2 = portlet.elements("supported-locale").iterator();
0656:
0657:                    while (itr2.hasNext()) {
0658:                        Element supportedLocaleEl = (Element) itr2.next();
0659:
0660:                        String supportedLocale = supportedLocaleEl.getText();
0661:
0662:                        supportedLocales.add(supportedLocale);
0663:                    }
0664:
0665:                    portletModel.setResourceBundle(portlet
0666:                            .elementText("resource-bundle"));
0667:
0668:                    Element portletInfo = portlet.element("portlet-info");
0669:
0670:                    String portletInfoTitle = null;
0671:                    String portletInfoShortTitle = null;
0672:                    String portletInfoKeyWords = null;
0673:
0674:                    if (portletInfo != null) {
0675:                        portletInfoTitle = portletInfo.elementText("title");
0676:                        portletInfoShortTitle = portletInfo
0677:                                .elementText("short-title");
0678:                        portletInfoKeyWords = portletInfo
0679:                                .elementText("keywords");
0680:                    }
0681:
0682:                    portletModel.setPortletInfo(new PortletInfo(
0683:                            portletInfoTitle, portletInfoShortTitle,
0684:                            portletInfoKeyWords));
0685:
0686:                    Element portletPreferences = portlet
0687:                            .element("portlet-preferences");
0688:
0689:                    String defaultPreferences = null;
0690:                    String prefsValidator = null;
0691:
0692:                    if (portletPreferences != null) {
0693:                        Element prefsValidatorEl = portletPreferences
0694:                                .element("preferences-validator");
0695:
0696:                        if (prefsValidatorEl != null) {
0697:                            prefsValidator = prefsValidatorEl.getText();
0698:
0699:                            portletPreferences.remove(prefsValidatorEl);
0700:                        }
0701:
0702:                        StringWriter sw = new StringWriter();
0703:
0704:                        XMLWriter writer = new XMLWriter(sw, OutputFormat
0705:                                .createCompactFormat());
0706:
0707:                        writer.write(portletPreferences);
0708:
0709:                        defaultPreferences = sw.toString();
0710:                    }
0711:
0712:                    portletModel.setDefaultPreferences(defaultPreferences);
0713:                    portletModel.setPreferencesValidator(prefsValidator);
0714:
0715:                    if (!portletModel.isWARFile()
0716:                            && Validator.isNotNull(prefsValidator)
0717:                            && PropsValues.PREFERENCE_VALIDATE_ON_STARTUP) {
0718:
0719:                        try {
0720:                            PreferencesValidator prefsValidatorObj = PortalUtil
0721:                                    .getPreferencesValidator(portletModel);
0722:
0723:                            prefsValidatorObj
0724:                                    .validate(PortletPreferencesSerializer
0725:                                            .fromDefaultXML(defaultPreferences));
0726:                        } catch (Exception e) {
0727:                            if (_log.isWarnEnabled()) {
0728:                                _log
0729:                                        .warn("Portlet with the name "
0730:                                                + portletId
0731:                                                + " does not have valid default preferences");
0732:                            }
0733:                        }
0734:                    }
0735:
0736:                    Set unlikedRoles = portletModel.getUnlinkedRoles();
0737:
0738:                    itr2 = portlet.elements("security-role-ref").iterator();
0739:
0740:                    while (itr2.hasNext()) {
0741:                        Element role = (Element) itr2.next();
0742:
0743:                        unlikedRoles.add(role.elementText("role-name"));
0744:                    }
0745:
0746:                    portletModel.getUserAttributes().addAll(userAttributes);
0747:                }
0748:
0749:                return portletIds;
0750:            }
0751:
0752:            private void _readLiferayDisplay(String servletContextName,
0753:                    Element el, PortletCategory portletCategory, Set portletIds) {
0754:
0755:                Iterator itr1 = el.elements("category").iterator();
0756:
0757:                while (itr1.hasNext()) {
0758:                    Element category = (Element) itr1.next();
0759:
0760:                    String name = category.attributeValue("name");
0761:
0762:                    PortletCategory curPortletCategory = new PortletCategory(
0763:                            name);
0764:
0765:                    portletCategory.addCategory(curPortletCategory);
0766:
0767:                    Set curPortletIds = curPortletCategory.getPortlets();
0768:
0769:                    Iterator itr2 = category.elements("portlet").iterator();
0770:
0771:                    while (itr2.hasNext()) {
0772:                        Element portlet = (Element) itr2.next();
0773:
0774:                        String portletId = portlet.attributeValue("id");
0775:
0776:                        if (servletContextName != null) {
0777:                            portletId = portletId + PortletImpl.WAR_SEPARATOR
0778:                                    + servletContextName;
0779:                        }
0780:
0781:                        portletId = PortalUtil.getJsSafePortletId(portletId);
0782:
0783:                        portletIds.add(portletId);
0784:                        curPortletIds.add(portletId);
0785:                    }
0786:
0787:                    _readLiferayDisplay(servletContextName, category,
0788:                            curPortletCategory, portletIds);
0789:                }
0790:            }
0791:
0792:            private PortletCategory _readLiferayDisplayXML(String xml)
0793:                    throws DocumentException, IOException {
0794:
0795:                return _readLiferayDisplayXML(null, xml);
0796:            }
0797:
0798:            private PortletCategory _readLiferayDisplayXML(
0799:                    String servletContextName, String xml)
0800:                    throws DocumentException, IOException {
0801:
0802:                PortletCategory portletCategory = new PortletCategory();
0803:
0804:                if (xml == null) {
0805:                    xml = ContentUtil
0806:                            .get("com/liferay/portal/deploy/dependencies/liferay-display.xml");
0807:                }
0808:
0809:                Document doc = PortalUtil.readDocumentFromXML(xml, true);
0810:
0811:                Element root = doc.getRootElement();
0812:
0813:                Set portletIds = new HashSet();
0814:
0815:                _readLiferayDisplay(servletContextName, root, portletCategory,
0816:                        portletIds);
0817:
0818:                // Portlets that do not belong to any categories should default to the
0819:                // Undefined category
0820:
0821:                Set undefinedPortletIds = new HashSet();
0822:
0823:                Iterator itr = _getPortletsPool().values().iterator();
0824:
0825:                while (itr.hasNext()) {
0826:                    Portlet portlet = (Portlet) itr.next();
0827:
0828:                    String portletId = portlet.getPortletId();
0829:
0830:                    if ((servletContextName != null)
0831:                            && (portlet.isWARFile())
0832:                            && (portletId
0833:                                    .endsWith(PortletImpl.WAR_SEPARATOR
0834:                                            + PortalUtil
0835:                                                    .getJsSafePortletId(servletContextName)) && (!portletIds
0836:                                    .contains(portletId)))) {
0837:
0838:                        undefinedPortletIds.add(portletId);
0839:                    } else if ((servletContextName == null)
0840:                            && (!portlet.isWARFile())
0841:                            && (portletId.indexOf(PortletImpl.WAR_SEPARATOR) == -1)
0842:                            && (!portletIds.contains(portletId))) {
0843:
0844:                        undefinedPortletIds.add(portletId);
0845:                    }
0846:                }
0847:
0848:                if (undefinedPortletIds.size() > 0) {
0849:                    PortletCategory undefinedCategory = new PortletCategory(
0850:                            "category.undefined");
0851:
0852:                    portletCategory.addCategory(undefinedCategory);
0853:
0854:                    undefinedCategory.getPortlets().addAll(undefinedPortletIds);
0855:                }
0856:
0857:                return portletCategory;
0858:            }
0859:
0860:            private Set _readLiferayPortletXML(String xml, Map portletsPool)
0861:                    throws DocumentException, IOException {
0862:
0863:                return _readLiferayPortletXML(null, xml, portletsPool);
0864:            }
0865:
0866:            private Set _readLiferayPortletXML(String servletContextName,
0867:                    String xml, Map portletsPool) throws DocumentException,
0868:                    IOException {
0869:
0870:                Set liferayPortletIds = new HashSet();
0871:
0872:                if (xml == null) {
0873:                    return liferayPortletIds;
0874:                }
0875:
0876:                Document doc = PortalUtil.readDocumentFromXML(xml, true);
0877:
0878:                Element root = doc.getRootElement();
0879:
0880:                Map roleMappers = new HashMap();
0881:
0882:                Iterator itr1 = root.elements("role-mapper").iterator();
0883:
0884:                while (itr1.hasNext()) {
0885:                    Element roleMapper = (Element) itr1.next();
0886:
0887:                    String roleName = roleMapper.elementText("role-name");
0888:                    String roleLink = roleMapper.elementText("role-link");
0889:
0890:                    roleMappers.put(roleName, roleLink);
0891:                }
0892:
0893:                Map customUserAttributes = new HashMap();
0894:
0895:                itr1 = root.elements("custom-user-attribute").iterator();
0896:
0897:                while (itr1.hasNext()) {
0898:                    Element customUserAttribute = (Element) itr1.next();
0899:
0900:                    String customClass = customUserAttribute
0901:                            .elementText("custom-class");
0902:
0903:                    Iterator itr2 = customUserAttribute.elements("name")
0904:                            .iterator();
0905:
0906:                    while (itr2.hasNext()) {
0907:                        Element nameEl = (Element) itr2.next();
0908:
0909:                        String name = nameEl.getText();
0910:
0911:                        customUserAttributes.put(name, customClass);
0912:                    }
0913:                }
0914:
0915:                itr1 = root.elements("portlet").iterator();
0916:
0917:                while (itr1.hasNext()) {
0918:                    Element portlet = (Element) itr1.next();
0919:
0920:                    String portletId = portlet.elementText("portlet-name");
0921:
0922:                    if (servletContextName != null) {
0923:                        portletId = portletId + PortletImpl.WAR_SEPARATOR
0924:                                + servletContextName;
0925:                    }
0926:
0927:                    portletId = PortalUtil.getJsSafePortletId(portletId);
0928:
0929:                    if (_log.isDebugEnabled()) {
0930:                        _log.debug("Reading portlet extension " + portletId);
0931:                    }
0932:
0933:                    liferayPortletIds.add(portletId);
0934:
0935:                    Portlet portletModel = (Portlet) portletsPool
0936:                            .get(portletId);
0937:
0938:                    if (portletModel != null) {
0939:                        portletModel.setIcon(GetterUtil.getString(portlet
0940:                                .elementText("icon"), portletModel.getIcon()));
0941:                        portletModel.setVirtualPath(GetterUtil.getString(
0942:                                portlet.elementText("virtual-path"),
0943:                                portletModel.getVirtualPath()));
0944:                        portletModel.setStrutsPath(GetterUtil.getString(portlet
0945:                                .elementText("struts-path"), portletModel
0946:                                .getStrutsPath()));
0947:
0948:                        if (Validator.isNotNull(portlet
0949:                                .elementText("configuration-path"))) {
0950:
0951:                            _log
0952:                                    .error("The configuration-path element is no longer "
0953:                                            + "supported. Use configuration-action-class "
0954:                                            + "instead.");
0955:                        }
0956:
0957:                        portletModel
0958:                                .setConfigurationActionClass(GetterUtil
0959:                                        .getString(
0960:                                                portlet
0961:                                                        .elementText("configuration-action-class"),
0962:                                                portletModel
0963:                                                        .getConfigurationActionClass()));
0964:                        portletModel.setIndexerClass(GetterUtil.getString(
0965:                                portlet.elementText("indexer-class"),
0966:                                portletModel.getIndexerClass()));
0967:                        portletModel.setOpenSearchClass(GetterUtil.getString(
0968:                                portlet.elementText("open-search-class"),
0969:                                portletModel.getOpenSearchClass()));
0970:                        portletModel.setSchedulerClass(GetterUtil.getString(
0971:                                portlet.elementText("scheduler-class"),
0972:                                portletModel.getSchedulerClass()));
0973:                        portletModel.setPortletURLClass(GetterUtil.getString(
0974:                                portlet.elementText("portlet-url-class"),
0975:                                portletModel.getPortletURLClass()));
0976:
0977:                        portletModel
0978:                                .setFriendlyURLMapperClass(GetterUtil
0979:                                        .getString(
0980:                                                portlet
0981:                                                        .elementText("friendly-url-mapper-class"),
0982:                                                portletModel
0983:                                                        .getFriendlyURLMapperClass()));
0984:
0985:                        if (Validator.isNull(portletModel
0986:                                .getFriendlyURLMapperClass())) {
0987:
0988:                            _friendlyURLMapperPortlets.remove(portletId);
0989:                        } else {
0990:                            _friendlyURLMapperPortlets.put(portletId,
0991:                                    portletModel);
0992:                        }
0993:
0994:                        portletModel.setURLEncoderClass(GetterUtil.getString(
0995:                                portlet.elementText("url-encoder-class"),
0996:                                portletModel.getURLEncoderClass()));
0997:                        portletModel
0998:                                .setPortletDataHandlerClass(GetterUtil
0999:                                        .getString(
1000:                                                portlet
1001:                                                        .elementText("portlet-data-handler-class"),
1002:                                                portletModel
1003:                                                        .getPortletDataHandlerClass()));
1004:                        portletModel
1005:                                .setPortletLayoutListenerClass(GetterUtil
1006:                                        .getString(
1007:                                                portlet
1008:                                                        .elementText("portlet-layout-listener-class"),
1009:                                                portletModel
1010:                                                        .getPortletLayoutListenerClass()));
1011:                        portletModel
1012:                                .setActivityTrackerInterpreterClass(GetterUtil
1013:                                        .getString(
1014:                                                portlet
1015:                                                        .elementText("activity-tracker-interpreter-class"),
1016:                                                portletModel
1017:                                                        .getActivityTrackerInterpreterClass()));
1018:                        portletModel
1019:                                .setPopMessageListenerClass(GetterUtil
1020:                                        .getString(
1021:                                                portlet
1022:                                                        .elementText("pop-message-listener-class"),
1023:                                                portletModel
1024:                                                        .getPopMessageListenerClass()));
1025:                        portletModel
1026:                                .setPreferencesCompanyWide(GetterUtil
1027:                                        .getBoolean(
1028:                                                portlet
1029:                                                        .elementText("preferences-company-wide"),
1030:                                                portletModel
1031:                                                        .isPreferencesCompanyWide()));
1032:                        portletModel
1033:                                .setPreferencesUniquePerLayout(GetterUtil
1034:                                        .getBoolean(
1035:                                                portlet
1036:                                                        .elementText("preferences-unique-per-layout"),
1037:                                                portletModel
1038:                                                        .isPreferencesUniquePerLayout()));
1039:                        portletModel
1040:                                .setPreferencesOwnedByGroup(GetterUtil
1041:                                        .getBoolean(
1042:                                                portlet
1043:                                                        .elementText("preferences-owned-by-group"),
1044:                                                portletModel
1045:                                                        .isPreferencesOwnedByGroup()));
1046:                        portletModel.setUseDefaultTemplate(GetterUtil
1047:                                .getBoolean(portlet
1048:                                        .elementText("use-default-template"),
1049:                                        portletModel.isUseDefaultTemplate()));
1050:                        portletModel
1051:                                .setShowPortletAccessDenied(GetterUtil
1052:                                        .getBoolean(
1053:                                                portlet
1054:                                                        .elementText("show-portlet-access-denied"),
1055:                                                portletModel
1056:                                                        .isShowPortletAccessDenied()));
1057:                        portletModel.setShowPortletInactive(GetterUtil
1058:                                .getBoolean(portlet
1059:                                        .elementText("show-portlet-inactive"),
1060:                                        portletModel.isShowPortletInactive()));
1061:                        portletModel.setActionURLRedirect(GetterUtil
1062:                                .getBoolean(portlet
1063:                                        .elementText("action-url-redirect"),
1064:                                        portletModel.isActionURLRedirect()));
1065:                        portletModel.setRestoreCurrentView(GetterUtil
1066:                                .getBoolean(portlet
1067:                                        .elementText("restore-current-view"),
1068:                                        portletModel.isRestoreCurrentView()));
1069:                        portletModel.setMaximizeEdit(GetterUtil.getBoolean(
1070:                                portlet.elementText("maximize-edit"),
1071:                                portletModel.isMaximizeEdit()));
1072:                        portletModel.setMaximizeHelp(GetterUtil.getBoolean(
1073:                                portlet.elementText("maximize-help"),
1074:                                portletModel.isMaximizeHelp()));
1075:                        portletModel.setPopUpPrint(GetterUtil.getBoolean(
1076:                                portlet.elementText("pop-up-print"),
1077:                                portletModel.isPopUpPrint()));
1078:                        portletModel.setLayoutCacheable(GetterUtil.getBoolean(
1079:                                portlet.elementText("layout-cacheable"),
1080:                                portletModel.isLayoutCacheable()));
1081:                        portletModel.setInstanceable(GetterUtil.getBoolean(
1082:                                portlet.elementText("instanceable"),
1083:                                portletModel.isInstanceable()));
1084:                        portletModel
1085:                                .setUserPrincipalStrategy(GetterUtil
1086:                                        .getString(
1087:                                                portlet
1088:                                                        .elementText("user-principal-strategy"),
1089:                                                portletModel
1090:                                                        .getUserPrincipalStrategy()));
1091:                        portletModel
1092:                                .setPrivateRequestAttributes(GetterUtil
1093:                                        .getBoolean(
1094:                                                portlet
1095:                                                        .elementText("private-request-attributes"),
1096:                                                portletModel
1097:                                                        .isPrivateRequestAttributes()));
1098:                        portletModel
1099:                                .setPrivateSessionAttributes(GetterUtil
1100:                                        .getBoolean(
1101:                                                portlet
1102:                                                        .elementText("private-session-attributes"),
1103:                                                portletModel
1104:                                                        .isPrivateSessionAttributes()));
1105:                        portletModel.setRenderWeight(GetterUtil.getInteger(
1106:                                portlet.elementText("render-weight"),
1107:                                portletModel.getRenderWeight()));
1108:                        portletModel.setAjaxable(GetterUtil.getBoolean(portlet
1109:                                .elementText("ajaxable"), portletModel
1110:                                .isAjaxable()));
1111:
1112:                        List headerPortalCssList = portletModel
1113:                                .getHeaderPortalCss();
1114:
1115:                        Iterator itr2 = portlet.elements("header-portal-css")
1116:                                .iterator();
1117:
1118:                        while (itr2.hasNext()) {
1119:                            Element headerPortalCssEl = (Element) itr2.next();
1120:
1121:                            headerPortalCssList
1122:                                    .add(headerPortalCssEl.getText());
1123:                        }
1124:
1125:                        List headerPortletCssList = portletModel
1126:                                .getHeaderPortletCss();
1127:
1128:                        List list = new ArrayList();
1129:
1130:                        list.addAll(portlet.elements("header-css"));
1131:                        list.addAll(portlet.elements("header-portlet-css"));
1132:
1133:                        itr2 = list.iterator();
1134:
1135:                        while (itr2.hasNext()) {
1136:                            Element headerPortletCssEl = (Element) itr2.next();
1137:
1138:                            headerPortletCssList.add(headerPortletCssEl
1139:                                    .getText());
1140:                        }
1141:
1142:                        List headerPortalJavaScriptList = portletModel
1143:                                .getHeaderPortalJavaScript();
1144:
1145:                        itr2 = portlet.elements("header-portal-javascript")
1146:                                .iterator();
1147:
1148:                        while (itr2.hasNext()) {
1149:                            Element headerPortalJavaScriptEl = (Element) itr2
1150:                                    .next();
1151:
1152:                            headerPortalJavaScriptList
1153:                                    .add(headerPortalJavaScriptEl.getText());
1154:                        }
1155:
1156:                        List headerPortletJavaScriptList = portletModel
1157:                                .getHeaderPortletJavaScript();
1158:
1159:                        list.clear();
1160:
1161:                        list.addAll(portlet.elements("header-javascript"));
1162:                        list.addAll(portlet
1163:                                .elements("header-portlet-javascript"));
1164:
1165:                        itr2 = list.iterator();
1166:
1167:                        while (itr2.hasNext()) {
1168:                            Element headerPortletJavaScriptEl = (Element) itr2
1169:                                    .next();
1170:
1171:                            headerPortletJavaScriptList
1172:                                    .add(headerPortletJavaScriptEl.getText());
1173:                        }
1174:
1175:                        List footerPortalCssList = portletModel
1176:                                .getFooterPortalCss();
1177:
1178:                        itr2 = portlet.elements("footer-portal-css").iterator();
1179:
1180:                        while (itr2.hasNext()) {
1181:                            Element footerPortalCssEl = (Element) itr2.next();
1182:
1183:                            footerPortalCssList
1184:                                    .add(footerPortalCssEl.getText());
1185:                        }
1186:
1187:                        List footerPortletCssList = portletModel
1188:                                .getFooterPortletCss();
1189:
1190:                        itr2 = portlet.elements("footer-portlet-css")
1191:                                .iterator();
1192:
1193:                        while (itr2.hasNext()) {
1194:                            Element footerPortletCssEl = (Element) itr2.next();
1195:
1196:                            footerPortletCssList.add(footerPortletCssEl
1197:                                    .getText());
1198:                        }
1199:
1200:                        List footerPortalJavaScriptList = portletModel
1201:                                .getFooterPortalJavaScript();
1202:
1203:                        itr2 = portlet.elements("footer-portal-javascript")
1204:                                .iterator();
1205:
1206:                        while (itr2.hasNext()) {
1207:                            Element footerPortalJavaScriptEl = (Element) itr2
1208:                                    .next();
1209:
1210:                            footerPortalJavaScriptList
1211:                                    .add(footerPortalJavaScriptEl.getText());
1212:                        }
1213:
1214:                        List footerPortletJavaScriptList = portletModel
1215:                                .getFooterPortletJavaScript();
1216:
1217:                        itr2 = portlet.elements("footer-portlet-javascript")
1218:                                .iterator();
1219:
1220:                        while (itr2.hasNext()) {
1221:                            Element footerPortletJavaScriptEl = (Element) itr2
1222:                                    .next();
1223:
1224:                            footerPortletJavaScriptList
1225:                                    .add(footerPortletJavaScriptEl.getText());
1226:                        }
1227:
1228:                        portletModel.setCssClassWrapper(GetterUtil.getString(
1229:                                portlet.elementText("css-class-wrapper"),
1230:                                portletModel.getCssClassWrapper()));
1231:                        portletModel.setAddDefaultResource(GetterUtil
1232:                                .getBoolean(portlet
1233:                                        .elementText("add-default-resource"),
1234:                                        portletModel.isAddDefaultResource()));
1235:                        portletModel.setSystem(GetterUtil
1236:                                .getBoolean(portlet.elementText("system"),
1237:                                        portletModel.isSystem()));
1238:                        portletModel.setActive(GetterUtil
1239:                                .getBoolean(portlet.elementText("active"),
1240:                                        portletModel.isActive()));
1241:                        portletModel.setInclude(GetterUtil.getBoolean(portlet
1242:                                .elementText("include"), portletModel
1243:                                .isInclude()));
1244:
1245:                        if (!portletModel.isAjaxable()
1246:                                && (portletModel.getRenderWeight() < 1)) {
1247:
1248:                            portletModel.setRenderWeight(1);
1249:                        }
1250:
1251:                        portletModel.getRoleMappers().putAll(roleMappers);
1252:                        portletModel.linkRoles();
1253:
1254:                        portletModel.getCustomUserAttributes().putAll(
1255:                                customUserAttributes);
1256:                    }
1257:                }
1258:
1259:                return liferayPortletIds;
1260:            }
1261:
1262:            private List _readWebXML(String xml) throws DocumentException,
1263:                    IOException {
1264:                List servletURLPatterns = new ArrayList();
1265:
1266:                if (xml == null) {
1267:                    return servletURLPatterns;
1268:                }
1269:
1270:                Document doc = PortalUtil.readDocumentFromXML(xml);
1271:
1272:                Element root = doc.getRootElement();
1273:
1274:                Iterator itr = root.elements("servlet-mapping").iterator();
1275:
1276:                while (itr.hasNext()) {
1277:                    Element servletMapping = (Element) itr.next();
1278:
1279:                    String urlPattern = servletMapping
1280:                            .elementText("url-pattern");
1281:
1282:                    servletURLPatterns.add(urlPattern);
1283:                }
1284:
1285:                return servletURLPatterns;
1286:
1287:            }
1288:
1289:            private static Log _log = LogFactory
1290:                    .getLog(PortletLocalServiceImpl.class);
1291:
1292:            private static Map _portletsPool = CollectionFactory
1293:                    .getSyncHashMap();
1294:            private static Map _companyPortletsPool = CollectionFactory
1295:                    .getSyncHashMap();
1296:            private static Map _portletIdsByStrutsPath = CollectionFactory
1297:                    .getSyncHashMap();
1298:            private static Map _friendlyURLMapperPortlets = CollectionFactory
1299:                    .getSyncHashMap();
1300:
1301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.