001: /*
002: * Created on Mar 16, 2005
003: */
004: package com.sun.portal.wireless.admin;
005:
006: import java.util.HashMap;
007: import java.util.Iterator;
008: import java.util.Map;
009:
010: import com.sun.portal.admin.common.AttributeInfo;
011:
012: /**
013: * Registry for MobileAppAttributeHandler implementation instances.
014: *
015: * @author ashwin.mathew@sun.com
016: */
017: public class MobileAppAttributeHandlerRegistry {
018:
019: // Map of MobileAppAttribute instances for services,
020: // keyed by user-friendly name
021: private static HashMap mailAttrMap = new HashMap();
022: private static HashMap calendarAttrMap = new HashMap();
023: private static HashMap addressBookAttrMap = new HashMap();
024: private static HashMap faxAttrMap = new HashMap();
025:
026: public static void registerHandler(MobileAppAttributeHandler handler) {
027: if (handler.getService().equals(
028: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE)) {
029: mailAttrMap.put(
030: handler.getUserFriendlyName().toLowerCase(),
031: handler);
032: } else if (handler
033: .getService()
034: .equals(
035: MobileAppAttributeHandler.SUN_MOBILE_APP_CALENDAR_SERVICE)) {
036: calendarAttrMap.put(handler.getUserFriendlyName()
037: .toLowerCase(), handler);
038: } else if (handler
039: .getService()
040: .equals(
041: MobileAppAttributeHandler.SUN_MOBILE_APP_ADDRESS_BOOK_SERVICE)) {
042: addressBookAttrMap.put(handler.getUserFriendlyName()
043: .toLowerCase(), handler);
044: } else if (handler.getService().equals(
045: MobileAppAttributeHandler.SUN_MOBILE_APP_FAX_SERVICE)) {
046: faxAttrMap.put(handler.getUserFriendlyName().toLowerCase(),
047: handler);
048: }
049: }
050:
051: public static MobileAppAttributeHandler findHandler(
052: String userFriendlyName, String componentName) {
053: MobileAppAttributeHandler handler = null;
054:
055: if (componentName
056: .equals(MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE)) {
057: handler = (MobileAppAttributeHandler) mailAttrMap
058: .get(userFriendlyName.toLowerCase());
059: } else if (componentName
060: .equals(MobileAppAttributeHandler.SUN_MOBILE_APP_CALENDAR_SERVICE)) {
061: handler = (MobileAppAttributeHandler) calendarAttrMap
062: .get(userFriendlyName.toLowerCase());
063: } else if (componentName
064: .equals(MobileAppAttributeHandler.SUN_MOBILE_APP_ADDRESS_BOOK_SERVICE)) {
065: handler = (MobileAppAttributeHandler) addressBookAttrMap
066: .get(userFriendlyName.toLowerCase());
067: } else if (componentName
068: .equals(MobileAppAttributeHandler.SUN_MOBILE_APP_FAX_SERVICE)) {
069: handler = (MobileAppAttributeHandler) faxAttrMap
070: .get(userFriendlyName.toLowerCase());
071: }
072:
073: return handler;
074: }
075:
076: public static Map listAttributes(String componentName) {
077: HashMap attrMap = null;
078:
079: if (componentName
080: .equals(MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE)) {
081: attrMap = mailAttrMap;
082: } else if (componentName
083: .equals(MobileAppAttributeHandler.SUN_MOBILE_APP_CALENDAR_SERVICE)) {
084: attrMap = calendarAttrMap;
085: } else if (componentName
086: .equals(MobileAppAttributeHandler.SUN_MOBILE_APP_ADDRESS_BOOK_SERVICE)) {
087: attrMap = addressBookAttrMap;
088: } else if (componentName
089: .equals(MobileAppAttributeHandler.SUN_MOBILE_APP_FAX_SERVICE)) {
090: attrMap = faxAttrMap;
091: }
092:
093: return listAttributes(attrMap);
094: }
095:
096: private static Map listAttributes(HashMap attrMap) {
097: Map attrList = new HashMap();
098:
099: Iterator keys = attrMap.keySet().iterator();
100: while (keys.hasNext()) {
101: String key = (String) keys.next();
102: MobileAppAttributeHandler handler = (MobileAppAttributeHandler) attrMap
103: .get(key);
104:
105: attrList.put(handler.getUserFriendlyName(), handler
106: .getAttributeInfoList());
107: }
108:
109: return attrList;
110: }
111:
112: // Register all the attribute handlers
113: static {
114: // Mail attributes
115:
116: registerHandler(new DefaultPipeMobileAppAttributeHandler(
117: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
118: "sunMobileAppMailJspNumFolders", "foldersPerPage",
119: MobileAppAttributeHandler.SCOPE_GLOBAL,
120: AttributeInfo.LIST_STRING,
121: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
122:
123: registerHandler(new DefaultPipeMobileAppAttributeHandler(
124: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
125: "sunMobileAppMailJspInboxNumLines",
126: "inboxLinesPerPage",
127: MobileAppAttributeHandler.SCOPE_GLOBAL,
128: AttributeInfo.LIST_STRING,
129: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
130:
131: registerHandler(new DefaultPipeMobileAppAttributeHandler(
132: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
133: "sunMobileAppMailJspMsgNumLines",
134: "messageLinesPerPage",
135: MobileAppAttributeHandler.SCOPE_GLOBAL,
136: AttributeInfo.LIST_STRING,
137: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
138:
139: registerHandler(new DefaultPipeMobileAppAttributeHandler(
140: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
141: "sunMobileAppMailJspFromLength", "fromHeaderLength",
142: MobileAppAttributeHandler.SCOPE_GLOBAL,
143: AttributeInfo.LIST_STRING,
144: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
145:
146: registerHandler(new DefaultPipeMobileAppAttributeHandler(
147: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
148: "sunMobileAppMailJspSubjectLength",
149: "subjectHeaderLength",
150: MobileAppAttributeHandler.SCOPE_GLOBAL,
151: AttributeInfo.LIST_STRING,
152: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
153:
154: registerHandler(new DefaultMobileAppAttributeHandler(
155: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
156: "sunMobileAppMailOutboundMailCharset",
157: "outboundMailCharsets",
158: MobileAppAttributeHandler.SCOPE_GLOBAL,
159: AttributeInfo.LIST_STRING, AttributeInfo.LIST_STRING,
160: AttributeInfo.READ_WRITE));
161:
162: registerHandler(new DefaultMobileAppAttributeHandler(
163: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
164: "sunMobileAppMailDefaultMailDomain",
165: "defaultMailDomain",
166: MobileAppAttributeHandler.SCOPE_ORGANIZATION,
167: AttributeInfo.SINGLE_STRING,
168: AttributeInfo.SINGLE_STRING, AttributeInfo.READ_WRITE));
169:
170: registerHandler(new DefaultMobileAppAttributeHandler(
171: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
172: "sunMobileAppMailSignature", "emailSignature",
173: MobileAppAttributeHandler.SCOPE_USER,
174: AttributeInfo.SINGLE_STRING,
175: AttributeInfo.SINGLE_STRING, AttributeInfo.READ_WRITE));
176:
177: registerHandler(new PredefinedRepliesMobileAppAttributeHandler(
178: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
179: "sunMobileAppMailPredefinedReplies",
180: "predefinedReplies",
181: MobileAppAttributeHandler.SCOPE_USER,
182: AttributeInfo.LIST_STRING, AttributeInfo.LIST_STRING,
183: AttributeInfo.READ_WRITE));
184:
185: // The next two should be ConfigURL attr handlers, at the user level
186: registerHandler(new DefaultMobileAppAttributeHandler(
187: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
188: "sunMobileAppMailConfig", "sentFolderCopy",
189: MobileAppAttributeHandler.SCOPE_GLOBAL,
190: AttributeInfo.LIST_STRING,
191: AttributeInfo.SINGLE_BOOLEAN, AttributeInfo.READ_WRITE));
192:
193: registerHandler(new DefaultMobileAppAttributeHandler(
194: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE,
195: "sunMobileAppMailConfig", "fromAddress",
196: MobileAppAttributeHandler.SCOPE_GLOBAL,
197: AttributeInfo.LIST_STRING, AttributeInfo.SINGLE_STRING,
198: AttributeInfo.READ_WRITE));
199:
200: /* Doesn't make sense to support these via CLI
201: registerHandler(new DefaultMobileAppAttributeHandler(
202: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE ,
203: "sunMobileAppMailViewClients",
204: "perClientViews",
205: MobileAppAttributeHandler.SCOPE_USER,
206: AttributeInfo.LIST_STRING,
207: AttributeInfo.READ_WRITE));
208:
209: registerHandler(new DefaultMobileAppAttributeHandler(
210: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE ,
211: "sunMobileAppMailViews",
212: "views",
213: MobileAppAttributeHandler.SCOPE_USER,
214: AttributeInfo.LIST_STRING,
215: AttributeInfo.READ_WRITE));
216:
217: registerHandler(new DefaultMobileAppAttributeHandler(
218: MobileAppAttributeHandler.SUN_MOBILE_APP_MAIL_SERVICE ,
219: "sunMobileAppMailViewRules",
220: "viewRules",
221: MobileAppAttributeHandler.SCOPE_USER,
222: AttributeInfo.LIST_STRING,
223: AttributeInfo.READ_WRITE));*/
224:
225: // Calendar attributes
226: registerHandler(new DefaultPipeMobileAppAttributeHandler(
227: MobileAppAttributeHandler.SUN_MOBILE_APP_CALENDAR_SERVICE,
228: "sunMobileAppCalendarJspCalendarNumLines",
229: "displayCalendarsPerPage",
230: MobileAppAttributeHandler.SCOPE_GLOBAL,
231: AttributeInfo.LIST_STRING,
232: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
233:
234: registerHandler(new DefaultPipeMobileAppAttributeHandler(
235: MobileAppAttributeHandler.SUN_MOBILE_APP_CALENDAR_SERVICE,
236: "sunMobileAppCalendarJspEventNumLines",
237: "eventsPerPage",
238: MobileAppAttributeHandler.SCOPE_GLOBAL,
239: AttributeInfo.LIST_STRING,
240: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
241:
242: registerHandler(new DefaultPipeMobileAppAttributeHandler(
243: MobileAppAttributeHandler.SUN_MOBILE_APP_CALENDAR_SERVICE,
244: "sunMobileAppCalendarJspSummaryLength",
245: "eventSummaryLength",
246: MobileAppAttributeHandler.SCOPE_GLOBAL,
247: AttributeInfo.LIST_STRING,
248: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
249:
250: registerHandler(new DefaultPipeMobileAppAttributeHandler(
251: MobileAppAttributeHandler.SUN_MOBILE_APP_CALENDAR_SERVICE,
252: "sunMobileAppCalendarJspLocationLength",
253: "eventLocationLength",
254: MobileAppAttributeHandler.SCOPE_GLOBAL,
255: AttributeInfo.LIST_STRING,
256: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
257:
258: registerHandler(new DefaultPipeMobileAppAttributeHandler(
259: MobileAppAttributeHandler.SUN_MOBILE_APP_CALENDAR_SERVICE,
260: "sunMobileAppCalendarJspDescLength",
261: "eventDescriptionLength",
262: MobileAppAttributeHandler.SCOPE_GLOBAL,
263: AttributeInfo.LIST_STRING,
264: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
265:
266: // Address Book attributes
267:
268: registerHandler(new DefaultPipeMobileAppAttributeHandler(
269: MobileAppAttributeHandler.SUN_MOBILE_APP_ADDRESS_BOOK_SERVICE,
270: "sunMobileAppABJspAbNumLines", "displayLinesPerPage",
271: MobileAppAttributeHandler.SCOPE_GLOBAL,
272: AttributeInfo.LIST_STRING,
273: AttributeInfo.SINGLE_NUMERIC, AttributeInfo.READ_WRITE));
274:
275: // These two are URL config sorts as well, at the user level
276: registerHandler(new DefaultMobileAppAttributeHandler(
277: MobileAppAttributeHandler.SUN_MOBILE_APP_ADDRESS_BOOK_SERVICE,
278: "sunMobileAppABConfig", "sortBy",
279: MobileAppAttributeHandler.SCOPE_GLOBAL,
280: AttributeInfo.LIST_STRING, AttributeInfo.SINGLE_STRING,
281: AttributeInfo.READ_WRITE));
282:
283: registerHandler(new DefaultMobileAppAttributeHandler(
284: MobileAppAttributeHandler.SUN_MOBILE_APP_ADDRESS_BOOK_SERVICE,
285: "sunMobileAppABConfig", "sortOrder",
286: MobileAppAttributeHandler.SCOPE_GLOBAL,
287: AttributeInfo.LIST_STRING, AttributeInfo.SINGLE_STRING,
288: AttributeInfo.READ_WRITE));
289:
290: // Fax attributes
291:
292: registerHandler(new DefaultMobileAppAttributeHandler(
293: MobileAppAttributeHandler.SUN_MOBILE_APP_FAX_SERVICE,
294: "sunPortalFaxServiceProviderMailId",
295: "faxServiceProviderMailId",
296: MobileAppAttributeHandler.SCOPE_ORGANIZATION,
297: AttributeInfo.LIST_STRING, AttributeInfo.SINGLE_STRING,
298: AttributeInfo.READ_WRITE));
299:
300: registerHandler(new DefaultMobileAppAttributeHandler(
301: MobileAppAttributeHandler.SUN_MOBILE_APP_FAX_SERVICE,
302: "sunPortalFaxFromAddress", "faxFromAddress",
303: MobileAppAttributeHandler.SCOPE_ORGANIZATION,
304: AttributeInfo.LIST_STRING, AttributeInfo.SINGLE_STRING,
305: AttributeInfo.READ_WRITE));
306:
307: registerHandler(new DefaultMobileAppAttributeHandler(
308: MobileAppAttributeHandler.SUN_MOBILE_APP_FAX_SERVICE,
309: "sunPortalFaxSubject", "faxSubject",
310: MobileAppAttributeHandler.SCOPE_ORGANIZATION,
311: AttributeInfo.LIST_STRING, AttributeInfo.SINGLE_STRING,
312: AttributeInfo.READ_WRITE));
313: }
314:
315: }
|