Package de.innovationgate.webgate.api

Examples of de.innovationgate.webgate.api.WGIllegalDataException


                try {
                    XStream xstream = new XStream(new Dom4JDriver());
                    return xstream.fromXML(item.getText());
                }
                catch (Exception e) {
                    throw new WGIllegalDataException("Error deserializing itemvalue of type 'ITEMTYPE_SERIALIZED_XSTREAM'.", e);
                }

            case ITEMTYPE_SERIALIZED_CASTOR:
                Unmarshaller unmarshaller = new Unmarshaller();
                try {

                    // Workaround for castor bug. Primitive wrappers for
                    // boolean, character, long do not contain xsi:type
                    Document doc = DocumentHelper.parseText(item.getText());
                    Element root = doc.getRootElement();
                    if (root.getName().equals("boolean")) {
                        root.addNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                        root.addAttribute("xsi:type", "java:java.lang.Boolean");
                    }
                    else if (root.getName().equals("character")) {
                        root.addNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                        root.addAttribute("xsi:type", "java:java.lang.Boolean");
                    }
                    else if (root.getName().equals("long")) {
                        root.addNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                        root.addAttribute("xsi:type", "java:java.lang.Long");
                    }
                    else if (root.getName().equals("array-list")) {
                        root.addNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                        root.addAttribute("xsi:type", "java:java.util.ArrayList");
                    }

                    DOMWriter domWriter = new DOMWriter();
                    return unmarshaller.unmarshal(domWriter.write(doc));
                    // return unmarshaller.unmarshal(new
                    // StringReader(item.getText()));
                }
                catch (MarshalException e) {
                    throw new WGIllegalDataException("Error unmarshaling serialized object", e);
                }
                catch (ValidationException e) {
                    throw new WGIllegalDataException("Error unmarshaling serialized object", e);
                }
                catch (DocumentException e) {
                    throw new WGIllegalDataException("Error unmarshaling serialized object", e);
                }

            case ITEMTYPE_STRING:
                return item.getText();
View Full Code Here

TOP

Related Classes of de.innovationgate.webgate.api.WGIllegalDataException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.