1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model;
21  
22  /**
23   * <a href="PortletConstants.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   *
27   */
28  public class PortletConstants {
29  
30      /**
31       * War file separator.
32       */
33      public static final String WAR_SEPARATOR = "_WAR_";
34  
35      /**
36       * Instance separator.
37       */
38      public static final String INSTANCE_SEPARATOR = "_INSTANCE_";
39  
40      /**
41       * Layout separator.
42       */
43      public static final String LAYOUT_SEPARATOR = "_LAYOUT_";
44  
45      /**
46       * Default preferences.
47       */
48      public static final String DEFAULT_PREFERENCES = "<portlet-preferences />";
49  
50      /**
51       * User principal strategy for screen name.
52       */
53      public static final String USER_PRINCIPAL_STRATEGY_SCREEN_NAME =
54          "screenName";
55  
56      /**
57       * User principal strategy for screen name.
58       */
59      public static final String USER_PRINCIPAL_STRATEGY_USER_ID = "userId";
60  
61      /**
62       * Facebook integration method for FBML.
63       */
64      public static final String FACEBOOK_INTEGRATION_FBML = "fbml";
65  
66      /**
67       * Facebook integration method for IFrame.
68       */
69      public static final String FACEBOOK_INTEGRATION_IFRAME = "iframe";
70  
71      /**
72       * Gets the root portlet id of the portlet.
73       *
74       * @param       portletId the portlet id of the portlet
75       * @return      the root portlet id of the portlet
76       */
77      public static String getRootPortletId(String portletId) {
78          int pos = portletId.indexOf(INSTANCE_SEPARATOR);
79  
80          if (pos == -1) {
81              return portletId;
82          }
83          else {
84              return portletId.substring(0, pos);
85          }
86      }
87  
88      /**
89       * Gets the instance id of the portlet.
90       *
91       * @param       portletId the portlet id of the portlet
92       * @return      the instance id of the portlet
93       */
94      public static String getInstanceId(String portletId) {
95          int pos = portletId.indexOf(INSTANCE_SEPARATOR);
96  
97          if (pos == -1) {
98              return null;
99          }
100         else {
101             return portletId.substring(
102                 pos + INSTANCE_SEPARATOR.length(), portletId.length());
103         }
104     }
105 
106 }