01: package com.sun.portal.wsrp.consumer.producermanager.impl;
02:
03: import com.sun.portal.util.ResourceLoader;
04: import com.sun.portal.desktop.ServletContextThreadLocalizer;
05: import com.sun.portal.admin.common.util.AdminUtil;
06: import java.util.*;
07:
08: public class ISConsumerMultiPortalConstants implements ISConstants {
09:
10: //
11: // WSRPConsumer service
12: //
13: public String MP_SERVICE_WSRP_CONSUMER = "SunPortalWSRPConsumerService";
14:
15: //
16: // prefix prepended to all attributes
17: //
18: public String MP_ATTR_PREFIX = "sunPortalWSRPConsumer";
19:
20: //
21: // name for the consumer organizational unit
22: //
23: public String MP_CONSUMER = "WSRPConsumer";
24:
25: //
26: // RDN of the consumer organizational unit
27: //
28: public String MP_RDN_CONSUMER = "ou=" + MP_CONSUMER;
29:
30: private static Map instances = new HashMap(2);
31: private static String staticId = null;
32:
33: private ISConsumerMultiPortalConstants(String id) {
34: validateId(id);
35: if (!id.equals(AdminUtil.UPGRADED_PORTAL)) {
36: id = id.trim();
37: MP_ATTR_PREFIX = "sunPortal" + id + "WSRPConsumer";
38: MP_SERVICE_WSRP_CONSUMER = "SunPortal" + id
39: + "WSRPConsumerService";
40: MP_CONSUMER = "WSRPConsumer" + id;
41: MP_RDN_CONSUMER = "ou=" + MP_CONSUMER;
42:
43: }
44:
45: }
46:
47: private static synchronized void createInstance(String id) {
48: if (!instances.containsKey(id)) {
49: instances.put(id, new ISConsumerMultiPortalConstants(id));
50: }
51: }
52:
53: public static ISConsumerMultiPortalConstants getInstance() {
54: /*Current assumption - only webapps use this method
55: cli's or anything outside the container should not use
56: this method*/
57:
58: if (staticId == null) {
59: staticId = ResourceLoader.getInstance(
60: System.getProperties()).getPortalId();
61: }
62: createInstance(staticId);
63: return (ISConsumerMultiPortalConstants) instances.get(staticId);
64: }
65:
66: public static ISConsumerMultiPortalConstants getInstance(String id) {
67: if (id == null) {
68: return getInstance();
69: }
70: createInstance(id);
71: return (ISConsumerMultiPortalConstants) instances.get(id);
72: }
73:
74: private void validateId(String id) {
75: if (id == null || id.length() == 0) {
76: throw new IllegalArgumentException(
77: "Invalid portal identifier :" + id);
78: } else if (id.matches(".*[^a-zA-Z0-9-].*")) {
79: throw new IllegalArgumentException(
80: "Invalid portal identifier :" + id);
81: }
82: }
83: }
|