001: /*
002: * $Id: GatewayProfile.java,v 1.12 2005/11/30 11:27:15 ss150821 Exp $
003: * $Source: /m/portal/ps/srap/src/com/sun/portal/rproxy/configservlet/client/GatewayProfile.java,v $
004: * $Log: GatewayProfile.java,v $
005: * Revision 1.12 2005/11/30 11:27:15 ss150821
006: * 6356996 - Srap Code base needs to save files in the unix file format and not windows
007: *
008: * Revision 1.11 2005/02/23 09:14:06 ss150821
009: * RFE 6223490 - SRA Should use JDK based logging
010: *
011: * Revision 1.10 2005/02/23 09:13:04 ss150821
012: * RFE 6223490 - SRA Should use JDK based logging
013: *
014: * Revision 1.9 2004/07/27 12:52:04 vt126379
015: * RFE#5075809, CRT#99
016: *
017: * Revision 1.8 2003/05/14 04:07:02 rt130506
018: * Liberty Support
019: *
020: * Revision 1.7 2003/03/28 07:02:16 rt130506
021: * MAP Fixes
022: *
023: * Revision 1.6 2003/01/23 10:10:12 bv131302
024: * id60 changes merged
025: *
026: * Revision 1.5.12.1 2002/12/30 11:13:47 bv131302
027: * id60 related changes
028: *
029: * Revision 1.5 2002/08/21 11:23:37 bv131302
030: * fix for 4730563
031: *
032: * Revision 1.4 2002/08/16 15:13:05 bv131302
033: * Hana CRT#1888 - Check log settings before logging
034: *
035: * Revision 1.3 2002/07/29 05:07:15 rt130506
036: * CRT 1742
037: *
038: * Revision 1.2 2002/06/21 13:04:13 bv131302
039: * LDAP Attribute name changes
040: *
041: * Revision 1.1 2002/06/14 09:53:48 rt130506
042: * SRAP rebranding
043: *
044: * Revision 1.3 2002/06/11 16:02:10 bv131302
045: * new branded
046: *
047: * Revision 1.2 2002/03/25 14:02:30 mm132998
048: * Bugid : # 4653309 , CRT # 644
049: *
050: *
051: */
052: package com.sun.portal.rproxy.configservlet.client;
053:
054: import java.util.List;
055: import java.util.Map;
056: import java.util.logging.Level;
057: import java.util.logging.Logger;
058:
059: import com.sun.portal.log.common.PortalLogger;
060: import com.sun.portal.rproxy.configservlet.GatewayRequest;
061: import com.sun.portal.rproxy.configservlet.Request;
062: import com.sun.portal.rproxy.configservlet.Response;
063:
064: public class GatewayProfile {
065:
066: private static final String ATTRIBUTE_PREFIX = "sunPortalGateway";
067:
068: private static final String SERVICE_NAME = "srapGatewayService";
069:
070: private static final String GET_REQUEST = "GET_GLOBALS";
071:
072: private static Map result;
073:
074: // private static Logger logger =
075: // Logger.getLogger("com.sun.portal.sra.rproxy");
076: private static Logger logger = PortalLogger
077: .getLogger(GatewayProfile.class);
078:
079: // private contructor
080: private GatewayProfile() {
081: }
082:
083: public static void init(String sessionId)
084: throws SendRequestException, GetResponseException {
085: Request request = new Request(sessionId, SERVICE_NAME,
086: GET_REQUEST);
087: Response response = SrapClient.execute(request);
088: result = (Map) response.getReturnedObject();
089: }
090:
091: public static void init(String sessionId, String instanceName)
092: throws SendRequestException, GetResponseException {
093: GatewayRequest request = new GatewayRequest(sessionId,
094: SERVICE_NAME, "retrieveInstance", instanceName);
095: Response response = null;
096: response = SrapClient.bootupExecute(request);
097: result = (Map) response.getReturnedObject();
098: // Bug ID # 4653309
099: if (result.isEmpty()) {
100: // logger.severe("Gateway Aborting : Unable to retrieve the gateway
101: // profile : " + instanceName);
102: Object[] params0 = { instanceName };
103: logger.log(Level.SEVERE, "PSSRRPROXY_CSPRCSERVLETC002",
104: params0);
105: System.exit(-1);
106: }
107: // EOC : Bug ID # 4653309
108: }
109:
110: public static String getString(String name, String defaultValue) {
111: return AttributeExtractor.getString(result, ATTRIBUTE_PREFIX
112: + name, defaultValue);
113:
114: }
115:
116: public static int getInt(String name, int defaultValue) {
117: return AttributeExtractor.getInt(result, ATTRIBUTE_PREFIX
118: + name, defaultValue);
119: }
120:
121: public static boolean getBoolean(String name, boolean defaultValue) {
122: return AttributeExtractor.getBoolean(result, ATTRIBUTE_PREFIX
123: + name, defaultValue);
124: }
125:
126: public static List getStringList(String name) {
127: return AttributeExtractor.getStringList(result,
128: ATTRIBUTE_PREFIX + name);
129: }
130:
131: public static List getLowerCaseStringList(String name) {
132: return AttributeExtractor.getLowerCaseStringList(result,
133: ATTRIBUTE_PREFIX + name);
134: }
135:
136: public static List getLowerCaseURLList(String name) {
137: return AttributeExtractor.getLowerCaseURLList(result,
138: ATTRIBUTE_PREFIX + name);
139: }
140:
141: public static String getLowerCaseString(String name,
142: String defaultValue) {
143: return AttributeExtractor.getLowerCaseString(result,
144: ATTRIBUTE_PREFIX + name, defaultValue);
145:
146: }
147:
148: }
|