001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     */
020    public class PortletConstants {
021    
022            /**
023             * War file separator.
024             */
025            public static final String WAR_SEPARATOR = "_WAR_";
026    
027            /**
028             * Instance separator.
029             */
030            public static final String INSTANCE_SEPARATOR = "_INSTANCE_";
031    
032            /**
033             * Layout separator.
034             */
035            public static final String LAYOUT_SEPARATOR = "_LAYOUT_";
036    
037            /**
038             * Default preferences.
039             */
040            public static final String DEFAULT_PREFERENCES = "<portlet-preferences />";
041    
042            /**
043             * User principal strategy for screen name.
044             */
045            public static final String USER_PRINCIPAL_STRATEGY_SCREEN_NAME =
046                    "screenName";
047    
048            /**
049             * User principal strategy for screen name.
050             */
051            public static final String USER_PRINCIPAL_STRATEGY_USER_ID = "userId";
052    
053            /**
054             * Facebook integration method for FBML.
055             */
056            public static final String FACEBOOK_INTEGRATION_FBML = "fbml";
057    
058            /**
059             * Facebook integration method for IFrame.
060             */
061            public static final String FACEBOOK_INTEGRATION_IFRAME = "iframe";
062    
063            /**
064             * Gets the root portlet id of the portlet.
065             *
066             * @return the root portlet id of the portlet
067             */
068            public static String getRootPortletId(String portletId) {
069                    int pos = portletId.indexOf(INSTANCE_SEPARATOR);
070    
071                    if (pos == -1) {
072                            return portletId;
073                    }
074                    else {
075                            return portletId.substring(0, pos);
076                    }
077            }
078    
079            /**
080             * Gets the instance id of the portlet.
081             *
082             * @return the instance id of the portlet
083             */
084            public static String getInstanceId(String portletId) {
085                    int pos = portletId.indexOf(INSTANCE_SEPARATOR);
086    
087                    if (pos == -1) {
088                            return null;
089                    }
090                    else {
091                            return portletId.substring(
092                                    pos + INSTANCE_SEPARATOR.length(), portletId.length());
093                    }
094            }
095    
096    }