Package org.apache.pivot.web

Examples of org.apache.pivot.web.QueryException


    @Override
    protected URL doPost(Path path, Object value) throws QueryException {
        if (path.getLength() > 0
            || value == null) {
            throw new QueryException(Query.Status.BAD_REQUEST);
        }

        // Write the value to a temp file
        File directory = new File(System.getProperty("java.io.tmpdir"));
        File file;
        try {
            file = File.createTempFile(getClass().getName(), null, directory);

            JSONSerializer jsonSerializer = new JSONSerializer();
            jsonSerializer.writeObject(value, new FileOutputStream(file));
        } catch (IOException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        } catch (SerializationException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        }

        // Return the location of the resource
        URL location;
        try {
            location = new URL(getLocation(), file.getName());
        } catch (MalformedURLException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        }

        return location;
    }
View Full Code Here


    @Override
    protected boolean doPut(Path path, Object value) throws QueryException {
        if (path.getLength() != 1
            || value == null) {
            throw new QueryException(Query.Status.BAD_REQUEST);
        }

        // Write the value to the temp file
        File directory = new File(System.getProperty("java.io.tmpdir"));
        File file = new File(directory, path.get(0));
        if (!file.exists()) {
            throw new QueryException(Query.Status.NOT_FOUND);
        }

        try {
            JSONSerializer jsonSerializer = new JSONSerializer();
            jsonSerializer.writeObject(value, new FileOutputStream(file));
        } catch (IOException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        } catch (SerializationException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        }

        return false;
    }
View Full Code Here

    }

    @Override
    protected void doDelete(Path path) throws QueryException {
        if (path.getLength() != 1) {
            throw new QueryException(Query.Status.BAD_REQUEST);
        }

        // Delete the file
        File directory = new File(System.getProperty("java.io.tmpdir"));
        File file = new File(directory, path.get(0));
        if (!file.exists()) {
            throw new QueryException(Query.Status.NOT_FOUND);
        }

        boolean deleted = file.delete();
        if (!deleted)
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
    }
View Full Code Here

    private static final long serialVersionUID = 0;

    @Override
    protected Object doGet(Path path) throws QueryException {
        if (path.getLength() != 1) {
            throw new QueryException(Query.Status.BAD_REQUEST);
        }

        // Read the value from the temp file
        File directory = new File(System.getProperty("java.io.tmpdir"));
        File file = new File(directory, path.get(0));
        if (!file.exists()) {
            throw new QueryException(Query.Status.NOT_FOUND);
        }

        Object value;
        try {
            JSONSerializer jsonSerializer = new JSONSerializer();
            value = jsonSerializer.readObject(new FileInputStream(file));
        } catch (IOException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        } catch (SerializationException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        }

        return value;
    }
View Full Code Here

     * The result of the GET.
     *
     * @throws QueryException
     */
    protected Object doGet(Path path) throws QueryException {
        throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
    }
View Full Code Here

     * operation did not result in the creation of a resource.
     *
     * @throws QueryException
     */
    protected URL doPost(Path path, Object value) throws QueryException {
        throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
    }
View Full Code Here

     * <tt>false</tt>, otherwise.
     *
     * @throws QueryException
     */
    protected boolean doPut(Path path, Object value) throws QueryException {
        throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
    }
View Full Code Here

     * @param path
     *
     * @throws QueryException
     */
    protected void doDelete(Path path) throws QueryException {
        throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
    }
View Full Code Here

     * operation did not result in the creation of a resource.
     *
     * @throws QueryException
     */
    protected URL doPost(Path path, Object value) throws QueryException {
        throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
    }
View Full Code Here

     * <tt>false</tt>, otherwise.
     *
     * @throws QueryException
     */
    protected boolean doPut(Path path, Object value) throws QueryException {
        throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.web.QueryException

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.