Source Code Cross Referenced for CmsResourceUtil.java in  » Content-Management-System » opencms » org » opencms » workplace » explorer » 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 » Content Management System » opencms » org.opencms.workplace.explorer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/workplace/explorer/CmsResourceUtil.java,v $
0003:         * Date   : $Date: 2008-02-27 12:05:21 $
0004:         * Version: $Revision: 1.11 $
0005:         *
0006:         * This library is part of OpenCms -
0007:         * the Open Source Content Management System
0008:         *
0009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
0010:         *
0011:         * This library is free software; you can redistribute it and/or
0012:         * modify it under the terms of the GNU Lesser General Public
0013:         * License as published by the Free Software Foundation; either
0014:         * version 2.1 of the License, or (at your option) any later version.
0015:         *
0016:         * This library is distributed in the hope that it will be useful,
0017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0019:         * Lesser General Public License for more details.
0020:         *
0021:         * For further information about Alkacon Software GmbH, please see the
0022:         * company website: http://www.alkacon.com
0023:         *
0024:         * For further information about OpenCms, please see the
0025:         * project website: http://www.opencms.org
0026:         * 
0027:         * You should have received a copy of the GNU Lesser General Public
0028:         * License along with this library; if not, write to the Free Software
0029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0030:         */
0031:
0032:        package org.opencms.workplace.explorer;
0033:
0034:        import org.opencms.db.CmsResourceState;
0035:        import org.opencms.file.CmsObject;
0036:        import org.opencms.file.CmsProject;
0037:        import org.opencms.file.CmsPropertyDefinition;
0038:        import org.opencms.file.CmsRequestContext;
0039:        import org.opencms.file.CmsResource;
0040:        import org.opencms.file.CmsResourceFilter;
0041:        import org.opencms.file.types.CmsResourceTypePlain;
0042:        import org.opencms.file.types.I_CmsResourceType;
0043:        import org.opencms.i18n.CmsMessages;
0044:        import org.opencms.lock.CmsLock;
0045:        import org.opencms.main.CmsException;
0046:        import org.opencms.main.CmsLog;
0047:        import org.opencms.main.OpenCms;
0048:        import org.opencms.security.CmsOrganizationalUnit;
0049:        import org.opencms.security.CmsPermissionSet;
0050:        import org.opencms.security.CmsPermissionSetCustom;
0051:        import org.opencms.security.CmsPrincipal;
0052:        import org.opencms.util.A_CmsModeIntEnumeration;
0053:        import org.opencms.util.CmsStringUtil;
0054:        import org.opencms.util.CmsUUID;
0055:        import org.opencms.workplace.CmsWorkplace;
0056:        import org.opencms.workplace.commons.CmsTouch;
0057:
0058:        import java.util.ArrayList;
0059:        import java.util.List;
0060:
0061:        import org.apache.commons.logging.Log;
0062:
0063:        /**
0064:         * Provides {@link CmsResource} utility functions.<p>
0065:         * 
0066:         * This class provides in java all resource information used by the explorer view,
0067:         * mostly generated in javascript (see explorer.js)<p>
0068:         * 
0069:         * @author Michael Moossen
0070:         * 
0071:         * @version $Revision: 1.11 $ 
0072:         * 
0073:         * @since 6.0.0 
0074:         */
0075:        public final class CmsResourceUtil {
0076:
0077:            /**
0078:             * Enumeration class for defining the resource project state.<p>
0079:             */
0080:            public static class CmsResourceProjectState extends
0081:                    A_CmsModeIntEnumeration {
0082:
0083:                /** Constant for the project state unlocked. */
0084:                protected static final CmsResourceProjectState CLEAN = new CmsResourceProjectState(
0085:                        0);
0086:
0087:                /** Constant for the project state locked for publishing. */
0088:                protected static final CmsResourceProjectState LOCKED_FOR_PUBLISHING = new CmsResourceProjectState(
0089:                        5);
0090:
0091:                /** Constant for the project state locked in current project. */
0092:                protected static final CmsResourceProjectState MODIFIED_IN_CURRENT_PROJECT = new CmsResourceProjectState(
0093:                        1);
0094:
0095:                /** Constant for the project state locked in other project. */
0096:                protected static final CmsResourceProjectState MODIFIED_IN_OTHER_PROJECT = new CmsResourceProjectState(
0097:                        2);
0098:
0099:                private static final long serialVersionUID = 4580450220255428716L;
0100:
0101:                /**
0102:                 * Default constructor.<p>
0103:                 * 
0104:                 * @param mode the mode descriptor
0105:                 */
0106:                protected CmsResourceProjectState(int mode) {
0107:
0108:                    super (mode);
0109:                }
0110:
0111:                /**
0112:                 * Checks if this is a {@link #LOCKED_FOR_PUBLISHING} state.<p>
0113:                 * 
0114:                 * @return <code>true</code> if this is a {@link #LOCKED_FOR_PUBLISHING} state
0115:                 */
0116:                public boolean isLockedForPublishing() {
0117:
0118:                    return (this  == LOCKED_FOR_PUBLISHING);
0119:                }
0120:
0121:                /**
0122:                 * Checks if this is a {@link #MODIFIED_IN_CURRENT_PROJECT} state.<p>
0123:                 * 
0124:                 * @return <code>true</code> if this is a {@link #MODIFIED_IN_CURRENT_PROJECT} state
0125:                 */
0126:                public boolean isModifiedInCurrentProject() {
0127:
0128:                    return (this  == MODIFIED_IN_CURRENT_PROJECT);
0129:                }
0130:
0131:                /**
0132:                 * Checks if this is a {@link #MODIFIED_IN_OTHER_PROJECT} state.<p>
0133:                 * 
0134:                 * @return <code>true</code> if this is a {@link #MODIFIED_IN_OTHER_PROJECT} state
0135:                 */
0136:                public boolean isModifiedInOtherProject() {
0137:
0138:                    return (this  == MODIFIED_IN_OTHER_PROJECT);
0139:                }
0140:
0141:                /**
0142:                 * Checks if this is a {@link #CLEAN} state.<p>
0143:                 * 
0144:                 * @return <code>true</code> if this is a {@link #CLEAN} state
0145:                 */
0146:                public boolean isUnlocked() {
0147:
0148:                    return (this  == CLEAN);
0149:                }
0150:            }
0151:
0152:            /**
0153:             * Enumeration class for defining the site modes.<p>
0154:             */
0155:            private static class CmsResourceUtilSiteMode {
0156:
0157:                /**
0158:                 * Default constructor.<p>
0159:                 */
0160:                protected CmsResourceUtilSiteMode() {
0161:
0162:                    // noop
0163:                }
0164:            }
0165:
0166:            /** Layout style for resources after expire date. */
0167:            public static final int LAYOUTSTYLE_AFTEREXPIRE = 2;
0168:
0169:            /** Layout style for resources before release date. */
0170:            public static final int LAYOUTSTYLE_BEFORERELEASE = 1;
0171:
0172:            /** Layout style for resources after release date and before expire date. */
0173:            public static final int LAYOUTSTYLE_INRANGE = 0;
0174:
0175:            /** Constant that signalizes that all path operations will be based on the current site. */
0176:            public static final CmsResourceUtilSiteMode SITE_MODE_CURRENT = new CmsResourceUtilSiteMode();
0177:
0178:            /** Constant that signalizes that all path operations will be based on the best matching site. */
0179:            public static final CmsResourceUtilSiteMode SITE_MODE_MATCHING = new CmsResourceUtilSiteMode();
0180:
0181:            /** Constant that signalizes that all path operations will be based on the root path. */
0182:            public static final CmsResourceUtilSiteMode SITE_MODE_ROOT = new CmsResourceUtilSiteMode();
0183:
0184:            /** Constant for the project state locked for publishing. */
0185:            public static final CmsResourceProjectState STATE_LOCKED_FOR_PUBLISHING = CmsResourceProjectState.LOCKED_FOR_PUBLISHING;
0186:
0187:            /** Constant for the project state locked in current project. */
0188:            public static final CmsResourceProjectState STATE_MODIFIED_IN_CURRENT_PROJECT = CmsResourceProjectState.MODIFIED_IN_CURRENT_PROJECT;
0189:
0190:            /** Constant for the project state locked in other project. */
0191:            public static final CmsResourceProjectState STATE_MODIFIED_IN_OTHER_PROJECT = CmsResourceProjectState.MODIFIED_IN_OTHER_PROJECT;
0192:
0193:            /** The log object for this class. */
0194:            private static final Log LOG = CmsLog.getLog(CmsResourceUtil.class);
0195:
0196:            /** The folder size display string constant. */
0197:            private static final String SIZE_DIR = "-";
0198:
0199:            /** Constant for the project state unlocked. */
0200:            private static final CmsResourceProjectState STATE_CLEAN = CmsResourceProjectState.CLEAN;
0201:
0202:            /** If greater than zero, the path will be formatted to this number of chars. */
0203:            private int m_abbrevLength;
0204:
0205:            /** The current cms context. */
0206:            private CmsObject m_cms;
0207:
0208:            /** The current resource lock. */
0209:            private CmsLock m_lock;
0210:
0211:            /** The message bundle for formatting dates, depends on the request locale. */
0212:            private CmsMessages m_messages;
0213:
0214:            /** Reference project resources cache. */
0215:            private List m_projectResources;
0216:
0217:            /** The project to use to check project state, if <code>null</code> the current project will be used. */
0218:            private CmsProject m_referenceProject;
0219:
0220:            /** The 'relative to' path. */
0221:            private String m_relativeTo;
0222:
0223:            /** The current request context. */
0224:            private CmsRequestContext m_request;
0225:
0226:            /** The current resource. */
0227:            private CmsResource m_resource;
0228:
0229:            /** The current resource type. */
0230:            private I_CmsResourceType m_resourceType;
0231:
0232:            /** The current site mode. */
0233:            private CmsResourceUtilSiteMode m_siteMode = SITE_MODE_CURRENT;
0234:
0235:            /**
0236:             * Creates a new {@link CmsResourceUtil} object.<p> 
0237:             * 
0238:             * @param cms the cms context
0239:             */
0240:            public CmsResourceUtil(CmsObject cms) {
0241:
0242:                setCms(cms);
0243:            }
0244:
0245:            /**
0246:             * Creates a new {@link CmsResourceUtil} object.<p> 
0247:             * 
0248:             * @param cms the cms context
0249:             * @param resource the resource
0250:             */
0251:            public CmsResourceUtil(CmsObject cms, CmsResource resource) {
0252:
0253:                setCms(cms);
0254:                setResource(resource);
0255:            }
0256:
0257:            /**
0258:             * Creates a new {@link CmsResourceUtil} object.<p> 
0259:             * 
0260:             * @param resource the resource
0261:             */
0262:            public CmsResourceUtil(CmsResource resource) {
0263:
0264:                setResource(resource);
0265:            }
0266:
0267:            /**
0268:             * Returns the path abbreviation length.<p>
0269:             *
0270:             * If greater than zero, the path will be formatted to this number of chars.<p>
0271:             * 
0272:             * This only affects the generation of the path for the current resource.<p> 
0273:             *
0274:             * @return the path abbreviation Length
0275:             */
0276:            public int getAbbrevLength() {
0277:
0278:                return m_abbrevLength;
0279:            }
0280:
0281:            /**
0282:             * Returns the cms context.<p>
0283:             *
0284:             * @return the cms context
0285:             */
0286:            public CmsObject getCms() {
0287:
0288:                return m_cms;
0289:            }
0290:
0291:            /**
0292:             * Returns the formatted date of expiration.<p>
0293:             * 
0294:             * @return the formatted date of expiration
0295:             */
0296:            public String getDateExpired() {
0297:
0298:                long release = m_resource.getDateExpired();
0299:                if (release != CmsResource.DATE_EXPIRED_DEFAULT) {
0300:                    return getMessages().getDateTime(release);
0301:                } else {
0302:                    return CmsTouch.DEFAULT_DATE_STRING;
0303:                }
0304:            }
0305:
0306:            /**
0307:             * Returns the formatted date of release.<p>
0308:             * 
0309:             * @return the formatted date of release
0310:             */
0311:            public String getDateReleased() {
0312:
0313:                long release = m_resource.getDateReleased();
0314:                if (release != CmsResource.DATE_RELEASED_DEFAULT) {
0315:                    return getMessages().getDateTime(release);
0316:                } else {
0317:                    return CmsTouch.DEFAULT_DATE_STRING;
0318:                }
0319:            }
0320:
0321:            /**
0322:             * Returns the path of the current resource, taking into account just the site mode.<p>
0323:             * 
0324:             * @return the full path
0325:             */
0326:            public String getFullPath() {
0327:
0328:                String path = m_resource.getRootPath();
0329:                if ((m_siteMode != SITE_MODE_ROOT) && (m_cms != null)) {
0330:                    String site = getSite();
0331:                    if (path.startsWith(site)) {
0332:                        path = path.substring(site.length());
0333:                    }
0334:                }
0335:                return path;
0336:            }
0337:
0338:            /**
0339:             * Returns the resource icon path displayed in the explorer view for the given resource.<p>
0340:             * 
0341:             * Relative to <code>/system/workplace/resources/</code>.<p>
0342:             * 
0343:             * If the resource has no sibling it is the same as {@link #getIconPathResourceType()}.<p>
0344:             * 
0345:             * @return the resource icon path displayed in the explorer view for the given resource
0346:             * 
0347:             * @see #getStyleSiblings()
0348:             */
0349:            public String getIconPathExplorer() {
0350:
0351:                if (m_resource.getSiblingCount() > 1) {
0352:                    // links are present
0353:                    if (m_resource.isLabeled()) {
0354:                        // there is at least one link in a marked site
0355:                        return "explorer/link_labeled.gif";
0356:                    } else {
0357:                        // common links are present
0358:                        return "explorer/link.gif";
0359:                    }
0360:                } else {
0361:                    return getIconPathResourceType();
0362:                }
0363:            }
0364:
0365:            /**
0366:             * Returns the lock icon path for the given resource.<p>
0367:             * 
0368:             * Relative to <code>/system/workplace/resources/</code>.<p>
0369:             * 
0370:             * Returns <code>explorer/project_none.gif</code> if request context is <code>null</code>.<p>
0371:             * 
0372:             * @return the lock icon path for the given resource
0373:             */
0374:            public String getIconPathLock() {
0375:
0376:                CmsLock lock = getLock();
0377:                String iconPath = null;
0378:                if (!lock.isUnlocked() && (m_request != null)
0379:                        && isInsideProject()) {
0380:                    if (getLock().isOwnedBy(m_request.currentUser())
0381:                            && (getLockedInProjectId()
0382:                                    .equals(getReferenceProject().getUuid()))) {
0383:                        if (lock.isShared()) {
0384:                            iconPath = "shared";
0385:                        } else {
0386:                            iconPath = "user";
0387:                        }
0388:                    } else {
0389:                        iconPath = "other";
0390:                    }
0391:                }
0392:                if (iconPath == null) {
0393:                    iconPath = "project_none";
0394:                } else {
0395:                    iconPath = "lock_" + iconPath;
0396:                }
0397:                return "explorer/" + iconPath + ".gif";
0398:            }
0399:
0400:            /**
0401:             * Returns the project state icon path for the given resource.<p>
0402:             * 
0403:             * Relative to <code>/system/workplace/resources/</code>.<p>
0404:             * 
0405:             * @return the project state icon path for the given resource
0406:             */
0407:            public String getIconPathProjectState() {
0408:
0409:                String iconPath;
0410:                if (getProjectState() == STATE_MODIFIED_IN_CURRENT_PROJECT) {
0411:                    iconPath = "this.png";
0412:                } else if (getProjectState() == STATE_MODIFIED_IN_OTHER_PROJECT) {
0413:                    iconPath = "other.png";
0414:                } else if (getProjectState() == STATE_LOCKED_FOR_PUBLISHING) {
0415:                    iconPath = "publish.png";
0416:                } else {
0417:                    // STATE_UNLOCKED
0418:                    iconPath = "none.gif";
0419:                }
0420:                return "explorer/project_" + iconPath;
0421:            }
0422:
0423:            /**
0424:             * Returns the resource type icon path for the given resource.<p>
0425:             * 
0426:             * Relative to <code>/system/workplace/resources/</code>.<p>
0427:             * 
0428:             * @return the resource type icon path for the given resource
0429:             */
0430:            public String getIconPathResourceType() {
0431:
0432:                if (!isEditable()) {
0433:                    return "filetypes/"
0434:                            + OpenCms.getWorkplaceManager()
0435:                                    .getExplorerTypeSetting(
0436:                                            CmsResourceTypePlain
0437:                                                    .getStaticTypeName())
0438:                                    .getIcon();
0439:                }
0440:                return "filetypes/"
0441:                        + OpenCms.getWorkplaceManager().getExplorerTypeSetting(
0442:                                getResourceTypeName()).getIcon();
0443:            }
0444:
0445:            /**
0446:             * Returns an integer representation for the link type.<p>
0447:             * 
0448:             * <ul>
0449:             *   <li><code>0</code>: No sibling
0450:             *   <li><code>1</code>: Sibling
0451:             *   <li><code>2</code>: Labeled sibling
0452:             * </ul>
0453:             * 
0454:             * @return an integer representation for the link type
0455:             */
0456:            public int getLinkType() {
0457:
0458:                if (m_resource.getSiblingCount() > 1) {
0459:                    // links are present
0460:                    if (m_resource.isLabeled()) {
0461:                        // there is at least one link in a marked site
0462:                        return 2;
0463:                    } else {
0464:                        // common links are present
0465:                        return 1;
0466:                    }
0467:                } else {
0468:                    // no links to the resource are in the VFS
0469:                    return 0;
0470:                }
0471:            }
0472:
0473:            /**
0474:             * Returns the the lock for the given resource.<p>
0475:             * 
0476:             * @return the lock the given resource
0477:             */
0478:            public CmsLock getLock() {
0479:
0480:                if (m_lock == null) {
0481:                    try {
0482:                        m_lock = getCms().getLock(m_resource);
0483:                    } catch (Throwable e) {
0484:                        m_lock = CmsLock.getNullLock();
0485:                        LOG.error(e.getLocalizedMessage(), e);
0486:                    }
0487:                }
0488:                return m_lock;
0489:            }
0490:
0491:            /**
0492:             * Returns the user name who owns the lock for the given resource.<p>
0493:             * 
0494:             * @return the user name who owns the lock for the given resource
0495:             */
0496:            public String getLockedByName() {
0497:
0498:                String lockedBy = "";
0499:                if (!getLock().isNullLock()) {
0500:                    try {
0501:                        lockedBy = getCurrentOuRelativeName(getCms().readUser(
0502:                                getLock().getUserId()).getName());
0503:                    } catch (Throwable e) {
0504:                        lockedBy = e.getMessage();
0505:                    }
0506:                }
0507:                return lockedBy;
0508:            }
0509:
0510:            /**
0511:             * Returns the id of the project in which the given resource is locked.<p>
0512:             * 
0513:             * @return the id of the project in which the given resource is locked
0514:             */
0515:            public CmsUUID getLockedInProjectId() {
0516:
0517:                CmsUUID lockedInProject = null;
0518:                if (getLock().isNullLock()
0519:                        && !getResource().getState().isUnchanged()) {
0520:                    // resource is unlocked and modified
0521:                    lockedInProject = getResource().getProjectLastModified();
0522:                } else if (!getResource().getState().isUnchanged()) {
0523:                    // resource is locked and modified
0524:                    lockedInProject = getProjectId();
0525:                } else if (!getLock().isNullLock()) {
0526:                    // resource is locked and unchanged
0527:                    lockedInProject = getLock().getProjectId();
0528:                }
0529:                return lockedInProject;
0530:            }
0531:
0532:            /**
0533:             * Returns the project name that locked the current resource's.<p>
0534:             * 
0535:             * @return the the project name that locked the current resource's
0536:             */
0537:            public String getLockedInProjectName() {
0538:
0539:                try {
0540:                    CmsUUID pId = getLockedInProjectId();
0541:                    if (pId == null) {
0542:                        // the resource is unlocked and unchanged
0543:                        return "";
0544:                    }
0545:                    return getCurrentOuRelativeName(getCms().readProject(pId)
0546:                            .getName());
0547:                } catch (Throwable e) {
0548:                    LOG.error(e.getLocalizedMessage(), e);
0549:                    return "";
0550:                }
0551:            }
0552:
0553:            /**
0554:             * Returns the lock state of the current resource.<p>
0555:             * 
0556:             * @return the lock state of the current resource
0557:             */
0558:            public int getLockState() {
0559:
0560:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(getLockedByName())) {
0561:                    // unlocked
0562:                    return 0;
0563:                }
0564:                if (!getLockedByName().equals(
0565:                        getCurrentOuRelativeName(m_request.currentUser()
0566:                                .getName()))
0567:                        || !getLockedInProjectId().equals(
0568:                                m_request.currentProject().getUuid())) {
0569:                    // locked by other user and/or project
0570:                    return 1;
0571:                }
0572:                if (getLock().getType().isShared()) {
0573:                    // shared lock
0574:                    return 2;
0575:                }
0576:                // exclusive lock
0577:                return 3;
0578:            }
0579:
0580:            /**
0581:             * Returns the navtext of a resource.<p>
0582:             * 
0583:             * @return the navtext for that resource
0584:             */
0585:            public String getNavText() {
0586:
0587:                String navText = "";
0588:                try {
0589:                    navText = getCms().readPropertyObject(
0590:                            getCms().getSitePath(m_resource),
0591:                            CmsPropertyDefinition.PROPERTY_NAVTEXT, false)
0592:                            .getValue();
0593:                } catch (Throwable e) {
0594:                    String storedSiteRoot = getCms().getRequestContext()
0595:                            .getSiteRoot();
0596:                    try {
0597:                        getCms().getRequestContext().setSiteRoot("");
0598:                        navText = getCms().readPropertyObject(
0599:                                m_resource.getRootPath(),
0600:                                CmsPropertyDefinition.PROPERTY_NAVTEXT, false)
0601:                                .getValue();
0602:                    } catch (Exception e1) {
0603:                        // should usually never happen
0604:                        if (LOG.isInfoEnabled()) {
0605:                            LOG.info(e);
0606:                        }
0607:                    } finally {
0608:                        getCms().getRequestContext()
0609:                                .setSiteRoot(storedSiteRoot);
0610:                    }
0611:                }
0612:                if (navText == null) {
0613:                    navText = "";
0614:                }
0615:                return navText;
0616:            }
0617:
0618:            /**
0619:             * Returns the path of the current resource.<p>
0620:             * 
0621:             * Taking into account following settings:<br>
0622:             * <ul>
0623:             *    <li>site mode
0624:             *    <li>abbreviation length
0625:             *    <li>relative to
0626:             * </ul>
0627:             * 
0628:             * @return the path
0629:             */
0630:            public String getPath() {
0631:
0632:                String path = getFullPath();
0633:                if (m_relativeTo != null) {
0634:                    path = getResource().getRootPath();
0635:                    if (path.startsWith(m_relativeTo)) {
0636:                        path = path.substring(m_relativeTo.length());
0637:                        if (path.length() == 0) {
0638:                            path = ".";
0639:                        }
0640:                    } else {
0641:                        String site = getSite();
0642:                        if (path.startsWith(site + "/") || path.equals(site)) {
0643:                            path = path.substring(site.length());
0644:                        }
0645:                    }
0646:                }
0647:                if (m_abbrevLength > 0) {
0648:                    boolean absolute = path.startsWith("/");
0649:                    path = CmsStringUtil.formatResourceName(path,
0650:                            m_abbrevLength);
0651:                    if (!absolute && path.startsWith("/")) {
0652:                        // remove leading '/'
0653:                        path = path.substring(1);
0654:                    }
0655:                }
0656:                return path;
0657:            }
0658:
0659:            /**
0660:             * Returns the permission set for the given resource.<p>
0661:             * 
0662:             * @return the permission set for the given resource
0663:             */
0664:            public CmsPermissionSet getPermissionSet() {
0665:
0666:                CmsPermissionSetCustom pset = new CmsPermissionSetCustom();
0667:                CmsResource resource = getResource();
0668:                try {
0669:                    if (getCms().hasPermissions(resource,
0670:                            CmsPermissionSet.ACCESS_CONTROL, false,
0671:                            CmsResourceFilter.ALL)) {
0672:                        pset
0673:                                .grantPermissions(CmsPermissionSet.PERMISSION_CONTROL);
0674:                    } else {
0675:                        pset
0676:                                .denyPermissions(CmsPermissionSet.PERMISSION_CONTROL);
0677:                    }
0678:                } catch (CmsException e) {
0679:                    LOG.error(e.getLocalizedMessage());
0680:                }
0681:                try {
0682:                    if (getCms().hasPermissions(resource,
0683:                            CmsPermissionSet.ACCESS_DIRECT_PUBLISH, false,
0684:                            CmsResourceFilter.ALL)) {
0685:                        pset
0686:                                .grantPermissions(CmsPermissionSet.PERMISSION_DIRECT_PUBLISH);
0687:                    } else {
0688:                        pset
0689:                                .denyPermissions(CmsPermissionSet.PERMISSION_DIRECT_PUBLISH);
0690:                    }
0691:                } catch (CmsException e) {
0692:                    LOG.error(e.getLocalizedMessage());
0693:                }
0694:                try {
0695:                    if (getCms().hasPermissions(resource,
0696:                            CmsPermissionSet.ACCESS_READ, false,
0697:                            CmsResourceFilter.ALL)) {
0698:                        pset.grantPermissions(CmsPermissionSet.PERMISSION_READ);
0699:                    } else {
0700:                        pset.denyPermissions(CmsPermissionSet.PERMISSION_READ);
0701:                    }
0702:                } catch (CmsException e) {
0703:                    LOG.error(e.getLocalizedMessage());
0704:                }
0705:                try {
0706:                    if (getCms().hasPermissions(resource,
0707:                            CmsPermissionSet.ACCESS_VIEW, false,
0708:                            CmsResourceFilter.ALL)) {
0709:                        pset.grantPermissions(CmsPermissionSet.PERMISSION_VIEW);
0710:                    } else {
0711:                        pset.denyPermissions(CmsPermissionSet.PERMISSION_VIEW);
0712:                    }
0713:                } catch (CmsException e) {
0714:                    LOG.error(e.getLocalizedMessage());
0715:                }
0716:                try {
0717:                    if (getCms().hasPermissions(resource,
0718:                            CmsPermissionSet.ACCESS_WRITE, false,
0719:                            CmsResourceFilter.ALL)) {
0720:                        pset
0721:                                .grantPermissions(CmsPermissionSet.PERMISSION_WRITE);
0722:                    } else {
0723:                        pset.denyPermissions(CmsPermissionSet.PERMISSION_WRITE);
0724:                    }
0725:                } catch (CmsException e) {
0726:                    LOG.error(e.getLocalizedMessage());
0727:                }
0728:
0729:                return pset;
0730:            }
0731:
0732:            /**
0733:             * Returns the permissions string for the given resource.<p>
0734:             * 
0735:             * @return the permissions string for the given resource
0736:             */
0737:            public String getPermissionString() {
0738:
0739:                return getPermissionSet().getPermissionString();
0740:            }
0741:
0742:            /**
0743:             * Returns the id of the project which the resource belongs to.<p>
0744:             * 
0745:             * @return the id of the project which the resource belongs to
0746:             */
0747:            public CmsUUID getProjectId() {
0748:
0749:                CmsUUID projectId = m_resource.getProjectLastModified();
0750:                if (!getLock().isUnlocked() && !getLock().isInherited()) {
0751:                    // use lock project ID only if lock is not inherited
0752:                    projectId = getLock().getProjectId();
0753:                }
0754:                return projectId;
0755:            }
0756:
0757:            /**
0758:             * Returns the project state of the given resource.<p>
0759:             * 
0760:             * <ul>
0761:             *   <li>null: unchanged.</li>
0762:             *   <li>true: locked in current project.</li>
0763:             *   <li>false: not locked in current project.</li>
0764:             * </ul>
0765:             * 
0766:             * @return the project state of the given resource
0767:             */
0768:            public CmsResourceProjectState getProjectState() {
0769:
0770:                if (getResource().getState().isUnchanged()) {
0771:                    return STATE_CLEAN; // STATE_CLEAN
0772:                } else if (getLock().getSystemLock().isPublish()) {
0773:                    return STATE_LOCKED_FOR_PUBLISHING;
0774:                } else if (getResource().getProjectLastModified().equals(
0775:                        getReferenceProject().getUuid())) {
0776:                    return STATE_MODIFIED_IN_CURRENT_PROJECT; // STATE_MODIFIED_CURRENT_PROJECT
0777:                } else {
0778:                    return STATE_MODIFIED_IN_OTHER_PROJECT; // STATE_MODIFIED_OTHER_PROJECT
0779:                }
0780:            }
0781:
0782:            /**
0783:             * Returns the project to use to check project state.<p>
0784:             *
0785:             * @return the project to use to check project state
0786:             */
0787:            public CmsProject getReferenceProject() {
0788:
0789:                if (m_referenceProject == null) {
0790:                    if (m_request != null) {
0791:                        m_referenceProject = m_request.currentProject();
0792:                    }
0793:                }
0794:                return m_referenceProject;
0795:            }
0796:
0797:            /**
0798:             * Returns the 'relative to' path.<p>
0799:             *
0800:             * This only affects the generation of the path for the current resource.<p> 
0801:             *
0802:             * @return the 'relative to' path
0803:             */
0804:            public String getRelativeTo() {
0805:
0806:                return m_relativeTo;
0807:            }
0808:
0809:            /**
0810:             * Returns the resource.<p>
0811:             *
0812:             * @return the resource
0813:             */
0814:            public CmsResource getResource() {
0815:
0816:                return m_resource;
0817:            }
0818:
0819:            /**
0820:             * Returns the resource type for the given resource.<p>
0821:             * 
0822:             * @return the resource type for the given resource
0823:             */
0824:            public I_CmsResourceType getResourceType() {
0825:
0826:                if (m_resourceType == null) {
0827:                    m_resourceType = OpenCms.getResourceManager()
0828:                            .getResourceType(m_resource);
0829:                }
0830:                return m_resourceType;
0831:            }
0832:
0833:            /**
0834:             * Returns the resource type id for the given resource.<p>
0835:             * 
0836:             * @return the resource type id for the given resource
0837:             */
0838:            public int getResourceTypeId() {
0839:
0840:                return getResourceType().getTypeId();
0841:            }
0842:
0843:            /**
0844:             * Returns the resource type name for the given resource.<p>
0845:             * 
0846:             * @return the resource type name for the given resource
0847:             */
0848:            public String getResourceTypeName() {
0849:
0850:                return getResourceType().getTypeName();
0851:            }
0852:
0853:            /**
0854:             * Returns the site of the current resources,
0855:             * taking into account the set site mode.<p>
0856:             * 
0857:             * @return the site path
0858:             */
0859:            public String getSite() {
0860:
0861:                String site = null;
0862:                if ((m_siteMode == SITE_MODE_MATCHING) || (m_cms == null)) {
0863:                    site = OpenCms.getSiteManager().getSiteRoot(
0864:                            m_resource.getRootPath());
0865:                } else if (m_siteMode == SITE_MODE_CURRENT) {
0866:                    site = m_cms.getRequestContext().getSiteRoot();
0867:                } else if (m_siteMode == SITE_MODE_ROOT) {
0868:                    site = "";
0869:                }
0870:                return (site == null ? "" : site);
0871:            }
0872:
0873:            /**
0874:             * Returns the site mode.<p>
0875:             *
0876:             * This only affects the generation of the path for the current resource.<p> 
0877:             *
0878:             * @return the site mode
0879:             */
0880:            public CmsResourceUtilSiteMode getSiteMode() {
0881:
0882:                return m_siteMode;
0883:            }
0884:
0885:            /**
0886:             * Returns the title of the site.<p>
0887:             * 
0888:             * @return the title of the site
0889:             */
0890:            public String getSiteTitle() {
0891:
0892:                String title = getSite();
0893:                String rootSite = getCms().getRequestContext().getSiteRoot();
0894:                try {
0895:                    getCms().getRequestContext().setSiteRoot("");
0896:                    title = getCms().readPropertyObject(title,
0897:                            CmsPropertyDefinition.PROPERTY_TITLE, false)
0898:                            .getValue(title);
0899:                } catch (CmsException e) {
0900:                    // ignore
0901:                } finally {
0902:                    getCms().getRequestContext().setSiteRoot(rootSite);
0903:                }
0904:                return title;
0905:            }
0906:
0907:            /**
0908:             * Returns the size of the given resource as a String.<p>
0909:             * 
0910:             * For directories it returns <code>SIZE_DIR</code>.<p>
0911:             * 
0912:             * @return the size of the given resource as a String
0913:             */
0914:            public String getSizeString() {
0915:
0916:                return m_resource.getLength() == -1 ? SIZE_DIR : ""
0917:                        + m_resource.getLength();
0918:            }
0919:
0920:            /**
0921:             * Returns resource state abbreviation.<p>
0922:             * 
0923:             * @return resource state abbreviation
0924:             */
0925:            public char getStateAbbreviation() {
0926:
0927:                return getResource().getState().getAbbreviation();
0928:            }
0929:
0930:            /**
0931:             * Returns the state name for a resource.<p>
0932:             * 
0933:             * Uses default locale if request context is <code>null</code>.<p>
0934:             * 
0935:             * @return the state name for that resource
0936:             */
0937:            public String getStateName() {
0938:
0939:                CmsResourceState state = m_resource.getState();
0940:                String name;
0941:                if (m_request == null) {
0942:                    name = org.opencms.workplace.explorer.Messages.get()
0943:                            .getBundle().key(
0944:                                    org.opencms.workplace.explorer.Messages
0945:                                            .getStateKey(state));
0946:                } else {
0947:                    name = org.opencms.workplace.explorer.Messages.get()
0948:                            .getBundle(m_request.getLocale()).key(
0949:                                    org.opencms.workplace.explorer.Messages
0950:                                            .getStateKey(state));
0951:                }
0952:                return name;
0953:            }
0954:
0955:            /**
0956:             * Returns the style class to use for the given resource.<p>
0957:             * 
0958:             * @return style class name
0959:             * 
0960:             * @see org.opencms.workplace.list.CmsListExplorerColumn#getExplorerStyleDef()
0961:             */
0962:            public String getStyleClassName() {
0963:
0964:                if (isInsideProject() && isEditable()) {
0965:                    if (m_resource.getState().isChanged()) {
0966:                        return "fc";
0967:                    } else if (m_resource.getState().isNew()) {
0968:                        return "fn";
0969:                    } else if (m_resource.getState().isDeleted()) {
0970:                        return "fd";
0971:                    } else {
0972:                        return "nf";
0973:                    }
0974:                }
0975:                return "fp";
0976:            }
0977:
0978:            /**
0979:             * Returns additional style sheets for the resource type icon depending on siblings.<p>
0980:             * 
0981:             * That is, depending on {@link CmsResource#getSiblingCount()}
0982:             * 
0983:             * Use it with the {@link #getIconPathExplorer} method.<p>
0984:             * 
0985:             * @return additional style sheets depending on siblings
0986:             */
0987:            public String getStyleSiblings() {
0988:
0989:                StringBuffer style = new StringBuffer(128);
0990:                if (m_resource.getSiblingCount() > 1) {
0991:                    style.append("background-image:url(");
0992:                    style.append(CmsWorkplace.getSkinUri());
0993:                    style.append(getIconPathResourceType());
0994:                    style
0995:                            .append("); background-position: 0px 0px; background-repeat: no-repeat; ");
0996:                }
0997:                return style.toString();
0998:            }
0999:
1000:            /**
1001:             * Returns the system lock information tooltip for the explorer view.<p>
1002:             * 
1003:             * @param forExplorer if the tool tip should be generated for the explorer view
1004:             * 
1005:             * @return the system lock information tooltip
1006:             */
1007:            public String getSystemLockInfo(boolean forExplorer) {
1008:
1009:                if (getLock().getSystemLock().isPublish()) {
1010:                    if (!forExplorer) {
1011:                        return getMessages()
1012:                                .key(Messages.GUI_PUBLISH_TOOLTIP_0);
1013:                    } else {
1014:                        // see explorer.js(sysLockInfo) and top_js.jsp(publishlock)
1015:                        return "p"; // should have length == 1
1016:                    }
1017:                }
1018:                return "";
1019:            }
1020:
1021:            /**
1022:             * Returns additional style sheets depending on publication constraints.<p>
1023:             * 
1024:             * That is, depending on {@link CmsResource#getDateReleased()} and 
1025:             * {@link CmsResource#getDateExpired()}.<p>
1026:             * 
1027:             * @return additional style sheets depending on publication constraints
1028:             * 
1029:             * @see #getTimeWindowLayoutType()
1030:             */
1031:            public String getTimeWindowLayoutStyle() {
1032:
1033:                return getTimeWindowLayoutType() == CmsResourceUtil.LAYOUTSTYLE_INRANGE ? ""
1034:                        : "font-style:italic;";
1035:            }
1036:
1037:            /**
1038:             * Returns the layout style for the current time window state.<p>
1039:             * 
1040:             * <ul>
1041:             *   <li><code>{@link CmsResourceUtil#LAYOUTSTYLE_INRANGE}</code>: The time window is in range
1042:             *   <li><code>{@link CmsResourceUtil#LAYOUTSTYLE_BEFORERELEASE}</code>: The resource is not yet released
1043:             *   <li><code>{@link CmsResourceUtil#LAYOUTSTYLE_AFTEREXPIRE}</code>: The resource has already expired
1044:             * </ul>
1045:             * 
1046:             * @return the layout style for the current time window state
1047:             * 
1048:             * @see #getTimeWindowLayoutStyle()
1049:             */
1050:            public int getTimeWindowLayoutType() {
1051:
1052:                int layoutstyle = CmsResourceUtil.LAYOUTSTYLE_INRANGE;
1053:                if (!m_resource.isReleased(getCms().getRequestContext()
1054:                        .getRequestTime())) {
1055:                    layoutstyle = CmsResourceUtil.LAYOUTSTYLE_BEFORERELEASE;
1056:                } else if (m_resource.isExpired(getCms().getRequestContext()
1057:                        .getRequestTime())) {
1058:                    layoutstyle = CmsResourceUtil.LAYOUTSTYLE_AFTEREXPIRE;
1059:                }
1060:                return layoutstyle;
1061:            }
1062:
1063:            /**
1064:             * Returns the title of a resource.<p>
1065:             * 
1066:             * @return the title for that resource
1067:             */
1068:            public String getTitle() {
1069:
1070:                String title = "";
1071:                try {
1072:                    title = getCms().readPropertyObject(
1073:                            getCms().getSitePath(m_resource),
1074:                            CmsPropertyDefinition.PROPERTY_TITLE, false)
1075:                            .getValue();
1076:                } catch (Throwable e) {
1077:                    String storedSiteRoot = getCms().getRequestContext()
1078:                            .getSiteRoot();
1079:                    try {
1080:                        getCms().getRequestContext().setSiteRoot("");
1081:                        title = getCms().readPropertyObject(
1082:                                m_resource.getRootPath(),
1083:                                CmsPropertyDefinition.PROPERTY_TITLE, false)
1084:                                .getValue();
1085:                    } catch (Exception e1) {
1086:                        // should usually never happen
1087:                        if (LOG.isInfoEnabled()) {
1088:                            LOG.info(e);
1089:                        }
1090:                    } finally {
1091:                        getCms().getRequestContext()
1092:                                .setSiteRoot(storedSiteRoot);
1093:                    }
1094:                }
1095:                if (title == null) {
1096:                    title = "";
1097:                }
1098:                return title;
1099:            }
1100:
1101:            /**
1102:             * Returns the name of the user who created the given resource.<p>
1103:             * 
1104:             * @return the name of the user who created the given resource
1105:             */
1106:            public String getUserCreated() {
1107:
1108:                String user = m_resource.getUserCreated().toString();
1109:                try {
1110:                    user = getCurrentOuRelativeName(CmsPrincipal
1111:                            .readPrincipalIncludingHistory(getCms(),
1112:                                    m_resource.getUserCreated()).getName());
1113:                } catch (Throwable e) {
1114:                    LOG.error(e.getLocalizedMessage());
1115:                }
1116:                return user;
1117:            }
1118:
1119:            /**
1120:             * Returns the name of the user who last modified the given resource.<p>
1121:             * 
1122:             * @return the name of the user who last modified the given resource
1123:             */
1124:            public String getUserLastModified() {
1125:
1126:                String user = m_resource.getUserLastModified().toString();
1127:                try {
1128:                    user = getCurrentOuRelativeName(CmsPrincipal
1129:                            .readPrincipalIncludingHistory(getCms(),
1130:                                    m_resource.getUserLastModified()).getName());
1131:                } catch (Throwable e) {
1132:                    LOG.error(e.getLocalizedMessage());
1133:                }
1134:                return user;
1135:            }
1136:
1137:            /**
1138:             * Returns <code>true</code> if the given resource is editable by the current user.<p>
1139:             * 
1140:             * Returns <code>false</code> if no request context is set.<p>
1141:             * 
1142:             * @return <code>true</code> if the given resource is editable by the current user
1143:             */
1144:            public boolean isEditable() {
1145:
1146:                if (m_request == null) {
1147:                    return false;
1148:                }
1149:                CmsExplorerTypeSettings settings = OpenCms
1150:                        .getWorkplaceManager().getExplorerTypeSetting(
1151:                                getResourceTypeName());
1152:                if (settings != null) {
1153:                    String rightSite = OpenCms.getSiteManager().getSiteRoot(
1154:                            getResource().getRootPath());
1155:                    if (rightSite == null) {
1156:                        rightSite = "";
1157:                    }
1158:                    String currentSite = getCms().getRequestContext()
1159:                            .getSiteRoot();
1160:                    try {
1161:                        getCms().getRequestContext().setSiteRoot(rightSite);
1162:                        return settings.isEditable(getCms(), getResource());
1163:                    } finally {
1164:                        getCms().getRequestContext().setSiteRoot(currentSite);
1165:                    }
1166:                }
1167:                return false;
1168:            }
1169:
1170:            /**
1171:             * Returns <code>true</code> if the given resource is in the reference project.<p>
1172:             * 
1173:             * Returns <code>false</code> if the request context is <code>null</code>.<p>
1174:             * 
1175:             * @return <code>true</code> if the given resource is in the reference project
1176:             * 
1177:             * @see #getReferenceProject()
1178:             */
1179:            public boolean isInsideProject() {
1180:
1181:                return CmsProject.isInsideProject(getProjectResources(),
1182:                        getResource());
1183:            }
1184:
1185:            /**
1186:             * Returns <code>true</code> if the stored resource has been released and has not expired.<p>
1187:             * 
1188:             * If no request context is available, the current time is used for the validation check.<p>
1189:             * 
1190:             * @return <code>true</code> if the stored resource has been released and has not expired
1191:             * 
1192:             * @see CmsResource#isReleasedAndNotExpired(long)
1193:             */
1194:            public boolean isReleasedAndNotExpired() {
1195:
1196:                long requestTime;
1197:                if (m_request == null) {
1198:                    requestTime = System.currentTimeMillis();
1199:                } else {
1200:                    requestTime = m_request.getRequestTime();
1201:                }
1202:                return m_resource.isReleasedAndNotExpired(requestTime);
1203:            }
1204:
1205:            /**
1206:             * Sets the path abbreviation length.<p>
1207:             *
1208:             * If greater than zero, the path will be formatted to this number of chars.<p>
1209:             *
1210:             * This only affects the generation of the path for the current resource.<p> 
1211:             *
1212:             * @param abbrevLength the path abbreviation length to set
1213:             */
1214:            public void setAbbrevLength(int abbrevLength) {
1215:
1216:                m_abbrevLength = abbrevLength;
1217:            }
1218:
1219:            /**
1220:             * Sets the cms context.<p>
1221:             *
1222:             * @param cms the cms context to set
1223:             */
1224:            public void setCms(CmsObject cms) {
1225:
1226:                m_cms = cms;
1227:                m_request = cms.getRequestContext();
1228:                m_referenceProject = null;
1229:                m_projectResources = null;
1230:                m_messages = null;
1231:            }
1232:
1233:            /**
1234:             * Sets the project to use to check project state.<p>
1235:             *
1236:             * @param project the project to set
1237:             */
1238:            public void setReferenceProject(CmsProject project) {
1239:
1240:                m_referenceProject = project;
1241:                m_projectResources = null;
1242:            }
1243:
1244:            /**
1245:             * Sets the 'relative to' path.<p>
1246:             *
1247:             * This only affects the generation of the path for the current resource.<p> 
1248:             *
1249:             * @param relativeTo the 'relative to' path to set
1250:             */
1251:            public void setRelativeTo(String relativeTo) {
1252:
1253:                m_relativeTo = relativeTo;
1254:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_relativeTo)) {
1255:                    m_relativeTo = null;
1256:                } else {
1257:                    if (!m_relativeTo.startsWith("/")) {
1258:                        m_relativeTo = "/" + m_relativeTo;
1259:                    }
1260:                    if (!m_relativeTo.endsWith("/")) {
1261:                        m_relativeTo += "/";
1262:                    }
1263:                }
1264:            }
1265:
1266:            /**
1267:             * Sets the resource.<p>
1268:             *
1269:             * @param resource the resource to set
1270:             */
1271:            public void setResource(CmsResource resource) {
1272:
1273:                m_resource = resource;
1274:                m_lock = null;
1275:                m_resourceType = null;
1276:            }
1277:
1278:            /**
1279:             * Sets the site mode.<p>
1280:             *
1281:             * This only affects the generation of the path for the current resource.<p> 
1282:             *
1283:             * @param siteMode the site mode to set
1284:             */
1285:            public void setSiteMode(CmsResourceUtilSiteMode siteMode) {
1286:
1287:                m_siteMode = siteMode;
1288:            }
1289:
1290:            /**
1291:             * Returns the simple name if the ou is the same as the current user's ou.<p>
1292:             * 
1293:             * @param name the fully qualified name to check
1294:             * 
1295:             * @return the simple name if the ou is the same as the current user's ou
1296:             */
1297:            private String getCurrentOuRelativeName(String name) {
1298:
1299:                if (m_request == null) {
1300:                    return CmsOrganizationalUnit.SEPARATOR + name;
1301:                }
1302:                String ou = CmsOrganizationalUnit.getParentFqn(name);
1303:                if (ou.equals(m_request.currentUser().getOuFqn())) {
1304:                    return CmsOrganizationalUnit.getSimpleName(name);
1305:                }
1306:                return CmsOrganizationalUnit.SEPARATOR + name;
1307:            }
1308:
1309:            /**
1310:             * Returns the message bundle for formatting dates, depends on the request locale.<p>
1311:             * 
1312:             * @return the message bundle for formatting dates
1313:             */
1314:            private CmsMessages getMessages() {
1315:
1316:                if (m_messages == null) {
1317:                    if (m_request != null) {
1318:                        m_messages = Messages.get().getBundle(
1319:                                m_request.getLocale());
1320:                    } else {
1321:                        m_messages = Messages.get().getBundle();
1322:                    }
1323:                }
1324:                return m_messages;
1325:            }
1326:
1327:            /**
1328:             * Returns the reference project resources.<p>
1329:             * 
1330:             * @return the reference project resources
1331:             */
1332:            private List getProjectResources() {
1333:
1334:                if (m_projectResources == null) {
1335:                    try {
1336:                        m_projectResources = getCms().readProjectResources(
1337:                                getReferenceProject());
1338:                    } catch (Throwable e) {
1339:                        LOG.error(e.getLocalizedMessage(), e);
1340:                        // use an empty list (all resources are "outside")
1341:                        m_projectResources = new ArrayList();
1342:                    }
1343:                }
1344:                return m_projectResources;
1345:            }
1346:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.