1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model;
16  
17  /**
18   * <a href="PortletConstants.java.html"><b><i>View Source</i></b></a>
19   *
20   * @author Brian Wing Shun Chan
21   */
22  public class PortletConstants {
23  
24      /**
25       * War file separator.
26       */
27      public static final String WAR_SEPARATOR = "_WAR_";
28  
29      /**
30       * Instance separator.
31       */
32      public static final String INSTANCE_SEPARATOR = "_INSTANCE_";
33  
34      /**
35       * Layout separator.
36       */
37      public static final String LAYOUT_SEPARATOR = "_LAYOUT_";
38  
39      /**
40       * Default preferences.
41       */
42      public static final String DEFAULT_PREFERENCES = "<portlet-preferences />";
43  
44      /**
45       * User principal strategy for screen name.
46       */
47      public static final String USER_PRINCIPAL_STRATEGY_SCREEN_NAME =
48          "screenName";
49  
50      /**
51       * User principal strategy for screen name.
52       */
53      public static final String USER_PRINCIPAL_STRATEGY_USER_ID = "userId";
54  
55      /**
56       * Facebook integration method for FBML.
57       */
58      public static final String FACEBOOK_INTEGRATION_FBML = "fbml";
59  
60      /**
61       * Facebook integration method for IFrame.
62       */
63      public static final String FACEBOOK_INTEGRATION_IFRAME = "iframe";
64  
65      /**
66       * Gets the root portlet id of the portlet.
67       *
68       * @return the root portlet id of the portlet
69       */
70      public static String getRootPortletId(String portletId) {
71          int pos = portletId.indexOf(INSTANCE_SEPARATOR);
72  
73          if (pos == -1) {
74              return portletId;
75          }
76          else {
77              return portletId.substring(0, pos);
78          }
79      }
80  
81      /**
82       * Gets the instance id of the portlet.
83       *
84       * @return the instance id of the portlet
85       */
86      public static String getInstanceId(String portletId) {
87          int pos = portletId.indexOf(INSTANCE_SEPARATOR);
88  
89          if (pos == -1) {
90              return null;
91          }
92          else {
93              return portletId.substring(
94                  pos + INSTANCE_SEPARATOR.length(), portletId.length());
95          }
96      }
97  
98  }