Source Code Cross Referenced for DPAModify.java in  » Portal » Open-Portal » com » sun » portal » desktop » dp » cli » 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.desktop.dp.cli 
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.desktop.dp.cli;
006:
007:        import java.util.Map;
008:        import java.util.Set;
009:        import java.util.Iterator;
010:        import java.util.logging.Level;
011:        import java.util.logging.Logger;
012:
013:        import org.w3c.dom.Element;
014:        import org.xml.sax.SAXParseException;
015:
016:        import java.io.InputStream;
017:        import java.io.StringReader;
018:        import com.sun.portal.desktop.context.AdminDPContext;
019:        import com.sun.portal.desktop.context.DPContext;
020:
021:        import com.sun.portal.desktop.dp.DPError;
022:        import com.sun.portal.desktop.dp.DPRoot;
023:        import com.sun.portal.desktop.dp.DPNode;
024:        import com.sun.portal.desktop.dp.DPProvider;
025:        import com.sun.portal.desktop.dp.DPPropertyHolder;
026:        import com.sun.portal.desktop.dp.DPContainerChannel;
027:        import com.sun.portal.desktop.dp.DPChannel;
028:        import com.sun.portal.desktop.dp.DPProperties;
029:        import com.sun.portal.desktop.dp.DPCollection;
030:        import com.sun.portal.desktop.dp.DPProperty;
031:        import com.sun.portal.desktop.dp.DPCollection;
032:        import com.sun.portal.desktop.dp.DPReferenceList;
033:
034:        import com.sun.portal.desktop.dp.xml.XMLDPFactory;
035:        import com.sun.portal.desktop.dp.xml.XMLDPTags;
036:        import com.sun.portal.desktop.dp.xml.XMLDPCollection;
037:        import com.sun.portal.desktop.dp.xml.XMLDPRoot;
038:        import com.sun.portal.desktop.dp.xml.XMLDPNode;
039:        import com.sun.portal.desktop.dp.xml.XMLDPPropertyHolder;
040:        import com.sun.portal.desktop.dp.xml.XMLDPContainerChannel;
041:        import com.sun.portal.desktop.dp.xml.XMLDPProperties;
042:        import com.sun.portal.desktop.dp.xml.XMLDPReferenceList;
043:        import com.sun.portal.log.common.PortalLogger;
044:
045:        import java.util.logging.Level;
046:        import java.util.logging.Logger;
047:
048:        class DPAModify {
049:
050:            private static Logger logger = PortalLogger
051:                    .getLogger(DPAModify.class);
052:            // XML DP Factory
053:            XMLDPFactory dpf = XMLDPFactory.getInstance();
054:
055:            boolean verbose = false;
056:
057:            public void process(AdminDPContext adc, String dn, boolean global,
058:                    String parent, boolean combine,
059:                    InputStream[] xmlByteStreams, boolean verbose,
060:                    boolean dryrun, Logger logger) throws DPAException {
061:
062:                this .verbose = verbose;
063:
064:                if (verbose) {
065:                    logger.log(Level.FINEST, "PSDT_CSPDDC0023");
066:                }
067:
068:                // get document
069:                String doc = null;
070:                try {
071:                    if (!global) {
072:                        doc = adc.getDPDocument(dn);
073:                    } else {
074:                        doc = adc.getGlobalDPDocument();
075:                    }
076:                } catch (Throwable ex) {
077:                    Object[] tokens = { global ? DPAUtil
078:                            .getLocalizedString("msgGlobal") : dn };
079:                    throw new DPAException("errorRetrieveDP", ex, tokens);
080:                }
081:                // build dproot
082:                DPRoot dpr = null;
083:                try {
084:                    if (doc != null && doc.length() > 0) {
085:                        dpr = dpf.createRoot(adc, doc);
086:                    }
087:                } catch (Throwable ex) {
088:                    Object[] tokens = { global ? DPAUtil
089:                            .getLocalizedString("msgGlobal") : dn };
090:                    throw new DPAException("errorCreateDPRoot", ex, tokens);
091:                }
092:
093:                // iterate over xml input
094:                for (int i = 0; i < xmlByteStreams.length; i++) {
095:                    dpr = doModify(adc, dn, global, parent, combine,
096:                            xmlByteStreams[i], verbose, dpr);
097:                }
098:
099:                if (verbose) {
100:                    logger.log(Level.FINEST, "PSDT_CSPDDC0024");
101:                }
102:
103:                //
104:                // FIXME(susu): thre may be a better way to check for
105:                //              invalid xml.
106:                //
107:
108:                // check for invalid XML
109:                String dpDoc = null;
110:                try {
111:                    //
112:                    // set dirty to false before writing out.
113:                    // not doing this will cause "dirty=true" attribute to
114:                    // be added which will then cause validation error.
115:                    //
116:                    if (dpr.isDirty()) {
117:                        dpr.setDirty(false);
118:                    }
119:                    dpDoc = dpr.toString();
120:                    dpf.createRoot(adc, dpDoc);
121:                } catch (DPError de) {
122:                    Throwable wrapped = de.getCause();
123:                    if (wrapped != null && wrapped instanceof  SAXParseException) {
124:                        SAXParseException spe = (SAXParseException) wrapped;
125:                        int linenum = spe.getLineNumber();
126:                        Object[] tokens = { DPAUtil.getLines(new StringReader(
127:                                dpDoc), linenum) };
128:                        throw new DPAException("errorInvalidXMLText", de,
129:                                tokens);
130:                    }
131:                } catch (Throwable ex) {
132:                    throw new DPAException("errorInvalidXML", ex);
133:                }
134:
135:                // write out changed dp only if dryrun is off
136:                if (!dryrun) {
137:                    if (verbose) {
138:                        logger.log(Level.FINEST, "PSDT_CSPDDC0025");
139:                    }
140:                    try {
141:                        StringBuffer sb = new StringBuffer(256);
142:                        dpr.toXML(sb, 0);
143:                        if (!global) {
144:                            adc.storeDPDocument(dn, sb.toString());
145:                        } else {
146:                            adc.storeGlobalDPDocument(sb.toString());
147:                        }
148:                    } catch (Throwable ex) {
149:                        throw new DPAException("errorStoreDP", ex);
150:                    }
151:                }
152:            }
153:
154:            private DPRoot doModify(AdminDPContext adc, String dn,
155:                    boolean global, String parent, boolean combine,
156:                    InputStream xmlByteStream, boolean verbose, DPRoot dpr)
157:                    throws DPAException {
158:
159:                Element element = DPAUtil.getElement(adc, xmlByteStream);
160:                String tag = element.getTagName();
161:
162:                if (verbose) {
163:                    Object[] tokens = { tag };
164:                    logger.log(Level.FINEST, "PSDT_CSPDDC0026", tokens);
165:                }
166:
167:                // combine flag is only supported for certain tags
168:                if (!tag.equals(XMLDPTags.DISPLAYPROFILE_TAG)
169:                        && !tag.equals(XMLDPTags.CHANNEL_TAG)
170:                        && !tag.equals(XMLDPTags.CONTAINER_TAG)
171:                        && !tag.equals(XMLDPTags.PROPERTIES_TAG)
172:                        && !tag.equals(XMLDPTags.COLLECTION_TAG)
173:                        && !tag.equals(XMLDPTags.CONDITIONALPROPERTIES_TAG)
174:                        && !tag.equals(XMLDPTags.LOCALE_TAG)
175:                        && !tag.equals(XMLDPTags.AVAILABLE_TAG)
176:                        && !tag.equals(XMLDPTags.SELECTED_TAG)) {
177:
178:                    if (combine) {
179:                        Object[] tokens = { tag };
180:                        throw new DPAException("errorCombineNotSupported",
181:                                tokens);
182:                    }
183:                }
184:
185:                // modifying dp
186:                if (tag.equals(XMLDPTags.DISPLAYPROFILE_TAG)) {
187:
188:                    if (parent != null) {
189:                        Object[] tokens = { parent };
190:                        throw new DPAException("errorCannotHaveParent", tokens);
191:                    }
192:                    dpr = doModifyDP(adc, dn, global, combine, element, dpr);
193:
194:                } else {
195:
196:                    // modify dp obj.
197:                    if (tag.equals(XMLDPTags.CHANNEL_TAG)
198:                            || tag.equals(XMLDPTags.CONTAINER_TAG)) {
199:
200:                        dpr = doModifyChannel(adc, dpr, parent, combine,
201:                                element);
202:
203:                    } else if (tag.equals(XMLDPTags.PROVIDER_TAG)) {
204:
205:                        if (parent != null) {
206:                            Object[] tokens = { parent };
207:                            throw new DPAException(
208:                                    "errorProviderCannotHaveParent", tokens);
209:                        }
210:                        dpr = doModifyProvider(adc, dpr, element);
211:
212:                    } else if (tag.equals(XMLDPTags.STRING_TAG)
213:                            || tag.equals(XMLDPTags.BOOLEAN_TAG)
214:                            || tag.equals(XMLDPTags.INTEGER_TAG)
215:                            || tag.equals(XMLDPTags.COLLECTION_TAG)
216:                            || tag.equals(XMLDPTags.CONDITIONALPROPERTIES_TAG)
217:                            || tag.equals(XMLDPTags.LOCALE_TAG)) {
218:
219:                        dpr = doModifyProperty(adc, dpr, parent, combine,
220:                                element);
221:
222:                    } else if (tag.equals(XMLDPTags.PROPERTIES_TAG)) {
223:
224:                        dpr = doModifyProperties(adc, dpr, parent, combine,
225:                                element);
226:
227:                    } else if (tag.equals(XMLDPTags.AVAILABLE_TAG)
228:                            || tag.equals(XMLDPTags.SELECTED_TAG)) {
229:
230:                        if (parent == null) {
231:                            throw new DPAException("errorParentUnspecified");
232:                        }
233:                        dpr = doModifyList(adc, dpr, parent, combine, element,
234:                                tag);
235:
236:                    } else {
237:                        Object[] tokens = { tag };
238:                        throw new DPAException("errorUnsupportedTag", tokens);
239:                    }
240:                }
241:
242:                return dpr;
243:            }
244:
245:            private DPRoot doModifyDP(AdminDPContext adc, String dn,
246:                    boolean global, boolean combine, Element element, DPRoot dpr)
247:                    throws DPAException {
248:
249:                if (verbose) {
250:                    Object[] tokens = { global ? DPAUtil
251:                            .getLocalizedString("msgGlobal") : dn };
252:                    logger.log(Level.FINEST, "PSDT_CSPDDC0027", tokens);
253:                }
254:
255:                StringBuffer doc = null;
256:                DPRoot newDpr = null;
257:                try {
258:                    newDpr = dpf.getRoot(adc, element);
259:                } catch (Throwable ex) {
260:                    throw new DPAException("errorInvalidXML", ex);
261:                }
262:
263:                if (combine) {
264:                    //
265:                    // first, check to make sure that the DP is a valid XML
266:                    //
267:                    if (verbose) {
268:                        logger.log(Level.FINEST, "PSDT_CSPDDC0028");
269:                    }
270:
271:                    //
272:                    // FIXME(susu): thre may be a better way to check for
273:                    //              invalid xml.
274:                    //
275:
276:                    String dpDoc = null;
277:                    try {
278:                        dpDoc = newDpr.toString();
279:                        dpf.createRoot(adc, dpDoc);
280:                    } catch (DPError de) {
281:                        Throwable wrapped = de.getCause();
282:                        if (wrapped != null
283:                                && wrapped instanceof  SAXParseException) {
284:                            SAXParseException spe = (SAXParseException) wrapped;
285:                            int linenum = spe.getLineNumber();
286:                            Object[] tokens = { DPAUtil.getLines(
287:                                    new StringReader(dpDoc), linenum) };
288:                            throw new DPAException("errorInvalidXMLText", de,
289:                                    tokens);
290:                        }
291:                    } catch (Throwable ex) {
292:                        throw new DPAException("errorInvalidXML", ex);
293:                    }
294:
295:                    if (dpr != null) {
296:                        DPAUtil.combineRoots(dpr, newDpr);
297:                        newDpr = dpr;
298:                    }
299:                    // else {
300:                    //   original doc was empty
301:                    //   just replace the entire content with the new dp.
302:                    // }
303:                }
304:
305:                return newDpr;
306:            }
307:
308:            private DPRoot doModifyChannel(DPContext adc, DPRoot dpr,
309:                    String parent, boolean combine, Element element)
310:                    throws DPAException {
311:
312:                if (verbose) {
313:                    Object[] tokens = {
314:                            element.getAttribute("name"),
315:                            (parent == null ? DPAUtil
316:                                    .getLocalizedString("msgRoot") : parent) };
317:
318:                    logger.log(Level.FINEST, "PSDT_CSPDDC0029", tokens);
319:                }
320:
321:                DPNode node = null;
322:                try {
323:                    if (parent == null) {
324:                        node = dpr;
325:                    } else {
326:                        if (verbose) {
327:                            Object[] tokens = { parent };
328:                            logger.log(Level.FINEST, "PSDT_CSPDDC0030", tokens);
329:                        }
330:                        XMLDPRoot xdpr = (XMLDPRoot) dpr;
331:                        node = xdpr.getChannelFromThis(parent);
332:                    }
333:                } catch (Throwable ex) {
334:                    Object[] tokens = { parent == null ? DPAUtil
335:                            .getLocalizedString("msgRoot") : parent };
336:                    throw new DPAException("errorFindParent", ex, tokens);
337:                }
338:
339:                if (node == null) {
340:                    Object[] tokens = { parent == null ? DPAUtil
341:                            .getLocalizedString("msgRoot") : parent };
342:                    throw new DPAException("errorFindParent", tokens);
343:                }
344:
345:                if (verbose) {
346:                    logger.log(Level.FINEST, "PSDT_CSPDDC0031");
347:                }
348:                DPChannel ch = null;
349:                try {
350:                    ch = dpf.getChannel(adc, dpr, element);
351:                } catch (Throwable ex) {
352:                    throw new DPAException("errorCreateDPChannel", ex);
353:                }
354:
355:                if (verbose) {
356:                    Object[] tokens = { parent == null ? DPAUtil
357:                            .getLocalizedString("msgRoot") : parent };
358:                    logger.log(Level.FINEST, "PSDT_CSPDDC0032", tokens);
359:                }
360:                DPChannel och = null;
361:                try {
362:                    XMLDPNode xnode = (XMLDPNode) node;
363:                    och = xnode.getChannelFromThis(ch.getName());
364:                } catch (Throwable ex) {
365:                    Object[] tokens = {
366:                            (parent == null ? DPAUtil
367:                                    .getLocalizedString("msgRoot") : parent),
368:                            ch.getName() };
369:                    throw new DPAException("errorLookupChannel", ex, tokens);
370:                }
371:
372:                if (och == null) {
373:                    Object[] tokens = {
374:                            (parent == null ? DPAUtil
375:                                    .getLocalizedString("msgRoot") : parent),
376:                            ch.getName() };
377:                    throw new DPAException("errorFindChannel", tokens);
378:                }
379:
380:                try {
381:                    if (combine) {
382:                        DPAUtil.combineChannels(och, ch);
383:                    } else {
384:                        node.removeChannel(ch.getName());
385:                        node.addChannel(ch);
386:                    }
387:                } catch (Throwable ex) {
388:                    Object[] tokens = {
389:                            (parent == null ? DPAUtil
390:                                    .getLocalizedString("msgRoot") : parent),
391:                            ch.getName() };
392:                    throw new DPAException("errorModifyChannel", ex, tokens);
393:                }
394:
395:                return dpr;
396:            }
397:
398:            private DPRoot doModifyProvider(DPContext adc, DPRoot dpr,
399:                    Element element) throws DPAException {
400:
401:                if (verbose) {
402:                    Object[] tokens = { element.getAttribute("name") };
403:                    logger.log(Level.FINEST, "PSDT_CSPDDC0033", tokens);
404:                }
405:
406:                if (verbose) {
407:                    logger.log(Level.FINEST, "PSDT_CSPDDC0034");
408:                }
409:                DPProvider p = null;
410:                try {
411:                    p = dpf.getProvider(adc, dpr, element);
412:                } catch (Throwable ex) {
413:                    throw new DPAException("errorCreateDPProvider", ex);
414:                }
415:
416:                if (verbose) {
417:                    logger.log(Level.FINEST, "PSDT_CSPDDC0035");
418:                }
419:                boolean exists = false;
420:                try {
421:                    XMLDPRoot xdpr = (XMLDPRoot) dpr;
422:                    exists = (xdpr.getProviderFromThis(p.getName()) != null);
423:                } catch (Throwable ex) {
424:                    Object[] tokens = { p.getName() };
425:                    throw new DPAException("errorLookupProvider", ex, tokens);
426:                }
427:                if (!exists) {
428:                    Object[] tokens = { p.getName() };
429:                    throw new DPAException("errorFindProvider", tokens);
430:                }
431:
432:                try {
433:                    dpr.removeProvider(p.getName());
434:                    dpr.addProvider(p);
435:                } catch (Throwable ex) {
436:                    Object[] tokens = { p.getName() };
437:                    throw new DPAException("errorModifyProvider", ex, tokens);
438:                }
439:
440:                return dpr;
441:            }
442:
443:            private DPRoot doModifyProperties(DPContext adc, DPRoot dpr,
444:                    String parent, boolean combine, Element element)
445:                    throws DPAException {
446:
447:                if (verbose) {
448:                    Object[] tokens = {
449:                            element.getAttribute("name"),
450:                            (parent == null ? DPAUtil
451:                                    .getLocalizedString("msgRoot") : parent) };
452:                    logger.log(Level.FINEST, "PSDT_CSPDDC0036", tokens);
453:                }
454:
455:                DPPropertyHolder ph = null;
456:                try {
457:                    if (parent == null) {
458:                        ph = dpr;
459:                    } else {
460:                        if (verbose) {
461:                            Object[] tokens = { parent };
462:                            logger.log(Level.FINEST, "PSDT_CSPDDC0037", tokens);
463:                        }
464:                        XMLDPRoot xdpr = (XMLDPRoot) dpr;
465:                        ph = xdpr.getChannelFromThis(parent);
466:                        if (ph == null) {
467:                            ph = xdpr.getProviderFromThis(parent);
468:                        }
469:                    }
470:                } catch (Throwable ex) {
471:                    Object[] tokens = { parent == null ? DPAUtil
472:                            .getLocalizedString("msgRoot") : parent };
473:                    throw new DPAException("errorFindParent", ex, tokens);
474:                }
475:
476:                if (ph == null) {
477:                    Object[] tokens = { parent == null ? DPAUtil
478:                            .getLocalizedString("msgRoot") : parent };
479:                    throw new DPAException("errorFindParent", tokens);
480:                }
481:
482:                if (verbose) {
483:                    logger.log(Level.FINEST, "PSDT_CSPDDC0038");
484:                }
485:                DPCollection c = null;
486:                DPProperties op = null;
487:                try {
488:                    XMLDPPropertyHolder xph = (XMLDPPropertyHolder) ph;
489:                    op = xph.getPropertiesFromThis();
490:
491:                    //
492:                    // treat what is actually a Properties element as
493:                    // a Collection. this is to avoid the
494:                    // look in the provider, look in parent node
495:                    // semantics that are include in the 
496:                    // XMLDPProperties class
497:                    //
498:                    c = dpf.getCollectionProperty(adc, dpr, element);
499:                } catch (Throwable ex) {
500:                    throw new DPAException("errorCreateDPProperties", ex);
501:                }
502:
503:                try {
504:                    if (combine) {
505:                        DPAUtil.combineProperties(op, c);
506:                    } else {
507:                        op.removeAll();
508:
509:                        //
510:                        // FIXME(susu): is there a quicker way to do this
511:                        //              than iterating one by one?
512:                        //
513:                        XMLDPCollection xc = (XMLDPCollection) c;
514:                        Set names = xc.getNamesFromThis();
515:                        for (Iterator i = names.iterator(); i.hasNext();) {
516:                            op.add(xc.getFromThis((String) i.next()));
517:                        }
518:
519:                        //
520:                        // reset merge attributes
521:                        //
522:                        XMLDPCollection xmlC = (XMLDPCollection) c;
523:                        Element e = xmlC.getElement();
524:                        op.setMergeType(c.getMergeType());
525:                        op.setLock(xmlC.isLockedElement(e));
526:                        op.setPropagate(xmlC.isPropagateElement(e));
527:                        op.setAdvanced(xmlC.isAdvancedElement(e));
528:                    }
529:                } catch (Throwable ex) {
530:                    Object[] tokens = { parent == null ? DPAUtil
531:                            .getLocalizedString("msgRoot") : parent };
532:                    throw new DPAException("errorModifyProperties", ex, tokens);
533:                }
534:
535:                return dpr;
536:            }
537:
538:            private DPRoot doModifyProperty(DPContext adc, DPRoot dpr,
539:                    String parent, boolean combine, Element element)
540:                    throws DPAException {
541:
542:                if (verbose) {
543:                    Object[] tokens = {
544:                            element.getAttribute("name"),
545:                            (parent == null ? DPAUtil
546:                                    .getLocalizedString("msgRoot") : parent) };
547:                    logger.log(Level.FINEST, "PSDT_CSPDDC0039", tokens);
548:                }
549:
550:                DPPropertyHolder ph = null;
551:                try {
552:                    if (parent == null) {
553:                        ph = dpr;
554:                    } else {
555:                        if (verbose) {
556:                            Object[] tokens = { parent };
557:                            logger.log(Level.FINEST, "PSDT_CSPDDC0040", tokens);
558:                        }
559:                        XMLDPRoot xdpr = (XMLDPRoot) dpr;
560:                        ph = xdpr.getChannelFromThis(parent);
561:                        if (ph == null) {
562:                            ph = xdpr.getProviderFromThis(parent);
563:                        }
564:                    }
565:                } catch (Throwable ex) {
566:                    Object[] tokens = { parent == null ? DPAUtil
567:                            .getLocalizedString("msgRoot") : parent };
568:                    throw new DPAException("errorFindParent", ex, tokens);
569:                }
570:
571:                if (ph == null) {
572:                    Object[] tokens = { parent == null ? DPAUtil
573:                            .getLocalizedString("msgRoot") : parent };
574:                    throw new DPAException("errorFindParent", tokens);
575:                }
576:
577:                if (verbose) {
578:                    logger.log(Level.FINEST, "PSDT_CSPDDC0041");
579:                }
580:                DPProperty p = null;
581:                try {
582:                    p = dpf.getProperty(adc, dpr, element);
583:                } catch (Throwable ex) {
584:                    throw new DPAException("errorCreateDPProperty", ex);
585:                }
586:
587:                if (verbose) {
588:                    Object[] tokens = { parent == null ? DPAUtil
589:                            .getLocalizedString("msgRoot") : parent };
590:                    logger.log(Level.FINEST, "PSDT_CSPDDC0042", tokens);
591:                }
592:                DPProperties props = null;
593:                boolean exists = false;
594:                try {
595:                    XMLDPPropertyHolder xph = (XMLDPPropertyHolder) ph;
596:                    props = xph.getPropertiesFromThis();
597:                    XMLDPProperties xprops = (XMLDPProperties) props;
598:                    exists = (xprops.getFromThis(p.getName()) != null);
599:                } catch (Throwable ex) {
600:                    Object[] tokens = {
601:                            (parent == null ? DPAUtil
602:                                    .getLocalizedString("msgRoot") : parent),
603:                            p.getName() };
604:                    throw new DPAException("PSDT_CSPDDC0043", ex, tokens);
605:                }
606:
607:                if (!exists) {
608:                    Object[] tokens = {
609:                            (parent == null ? DPAUtil
610:                                    .getLocalizedString("msgRoot") : parent),
611:                            p.getName() };
612:                    throw new DPAException("errorFindProperty", tokens);
613:                }
614:
615:                try {
616:                    if (combine) {
617:                        DPCollection c = (DPCollection) p;
618:                        XMLDPProperties xprops = (XMLDPProperties) props;
619:                        DPCollection oc = (DPCollection) xprops.getFromThis(c
620:                                .getName());
621:                        DPAUtil.combineProperties(oc, c);
622:                    } else {
623:                        props.remove(p.getName());
624:                        props.add(p);
625:                    }
626:                } catch (Throwable ex) {
627:                    Object[] tokens = { p };
628:                    throw new DPAException("errorModifyProperty", ex, tokens);
629:                }
630:
631:                return dpr;
632:            }
633:
634:            private DPRoot doModifyList(DPContext adc, DPRoot dpr,
635:                    String parent, boolean combine, Element element, String tag)
636:                    throws DPAException {
637:
638:                if (verbose) {
639:                    Object[] tokens = { tag, parent };
640:                    logger.log(Level.FINEST, "PSDT_CSPDDC0044", tokens);
641:                }
642:                DPNode node = null;
643:                try {
644:                    if (parent == null) {
645:                        node = dpr;
646:                    } else {
647:                        if (verbose) {
648:                            Object[] tokens = { parent };
649:                            logger.log(Level.FINEST, "PSDT_CSPDDC0045", tokens);
650:                        }
651:                        XMLDPRoot xdpr = (XMLDPRoot) dpr;
652:                        node = xdpr.getChannelFromThis(parent);
653:                    }
654:                } catch (Throwable ex) {
655:                    Object[] tokens = { parent == null ? DPAUtil
656:                            .getLocalizedString("msgRoot") : parent };
657:                    throw new DPAException("errorFindParent", ex, tokens);
658:                }
659:
660:                if (node == null) {
661:                    Object[] tokens = { parent == null ? DPAUtil
662:                            .getLocalizedString("msgRoot") : parent };
663:                    throw new DPAException("errorFindParent", tokens);
664:                }
665:
666:                if (!(node instanceof  DPContainerChannel)) {
667:                    Object[] tokens = { parent == null ? DPAUtil
668:                            .getLocalizedString("msgRoot") : parent };
669:                    throw new DPAException("errorParentNotCotainer", tokens);
670:                }
671:
672:                DPContainerChannel cc = (DPContainerChannel) node;
673:                DPReferenceList orl = null;
674:                try {
675:                    XMLDPContainerChannel xcc = (XMLDPContainerChannel) cc;
676:                    if (tag.equals(XMLDPTags.AVAILABLE_TAG)) {
677:                        orl = xcc.getAvailableFromThis();
678:                    } else if (tag.equals(XMLDPTags.SELECTED_TAG)) {
679:                        orl = xcc.getSelectedFromThis();
680:                    }
681:                } catch (Throwable ex) {
682:                    Object[] tokens = {
683:                            tag,
684:                            (parent == null ? DPAUtil
685:                                    .getLocalizedString("msgRoot") : parent) };
686:                    throw new DPAException("errorLookupDPList", ex, tokens);
687:                }
688:
689:                if (verbose) {
690:                    Object[] tokens = { tag };
691:                    logger.log(Level.FINEST, "PSDT_CSPDDC0046", tokens);
692:                }
693:                DPReferenceList rl = null;
694:                try {
695:                    if (tag.equals(XMLDPTags.AVAILABLE_TAG)) {
696:                        rl = dpf.getAvailable(adc, dpr, element);
697:                    } else if (tag.equals(XMLDPTags.SELECTED_TAG)) {
698:                        rl = dpf.getSelected(adc, dpr, element);
699:                    }
700:                } catch (Throwable ex) {
701:                    Object[] tokens = { tag };
702:                    throw new DPAException("errorCreateDPList", ex, tokens);
703:                }
704:
705:                try {
706:                    if (combine) {
707:                        DPAUtil.combineLists(orl, rl);
708:                    } else {
709:                        orl.removeAll();
710:
711:                        //
712:                        // FIXME(susu): is there a quicker way to do this
713:                        //              than iterating one by one?
714:                        //
715:                        XMLDPReferenceList xrl = (XMLDPReferenceList) rl;
716:                        Set names = xrl.getNamesFromThis();
717:                        for (Iterator i = names.iterator(); i.hasNext();) {
718:                            orl.add(xrl.getFromThis((String) i.next()));
719:                        }
720:                        //
721:                        // reset merge attributes
722:                        //
723:                        XMLDPReferenceList xmlRl = (XMLDPReferenceList) rl;
724:                        Element e = xmlRl.getElement();
725:                        orl.setMergeType(rl.getMergeType());
726:                        orl.setLock(xmlRl.isLockedElement(e));
727:                        orl.setAdvanced(xmlRl.isAdvancedElement(e));
728:                    }
729:                } catch (Throwable ex) {
730:                    Object[] tokens = { tag, parent };
731:                    throw new DPAException("errorModifyDPList", ex, tokens);
732:                }
733:                return dpr;
734:            }
735:
736:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.