1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.components.portletregistry;
18
19
20 /***
21 * <p>Helper class for the portlet registry.</p>
22 * @author <a href="dlestrat@apache.org">David Le Strat</a>
23 */
24 public class PortletRegistryHelper
25 {
26
27 /***
28 * <p>Parses the portlet application name from the portlet
29 * unique name.</p>
30 * @param uniqueName The portlet unique name.
31 */
32 public static String parseAppName(String uniqueName)
33 {
34 int split = splitUniqueName(uniqueName);
35 return uniqueName.substring(0, split);
36 }
37
38 /***
39 * <p>Parses the portlet name from the portlet
40 * unique name.</p>
41 * @param uniqueName The portlet unique name.
42 */
43 public static String parsePortletName(String uniqueName)
44 {
45 int split = splitUniqueName(uniqueName);
46 return uniqueName.substring((split + 2), uniqueName.length());
47 }
48
49 /***
50 * <p>Utility method to split the unique name given the
51 * PORTLET_UNIQUE_NAME_SEPARATOR.</p>
52 * @param uniqueName
53 * @return
54 */
55 private static int splitUniqueName(String uniqueName)
56 {
57 int split = 0;
58 if (null != uniqueName)
59 {
60 split = uniqueName.indexOf(PersistenceBrokerPortletRegistry.PORTLET_UNIQUE_NAME_SEPARATOR);
61 }
62 if (split < 1)
63 {
64 throw new IllegalArgumentException(
65 "The unique portlet name, \""
66 + uniqueName
67 + "\"; is not well formed. No "
68 + PersistenceBrokerPortletRegistry.PORTLET_UNIQUE_NAME_SEPARATOR
69 + " delimiter was found.");
70 }
71 return split;
72 }
73
74 }