Source Code Cross Referenced for GatewayModelImpl.java in  » Portal » Open-Portal » com » sun » portal » rproxy » admin » model » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.rproxy.admin.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.rproxy.admin.model;
006:
007:        import java.util.Set;
008:        import com.sun.portal.log.common.PortalLogger;
009:        import java.util.List;
010:        import java.util.Map;
011:        import java.util.Iterator;
012:        import java.util.ArrayList;
013:        import java.util.HashMap;
014:        import java.util.Arrays;
015:        import java.util.Collections;
016:        import java.util.Properties;
017:        import java.util.StringTokenizer;
018:        import java.util.SortedSet;
019:        import java.util.TreeSet;
020:        import java.util.HashSet;
021:        import java.util.ResourceBundle;
022:        import java.util.Collection;
023:
024:        import javax.servlet.http.HttpServletRequest;
025:
026:        import com.iplanet.sso.SSOException;
027:        import com.iplanet.am.console.base.model.AMModelBase; //import com.iplanet.sm.ServiceConfigManager;
028:        //import com.iplanet.sm.ServiceConfig;
029:        //import com.iplanet.sm.SMSException;
030:        //import com.iplanet.sm.AttributeSchema;
031:        //import com.iplanet.sm.ServiceSchemaManager;
032:        //import com.iplanet.sm.ServiceSchema;
033:        //import com.iplanet.sm.SchemaException;
034:        import com.sun.identity.sm.ServiceConfigManager;
035:        import com.sun.identity.sm.ServiceConfig;
036:        import com.sun.identity.sm.SMSException;
037:        import com.sun.identity.sm.AttributeSchema;
038:        import com.sun.identity.sm.ServiceSchemaManager;
039:        import com.sun.identity.sm.ServiceSchema;
040:        import com.sun.identity.sm.SchemaException;
041:        import com.iplanet.am.util.Locale;
042:        import com.iplanet.am.console.base.model.AMConsoleException;
043:        import com.iplanet.am.console.base.model.AMResourceBundleCache;
044:        import com.iplanet.am.console.base.model.AMAdminConstants;
045:
046:        import com.sun.portal.rproxy.admin.GatewayAdminModelManager;
047:
048:        /**
049:         * Model implemenation for the Rewriter admin UI
050:         * This model implemented is instantiated by all the Rewriter admin viewbeans
051:         */
052:        public class GatewayModelImpl extends AMModelBase implements 
053:                GatewayModel {
054:
055:            private String SERVICE_NAME = "srapGatewayService";
056:            private String SUB_SCHEMA_NAME = "Gateway-Profiles";
057:            private String SUB_SCHEMA_ID = "One-Instance-Profile";
058:            private boolean processed = false;
059:            /* The number of attrs in each schema type.*/
060:            private int schemaSize = 0;
061:
062:            private ResourceBundle svcResBundle = null;
063:
064:            /* The service schemas.*/
065:            private ServiceSchema serviceSchema = null;
066:
067:            /* Sorted list of attribute schemas.*/
068:            private List attrSchemaList = Collections.EMPTY_LIST;
069:
070:            /* Map of configurations */
071:            private HashMap configurationMap = null;
072:
073:            /* Map of configurations */
074:            private String currentConfigurationName = null;
075:
076:            /* map of attributes name=value pairs */
077:            private Map attributes = null;
078:
079:            /* These are set by setCurrentRow method.*/
080:            private AttributeSchema rowAttrSchema = null;
081:
082:            private boolean hasSchema = true;
083:
084:            /**
085:             * Constructor for the Rewriter Model Implementation
086:             * @param req Current HTTP Request
087:             */
088:            public GatewayModelImpl(HttpServletRequest req) {
089:                super (req, "srapgwadminmsg");
090:            }
091:
092:            public Set getConfigNames() {
093:                try {
094:                    Set keyNames = null;
095:                    ServiceConfigManager configManager = new ServiceConfigManager(
096:                            SERVICE_NAME, ssoToken);
097:                    /*
098:                     ServiceConfig config = configManager.getObjectConfig( SUB_SCHEMA_NAME,
099:                     ServiceConfigManager.Type.GLOBAL, null );
100:                     */
101:
102:                    ServiceConfig __config = configManager
103:                            .getGlobalConfig(null);
104:                    ServiceConfig config = __config
105:                            .getSubConfig(SUB_SCHEMA_NAME);
106:
107:                    keyNames = config.getSubConfigNames();
108:                    return keyNames;
109:                } catch (SMSException ex) {
110:                    GatewayAdminModelManager.debugError(
111:                            "GatewayCreateModelImpl : ", ex);
112:                } catch (SSOException ex) {
113:                    GatewayAdminModelManager.debugError(
114:                            "GatewayCreateModelImpl : ", ex);
115:                } catch (Exception ex) {
116:                    GatewayAdminModelManager.debugError(
117:                            "GatewayCreateModelImpl : ", ex);
118:                }
119:                return null;
120:            }
121:
122:            public boolean store(String newConfigName, String oldConfigName) {
123:                boolean success = false;
124:
125:                try {
126:                    ServiceConfigManager configManager = new ServiceConfigManager(
127:                            SERVICE_NAME, ssoToken);
128:                    /*
129:                     ServiceConfig config = configManager.getObjectConfig(SUB_SCHEMA_NAME, ServiceConfigManager.Type.GLOBAL, null );
130:                     */
131:                    ServiceConfig __config = configManager
132:                            .getGlobalConfig(null);
133:                    ServiceConfig config = __config
134:                            .getSubConfig(SUB_SCHEMA_NAME);
135:
136:                    ServiceConfig oldConfig = config
137:                            .getSubConfig(oldConfigName);
138:                    Map attrs = oldConfig.getAttributes();
139:                    config.addSubConfig(newConfigName, SUB_SCHEMA_ID, 1, attrs);
140:                    success = true;
141:                } catch (SMSException ex) {
142:                    GatewayAdminModelManager.debugError(
143:                            "GatewayCreateModelImpl : ", ex);
144:                } catch (SSOException ex) {
145:                    GatewayAdminModelManager.debugError(
146:                            "GatewayCreateModelImpl : ", ex);
147:                } catch (Exception ex) {
148:                    GatewayAdminModelManager.debugError(
149:                            "GatewayCreateModelImpl : ", ex);
150:                }
151:
152:                return success;
153:            }
154:
155:            /**
156:             * This method does the actual work of retrieving the attribute schemas and 
157:             * preparing a list of attributes.
158:             */
159:            public void process(String configName) {
160:                ServiceSchemaManager schemaMgr = null;
161:                String rbFileName = null;
162:
163:                //Get the schema manager.
164:                try {
165:                    schemaMgr = new ServiceSchemaManager(SERVICE_NAME, ssoToken);
166:                } catch (SMSException sms) {
167:                    //TOFIX: Handle this properly
168:                    GatewayAdminModelManager.debugError(
169:                            "GatewayDataModelImpl : " + sms.getMessage(), sms);
170:                    return;
171:                } catch (SSOException ssoe) {
172:                    //TOFIX: Handle this properly
173:                    GatewayAdminModelManager
174:                            .debugError("GatewayDataModelImpl : "
175:                                    + ssoe.getMessage(), ssoe);
176:                    return;
177:                }
178:
179:                //Get the resource bundle or default to super.resBundle
180:                rbFileName = schemaMgr.getI18NFileName();
181:                if (rbFileName != null) {
182:                    AMResourceBundleCache cache = AMResourceBundleCache
183:                            .getInstance();
184:                    svcResBundle = cache.getResBundle(rbFileName,
185:                            getUserLocale());
186:                    if (svcResBundle == null) {
187:                        svcResBundle = cache.getResBundle(
188:                                AMAdminConstants.DEFAULT_RB, getUserLocale());
189:                    }
190:                }
191:
192:                try {
193:                    // the subschema for the gateway service is two levels below
194:                    // get to that level and extract the schema
195:                    ServiceSchema globalSchema = schemaMgr.getGlobalSchema();
196:                    Set subSchemaNames = globalSchema.getSubSchemaNames();
197:                    Iterator i = subSchemaNames.iterator();
198:                    ServiceSchema subSchema = globalSchema
199:                            .getSubSchema((String) i.next());
200:                    subSchemaNames = subSchema.getSubSchemaNames();
201:                    i = subSchemaNames.iterator();
202:                    serviceSchema = subSchema.getSubSchema((String) i.next());
203:
204:                    // get the attribute schemas and its size
205:                    attrSchemaList = getAttributeSchemas(serviceSchema);
206:                    schemaSize = attrSchemaList.size();
207:
208:                    configurationMap = getConfigurations();
209:
210:                } catch (SMSException sms) {
211:                    attrSchemaList = Collections.EMPTY_LIST;
212:                    schemaSize = 0;
213:                    GatewayAdminModelManager.debugError(
214:                            "GatewayDataModelImpl : " + sms.getMessage(), sms);
215:                }
216:
217:                //Schema may be available, but no displayable attrs.
218:                if (schemaSize == 0) {
219:                    hasSchema = false;
220:                }
221:
222:                GatewayAdminModelManager
223:                        .debugMessage("GatewayDataModelImpl : process - "
224:                                + "global attributes = " + schemaSize);
225:
226:                /* Remember that this method has already executed and no need to 
227:                 * repeat the same thing again.*/
228:                processed = true;
229:
230:                setCurrentConfig(configName);
231:            }
232:
233:            private HashMap getConfigurations() {
234:                HashMap configMap = new HashMap();
235:
236:                try {
237:                    // get all the available configurations and load them into a HashMap
238:                    // the HashMap will have configName - SubConfig object
239:                    ServiceConfigManager configManager = new ServiceConfigManager(
240:                            SERVICE_NAME, ssoToken);
241:                    /*
242:                     ServiceConfig config = configManager.getObjectConfig(SUB_SCHEMA_NAME, ServiceConfigManager.Type.GLOBAL, null );
243:                     */
244:
245:                    ServiceConfig __config = configManager
246:                            .getGlobalConfig(null);
247:                    ServiceConfig config = __config
248:                            .getSubConfig(SUB_SCHEMA_NAME);
249:
250:                    Set configNames = config.getSubConfigNames();
251:                    Iterator i = configNames.iterator();
252:
253:                    while (i.hasNext()) {
254:                        String configName = (String) i.next();
255:                        configMap.put(configName, config
256:                                .getSubConfig(configName));
257:                    }
258:
259:                } catch (SMSException ex) {
260:                    GatewayAdminModelManager.debugError(
261:                            "GatewayDataModelImpl : " + ex.getMessage(), ex);
262:                } catch (SSOException ex) {
263:                    GatewayAdminModelManager.debugError(
264:                            "GatewayDataModelImpl : " + ex.getMessage(), ex);
265:                } catch (Exception ex) {
266:                    GatewayAdminModelManager.debugError(
267:                            "GatewayDataModelImpl : " + ex.getMessage(), ex);
268:                }
269:
270:                return configMap;
271:            }
272:
273:            /* 
274:             * Removes the non-displyable attrs and sorts the attr schemas
275:             * on their i18nKey.
276:             */
277:            private List getSortedAttrSchemaList(Collection attrs) {
278:                List list = Collections.EMPTY_LIST;
279:                if (attrs != null) {
280:                    Iterator it = attrs.iterator();
281:                    while (it.hasNext()) {
282:                        AttributeSchema as = (AttributeSchema) it.next();
283:                        if ((as == null) || (as.getI18NKey() == null)
284:                                || (as.getI18NKey().length() == 0)) {
285:                            it.remove();
286:                        }
287:                    }
288:                    //Sort the attributes on i18nKey
289:                    SortedSet set = new TreeSet(
290:                            new GatewayAttributeComparator());
291:                    set.addAll(attrs);
292:                    //Convert the set to list
293:                    ArrayList arrList = new ArrayList(set);
294:                    /* The ArrayList instance has an initial capacity of 110%
295:                     * the size of the specified collection. So trim it.*/
296:                    arrList.trimToSize();
297:                    list = arrList;
298:                }
299:                //Never return a null, instead return an empty list
300:                if (list == null) {
301:                    list = Collections.EMPTY_LIST;
302:                }
303:                return list;
304:            }
305:
306:            /*
307:             * Returns the list of displayable attribute schemas 
308:             * sorted on their i18nKey.
309:             *
310:             * @param svcSchema The service schema.
311:             * @return The list of attribute schemas.
312:             */
313:            private List getAttributeSchemas(ServiceSchema svcSchema) {
314:                List list = Collections.EMPTY_LIST;
315:                Collection attrs = null;
316:                if (svcSchema != null) {
317:                    attrs = svcSchema.getAttributeSchemas();
318:                    if (attrs != null) {
319:                        list = getSortedAttrSchemaList(attrs);
320:                    }
321:                }
322:                return list;
323:            }
324:
325:            /*
326:             * @param viewType One - GLOBAL_TYPE
327:             * @param The row number.
328:             * @return Attribute schema for the attribute in this row.
329:             */
330:            private AttributeSchema getAttrSchema(int row) {
331:                AttributeSchema as = null;
332:                if (row >= 0 && row < schemaSize)
333:                    as = (AttributeSchema) attrSchemaList.get(row);
334:                return as;
335:            }
336:
337:            /*
338:             * Method to store the attributes in the backend.
339:             * @param viewType - GLOBAL_TYPE
340:             * @param map A map of {String attrName, Set attrValues}
341:             * @return True if successful.
342:             */
343:            public boolean store(String configName, Map newMap)
344:                    throws SSOException {
345:                //TOFIX: store method should rethrow a suitable exception
346:                boolean success = false;
347:
348:                if (newMap != null && !newMap.isEmpty()) {
349:                    //If processing already done, then do not repeat
350:                    if (!processed) {
351:                        process(configName);
352:                    }
353:                    ServiceConfig subConfig = (ServiceConfig) configurationMap
354:                            .get(configName);
355:                    try {
356:                        setConfigAttributes(subConfig, newMap);
357:                    } catch (SMSException ex) {
358:                        GatewayAdminModelManager
359:                                .debugError("GatewayDataModelImpl : Store failed");
360:                        GatewayAdminModelManager
361:                                .debugError("GatewayDataModelImpl : "
362:                                        + ex.getMessage(), ex);
363:                    }
364:
365:                }
366:                return success;
367:            }
368:
369:            private void setConfigAttributes(ServiceConfig config, Map newMap)
370:                    throws SSOException, SMSException {
371:                //TOFIX: This method should rethrow a suitable exception
372:                Map diffMap = new HashMap(5);
373:                Set logMsgSet = new HashSet(5);
374:                Map currentMap = config.getAttributes();
375:
376:                if (newMap != null && currentMap != null) {
377:                    Iterator it = currentMap.keySet().iterator();
378:                    while (it.hasNext()) {
379:                        String key = (String) it.next();
380:                        Set currentValue = (Set) currentMap.get(key);
381:                        Set newValue = (Set) newMap.get(key);
382:                        /*
383:                         * Workaround for sms returning set of size 1 with
384:                         * an empty string as the value. Remove such entries.
385:                         */
386:                        if (currentValue != null && currentValue.size() == 1) {
387:                            Iterator setIterator = currentValue.iterator();
388:                            String xx = (String) setIterator.next();
389:                            if (xx != null && xx.length() == 0) {
390:                                setIterator.remove();
391:                            }
392:                        }
393:                        //Prepare a diff now
394:                        if (newValue != null && !newValue.equals(currentValue)) {
395:                            diffMap.put(key, newValue);
396:                            logMsgSet.add(SERVICE_NAME + "." + key + " "
397:                                    + currentValue + "->" + newValue);
398:                            GatewayAdminModelManager
399:                                    .debugMessage("GatewayDataModelImpl.setAttributeDefaults: "
400:                                            + key
401:                                            + " - "
402:                                            + currentValue
403:                                            + " -> " + newValue);
404:                        }
405:                    }
406:                    if (!diffMap.isEmpty()) {
407:                        GatewayAdminModelManager
408:                                .debugMessage("GatewayDataModelImpl.setAttributeDefaults: "
409:                                        + "Number of new attrs = "
410:                                        + diffMap.size());
411:                        try {
412:                            config.setAttributes(diffMap);
413:                            //Now log the changes
414:                            /*                    
415:                             Iterator iter = logMsgSet.iterator();
416:                             while (iter.hasNext()) {
417:                             logger.doLog("service.changed", (String)iter.next());
418:                             }
419:                             */
420:                        } catch (SchemaException se) {
421:                            //TOFIX: Throw it again to caller.
422:                            GatewayAdminModelManager.debugError(
423:                                    "GatewayDataModelImpl.store : ", se);
424:                        } catch (SMSException smse) {
425:                            //TOFIX: Throw it again to caller.
426:                            GatewayAdminModelManager.debugError(
427:                                    "GatewayDataModelImpl.store : ", smse);
428:                        }
429:                    }
430:                }
431:            }
432:
433:            /*
434:             * Returns the number of attributes in the view.
435:             *
436:             * @return Number of attributes in the view.
437:             */
438:            public int getSize() {
439:                return schemaSize;
440:            }
441:
442:            /*
443:             * @return The title of this view.
444:             */
445:            public String getTitle() {
446:                return currentConfigurationName;
447:            }
448:
449:            /**
450:             * @returns Returns true if service has any schema.
451:             */
452:            public boolean hasSchema() {
453:                return hasSchema;
454:            }
455:
456:            /**
457:             * @return The service name.
458:             */
459:            public String getServiceName() {
460:                return SERVICE_NAME;
461:            }
462:
463:            /*
464:             * Sets the current configuration, so that all attribute related operations are 
465:             * performed for the specified configuration This method must be called before
466:             * making any config specific attribute calls. 
467:             *
468:             * @param row The config name.
469:             * @return True is successful.
470:             */
471:            public boolean setCurrentConfig(String configName) {
472:                boolean success = false;
473:                ServiceConfig subConfig = (ServiceConfig) configurationMap
474:                        .get(configName);
475:                if (subConfig != null) {
476:                    success = true;
477:                    //            try {
478:                    attributes = subConfig.getAttributes();
479:                    currentConfigurationName = configName;
480:                    /*
481:                     } catch (SMSException ex) {
482:                     GatewayAdminModelManager.debugError("GatewayDataModelImpl.setCurrentConfig : ", ex);
483:                     success = false;
484:                     }
485:                     */
486:                }
487:                return success;
488:            }
489:
490:            /*
491:             * Sets the current row, so that all attribute related operations are 
492:             * performed for the specified row. This method must be called before
493:             * making any row specific attribute calls. 
494:             *
495:             * @param row The row number.
496:             * @return True is successful.
497:             */
498:            public boolean setCurrentRow(int row) {
499:                boolean success = false;
500:                rowAttrSchema = getAttrSchema(row);
501:                if (rowAttrSchema != null) {
502:                    success = true;
503:                }
504:                return success;
505:            }
506:
507:            /*
508:             * Current row must have been set using setCurrentRow method.
509:             *
510:             * @return The name of the attribute in the current row.
511:             */
512:            public String getAttrName() {
513:                String name = "";
514:                if (rowAttrSchema != null) {
515:                    name = rowAttrSchema.getName();
516:                }
517:                return (name == null ? "" : name);
518:            }
519:
520:            /*
521:             * Current row must have been set using setCurrentRow method.
522:             *
523:             * @return The localized label of the attribute in the current row.
524:             */
525:            public String getAttrLabel() {
526:                String label = "";
527:                if (rowAttrSchema != null) {
528:                    String key = rowAttrSchema.getI18NKey();
529:                    if (key != null) {
530:                        label = Locale.getString(svcResBundle, key, debug);
531:                    }
532:                }
533:                return (label == null ? "" : label);
534:            }
535:
536:            /*
537:             * Current row must have been set using setCurrentRow method.
538:             *
539:             * @return The type of the attribute from attribute schema of current row.
540:             */
541:            public int getAttrType() {
542:                //Default to SINGLE type
543:                int type = 0;
544:                if (rowAttrSchema != null) {
545:                    AttributeSchema.Type attrType = rowAttrSchema.getType();
546:                    if (attrType != null) {
547:                        if (attrType == AttributeSchema.Type.LIST) {
548:                            type = 3;
549:                        } else if (attrType == AttributeSchema.Type.SINGLE_CHOICE) {
550:                            type = 1;
551:                        } else if (attrType == AttributeSchema.Type.MULTIPLE_CHOICE) {
552:                            type = 2;
553:                        }
554:                        //                type = AMDisplayTypeConverter.getDisplayType(attrType);
555:                    }
556:                }
557:                return type;
558:            }
559:
560:            /*
561:             * Current row must have been set using setCurrentRow method.
562:             *
563:             * @return The syntax of the attribute from attribute schema of current row.
564:             */
565:            public int getAttrSyntax() {
566:                //Default to String type
567:                int syntax = 1;
568:                if (rowAttrSchema != null) {
569:                    AttributeSchema.Syntax attrSyn = rowAttrSchema.getSyntax();
570:                    if (attrSyn != null) {
571:                        if (attrSyn == AttributeSchema.Syntax.BOOLEAN) {
572:                            syntax = 0;
573:                        } else if (attrSyn == AttributeSchema.Syntax.PASSWORD) {
574:                            syntax = 2;
575:                        } else if (attrSyn == AttributeSchema.Syntax.PARAGRAPH
576:                                || attrSyn == AttributeSchema.Syntax.XML) {
577:                            syntax = 3;
578:                        }
579:                        //    syntax = AMDisplayTypeConverter.getDisplaySyntax(attrSyn);
580:                    }
581:                }
582:                return syntax;
583:            }
584:
585:            /*
586:             * Current row must have been set using setCurrentRow method.
587:             *
588:             * @return Set of attribute values for current row.
589:             */
590:            public Set getAttrValues() {
591:                Set set = Collections.EMPTY_SET;
592:                if (rowAttrSchema != null) {
593:                    /* Attribute values are the values returned by the sdk. 
594:                     * These should not be localized.*/
595:                    String name = rowAttrSchema.getName();
596:                    Map attrMap = attributes;
597:                    if (name != null && name.length() > 0 && attrMap != null) {
598:                        set = (Set) attrMap.get(name);
599:                        if (set == null) {
600:                            set = Collections.EMPTY_SET;
601:                        }
602:                    }
603:                }
604:                return set;
605:            }
606:
607:            /*
608:             * Current row must have been set using setCurrentRow method.
609:             *
610:             * @return The string array of choices for current row.
611:             */
612:            public String[] getAttrChoices() {
613:                String[] choices = { "" };
614:                if (rowAttrSchema != null) {
615:                    String strArray[] = rowAttrSchema.getChoiceValues();
616:                    if (strArray != null) {
617:                        for (int i = 0; i < strArray.length; i++) {
618:                            String key = rowAttrSchema
619:                                    .getChoiceValueI18NKey(strArray[i]);
620:                            if (key != null) {
621:                                String lStr = Locale.getString(svcResBundle,
622:                                        key, debug);
623:                                if (lStr != null && lStr.length() != 0) {
624:                                    strArray[i] = lStr;
625:                                }
626:                            }
627:                        }
628:                        choices = strArray;
629:                        //Sort the choice list
630:                        Arrays.sort(choices);
631:                    }
632:                }
633:                return choices;
634:            }
635:
636:            /*
637:             * Current row must have been set using setCurrentRow method.
638:             *
639:             * @return The string for true condition of a boolean type in current row.
640:             */
641:            public String getAttrTrueValue() {
642:                String value = "";
643:                if (rowAttrSchema != null) {
644:                    value = rowAttrSchema.getTrueValue();
645:                    if (value == null) {
646:                        value = "";
647:                    } else {
648:                        String key = rowAttrSchema.getTrueValueI18NKey();
649:                        if (key != null) {
650:                            String lValue = Locale.getString(svcResBundle, key
651:                                    + "." + value, debug);
652:                            value = (lValue != null && lValue.length() != 0) ? lValue
653:                                    : value;
654:                        }
655:                    }
656:                }
657:                return value;
658:            }
659:
660:            /*
661:             * Current row must have been set using setCurrentRow method.
662:             *
663:             * @return The string for false condition of a boolean type in current row.
664:             */
665:            public String getAttrFalseValue() {
666:                String value = "";
667:                if (rowAttrSchema != null) {
668:                    value = rowAttrSchema.getFalseValue();
669:                    if (value == null) {
670:                        value = "";
671:                    } else {
672:                        String key = rowAttrSchema.getFalseValueI18NKey();
673:                        if (key != null) {
674:                            String lValue = Locale.getString(svcResBundle, key
675:                                    + "." + value, debug);
676:                            value = (lValue != null && lValue.length() != 0) ? lValue
677:                                    : value;
678:                        }
679:                    }
680:                }
681:                return value;
682:            }
683:
684:            /**
685:             * Deletes a list of gateway profiles.
686:             * @param an array of profile names to be deleted.
687:             * @exception throws Exception when error(s) occurred.
688:             */
689:            public void deleteConfig(String[] config) throws Exception {
690:
691:                try {
692:                    ServiceConfigManager configManager = new ServiceConfigManager(
693:                            SERVICE_NAME, ssoToken);
694:                    ServiceConfig __config = configManager
695:                            .getGlobalConfig(null);
696:                    ServiceConfig subConfig = __config
697:                            .getSubConfig(SUB_SCHEMA_NAME);
698:
699:                    if ((config != null) && (config.length > 0)) {
700:                        for (int i = 0; i < config.length; i++) {
701:                            GatewayAdminModelManager
702:                                    .debugMessage("Delete called for : "
703:                                            + config[i]);
704:                            subConfig.removeSubConfig(config[i]);
705:                        }
706:                    }
707:                    Thread.currentThread().sleep(2000, 0);
708:                } catch (SMSException ex) {
709:                    GatewayAdminModelManager.debugError(
710:                            "GatewayDeleteModelImpl.deleteConfig : ", ex);
711:                } catch (SSOException ex) {
712:                    GatewayAdminModelManager.debugError(
713:                            "GatewayDeleteModelImpl.deleteConfig : ", ex);
714:                } catch (Exception ex) {
715:                    GatewayAdminModelManager.debugError(
716:                            "GatewayDeleteModelImpl.deleteConfig : ", ex);
717:                }
718:            }
719:
720:            /*
721:             *  Returns the number of gateway profiles present in the service configuration
722:             */
723:
724:            public int getGatewayProfileCount() {
725:                try {
726:                    ServiceConfigManager configManager = new ServiceConfigManager(
727:                            SERVICE_NAME, ssoToken);
728:                    ServiceConfig __config = configManager
729:                            .getGlobalConfig(null);
730:                    ServiceConfig config = __config
731:                            .getSubConfig(SUB_SCHEMA_NAME);
732:                    Set keyNames = config.getSubConfigNames();
733:                    return keyNames != null ? keyNames.size() : 0;
734:                } catch (SSOException ex) {
735:                    GatewayAdminModelManager.debugError(
736:                            "GatewaySelectModelImpl.retrieve : ", ex);
737:                } catch (SMSException ex) {
738:                    GatewayAdminModelManager.debugError(
739:                            "GatewaySelectModelImpl.retrieve : ", ex);
740:                }
741:                return 0;
742:            }
743:
744:            /**
745:             * gets the date in the default locale.
746:             *
747:             * @param dates a set of date strings
748:             * @return a set of date strings in the default locale.
749:             */
750:            public Set getDateInDefaultLocale(Set dates)
751:                    throws AMConsoleException {
752:                return super .getDateInDefaultLocale(dates);
753:            }
754:
755:            public int getGWAttributeIndex(String attr) {
756:                String aName = "";
757:                int attrIndex = -1;
758:
759:                for (int i = 0; i < schemaSize; i++) {
760:                    setCurrentRow(i);
761:                    aName = getAttrName();
762:
763:                    if (aName.equals(attr)) {
764:                        attrIndex = i;
765:                        break;
766:                    }
767:                }
768:                return attrIndex;
769:            }
770:
771:            public String getHelpUrl(String docName) {
772:                return getHelpURL(docName);
773:            }
774:
775:            public String getHelpAnchorTag(String key) {
776:                return super.getHelpAnchorTag(key);
777:            }
778:
779:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.