01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.rewriter.services.ids;
06:
07: import com.sun.portal.rewriter.rom.InvalidXMLException;
08: import com.sun.portal.rewriter.services.DataService;
09: import com.sun.portal.rewriter.services.DataServiceException;
10: import com.sun.portal.rewriter.services.DataServiceHelper;
11: import com.sun.portal.rewriter.util.ConfigManager;
12: import com.sun.portal.rewriter.util.Constants;
13: import com.sun.portal.rewriter.util.Debug;
14:
15: import java.util.Observable;
16: import java.util.Properties;
17: import java.util.Set;
18:
19: public final class IDSDataService implements DataService {
20: private static final String TESTS_DATA_SOURCE_CLASS = "com.sun.portal.rewriter.services.ids.test.MockIDSDataSource";
21: private static final String IDS_DATA_SOURCE_CLASS = "com.sun.portal.rewriter.services.ids.IDSDataSource";
22:
23: private DataSource dataSource;
24:
25: static {
26: DataServiceHelper
27: .initLogSystem(java.util.logging.FileHandler.class);
28: }
29:
30: public IDSDataService(final Properties aProps) {
31: final String type = aProps.getProperty(
32: Constants.PROPERTY_DATA_SOURCE_TYPE, "test");
33: String implClass = IDS_DATA_SOURCE_CLASS;
34:
35: if ("test".equals(type)) {
36: implClass = TESTS_DATA_SOURCE_CLASS;
37: }
38:
39: try {
40: dataSource = (DataSource) (Class.forName(implClass))
41: .newInstance();
42: } catch (Exception e) {
43: ConfigManager
44: .componentPanic(
45: "Unable to Load IDSDataService class, check the build.xml file\n",
46: e);
47: }
48: }//constructor
49:
50: public String storeXML(final String aRuleSetIDKey,
51: final String aXMLRuleSet) throws DataServiceException,
52: UnsupportedOperationException {
53: throw new UnsupportedOperationException(
54: "\"storeXML\" is not supported in IDS");
55: }//storeXML()
56:
57: public String deleteKey(final String aRuleSetID)
58: throws DataServiceException, UnsupportedOperationException {
59: throw new UnsupportedOperationException(
60: "\"deleteKey\" is not supported in IDS");
61: }//deleteKey()
62:
63: /**
64: * aRuleSetIDKey - is not used in ids as there is only one ruleset.
65: */
66: public String retrieveXML(final String aRuleSetIDKey)
67: throws DataServiceException {
68: try {
69: return IDSRuleSetBuilder.createRuleSet(dataSource).toXML();
70: } catch (InvalidXMLException e) {
71: Debug
72: .error(
73: "This Exception should never come IDSDataService as ID is hardcode to small case",
74: e);
75: return null;
76: }
77: }//retrieveXML()
78:
79: public Set retrieveKeys() throws DataServiceException {
80: return null;
81: }//retrieveKeys()
82:
83: public Observable getChangeNotifier() {
84: return new Observable();
85: }//getChangeNotifier()
86:
87: public String matchesWithID(final String aKey)
88: throws DataServiceException {
89: return null;
90: }//matchesWithID()
91:
92: public static void main(final String[] args)
93: throws DataServiceException {
94: Debug.println(new IDSDataService(new Properties())
95: .retrieveXML(null));
96: }//main()
97:
98: }//class IDSDataService
|