01: /**
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */package com.sun.portal.rproxy.rewriter.services.idsame;
05:
06: import com.sun.portal.rewriter.services.DataService;
07: import com.sun.portal.log.common.PortalLogger;
08: import com.sun.portal.rewriter.services.DataServiceException;
09: import com.sun.portal.rewriter.services.DataServiceHelper;
10: import com.sun.portal.rewriter.services.idsame.IDSAMEEventListenerImpl;
11: import com.sun.portal.rewriter.util.Debug;
12: import com.sun.portal.rproxy.configservlet.Request;
13: import com.sun.portal.rproxy.configservlet.Response;
14: import com.sun.portal.rproxy.configservlet.client.GetResponseException;
15: import com.sun.portal.rproxy.configservlet.client.SendRequestException;
16: import com.sun.portal.rproxy.configservlet.client.SrapClient;
17: import com.sun.portal.rproxy.rewriter.services.SRAPDataServiceAdapter;
18:
19: import java.rmi.RemoteException;
20: import java.util.Observable;
21: import java.util.Properties;
22:
23: /**
24: * @author sanjib.ghosh@sun.com
25: * @version 1.0
26: */
27: public class IDSAMEDataServiceStub extends SRAPDataServiceAdapter {
28: private static final IDSAMEEventListenerImpl registar = new IDSAMEEventListenerImpl();
29:
30: static {
31: DataServiceHelper
32: .initLogSystem(com.sun.portal.rewriter.services.idsame.IDSAMELogHandler.class);
33: //DataServiceHelper.initLogSystem( java.util.logging.FileHandler.FileHandler.class );
34: }
35:
36: public IDSAMEDataServiceStub(Properties aProperties) {
37: //do nothing
38: }//constructor
39:
40: public String retrieveXML(final String aRuleSetIDKey)
41: throws DataServiceException {
42: String[] arguments = { aRuleSetIDKey };
43:
44: //we don't supply session ID param as rulesets are fetched remotely
45: //which intrun uses AdminUtils username and password.
46: //may be when application specific login is provided we may need
47: //to change this code
48: Request request = new Request("UnUsedSessionIDParm",
49: SERVICE_NAME, RETRIEVE_XML, null, arguments);
50:
51: try {
52: Response response = SrapClient.bootupExecute(request);
53:
54: if (response.isNormal()) {
55: return (String) response.getReturnedObject();
56: } else {
57: Exception e = response.getExceptionObject();
58: if (e instanceof RemoteException) {
59: Debug
60: .error(
61: "IDSAMEDataServiceStub: RemoteException",
62: e);
63: throw new DataServiceException(e.getMessage(), e);
64: } else {
65: RuntimeException x = (RuntimeException) response
66: .getExceptionObject();
67: Debug
68: .error(
69: "IDSAMEDataServiceStub: Non-RemoteException",
70: x);
71: throw x;
72: }
73: }
74: } catch (final SendRequestException aSendRequestException) {
75: throw new DataServiceException(
76: "Not able to send retrieveXML request",
77: aSendRequestException);
78: } catch (final GetResponseException aGetResponseException) {
79: throw new DataServiceException(
80: "Not able to get response for retrieveXML request",
81: aGetResponseException);
82: }
83: }//retrieveXML()
84:
85: public Observable getChangeNotifier() {
86: return registar;
87: }//getChangeNotifier()
88:
89: public static void main(String[] args) {
90: DataService service = new IDSAMEDataServiceStub(
91: new Properties());
92: System.out.println("id = args[0], Value = "
93: + service.retrieveXML(args[0]));
94: }//main()
95:
96: }//IDSAMEDataServiceStub
|