Source Code Cross Referenced for WSRPFactory.java in  » Portal » Open-Portal » com » sun » portal » wsrp » common » 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.wsrp.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * $Id: WSRPFactory.java,v 1.7 2006/03/29 08:48:52 rt130506 Exp $
0003:         * Copyright 2003 Sun Microsystems, Inc. All
0004:         * rights reserved. Use of this product is subject
0005:         * to license terms. Federal Acquisitions:
0006:         * Commercial Software -- Government Users
0007:         * Subject to Standard License Terms and
0008:         * Conditions.
0009:         *
0010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
0011:         * are trademarks or registered trademarks of Sun Microsystems,
0012:         * Inc. in the United States and other countries.
0013:         */package com.sun.portal.wsrp.common;
0014:
0015:        import java.util.List;
0016:        import java.util.Iterator;
0017:        import java.util.Arrays;
0018:
0019:        import java.io.StringReader;
0020:        import java.io.StringWriter;
0021:        import java.io.ByteArrayInputStream;
0022:        import java.io.ByteArrayOutputStream;
0023:        import java.io.InputStream;
0024:        import java.io.UnsupportedEncodingException;
0025:
0026:        import javax.xml.bind.JAXBContext;
0027:        import javax.xml.bind.JAXBException;
0028:        import javax.xml.bind.Marshaller;
0029:        import javax.xml.bind.Unmarshaller;
0030:        import javax.xml.transform.stream.StreamSource;
0031:
0032:        import com.sun.portal.wsrp.WSRPException;
0033:
0034:        import com.sun.portal.wsrp.common.stubs.ServiceDescription;
0035:        import com.sun.portal.wsrp.common.stubs.RegistrationData;
0036:        import com.sun.portal.wsrp.common.stubs.RegistrationContext;
0037:        import com.sun.portal.wsrp.common.stubs.PortletDescription;
0038:        import com.sun.portal.wsrp.common.stubs.ItemDescription;
0039:        import com.sun.portal.wsrp.common.stubs.CookieProtocol;
0040:        import com.sun.portal.wsrp.common.stubs.ModelDescription;
0041:        import com.sun.portal.wsrp.common.stubs.Property;
0042:        import com.sun.portal.wsrp.common.stubs.ResourceList;
0043:        import com.sun.portal.wsrp.common.stubs.Resource;
0044:        import com.sun.portal.wsrp.common.stubs.ResourceValue;
0045:        import com.sun.portal.wsrp.common.stubs.LocalizedString;
0046:        import com.sun.portal.wsrp.common.stubs.Extension;
0047:        import com.sun.portal.wsrp.common.stubs.ModelTypes;
0048:        import com.sun.portal.wsrp.common.stubs.MarkupType;
0049:        import com.sun.portal.wsrp.common.stubs.PropertyDescription;
0050:        import com.sun.portal.wsrp.common.stubs.PortletContext;
0051:        import com.sun.portal.wsrp.common.stubs.DestroyPortletsResponse;
0052:        import com.sun.portal.wsrp.common.stubs.DestroyFailed;
0053:
0054:        import com.sun.portal.wsrp.common.jaxb.wsrp.ObjectFactory;
0055:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBServiceDescription;
0056:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBServiceDescriptionType;
0057:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBRegistrationData;
0058:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBRegistrationContext;
0059:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBPortletDescriptionType;
0060:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBItemDescriptionType;
0061:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBModelDescription;
0062:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBModelDescriptionType;
0063:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBPropertyType;
0064:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBResourceListType;
0065:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBResourceType;
0066:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBResourceValueType;
0067:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBLocalizedStringType;
0068:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBExtensionType;
0069:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBModelTypesType;
0070:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBMarkupTypeType;
0071:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBPropertyDescriptionType;
0072:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBPortletContextType;
0073:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBDestroyPortletsResponseType;
0074:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBDestroyFailedType; //PM
0075:        import com.sun.portal.wsrp.common.stubs.PropertyList;
0076:        import com.sun.portal.wsrp.common.stubs.Property;
0077:        import com.sun.portal.wsrp.common.stubs.ResetProperty;
0078:        import com.sun.portal.wsrp.common.stubs.PortletPropertyDescriptionResponse;
0079:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBPropertyListType;
0080:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBPropertyType;
0081:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBResetPropertyType;
0082:        import com.sun.portal.wsrp.common.jaxb.wsrp.JAXBPortletPropertyDescriptionResponseType;
0083:
0084:        //-PM
0085:        /**
0086:         * Utility class for converting JAX-RPC generated objects into
0087:         * JAXB-compatible and vice versa.  In addition, it has convenient
0088:         * methods for converting these objects into XML string.
0089:         *
0090:         * This class contains the following method patterns:
0091:         * <ul>
0092:         * <li>get[WSRP type]([JAXB type])) - gets the WSRP type from the corresponding
0093:         * JAXB type
0094:         * <li>get[WSRP type](String xml) - gets the WSRP type from the JAXB marshalled XML string
0095:         * <li>get[WSRP type]XML([WSRP type] - gets the JAXB marshalled XML based on the
0096:         * corresponding WSRP type
0097:         * <li>getJAXB[JAXB type]([WSRP type]) - gets the JAXB type for the corresponding
0098:         * WSRP type
0099:         * <li>getJAXB[JAXB type](String xml) - gets the JAXB type from the
0100:         * JAXB marshalled XML string.
0101:         * </ul>
0102:         *
0103:         * Note that not all method patterns are implemented for all JAXB / WSRP
0104:         * object types. If necessary, they can be added.
0105:         */
0106:        public class WSRPFactory {
0107:
0108:            //
0109:            // static instance
0110:            //
0111:            protected static WSRPFactory factory = null;
0112:
0113:            //
0114:            // jaxb context
0115:            //
0116:            private JAXBContext jc = null;
0117:            private ObjectFactory jfactory = null;
0118:
0119:            public static final String REGISTRATION_PROPERTY_DESC_LABEL = ".label";
0120:            public static final String REGISTRATION_PROPERTY_DESC_HINT = ".hint";
0121:
0122:            public static WSRPFactory getInstance() throws WSRPException {
0123:                //
0124:                // perform double-checked locking
0125:                //
0126:                if (factory == null) {
0127:                    synchronized (WSRPFactory.class) {
0128:                        if (factory == null) {
0129:                            factory = new WSRPFactory();
0130:                        }
0131:                    }
0132:                }
0133:                return factory;
0134:            }
0135:
0136:            private WSRPFactory() throws WSRPException {
0137:                init();
0138:            }
0139:
0140:            public void init() throws WSRPException {
0141:                //
0142:                // initialize jaxb
0143:                //
0144:                try {
0145:
0146:                    jc = JAXBContext.newInstance(
0147:                            "com.sun.portal.wsrp.common.jaxb.wsrp", this 
0148:                                    .getClass().getClassLoader());
0149:
0150:                    jfactory = new ObjectFactory();
0151:                } catch (JAXBException jbe) {
0152:                    throw new WSRPException(
0153:                            "WSRPFactory.init(): failed to initialize JAXB components.",
0154:                            jbe);
0155:                }
0156:            }
0157:
0158:            public ObjectFactory getObjectFactory() {
0159:                return jfactory;
0160:            }
0161:
0162:            public RegistrationData getRegistrationData(String rdXML)
0163:                    throws WSRPException {
0164:                if (rdXML == null || rdXML.length() == 0) {
0165:                    return null;
0166:                }
0167:
0168:                JAXBRegistrationData jrd = null;
0169:                try {
0170:                    Unmarshaller unmarshaller = jc.createUnmarshaller();
0171:                    jrd = (JAXBRegistrationData) unmarshaller
0172:                            .unmarshal(new StreamSource(new StringReader(rdXML)));
0173:                } catch (JAXBException jbe) {
0174:                    throw new WSRPException(
0175:                            "WSRPFactory.getRegistrationData(): failed to unmarshall registration data.  xml="
0176:                                    + rdXML, jbe);
0177:                }
0178:                RegistrationData rd = getRegistrationData(jrd);
0179:                return rd;
0180:            }
0181:
0182:            public RegistrationContext getRegistrationContext(String rcXML)
0183:                    throws WSRPException {
0184:                if (rcXML == null || rcXML.length() == 0) {
0185:                    return null;
0186:                }
0187:
0188:                JAXBRegistrationContext jrc = null;
0189:                try {
0190:                    Unmarshaller unmarshaller = jc.createUnmarshaller();
0191:                    jrc = (JAXBRegistrationContext) unmarshaller
0192:                            .unmarshal(new StreamSource(new StringReader(rcXML)));
0193:                } catch (JAXBException jbe) {
0194:                    throw new WSRPException(
0195:                            "WSRPFactory.getRegistrationContext(): failed to unmarshall registration context.  xml="
0196:                                    + rcXML, jbe);
0197:                }
0198:                RegistrationContext rc = getRegistrationContext(jrc);
0199:                return rc;
0200:            }
0201:
0202:            public ServiceDescription getServiceDescription(String sdXML)
0203:                    throws WSRPException {
0204:                if (sdXML == null || sdXML.length() == 0) {
0205:                    return null;
0206:                }
0207:
0208:                JAXBServiceDescriptionType jsd = null;
0209:                try {
0210:                    Unmarshaller unmarshaller = jc.createUnmarshaller();
0211:                    jsd = (JAXBServiceDescriptionType) unmarshaller
0212:                            .unmarshal(new StreamSource(new StringReader(sdXML)));
0213:                } catch (JAXBException jbe) {
0214:                    throw new WSRPException(
0215:                            "WSRPFactory.getServiceDescription(): failed to unmarshall service description.  xml="
0216:                                    + sdXML, jbe);
0217:                }
0218:                ServiceDescription sd = getServiceDescription(jsd);
0219:                return sd;
0220:            }
0221:
0222:            public String getRegistrationDataXML(RegistrationData rd)
0223:                    throws WSRPException {
0224:                return getRegistrationDataXML(rd, false);
0225:            }
0226:
0227:            public String getRegistrationDataXML(RegistrationData rd,
0228:                    boolean isFormatted) throws WSRPException {
0229:                String xml = null;
0230:                JAXBRegistrationData jrd = getJAXBRegistrationData(rd);
0231:                if (jrd != null) {
0232:                    StringWriter writer = new StringWriter();
0233:                    try {
0234:                        Marshaller marshaller = jc.createMarshaller();
0235:                        if (isFormatted) {
0236:                            marshaller.setProperty(
0237:                                    Marshaller.JAXB_FORMATTED_OUTPUT,
0238:                                    Boolean.TRUE);
0239:                        }
0240:                        marshaller.marshal(jrd, writer);
0241:                    } catch (JAXBException jbe) {
0242:                        throw new WSRPException(
0243:                                "WSRPFactory.getRegistrationDataXML(): failed to marshall registration data.  registrationData="
0244:                                        + rd, jbe);
0245:                    }
0246:                    xml = writer.toString();
0247:                }
0248:
0249:                return xml;
0250:            }
0251:
0252:            public String getRegistrationContextXML(RegistrationContext rc)
0253:                    throws WSRPException {
0254:                return getRegistrationContextXML(rc, false);
0255:            }
0256:
0257:            public String getRegistrationContextXML(RegistrationContext rc,
0258:                    boolean isFormatted) throws WSRPException {
0259:
0260:                String xml = null;
0261:                JAXBRegistrationContext jrc = getJAXBRegistrationContext(rc);
0262:                if (jrc != null) {
0263:                    StringWriter writer = new StringWriter();
0264:                    try {
0265:                        Marshaller marshaller = jc.createMarshaller();
0266:                        if (isFormatted) {
0267:                            marshaller.setProperty(
0268:                                    Marshaller.JAXB_FORMATTED_OUTPUT,
0269:                                    Boolean.TRUE);
0270:                        }
0271:                        marshaller.marshal(jrc, writer);
0272:                    } catch (JAXBException jbe) {
0273:                        throw new WSRPException(
0274:                                "WSRPFactory.getRegistrationContextXML(): failed to marshall registration context.  registrationContext="
0275:                                        + rc, jbe);
0276:                    }
0277:                    xml = writer.toString();
0278:                }
0279:
0280:                return xml;
0281:            }
0282:
0283:            //PM
0284:
0285:            public String getPropertyListXML(PropertyList pl)
0286:                    throws WSRPException {
0287:                return getPropertyListXML(pl, false);
0288:            }
0289:
0290:            public String getPropertyListXML(PropertyList pl,
0291:                    boolean isFormatted) throws WSRPException {
0292:                String xml = null;
0293:                JAXBPropertyListType jpl = getJAXBPropertyList(pl);
0294:                if (jpl != null) {
0295:                    StringWriter writer = new StringWriter();
0296:                    try {
0297:                        Marshaller marshaller = jc.createMarshaller();
0298:                        if (isFormatted) {
0299:                            marshaller.setProperty(
0300:                                    Marshaller.JAXB_FORMATTED_OUTPUT,
0301:                                    Boolean.TRUE);
0302:                        }
0303:                        marshaller.marshal(jpl, writer);
0304:                    } catch (JAXBException jbe) {
0305:                        throw new WSRPException(
0306:                                "WSRPFactory.getPropertyListXML(): failed to marshall propertList="
0307:                                        + pl, jbe);
0308:                    }
0309:                    xml = writer.toString();
0310:                }
0311:
0312:                return xml;
0313:            }
0314:
0315:            private JAXBPropertyListType getJAXBPropertyList(PropertyList pl)
0316:                    throws WSRPException {
0317:                if (pl == null) {
0318:                    return null;
0319:                }
0320:
0321:                JAXBPropertyListType jpl = null;
0322:
0323:                try {
0324:                    jpl = jfactory.createJAXBPropertyListType();
0325:                } catch (JAXBException jbe) {
0326:                    throw new WSRPException(
0327:                            "WSRPFactory.getJAXBPropertyList(): failed to create JAXB object.",
0328:                            jbe);
0329:                }
0330:
0331:                Property[] ps = pl.getProperties();
0332:                List jps = jpl.getProperties();
0333:
0334:                for (int i = 0; i < ps.length; i++) {
0335:                    JAXBPropertyType jp = getJAXBPropertyType(ps[i]);
0336:                    jps.add(jp);
0337:                }
0338:
0339:                ResetProperty[] rps = pl.getResetProperties();
0340:                List jrps = jpl.getResetProperties();
0341:
0342:                for (int i = 0; i < rps.length; i++) {
0343:                    JAXBResetPropertyType jrp = getJAXBResetPropertyType(rps[i]);
0344:                    jrps.add(jrp);
0345:                }
0346:
0347:                return jpl;
0348:            }
0349:
0350:            private JAXBResetPropertyType getJAXBResetPropertyType(
0351:                    ResetProperty rp) throws WSRPException {
0352:                if (rp == null) {
0353:                    return null;
0354:                }
0355:
0356:                JAXBResetPropertyType jrp = null;
0357:
0358:                try {
0359:                    jrp = jfactory.createJAXBResetPropertyType();
0360:                } catch (JAXBException jbe) {
0361:                    throw new WSRPException(
0362:                            "WSRPFactory.getJAXBResetPropertyType(): failed to create JAXB object.",
0363:                            jbe);
0364:                }
0365:
0366:                jrp.setName(rp.getName());
0367:
0368:                return jrp;
0369:            }
0370:
0371:            //-PM
0372:
0373:            public String getPortletDescriptionXML(PortletDescription pd)
0374:                    throws WSRPException {
0375:                return getPortletDescriptionXML(pd, false);
0376:            }
0377:
0378:            public String getPortletDescriptionXML(PortletDescription pd,
0379:                    boolean isFormatted) throws WSRPException {
0380:                String xml = null;
0381:                JAXBPortletDescriptionType jpd = getJAXBPortletDescriptionType(pd);
0382:                if (jpd != null) {
0383:                    StringWriter writer = new StringWriter();
0384:                    try {
0385:                        Marshaller marshaller = jc.createMarshaller();
0386:                        if (isFormatted) {
0387:                            marshaller.setProperty(
0388:                                    Marshaller.JAXB_FORMATTED_OUTPUT,
0389:                                    Boolean.TRUE);
0390:                        }
0391:                        marshaller.marshal(jpd, writer);
0392:                    } catch (JAXBException jbe) {
0393:                        throw new WSRPException(
0394:                                "WSRPFactory.getPortletDescriptionXML(): failed to marshall portlet description.  portletDescription="
0395:                                        + pd, jbe);
0396:                    }
0397:                    xml = writer.toString();
0398:                }
0399:
0400:                return xml;
0401:            }
0402:
0403:            public String getPortletContextXML(PortletContext pc)
0404:                    throws WSRPException {
0405:                return getPortletContextXML(pc, false);
0406:            }
0407:
0408:            public String getPortletContextXML(PortletContext pc,
0409:                    boolean isFormatted) throws WSRPException {
0410:                String xml = null;
0411:                JAXBPortletContextType jpc = getJAXBPortletContextType(pc);
0412:                if (jpc != null) {
0413:                    StringWriter writer = new StringWriter();
0414:                    try {
0415:                        Marshaller marshaller = jc.createMarshaller();
0416:                        if (isFormatted) {
0417:                            marshaller.setProperty(
0418:                                    Marshaller.JAXB_FORMATTED_OUTPUT,
0419:                                    Boolean.TRUE);
0420:                        }
0421:                        marshaller.marshal(jpc, writer);
0422:                    } catch (JAXBException jbe) {
0423:                        throw new WSRPException(
0424:                                "WSRPFactory.getPortletContextXML(): failed to marshall portlet context.  portletContext="
0425:                                        + pc, jbe);
0426:                    }
0427:                    xml = writer.toString();
0428:                }
0429:
0430:                return xml;
0431:            }
0432:
0433:            public String getDestroyPortletsResponseXML(
0434:                    DestroyPortletsResponse dpr) throws WSRPException {
0435:                return getDestroyPortletsResponseXML(dpr, false);
0436:            }
0437:
0438:            public String getDestroyPortletsResponseXML(
0439:                    DestroyPortletsResponse dpr, boolean isFormatted)
0440:                    throws WSRPException {
0441:                String xml = null;
0442:                JAXBDestroyPortletsResponseType jdpr = getJAXBDestroyPortletsResponseType(dpr);
0443:                if (jdpr != null) {
0444:                    StringWriter writer = new StringWriter();
0445:                    try {
0446:                        Marshaller marshaller = jc.createMarshaller();
0447:                        if (isFormatted) {
0448:                            marshaller.setProperty(
0449:                                    Marshaller.JAXB_FORMATTED_OUTPUT,
0450:                                    Boolean.TRUE);
0451:                        }
0452:                        marshaller.marshal(jdpr, writer);
0453:                    } catch (JAXBException jbe) {
0454:                        throw new WSRPException(
0455:                                "WSRPFactory.getDestroyPortletsResponseXML(): failed to marshall destroy portlets response.  dpr="
0456:                                        + dpr, jbe);
0457:                    }
0458:                    xml = writer.toString();
0459:                }
0460:
0461:                return xml;
0462:            }
0463:
0464:            //PM
0465:            public String getPortletPropertyDescriptionResponseXML(
0466:                    PortletPropertyDescriptionResponse ppdr)
0467:                    throws WSRPException {
0468:                return getPortletPropertyDescriptionResponseXML(ppdr, false);
0469:            }
0470:
0471:            public String getPortletPropertyDescriptionResponseXML(
0472:                    PortletPropertyDescriptionResponse ppdr, boolean isFormatted)
0473:                    throws WSRPException {
0474:                String xml = null;
0475:                JAXBPortletPropertyDescriptionResponseType jppdr = getJAXBPortletPropertyDescriptionResponseType(ppdr);
0476:                if (jppdr != null) {
0477:                    StringWriter writer = new StringWriter();
0478:                    try {
0479:                        Marshaller marshaller = jc.createMarshaller();
0480:                        if (isFormatted) {
0481:                            marshaller.setProperty(
0482:                                    Marshaller.JAXB_FORMATTED_OUTPUT,
0483:                                    Boolean.TRUE);
0484:                        }
0485:                        marshaller.marshal(jppdr, writer);
0486:                    } catch (JAXBException jbe) {
0487:                        throw new WSRPException(
0488:                                "WSRPFactory.getPortletPropertyDescriptionResponseXML(): failed to marshall PortletPropertyDescriptionResponse.  ppdr="
0489:                                        + ppdr, jbe);
0490:                    }
0491:                    xml = writer.toString();
0492:                }
0493:
0494:                return xml;
0495:            }
0496:
0497:            //-PM
0498:            public String getServiceDescriptionXML(ServiceDescription sd)
0499:                    throws WSRPException {
0500:                return getServiceDescriptionXML(sd, false);
0501:            }
0502:
0503:            public String getServiceDescriptionXML(ServiceDescription sd,
0504:                    boolean isFormatted) throws WSRPException {
0505:
0506:                String xml = null;
0507:                JAXBServiceDescription jsd = getJAXBServiceDescription(sd);
0508:                if (jsd != null) {
0509:                    StringWriter writer = new StringWriter();
0510:                    try {
0511:                        Marshaller marshaller = jc.createMarshaller();
0512:                        if (isFormatted) {
0513:                            marshaller.setProperty(
0514:                                    Marshaller.JAXB_FORMATTED_OUTPUT,
0515:                                    Boolean.TRUE);
0516:                        }
0517:                        marshaller.marshal(jsd, writer);
0518:                    } catch (JAXBException jbe) {
0519:                        throw new WSRPException(
0520:                                "WSRPFactory.getRegistrationContextXML(): failed to marshall service description.  serviceDescription="
0521:                                        + sd, jbe);
0522:                    }
0523:                    xml = writer.toString();
0524:                }
0525:
0526:                return xml;
0527:            }
0528:
0529:            public static ServiceDescription getServiceDescription(
0530:                    JAXBServiceDescriptionType jsd) {
0531:                if (jsd == null) {
0532:                    return null;
0533:                }
0534:
0535:                ServiceDescription sd = new ServiceDescription();
0536:
0537:                sd.setRequiresRegistration(jsd.isRequiresRegistration());
0538:
0539:                List jops = jsd.getOfferedPortlets();
0540:                if (jops != null) {
0541:                    PortletDescription[] ops = new PortletDescription[jops
0542:                            .size()];
0543:                    int j = 0;
0544:                    for (Iterator i = jops.iterator(); i.hasNext(); j++) {
0545:                        JAXBPortletDescriptionType jpd = (JAXBPortletDescriptionType) i
0546:                                .next();
0547:                        ops[j] = getPortletDescription(jpd);
0548:                    }
0549:                    sd.setOfferedPortlets(ops);
0550:                }
0551:                //
0552:                // TBD: else.. do we want to set to to null?
0553:                //
0554:
0555:                List jucs = jsd.getUserCategoryDescriptions();
0556:                if (jucs != null) {
0557:                    ItemDescription[] ucs = new ItemDescription[jucs.size()];
0558:                    int j = 0;
0559:                    for (Iterator i = jucs.iterator(); i.hasNext(); j++) {
0560:                        JAXBItemDescriptionType jid = (JAXBItemDescriptionType) i
0561:                                .next();
0562:                        ucs[j] = getItemDescription(jid);
0563:                    }
0564:                    sd.setUserCategoryDescriptions(ucs);
0565:                }
0566:
0567:                List jcups = jsd.getCustomUserProfileItemDescriptions();
0568:                if (jcups != null) {
0569:                    ItemDescription[] cups = new ItemDescription[jcups.size()];
0570:                    int j = 0;
0571:                    for (Iterator i = jcups.iterator(); i.hasNext(); j++) {
0572:                        JAXBItemDescriptionType jid = (JAXBItemDescriptionType) i
0573:                                .next();
0574:                        cups[j] = getItemDescription(jid);
0575:                    }
0576:                    sd.setCustomUserProfileItemDescriptions(cups);
0577:                }
0578:
0579:                List jcws = jsd.getCustomWindowStateDescriptions();
0580:                if (jcws != null) {
0581:                    ItemDescription[] cws = new ItemDescription[jcws.size()];
0582:                    int j = 0;
0583:                    for (Iterator i = jcws.iterator(); i.hasNext(); j++) {
0584:                        JAXBItemDescriptionType jid = (JAXBItemDescriptionType) i
0585:                                .next();
0586:                        cws[j] = getItemDescription(jid);
0587:                    }
0588:                    sd.setCustomWindowStateDescriptions(cws);
0589:                }
0590:
0591:                List jcms = jsd.getCustomModeDescriptions();
0592:                if (jcms != null) {
0593:                    ItemDescription[] cms = new ItemDescription[jcms.size()];
0594:                    int j = 0;
0595:                    for (Iterator i = jcms.iterator(); i.hasNext(); j++) {
0596:                        JAXBItemDescriptionType jid = (JAXBItemDescriptionType) i
0597:                                .next();
0598:                        cms[j] = getItemDescription(jid);
0599:                    }
0600:                    sd.setCustomModeDescriptions(cms);
0601:                }
0602:
0603:                String reqInitCookie = jsd.getRequiresInitCookie();
0604:                if (reqInitCookie != null) {
0605:                    sd.setRequiresInitCookie(CookieProtocol
0606:                            .fromString(reqInitCookie));
0607:                }
0608:
0609:                JAXBModelDescriptionType jrp = jsd
0610:                        .getRegistrationPropertyDescription();
0611:                if (jrp != null) {
0612:                    sd
0613:                            .setRegistrationPropertyDescription(getModelDescription(jrp));
0614:                }
0615:
0616:                List jlocales = jsd.getLocales();
0617:                if (jlocales != null) {
0618:                    String[] locales = (String[]) jlocales
0619:                            .toArray(new String[jlocales.size()]);
0620:                    sd.setLocales(locales);
0621:                }
0622:
0623:                JAXBResourceListType jrl = jsd.getResourceList();
0624:                if (jrl != null) {
0625:                    ResourceList rl = getResourceList(jrl);
0626:                    sd.setResourceList(rl);
0627:                }
0628:
0629:                List jexs = jsd.getExtensions();
0630:                if (jexs != null) {
0631:                    Extension[] exs = new Extension[jexs.size()];
0632:                    int j = 0;
0633:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
0634:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
0635:                        exs[j] = getExtension(jex);
0636:                    }
0637:                    sd.setExtensions(exs);
0638:                }
0639:
0640:                return sd;
0641:            }
0642:
0643:            public JAXBServiceDescription getJAXBServiceDescription(
0644:                    ServiceDescription sd) throws WSRPException {
0645:                if (sd == null) {
0646:                    return null;
0647:                }
0648:
0649:                JAXBServiceDescription jsd = null;
0650:                try {
0651:                    jsd = jfactory.createJAXBServiceDescription();
0652:                } catch (JAXBException jbe) {
0653:                    throw new WSRPException(
0654:                            "WSRPFactory.getJAXBServiceDescription(): failed to create JAXB object.",
0655:                            jbe);
0656:                }
0657:
0658:                jsd.setRequiresRegistration(sd.isRequiresRegistration());
0659:
0660:                List jops = jsd.getOfferedPortlets();
0661:                PortletDescription[] ops = sd.getOfferedPortlets();
0662:                if (ops != null && ops.length > 0) {
0663:                    for (int i = 0; i < ops.length; i++) {
0664:                        jops.add(getJAXBPortletDescriptionType(ops[i]));
0665:                    }
0666:                }
0667:
0668:                List jucs = jsd.getUserCategoryDescriptions();
0669:                ItemDescription[] ucs = sd.getUserCategoryDescriptions();
0670:                if (ucs != null && ucs.length > 0) {
0671:                    for (int i = 0; i < ucs.length; i++) {
0672:                        jucs.add(getJAXBItemDescriptionType(ucs[i]));
0673:                    }
0674:                }
0675:
0676:                List jcups = jsd.getCustomUserProfileItemDescriptions();
0677:                ItemDescription[] cups = sd
0678:                        .getCustomUserProfileItemDescriptions();
0679:                if (cups != null && cups.length > 0) {
0680:                    for (int i = 0; i < cups.length; i++) {
0681:                        jcups.add(getJAXBItemDescriptionType(cups[i]));
0682:                    }
0683:                }
0684:
0685:                List jcws = jsd.getCustomWindowStateDescriptions();
0686:                ItemDescription[] cws = sd.getCustomWindowStateDescriptions();
0687:                if (cws != null && cws.length > 0) {
0688:                    for (int i = 0; i < cws.length; i++) {
0689:                        jcws.add(getJAXBItemDescriptionType(cws[i]));
0690:                    }
0691:                }
0692:
0693:                List jcms = jsd.getCustomModeDescriptions();
0694:                ItemDescription[] cms = sd.getCustomModeDescriptions();
0695:                if (cms != null && cms.length > 0) {
0696:                    for (int i = 0; i < cms.length; i++) {
0697:                        jcms.add(getJAXBItemDescriptionType(cms[i]));
0698:                    }
0699:                }
0700:
0701:                CookieProtocol cp = sd.getRequiresInitCookie();
0702:                if (cp != null) {
0703:                    jsd.setRequiresInitCookie(cp.getValue());
0704:                }
0705:
0706:                ModelDescription rp = sd.getRegistrationPropertyDescription();
0707:                if (rp != null) {
0708:                    jsd
0709:                            .setRegistrationPropertyDescription(getJAXBModelDescriptionType(getJAXBModelDescription(rp)));
0710:                }
0711:
0712:                List jlocales = jsd.getLocales();
0713:                String[] locales = sd.getLocales();
0714:                if (locales != null && locales.length > 0) {
0715:                    for (int i = 0; i < locales.length; i++) {
0716:                        jlocales.add(locales[i]);
0717:                    }
0718:                }
0719:
0720:                ResourceList rl = sd.getResourceList();
0721:                if (rl != null) {
0722:                    jsd.setResourceList(getJAXBResourceListType(rl));
0723:                }
0724:
0725:                List jexs = jsd.getExtensions();
0726:                Extension[] exs = sd.getExtensions();
0727:                if (exs != null && exs.length > 0) {
0728:                    for (int i = 0; i < exs.length; i++) {
0729:                        jexs.add(getJAXBExtensionType(exs[i]));
0730:                    }
0731:                }
0732:
0733:                return jsd;
0734:            }
0735:
0736:            public static RegistrationData getRegistrationData(
0737:                    JAXBRegistrationData jrd) {
0738:                if (jrd == null) {
0739:                    return null;
0740:                }
0741:
0742:                RegistrationData rd = new RegistrationData();
0743:
0744:                rd.setConsumerName(jrd.getConsumerName());
0745:
0746:                rd.setConsumerAgent(jrd.getConsumerAgent());
0747:
0748:                rd.setMethodGetSupported(jrd.isMethodGetSupported());
0749:
0750:                List jcms = jrd.getConsumerModes();
0751:                if (jcms != null) {
0752:                    String[] cms = (String[]) jcms.toArray(new String[jcms
0753:                            .size()]);
0754:                    rd.setConsumerModes(cms);
0755:                }
0756:
0757:                List jcws = jrd.getConsumerWindowStates();
0758:                if (jcws != null) {
0759:                    String[] cws = (String[]) jcws.toArray(new String[jcws
0760:                            .size()]);
0761:                    rd.setConsumerWindowStates(cws);
0762:                }
0763:
0764:                List jcus = jrd.getConsumerUserScopes();
0765:                if (jcus != null) {
0766:                    String[] cus = (String[]) jcus.toArray(new String[jcus
0767:                            .size()]);
0768:                    rd.setConsumerUserScopes(cus);
0769:                }
0770:
0771:                List jcups = jrd.getCustomUserProfileData();
0772:                if (jcups != null) {
0773:                    String[] cups = (String[]) jcups.toArray(new String[jcups
0774:                            .size()]);
0775:                    rd.setCustomUserProfileData(cups);
0776:                }
0777:
0778:                List jrps = jrd.getRegistrationProperties();
0779:                if (jrps != null) {
0780:                    Property[] rps = new Property[jrps.size()];
0781:                    int j = 0;
0782:                    for (Iterator i = jrps.iterator(); i.hasNext(); j++) {
0783:                        JAXBPropertyType jrp = (JAXBPropertyType) i.next();
0784:                        rps[j] = getProperty(jrp);
0785:                    }
0786:                    rd.setRegistrationProperties(rps);
0787:                }
0788:
0789:                List jexs = jrd.getExtensions();
0790:                if (jexs != null) {
0791:                    Extension[] exs = new Extension[jexs.size()];
0792:                    int j = 0;
0793:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
0794:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
0795:                        exs[j] = getExtension(jex);
0796:                    }
0797:                    rd.setExtensions(exs);
0798:                }
0799:
0800:                return rd;
0801:            }
0802:
0803:            public JAXBRegistrationData getJAXBRegistrationData(
0804:                    RegistrationData rd) throws WSRPException {
0805:                if (rd == null) {
0806:                    return null;
0807:                }
0808:
0809:                JAXBRegistrationData jrd = null;
0810:                try {
0811:                    jrd = jfactory.createJAXBRegistrationData();
0812:                } catch (JAXBException jbe) {
0813:                    throw new WSRPException(
0814:                            "WSRPFactory.getJAXBRegistrationData(): failed to create JAXB object.",
0815:                            jbe);
0816:                }
0817:
0818:                jrd.setConsumerName(rd.getConsumerName());
0819:
0820:                jrd.setConsumerAgent(rd.getConsumerAgent());
0821:
0822:                jrd.setMethodGetSupported(rd.isMethodGetSupported());
0823:
0824:                List jcms = jrd.getConsumerModes();
0825:                String[] cms = rd.getConsumerModes();
0826:                if (cms != null && cms.length > 0) {
0827:                    for (int i = 0; i < cms.length; i++) {
0828:                        jcms.add(cms[i]);
0829:                    }
0830:                }
0831:
0832:                List jcws = jrd.getConsumerWindowStates();
0833:                String[] cws = rd.getConsumerWindowStates();
0834:                if (cws != null && cws.length > 0) {
0835:                    for (int i = 0; i < cws.length; i++) {
0836:                        jcws.add(cws[i]);
0837:                    }
0838:                }
0839:
0840:                List jcus = jrd.getConsumerUserScopes();
0841:                String[] cus = rd.getConsumerUserScopes();
0842:                if (cus != null && cus.length > 0) {
0843:                    for (int i = 0; i < cus.length; i++) {
0844:                        jcus.add(cus[i]);
0845:                    }
0846:                }
0847:
0848:                List jcups = jrd.getCustomUserProfileData();
0849:                String[] cups = rd.getCustomUserProfileData();
0850:                if (cups != null && cups.length > 0) {
0851:                    for (int i = 0; i < cups.length; i++) {
0852:                        jcups.add(cups[i]);
0853:                    }
0854:                }
0855:
0856:                List jrps = jrd.getRegistrationProperties();
0857:                Property[] rps = rd.getRegistrationProperties();
0858:                if (rps != null && rps.length > 0) {
0859:                    for (int i = 0; i < rps.length; i++) {
0860:                        jrps.add(getJAXBPropertyType(rps[i]));
0861:                    }
0862:                }
0863:
0864:                List jexs = jrd.getExtensions();
0865:                Extension[] exs = rd.getExtensions();
0866:                if (exs != null && exs.length > 0) {
0867:                    for (int i = 0; i < exs.length; i++) {
0868:                        jexs.add(getJAXBExtensionType(exs[i]));
0869:                    }
0870:                }
0871:
0872:                return jrd;
0873:
0874:            }
0875:
0876:            public static RegistrationContext getRegistrationContext(
0877:                    JAXBRegistrationContext jrc) {
0878:                if (jrc == null) {
0879:                    return null;
0880:                }
0881:
0882:                RegistrationContext rc = new RegistrationContext();
0883:
0884:                rc.setRegistrationHandle(jrc.getRegistrationHandle());
0885:
0886:                rc.setRegistrationState(jrc.getRegistrationState());
0887:
0888:                List jexs = jrc.getExtensions();
0889:                if (jexs != null) {
0890:                    Extension[] exs = new Extension[jexs.size()];
0891:                    int j = 0;
0892:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
0893:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
0894:                        exs[j] = getExtension(jex);
0895:                    }
0896:                    rc.setExtensions(exs);
0897:                }
0898:
0899:                return rc;
0900:            }
0901:
0902:            public JAXBRegistrationContext getJAXBRegistrationContext(
0903:                    RegistrationContext rc) throws WSRPException {
0904:                if (rc == null) {
0905:                    return null;
0906:                }
0907:
0908:                JAXBRegistrationContext jrc = null;
0909:                try {
0910:                    jrc = jfactory.createJAXBRegistrationContext();
0911:                } catch (JAXBException jbe) {
0912:                    throw new WSRPException(
0913:                            "WSRPFactory.getJAXBRegistrationContext(): failed to create JAXB object.",
0914:                            jbe);
0915:                }
0916:
0917:                jrc.setRegistrationHandle(rc.getRegistrationHandle());
0918:
0919:                jrc.setRegistrationState(rc.getRegistrationState());
0920:
0921:                List jexs = jrc.getExtensions();
0922:                Extension[] exs = rc.getExtensions();
0923:                if (exs != null && exs.length > 0) {
0924:                    for (int i = 0; i < exs.length; i++) {
0925:                        jexs.add(getJAXBExtensionType(exs[i]));
0926:                    }
0927:                }
0928:
0929:                return jrc;
0930:            }
0931:
0932:            public static PortletDescription getPortletDescription(
0933:                    JAXBPortletDescriptionType jpd) {
0934:                if (jpd == null) {
0935:                    return null;
0936:                }
0937:
0938:                PortletDescription pd = new PortletDescription();
0939:
0940:                pd.setPortletHandle(jpd.getPortletHandle());
0941:
0942:                List jmts = jpd.getMarkupTypes();
0943:                if (jmts != null) {
0944:                    MarkupType[] mts = new MarkupType[jmts.size()];
0945:                    int j = 0;
0946:                    for (Iterator i = jmts.iterator(); i.hasNext(); j++) {
0947:                        JAXBMarkupTypeType jmt = (JAXBMarkupTypeType) i.next();
0948:                        mts[j] = getMarkupType(jmt);
0949:                    }
0950:                    pd.setMarkupTypes(mts);
0951:                }
0952:
0953:                pd.setGroupID(jpd.getGroupID());
0954:
0955:                JAXBLocalizedStringType jd = jpd.getDescription();
0956:                if (jd != null) {
0957:                    pd.setDescription(getLocalizedString(jd));
0958:                }
0959:
0960:                JAXBLocalizedStringType jst = jpd.getShortTitle();
0961:                if (jst != null) {
0962:                    pd.setShortTitle(getLocalizedString(jst));
0963:                }
0964:
0965:                JAXBLocalizedStringType jt = jpd.getTitle();
0966:                if (jt != null) {
0967:                    pd.setTitle(getLocalizedString(jt));
0968:                }
0969:
0970:                JAXBLocalizedStringType jdn = jpd.getDisplayName();
0971:                if (jdn != null) {
0972:                    pd.setDisplayName(getLocalizedString(jdn));
0973:                }
0974:
0975:                List jks = jpd.getKeywords();
0976:                if (jks != null) {
0977:                    LocalizedString[] ks = new LocalizedString[jks.size()];
0978:                    int j = 0;
0979:                    for (Iterator i = jks.iterator(); i.hasNext(); j++) {
0980:                        JAXBLocalizedStringType jk = (JAXBLocalizedStringType) i
0981:                                .next();
0982:                        ks[j] = getLocalizedString(jk);
0983:                    }
0984:                    pd.setKeywords(ks);
0985:                }
0986:
0987:                List jucs = jpd.getUserCategories();
0988:                if (jucs != null) {
0989:                    String[] ucs = (String[]) jucs.toArray(new String[jucs
0990:                            .size()]);
0991:                    pd.setUserCategories(ucs);
0992:                }
0993:
0994:                List jups = jpd.getUserProfileItems();
0995:                if (jups != null) {
0996:                    String[] ups = (String[]) jups.toArray(new String[jups
0997:                            .size()]);
0998:                    pd.setUserProfileItems(ups);
0999:                }
1000:
1001:                pd.setUsesMethodGet(new Boolean(jpd.isUsesMethodGet()));
1002:
1003:                pd.setDefaultMarkupSecure(new Boolean(jpd
1004:                        .isDefaultMarkupSecure()));
1005:
1006:                pd.setOnlySecure(new Boolean(jpd.isOnlySecure()));
1007:
1008:                pd.setUserContextStoredInSession(new Boolean(jpd
1009:                        .isUserContextStoredInSession()));
1010:
1011:                pd.setTemplatesStoredInSession(new Boolean(jpd
1012:                        .isTemplatesStoredInSession()));
1013:
1014:                pd.setHasUserSpecificState(new Boolean(jpd
1015:                        .isHasUserSpecificState()));
1016:
1017:                pd.setDoesUrlTemplateProcessing(new Boolean(jpd
1018:                        .isDoesUrlTemplateProcessing()));
1019:
1020:                List jexs = jpd.getExtensions();
1021:                if (jexs != null) {
1022:                    Extension[] exs = new Extension[jexs.size()];
1023:                    int j = 0;
1024:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
1025:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
1026:                        exs[j] = getExtension(jex);
1027:                    }
1028:                    pd.setExtensions(exs);
1029:                }
1030:
1031:                return pd;
1032:            }
1033:
1034:            public JAXBDestroyPortletsResponseType getJAXBDestroyPortletsResponseType(
1035:                    DestroyPortletsResponse dpr) throws WSRPException {
1036:                if (dpr == null) {
1037:                    return null;
1038:                }
1039:
1040:                JAXBDestroyPortletsResponseType jdpr = null;
1041:                try {
1042:                    jdpr = jfactory.createJAXBDestroyPortletsResponseType();
1043:                } catch (JAXBException jbe) {
1044:                    throw new WSRPException(
1045:                            "WSRPFactory.getJAXBDestroyPortletsResponseType(): failed to create JAXB object.",
1046:                            jbe);
1047:                }
1048:
1049:                DestroyFailed[] dfs = dpr.getDestroyFailed();
1050:                for (int i = 0; i < dfs.length; i++) {
1051:                    JAXBDestroyFailedType jdf = getJAXBDestroyFailedType(dfs[i]);
1052:                    jdpr.getDestroyFailed().add(jdf);
1053:                }
1054:
1055:                return jdpr;
1056:            }
1057:
1058:            public JAXBDestroyFailedType getJAXBDestroyFailedType(
1059:                    DestroyFailed df) throws WSRPException {
1060:                if (df == null) {
1061:                    return null;
1062:                }
1063:
1064:                JAXBDestroyFailedType jdf = null;
1065:                try {
1066:                    jdf = jfactory.createJAXBDestroyFailedType();
1067:                } catch (JAXBException jbe) {
1068:                    throw new WSRPException(
1069:                            "WSRPFactory.getJAXBDestroyFailedType(): failed to create JAXB object.",
1070:                            jbe);
1071:                }
1072:
1073:                jdf.setPortletHandle(df.getPortletHandle());
1074:                jdf.setReason(df.getReason());
1075:
1076:                return jdf;
1077:            }
1078:
1079:            public JAXBPortletContextType getJAXBPortletContextType(
1080:                    PortletContext pc) throws WSRPException {
1081:                if (pc == null) {
1082:                    return null;
1083:                }
1084:
1085:                JAXBPortletContextType jpc = null;
1086:                try {
1087:                    jpc = jfactory.createJAXBPortletContextType();
1088:                } catch (JAXBException jbe) {
1089:                    throw new WSRPException(
1090:                            "WSRPFactory.getJAXBPortletContextType(): failed to create JAXB object.",
1091:                            jbe);
1092:                }
1093:
1094:                jpc.setPortletHandle(pc.getPortletHandle());
1095:                jpc.setPortletState(pc.getPortletState());
1096:
1097:                return jpc;
1098:            }
1099:
1100:            public JAXBPortletDescriptionType getJAXBPortletDescriptionType(
1101:                    PortletDescription pd) throws WSRPException {
1102:                if (pd == null) {
1103:                    return null;
1104:                }
1105:
1106:                JAXBPortletDescriptionType jpd = null;
1107:                try {
1108:                    jpd = jfactory.createJAXBPortletDescriptionType();
1109:                } catch (JAXBException jbe) {
1110:                    throw new WSRPException(
1111:                            "WSRPFactory.getJAXBPortletDescriptionType(): failed to create JAXB object.",
1112:                            jbe);
1113:                }
1114:
1115:                jpd.setPortletHandle(pd.getPortletHandle());
1116:
1117:                List jmts = jpd.getMarkupTypes();
1118:                MarkupType[] mts = pd.getMarkupTypes();
1119:                if (mts != null && mts.length > 0) {
1120:                    for (int i = 0; i < mts.length; i++) {
1121:                        jmts.add(getJAXBMarkupTypeType(mts[i]));
1122:                    }
1123:                }
1124:
1125:                jpd.setGroupID(pd.getGroupID());
1126:
1127:                LocalizedString d = pd.getDescription();
1128:                if (d != null) {
1129:                    jpd.setDescription(getJAXBLocalizedStringType(d));
1130:                }
1131:
1132:                LocalizedString st = pd.getShortTitle();
1133:                if (st != null) {
1134:                    jpd.setShortTitle(getJAXBLocalizedStringType(st));
1135:                }
1136:
1137:                LocalizedString t = pd.getTitle();
1138:                if (t != null) {
1139:                    jpd.setTitle(getJAXBLocalizedStringType(t));
1140:                }
1141:
1142:                LocalizedString dn = pd.getDisplayName();
1143:                if (dn != null) {
1144:                    jpd.setDisplayName(getJAXBLocalizedStringType(dn));
1145:                }
1146:
1147:                List jks = jpd.getKeywords();
1148:                LocalizedString[] ks = pd.getKeywords();
1149:                if (ks != null) {
1150:                    for (int i = 0; i < ks.length; i++) {
1151:                        jks.add(getJAXBLocalizedStringType(ks[i]));
1152:                    }
1153:                }
1154:
1155:                List jucs = jpd.getUserCategories();
1156:                String[] ucs = pd.getUserCategories();
1157:                if (ucs != null && ucs.length > 0) {
1158:                    for (int i = 0; i < ucs.length; i++) {
1159:                        jucs.add(ucs[i]);
1160:                    }
1161:                }
1162:
1163:                List jups = jpd.getUserProfileItems();
1164:                String[] ups = pd.getUserProfileItems();
1165:                if (ups != null) {
1166:                    for (int i = 0; i < ups.length; i++) {
1167:                        jups.add(ups[i]);
1168:                    }
1169:                }
1170:
1171:                Boolean umg = pd.getUsesMethodGet();
1172:                if (umg != null) {
1173:                    jpd.setUsesMethodGet(umg.booleanValue());
1174:                }
1175:                //
1176:                // TBD: else... what does this mean?
1177:                //
1178:
1179:                Boolean dms = pd.getDefaultMarkupSecure();
1180:                if (dms != null) {
1181:                    jpd.setDefaultMarkupSecure(dms.booleanValue());
1182:                }
1183:
1184:                Boolean os = pd.getOnlySecure();
1185:                if (os != null) {
1186:                    jpd.setOnlySecure(os.booleanValue());
1187:                }
1188:
1189:                Boolean ucsis = pd.getUserContextStoredInSession();
1190:                if (ucsis != null) {
1191:                    jpd.setUserContextStoredInSession(ucsis.booleanValue());
1192:                }
1193:
1194:                Boolean tsis = pd.getTemplatesStoredInSession();
1195:                if (tsis != null) {
1196:                    jpd.setTemplatesStoredInSession(tsis.booleanValue());
1197:                }
1198:
1199:                Boolean huss = pd.getHasUserSpecificState();
1200:                if (huss != null) {
1201:                    jpd.setHasUserSpecificState(huss.booleanValue());
1202:                }
1203:
1204:                Boolean dutp = pd.getDoesUrlTemplateProcessing();
1205:                if (dutp != null) {
1206:                    jpd.setDoesUrlTemplateProcessing(dutp.booleanValue());
1207:                }
1208:
1209:                List jexs = jpd.getExtensions();
1210:                Extension[] exs = pd.getExtensions();
1211:                if (exs != null && exs.length > 0) {
1212:                    for (int i = 0; i < exs.length; i++) {
1213:                        jexs.add(getJAXBExtensionType(exs[i]));
1214:                    }
1215:                }
1216:
1217:                return jpd;
1218:            }
1219:
1220:            public static ItemDescription getItemDescription(
1221:                    JAXBItemDescriptionType jid) {
1222:                if (jid == null) {
1223:                    return null;
1224:                }
1225:
1226:                ItemDescription id = new ItemDescription();
1227:
1228:                id.setItemName(jid.getItemName());
1229:
1230:                JAXBLocalizedStringType jd = jid.getDescription();
1231:                if (jd != null) {
1232:                    id.setDescription(getLocalizedString(jd));
1233:                }
1234:
1235:                List jexs = jid.getExtensions();
1236:                if (jexs != null) {
1237:                    Extension[] exs = new Extension[jexs.size()];
1238:                    int j = 0;
1239:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
1240:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
1241:                        exs[j] = getExtension(jex);
1242:                    }
1243:                    id.setExtensions(exs);
1244:                }
1245:
1246:                return id;
1247:            }
1248:
1249:            public JAXBItemDescriptionType getJAXBItemDescriptionType(
1250:                    ItemDescription id) throws WSRPException {
1251:                if (id == null) {
1252:                    return null;
1253:                }
1254:
1255:                JAXBItemDescriptionType jid = null;
1256:                try {
1257:                    jid = jfactory.createJAXBItemDescriptionType();
1258:                } catch (JAXBException jbe) {
1259:                    throw new WSRPException(
1260:                            "WSRPFactory.getJAXBItemDescriptionType(): failed to create JAXB object.",
1261:                            jbe);
1262:                }
1263:
1264:                jid.setItemName(id.getItemName());
1265:
1266:                LocalizedString d = id.getDescription();
1267:                if (d != null) {
1268:                    jid.setDescription(getJAXBLocalizedStringType(d));
1269:                }
1270:
1271:                List jexs = jid.getExtensions();
1272:                Extension[] exs = id.getExtensions();
1273:                if (exs != null && exs.length > 0) {
1274:                    for (int i = 0; i < exs.length; i++) {
1275:                        jexs.add(getJAXBExtensionType(exs[i]));
1276:                    }
1277:                }
1278:
1279:                return jid;
1280:            }
1281:
1282:            public static ModelDescription getModelDescription(
1283:                    JAXBModelDescriptionType jmd) {
1284:                if (jmd == null) {
1285:                    return null;
1286:                }
1287:
1288:                ModelDescription md = new ModelDescription();
1289:
1290:                List jpds = jmd.getPropertyDescriptions();
1291:                if (jpds != null) {
1292:                    PropertyDescription[] pds = new PropertyDescription[jpds
1293:                            .size()];
1294:                    int j = 0;
1295:                    for (Iterator i = jpds.iterator(); i.hasNext(); j++) {
1296:                        JAXBPropertyDescriptionType jpd = (JAXBPropertyDescriptionType) i
1297:                                .next();
1298:                        pds[j] = getPropertyDescription(jpd);
1299:                    }
1300:                    md.setPropertyDescriptions(pds);
1301:                }
1302:
1303:                JAXBModelTypesType jmt = jmd.getModelTypes();
1304:                if (jmt != null) {
1305:                    md.setModelTypes(getModelTypes(jmt));
1306:                }
1307:
1308:                List jexs = jmd.getExtensions();
1309:                if (jexs != null) {
1310:                    Extension[] exs = new Extension[jexs.size()];
1311:                    int j = 0;
1312:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
1313:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
1314:                        exs[j] = getExtension(jex);
1315:                    }
1316:                    md.setExtensions(exs);
1317:                }
1318:
1319:                return md;
1320:            }
1321:
1322:            public JAXBModelDescription getJAXBModelDescription(String xml)
1323:                    throws WSRPException {
1324:                InputStream is = null;
1325:
1326:                try {
1327:                    is = new ByteArrayInputStream(xml.getBytes("UTF-8"));
1328:                } catch (UnsupportedEncodingException uee) {
1329:                    throw new WSRPException(uee);
1330:                }
1331:
1332:                JAXBModelDescription jmd = null;
1333:
1334:                try {
1335:                    Unmarshaller unmarshaller = jc.createUnmarshaller();
1336:                    jmd = (JAXBModelDescription) unmarshaller.unmarshal(is);
1337:                } catch (JAXBException je) {
1338:                    throw new WSRPException(je);
1339:                }
1340:
1341:                return jmd;
1342:            }
1343:
1344:            public JAXBModelDescription getJAXBModelDescription(
1345:                    ModelDescription md) throws WSRPException {
1346:                if (md == null) {
1347:                    return null;
1348:                }
1349:
1350:                JAXBModelDescription jmd = null;
1351:                try {
1352:                    jmd = jfactory.createJAXBModelDescription();
1353:                } catch (JAXBException jbe) {
1354:                    throw new WSRPException(
1355:                            "WSRPFactory.getJAXBModelDescription(): failed to create JAXB object.",
1356:                            jbe);
1357:                }
1358:
1359:                List jpds = jmd.getPropertyDescriptions();
1360:                PropertyDescription[] pds = md.getPropertyDescriptions();
1361:                if (pds != null && pds.length > 0) {
1362:                    for (int i = 0; i < pds.length; i++) {
1363:                        jpds.add(getJAXBPropertyDescription(pds[i]));
1364:                    }
1365:                }
1366:
1367:                ModelTypes mt = md.getModelTypes();
1368:                if (mt != null) {
1369:                    jmd.setModelTypes(getJAXBModelTypesType(mt));
1370:                }
1371:
1372:                List jexs = jmd.getExtensions();
1373:                Extension[] exs = md.getExtensions();
1374:                if (exs != null && exs.length > 0) {
1375:                    for (int i = 0; i < exs.length; i++) {
1376:                        jexs.add(getJAXBExtensionType(exs[i]));
1377:                    }
1378:                }
1379:
1380:                return jmd;
1381:            }
1382:
1383:            public JAXBModelDescriptionType getJAXBModelDescriptionType(
1384:                    JAXBModelDescription jmd) throws WSRPException {
1385:                if (jmd == null) {
1386:                    return null;
1387:                }
1388:
1389:                JAXBModelDescriptionType jmdt = null;
1390:                try {
1391:                    jmdt = jfactory.createJAXBModelDescriptionType();
1392:                } catch (JAXBException jbe) {
1393:                    throw new WSRPException(
1394:                            "WSRPFactory.getJAXBModelDescriptionType(): failed to create JAXB object.",
1395:                            jbe);
1396:                }
1397:
1398:                jmdt.getPropertyDescriptions().addAll(
1399:                        jmd.getPropertyDescriptions());
1400:
1401:                JAXBModelTypesType jmt = jmd.getModelTypes();
1402:                if (jmt != null) {
1403:                    jmdt.setModelTypes(jmt);
1404:                }
1405:
1406:                List jexs = jmd.getExtensions();
1407:                if (jexs != null) {
1408:                    jmdt.getExtensions().addAll(jexs);
1409:                }
1410:
1411:                return jmdt;
1412:            }
1413:
1414:            public static ModelTypes getModelTypes(JAXBModelTypesType jmt) {
1415:                if (jmt == null) {
1416:                    return null;
1417:                }
1418:
1419:                ModelTypes mt = new ModelTypes();
1420:
1421:                mt.set_any((javax.xml.soap.SOAPElement) jmt.getAny());
1422:
1423:                return mt;
1424:            }
1425:
1426:            public JAXBModelTypesType getJAXBModelTypesType(ModelTypes mts)
1427:                    throws WSRPException {
1428:                if (mts == null) {
1429:                    return null;
1430:                }
1431:
1432:                JAXBModelTypesType jmt = null;
1433:                try {
1434:                    jmt = jfactory.createJAXBModelTypesType();
1435:                } catch (JAXBException jbe) {
1436:                    throw new WSRPException(
1437:                            "WSRPFactory.getJAXBModelTypes(): failed to create JAXB object.",
1438:                            jbe);
1439:                }
1440:
1441:                jmt.setAny(mts.get_any());
1442:
1443:                return jmt;
1444:            }
1445:
1446:            //PM
1447:            public JAXBPortletPropertyDescriptionResponseType getJAXBPortletPropertyDescriptionResponseType(
1448:                    PortletPropertyDescriptionResponse ppdr)
1449:                    throws WSRPException {
1450:                if (ppdr == null) {
1451:                    return null;
1452:                }
1453:
1454:                JAXBPortletPropertyDescriptionResponseType jppdr = null;
1455:                try {
1456:                    jppdr = jfactory
1457:                            .createJAXBPortletPropertyDescriptionResponseType();
1458:                } catch (JAXBException jbe) {
1459:                    throw new WSRPException(
1460:                            "WSRPFactory.getJAXBPortletPropertyDescriptionResponse(): failed to create JAXB object.",
1461:                            jbe);
1462:                }
1463:
1464:                JAXBResourceListType jrl = getJAXBResourceListType(ppdr
1465:                        .getResourceList());
1466:                jppdr.setResourceList(jrl);
1467:                JAXBModelDescriptionType jmd = getJAXBModelDescriptionType(getJAXBModelDescription(ppdr
1468:                        .getModelDescription()));
1469:                jppdr.setModelDescription(jmd);
1470:
1471:                return jppdr;
1472:            }
1473:
1474:            //-PM
1475:            public static MarkupType getMarkupType(JAXBMarkupTypeType jmt) {
1476:                if (jmt == null) {
1477:                    return null;
1478:                }
1479:
1480:                MarkupType mt = new MarkupType();
1481:
1482:                mt.setMimeType(jmt.getMimeType());
1483:
1484:                List jmds = jmt.getModes();
1485:                if (jmds != null) {
1486:                    String[] mds = (String[]) jmds.toArray(new String[jmds
1487:                            .size()]);
1488:                    mt.setModes(mds);
1489:                }
1490:
1491:                List jws = jmt.getWindowStates();
1492:                if (jws != null) {
1493:                    String[] ws = (String[]) jws
1494:                            .toArray(new String[jws.size()]);
1495:                    mt.setWindowStates(ws);
1496:                }
1497:
1498:                List jlocales = jmt.getLocales();
1499:                if (jlocales != null) {
1500:                    String[] locales = (String[]) jlocales
1501:                            .toArray(new String[jlocales.size()]);
1502:                    mt.setLocales(locales);
1503:                }
1504:
1505:                List jexs = jmt.getExtensions();
1506:                if (jexs != null) {
1507:                    Extension[] exs = new Extension[jexs.size()];
1508:                    int j = 0;
1509:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
1510:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
1511:                        exs[j] = getExtension(jex);
1512:                    }
1513:                    mt.setExtensions(exs);
1514:                }
1515:
1516:                return mt;
1517:            }
1518:
1519:            public JAXBMarkupTypeType getJAXBMarkupTypeType(MarkupType mt)
1520:                    throws WSRPException {
1521:                if (mt == null) {
1522:                    return null;
1523:                }
1524:
1525:                JAXBMarkupTypeType jmt = null;
1526:                try {
1527:                    jmt = jfactory.createJAXBMarkupTypeType();
1528:                } catch (JAXBException jbe) {
1529:                    throw new WSRPException(
1530:                            "WSRPFactory.getJAXBMarkupTypeType(): failed to create JAXB object.",
1531:                            jbe);
1532:                }
1533:
1534:                jmt.setMimeType(mt.getMimeType());
1535:
1536:                List jmds = jmt.getModes();
1537:                String[] mds = mt.getModes();
1538:                if (mds != null && mds.length > 0) {
1539:                    for (int i = 0; i < mds.length; i++) {
1540:                        jmds.add(mds[i]);
1541:                    }
1542:                }
1543:
1544:                List jws = jmt.getWindowStates();
1545:                String[] ws = mt.getWindowStates();
1546:                if (ws != null && ws.length > 0) {
1547:                    for (int i = 0; i < ws.length; i++) {
1548:                        jws.add(ws[i]);
1549:                    }
1550:                }
1551:
1552:                List jlocales = jmt.getLocales();
1553:                String[] locales = mt.getLocales();
1554:                if (locales != null && locales.length > 0) {
1555:                    for (int i = 0; i < locales.length; i++) {
1556:                        jlocales.add(locales[i]);
1557:                    }
1558:                }
1559:
1560:                List jexs = jmt.getExtensions();
1561:                Extension[] exs = mt.getExtensions();
1562:                if (exs != null && exs.length > 0) {
1563:                    for (int i = 0; i < exs.length; i++) {
1564:                        jexs.add(getJAXBExtensionType(exs[i]));
1565:                    }
1566:                }
1567:
1568:                return jmt;
1569:            }
1570:
1571:            public static Property getProperty(JAXBPropertyType jp) {
1572:                if (jp == null) {
1573:                    return null;
1574:                }
1575:
1576:                Property p = new Property();
1577:
1578:                p.setName(jp.getName());
1579:
1580:                p.setLang(jp.getLang());
1581:
1582:                p.setStringValue(jp.getStringValue());
1583:
1584:                List jas = jp.getAny();
1585:                if (jas != null) {
1586:                    javax.xml.soap.SOAPElement[] as = new javax.xml.soap.SOAPElement[jas
1587:                            .size()];
1588:                    int j = 0;
1589:                    for (Iterator i = jas.iterator(); i.hasNext(); j++) {
1590:                        Object ja = i.next();
1591:                        as[j] = (javax.xml.soap.SOAPElement) ja;
1592:                    }
1593:                    p.set_any(as);
1594:                }
1595:
1596:                return p;
1597:            }
1598:
1599:            public JAXBPropertyType getJAXBPropertyType(Property p)
1600:                    throws WSRPException {
1601:                if (p == null) {
1602:                    return null;
1603:                }
1604:
1605:                JAXBPropertyType jp = null;
1606:                try {
1607:                    jp = jfactory.createJAXBPropertyType();
1608:                } catch (JAXBException jbe) {
1609:                    throw new WSRPException(
1610:                            "WSRPFactory.getJAXBPropertyType(): failed to create JAXB object.",
1611:                            jbe);
1612:                }
1613:
1614:                jp.setName(p.getName());
1615:
1616:                jp.setLang(p.getLang());
1617:
1618:                jp.setStringValue(p.getStringValue());
1619:
1620:                List jas = jp.getAny();
1621:                javax.xml.soap.SOAPElement[] as = p.get_any();
1622:                if (as != null && as.length > 0) {
1623:                    for (int i = 0; i < as.length; i++) {
1624:                        jas.add(as[i]);
1625:                    }
1626:                }
1627:
1628:                return jp;
1629:            }
1630:
1631:            public static ResourceList getResourceList(JAXBResourceListType jrl) {
1632:                if (jrl == null) {
1633:                    return null;
1634:                }
1635:
1636:                ResourceList rl = new ResourceList();
1637:
1638:                List jrs = jrl.getResources();
1639:                if (jrs != null) {
1640:                    Resource[] rs = new Resource[jrs.size()];
1641:                    int j = 0;
1642:                    for (Iterator i = jrs.iterator(); i.hasNext(); j++) {
1643:                        JAXBResourceType jr = (JAXBResourceType) i.next();
1644:                        rs[j] = getResource(jr);
1645:                    }
1646:                    rl.setResources(rs);
1647:                }
1648:
1649:                List jexs = jrl.getExtensions();
1650:                if (jexs != null) {
1651:                    Extension[] exs = new Extension[jexs.size()];
1652:                    int j = 0;
1653:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
1654:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
1655:                        exs[j] = getExtension(jex);
1656:                    }
1657:                    rl.setExtensions(exs);
1658:                }
1659:
1660:                return rl;
1661:            }
1662:
1663:            public JAXBResourceListType getJAXBResourceListType(ResourceList rl)
1664:                    throws WSRPException {
1665:                if (rl == null) {
1666:                    return null;
1667:                }
1668:
1669:                JAXBResourceListType jrl = null;
1670:                try {
1671:                    jrl = jfactory.createJAXBResourceListType();
1672:                } catch (JAXBException jbe) {
1673:                    throw new WSRPException(
1674:                            "WSRPFactory.getJAXBResourceListType(): failed to create JAXB object.",
1675:                            jbe);
1676:                }
1677:
1678:                List jrs = jrl.getResources();
1679:                Resource[] rs = rl.getResources();
1680:                if (rs != null && rs.length > 0) {
1681:                    for (int i = 0; i < rs.length; i++) {
1682:                        jrs.add(getJAXBResourceType(rs[i]));
1683:                    }
1684:                }
1685:
1686:                List jexs = jrl.getExtensions();
1687:                Extension[] exs = rl.getExtensions();
1688:                if (exs != null && exs.length > 0) {
1689:                    for (int i = 0; i < exs.length; i++) {
1690:                        jexs.add(getJAXBExtensionType(exs[i]));
1691:                    }
1692:                }
1693:
1694:                return jrl;
1695:            }
1696:
1697:            public static Resource getResource(JAXBResourceType jr) {
1698:                if (jr == null) {
1699:                    return null;
1700:                }
1701:
1702:                Resource r = new Resource();
1703:
1704:                r.setResourceName(jr.getResourceName());
1705:
1706:                List jvs = jr.getValues();
1707:                if (jvs != null) {
1708:                    ResourceValue[] rvs = new ResourceValue[jvs.size()];
1709:                    int j = 0;
1710:                    for (Iterator i = jvs.iterator(); i.hasNext(); j++) {
1711:                        JAXBResourceValueType jrv = (JAXBResourceValueType) i
1712:                                .next();
1713:                        rvs[j] = getResourceValue(jrv);
1714:                    }
1715:                    r.setValues(rvs);
1716:                }
1717:
1718:                List jexs = jr.getExtensions();
1719:                if (jexs != null) {
1720:                    Extension[] exs = new Extension[jexs.size()];
1721:                    int j = 0;
1722:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
1723:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
1724:                        exs[j] = getExtension(jex);
1725:                    }
1726:                    r.setExtensions(exs);
1727:                }
1728:
1729:                return r;
1730:            }
1731:
1732:            public JAXBResourceType getJAXBResourceType(Resource r)
1733:                    throws WSRPException {
1734:                if (r == null) {
1735:                    return null;
1736:                }
1737:
1738:                JAXBResourceType jr = null;
1739:                try {
1740:                    jr = jfactory.createJAXBResourceType();
1741:                } catch (JAXBException jbe) {
1742:                    throw new WSRPException(
1743:                            "WSRPFactory.getJAXBResourceType(): failed to create JAXB object.",
1744:                            jbe);
1745:                }
1746:
1747:                jr.setResourceName(r.getResourceName());
1748:
1749:                List jvs = jr.getValues();
1750:                ResourceValue[] rvs = r.getValues();
1751:                if (rvs != null && rvs.length > 0) {
1752:                    for (int i = 0; i < rvs.length; i++) {
1753:                        jvs.add(getJAXBResourceValueType(rvs[i]));
1754:                    }
1755:                }
1756:
1757:                List jexs = jr.getExtensions();
1758:                Extension[] exs = r.getExtensions();
1759:                if (exs != null && exs.length > 0) {
1760:                    for (int i = 0; i < exs.length; i++) {
1761:                        jexs.add(getJAXBExtensionType(exs[i]));
1762:                    }
1763:                }
1764:
1765:                return jr;
1766:            }
1767:
1768:            public static ResourceValue getResourceValue(
1769:                    JAXBResourceValueType jrv) {
1770:                if (jrv == null) {
1771:                    return null;
1772:                }
1773:
1774:                ResourceValue rv = new ResourceValue();
1775:
1776:                rv.setLang(jrv.getLang());
1777:
1778:                rv.setValue(jrv.getValue());
1779:
1780:                List jexs = jrv.getExtensions();
1781:                if (jexs != null) {
1782:                    Extension[] exs = new Extension[jexs.size()];
1783:                    int j = 0;
1784:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
1785:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
1786:                        exs[j] = getExtension(jex);
1787:                    }
1788:                    rv.setExtensions(exs);
1789:                }
1790:
1791:                return rv;
1792:            }
1793:
1794:            public JAXBResourceValueType getJAXBResourceValueType(
1795:                    ResourceValue rv) throws WSRPException {
1796:                if (rv == null) {
1797:                    return null;
1798:                }
1799:
1800:                JAXBResourceValueType jrv = null;
1801:                try {
1802:                    jrv = jfactory.createJAXBResourceValueType();
1803:                } catch (JAXBException jbe) {
1804:                    throw new WSRPException(
1805:                            "WSRPFactory.getJAXBResourceValueType(): failed to create JAXB object.",
1806:                            jbe);
1807:                }
1808:
1809:                jrv.setLang(rv.getLang());
1810:
1811:                jrv.setValue(rv.getValue());
1812:
1813:                List jexs = jrv.getExtensions();
1814:                Extension[] exs = rv.getExtensions();
1815:                if (exs != null && exs.length > 0) {
1816:                    for (int i = 0; i < exs.length; i++) {
1817:                        jexs.add(getJAXBExtensionType(exs[i]));
1818:                    }
1819:                }
1820:
1821:                return jrv;
1822:            }
1823:
1824:            public static PropertyDescription getPropertyDescription(
1825:                    JAXBPropertyDescriptionType jpd) {
1826:                if (jpd == null) {
1827:                    return null;
1828:                }
1829:
1830:                PropertyDescription pd = new PropertyDescription();
1831:                String name = jpd.getName();
1832:
1833:                pd.setName(name);
1834:
1835:                pd.setType(jpd.getType());
1836:
1837:                JAXBLocalizedStringType jl = jpd.getLabel();
1838:                if (jl != null) {
1839:                    pd.setLabel(getLocalizedString(jl, name
1840:                            + REGISTRATION_PROPERTY_DESC_LABEL));
1841:                }
1842:
1843:                JAXBLocalizedStringType jh = jpd.getHint();
1844:                if (jh != null) {
1845:                    pd.setHint(getLocalizedString(jh, name
1846:                            + REGISTRATION_PROPERTY_DESC_HINT));
1847:                }
1848:
1849:                List jexs = jpd.getExtensions();
1850:                if (jexs != null) {
1851:                    Extension[] exs = new Extension[jexs.size()];
1852:                    int j = 0;
1853:                    for (Iterator i = jexs.iterator(); i.hasNext(); j++) {
1854:                        JAXBExtensionType jex = (JAXBExtensionType) i.next();
1855:                        exs[j] = getExtension(jex);
1856:                    }
1857:                    pd.setExtensions(exs);
1858:                }
1859:
1860:                return pd;
1861:            }
1862:
1863:            public JAXBPropertyDescriptionType getJAXBPropertyDescription(
1864:                    PropertyDescription pd) throws WSRPException {
1865:                if (pd == null) {
1866:                    return null;
1867:                }
1868:
1869:                JAXBPropertyDescriptionType jpd = null;
1870:                try {
1871:                    jpd = jfactory.createJAXBPropertyDescriptionType();
1872:                } catch (JAXBException jbe) {
1873:                    throw new WSRPException(
1874:                            "WSRPFactory.getJAXBPropertyDescription(): failed to create JAXB object.",
1875:                            jbe);
1876:                }
1877:
1878:                jpd.setName(pd.getName());
1879:                jpd.setType(pd.getType());
1880:
1881:                LocalizedString l = pd.getLabel();
1882:                if (l != null) {
1883:                    jpd.setLabel(getJAXBLocalizedStringType(l));
1884:                }
1885:
1886:                LocalizedString h = pd.getHint();
1887:                if (h != null) {
1888:                    jpd.setHint(getJAXBLocalizedStringType(h));
1889:                }
1890:
1891:                List jexs = jpd.getExtensions();
1892:                Extension[] exs = pd.getExtensions();
1893:                if (exs != null && exs.length > 0) {
1894:                    for (int i = 0; i < exs.length; i++) {
1895:                        jexs.add(getJAXBExtensionType(exs[i]));
1896:                    }
1897:                }
1898:
1899:                return jpd;
1900:            }
1901:
1902:            public static Extension getExtension(JAXBExtensionType jex) {
1903:                if (jex == null) {
1904:                    return null;
1905:                }
1906:
1907:                Extension e = new Extension();
1908:
1909:                e.set_any((javax.xml.soap.SOAPElement) jex.getAny());
1910:
1911:                return e;
1912:            }
1913:
1914:            public JAXBExtensionType getJAXBExtensionType(Extension ex)
1915:                    throws WSRPException {
1916:                if (ex == null) {
1917:                    return null;
1918:                }
1919:
1920:                JAXBExtensionType je = null;
1921:                try {
1922:                    je = jfactory.createJAXBExtensionType();
1923:                } catch (JAXBException jbe) {
1924:                    throw new WSRPException(
1925:                            "WSRPFactory.getJAXBExtensionType(): failed to create JAXB object.",
1926:                            jbe);
1927:                }
1928:
1929:                je.setAny(ex.get_any());
1930:
1931:                return je;
1932:            }
1933:
1934:            public static LocalizedString getLocalizedString(
1935:                    JAXBLocalizedStringType jls, String resourceName) {
1936:                if (jls == null) {
1937:                    return null;
1938:                }
1939:
1940:                LocalizedString ls = new LocalizedString();
1941:
1942:                ls.setLang(jls.getLang());
1943:
1944:                ls.setResourceName(resourceName);
1945:
1946:                ls.setValue(jls.getValue());
1947:
1948:                return ls;
1949:            }
1950:
1951:            public static LocalizedString getLocalizedString(
1952:                    JAXBLocalizedStringType jls) {
1953:                if (jls == null) {
1954:                    return null;
1955:                }
1956:
1957:                LocalizedString ls = new LocalizedString();
1958:
1959:                ls.setLang(jls.getLang());
1960:
1961:                ls.setResourceName(jls.getResourceName());
1962:
1963:                ls.setValue(jls.getValue());
1964:
1965:                return ls;
1966:            }
1967:
1968:            public JAXBLocalizedStringType getJAXBLocalizedStringType(
1969:                    LocalizedString ls) throws WSRPException {
1970:                if (ls == null) {
1971:                    return null;
1972:                }
1973:
1974:                JAXBLocalizedStringType jls = null;
1975:                try {
1976:                    jls = jfactory.createJAXBLocalizedStringType();
1977:                } catch (JAXBException jbe) {
1978:                    throw new WSRPException(
1979:                            "WSRPFactory.getJAXBLocalizedStringType(): failed to create JAXB object.",
1980:                            jbe);
1981:                }
1982:
1983:                jls.setLang(ls.getLang());
1984:
1985:                jls.setResourceName(ls.getResourceName());
1986:
1987:                jls.setValue(ls.getValue());
1988:
1989:                return jls;
1990:            }
1991:
1992:            public String getJAXBXML(Object jaxbObject) throws WSRPException {
1993:                return getJAXBXML(jaxbObject, false);
1994:            }
1995:
1996:            /**
1997:             * Gets the JAXB marshalled XML string.
1998:             */
1999:            public String getJAXBXML(Object jaxbObject, boolean isFormatted)
2000:                    throws WSRPException {
2001:                ByteArrayOutputStream os = new ByteArrayOutputStream();
2002:
2003:                try {
2004:                    Marshaller marshaller = jc.createMarshaller();
2005:                    if (isFormatted) {
2006:                        marshaller.setProperty(
2007:                                Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
2008:                    }
2009:                    marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
2010:                    marshaller.marshal(jaxbObject, os);
2011:                } catch (JAXBException je) {
2012:                    throw new WSRPException("could not marshal jaxb object", je);
2013:                }
2014:
2015:                String s = null;
2016:                try {
2017:                    s = os.toString("UTF-8");
2018:                } catch (UnsupportedEncodingException uee) {
2019:                    throw new WSRPException(
2020:                            "could not encode marshalled string s=" + s, uee);
2021:                }
2022:
2023:                return s;
2024:            }
2025:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.