Package org.apache.wink.common

Examples of org.apache.wink.common.RestException


     */
    public static AppService unmarshal(Reader reader) {
        try {
            return (AppService)AtomJAXBUtils.unmarshal(AppService.getUnmarshaller(), reader);
        } catch (IOException e) {
            throw new RestException(e);
        }
    }
View Full Code Here


     */
    public static AppCategories unmarshal(Reader reader) {
        try {
            return (AppCategories)AtomJAXBUtils.unmarshal(AppCategories.getUnmarshaller(), reader);
        } catch (IOException e) {
            throw new RestException(e);
        }
    }
View Full Code Here

     * Objects of the following type(s) are allowed in the list
     * {@link AtomCategory }
     */
    public List<AtomCategory> getCategory() {
        if (!isInline()) {
            throw new RestException(ERROR_MESSAGE);
        }
        return getCategoryNoCheck();
    }
View Full Code Here

        return getHref() == null;
    }

    public void checkValidity() {
        if ((getScheme() != null || getCategoryNoCheck().size() > 0 || isFixedSet()) && getHref() != null) {
            throw new RestException(ERROR_MESSAGE);
        }
    }
View Full Code Here

            Marshaller marshaller = context.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            return marshaller;
        } catch (JAXBException e) {
            throw new RestException(("failed to create WebDAV marshaller"), e);
        }
    }
View Full Code Here

    public static Unmarshaller createUnmarshaller() {
        try {
            Unmarshaller unmarshaller = context.createUnmarshaller();
            return unmarshaller;
        } catch (JAXBException e) {
            throw new RestException(("failed to create WebDAV unmarshaller"), e);
        }
    }
View Full Code Here

    public static void marshal(Marshaller m, Object element, Writer writer, String elementName) {
        try {
            m.marshal(element, writer);
        } catch (JAXBException e) {
            throw new RestException(String.format("Unable to marshal the WebDAV \"%s\" element",
                                                  elementName), e);
        }
    }
View Full Code Here

            Object object = u.unmarshal(reader);
            if (object instanceof JAXBElement) {
                object = ((JAXBElement<?>)object).getValue();
            }
            if (!(elementClass.equals(object.getClass()))) {
                throw new RestException(
                                        String
                                            .format("Incompatible type in the WebDAV \"%s\" element: received %s but the requested is %s",
                                                    elementName,
                                                    object.getClass().getName(),
                                                    elementClass.getName()));
            }
            return (T)object;
        } catch (JAXBException e) {
            throw new RestException(String.format("Unable to parse the WebDAV \"%s\" element",
                                                  elementName), e);
        }
    }
View Full Code Here

        return s != null ? s.toString() : null;
    }

    public void checkValidity() {
        if (getSrc() != null && getValue() != null) {
            throw new RestException("Content element may have either inline or out-of-line content");
        } else if (getSrc() != null && getType() != null) {
            if (type.equals("text") || type.equals("html") || type.equals("xhtml")) {
                throw new RestException(
                                        "Type attribute of content element must be a valid mime type when content is out-of-line");
            }
        }
    }
View Full Code Here

            if (handler instanceof LexicalHandler) {
                xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
            }
            xmlReader.parse(new InputSource(reader));
        } catch (SAXException e) {
            throw new RestException(errorMessage, e);
        } catch (ParserConfigurationException e) {
            // shoudln't happen
            throw new RestException(errorMessage, e);
        } catch (IOException e) {
            throw new RestException(errorMessage, e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.common.RestException

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.