Package org.apache.pivot.web

Examples of org.apache.pivot.web.PostQuery


                    final HashMap<String, Object> expense = new HashMap<String, Object>();
                    expenseSheet.store(expense);

                    // POST expense to server and then add to table
                    Expenses expensesApplicationLocal = getExpensesApplication();
                    PostQuery addExpenseQuery = new PostQuery(expensesApplicationLocal.getHostname(),
                        expensesApplicationLocal.getPort(), "/pivot-tutorials/expenses",
                        expensesApplicationLocal.isSecure()
                    );
                    addExpenseQuery.setValue(expense);

                    activityIndicatorBoxPane.setVisible(true);
                    activityIndicator.setActive(true);

                    addExpenseQuery.execute(new TaskAdapter<URL>(new TaskListener<URL>() {
                        @Override
                        public void taskExecuted(Task<URL> task) {
                            activityIndicatorBoxPane.setVisible(false);
                            activityIndicator.setActive(false);
View Full Code Here


                    final HashMap<String, Object> expense = new HashMap<String, Object>();
                    expenseSheet.store(expense);

                    // POST expense to server and then add to table
                    Expenses expensesApplication = Expenses.getInstance();
                    PostQuery addExpenseQuery = new PostQuery(expensesApplication.getHostname(),
                        expensesApplication.getPort(), "/pivot-tutorials/expenses",
                        expensesApplication.isSecure());
                    addExpenseQuery.setValue(expense);

                    activityIndicatorBoxPane.setVisible(true);
                    activityIndicator.setActive(true);

                    addExpenseQuery.execute(new TaskAdapter<URL>(new TaskListener<URL>() {
                        @Override
                        public void taskExecuted(Task<URL> task) {
                            activityIndicatorBoxPane.setVisible(false);
                            activityIndicator.setActive(false);
View Full Code Here

                    final HashMap<String, Object> expense = new HashMap<String, Object>();
                    expenseSheet.store(expense);

                    // POST expense to server and then add to table
                    Expenses expensesApplication = Expenses.getInstance();
                    PostQuery addExpenseQuery = new PostQuery(expensesApplication.getHostname(),
                        expensesApplication.getPort(), "/pivot-tutorials/expenses",
                        expensesApplication.isSecure());
                    addExpenseQuery.setValue(expense);

                    activityIndicatorBoxPane.setVisible(true);
                    activityIndicator.setActive(true);

                    addExpenseQuery.execute(new TaskAdapter<URL>(new TaskListener<URL>() {
                        @Override
                        public void taskExecuted(Task<URL> task) {
                            activityIndicatorBoxPane.setVisible(false);
                            activityIndicator.setActive(false);
View Full Code Here

    public void testCRUD() throws IOException, SerializationException, QueryException {
        JSONSerializer jsonSerializer = new JSONSerializer();
        Object contact = jsonSerializer.readObject(getClass().getResourceAsStream("contact.json"));

        // Create
        PostQuery postQuery = new PostQuery(hostname, port, "/pivot-demos/rest_demo", secure);
        postQuery.setValue(contact);
        URL location = postQuery.execute();

        assertNotNull(location);

        String path = location.getPath();
View Full Code Here

                    final HashMap<String, Object> expense = new HashMap<String, Object>();
                    expenseSheet.store(expense);

                    // POST expense to server and then add to table
                    Expenses expensesApplication = Expenses.getInstance();
                    PostQuery addExpenseQuery = new PostQuery(expensesApplication.getHostname(),
                        expensesApplication.getPort(), "/pivot-tutorials/expenses",
                        expensesApplication.isSecure());
                    addExpenseQuery.setValue(expense);

                    activityIndicatorBoxPane.setVisible(true);
                    activityIndicator.setActive(true);

                    addExpenseQuery.execute(new TaskAdapter<URL>(new TaskListener<URL>() {
                        @Override
                        public void taskExecuted(Task<URL> task) {
                            activityIndicatorBoxPane.setVisible(false);
                            activityIndicator.setActive(false);
View Full Code Here

    public void testCRUD() throws IOException, SerializationException, QueryException {
        JSONSerializer jsonSerializer = new JSONSerializer();
        Object contact = jsonSerializer.readObject(getClass().getResourceAsStream("contact.json"));

        // Create
        PostQuery postQuery = new PostQuery(hostname, port, "/pivot-demos/rest_demo", secure);
        postQuery.setValue(contact);
        URL location = postQuery.execute();

        assertNotNull(location);

        String path = location.getPath();
View Full Code Here

                    final HashMap<String, Object> expense = new HashMap<String, Object>();
                    expenseSheet.store(expense);

                    // POST expense to server and then add to table
                    Expenses expensesApplication = Expenses.getInstance();
                    PostQuery addExpenseQuery = new PostQuery(expensesApplication.getHostname(),
                        expensesApplication.getPort(), "/pivot-tutorials/expenses",
                        expensesApplication.isSecure());
                    addExpenseQuery.setValue(expense);

                    activityIndicatorBoxPane.setVisible(true);
                    activityIndicator.setActive(true);

                    addExpenseQuery.execute(new TaskAdapter<URL>(new TaskListener<URL>() {
                        @Override
                        public void taskExecuted(Task<URL> task) {
                            activityIndicatorBoxPane.setVisible(false);
                            activityIndicator.setActive(false);
View Full Code Here

        getQuery.getRequestHeaders().add("bar", "world");
        authentication.authenticate(getQuery);
        queryGroup.add(getQuery);

        // POST
        final PostQuery postQuery = new PostQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(postQuery);
        postQuery.setValue(JSONSerializer.parseList("[1, 2, 3]"));
        queryGroup.add(postQuery);

        // PUT
        final PutQuery putQuery = new PutQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(putQuery);
        putQuery.setValue(JSONSerializer.parseMap("{a:100, b:200, c:300}"));
        queryGroup.add(putQuery);

        // POST
        final DeleteQuery deleteQuery = new DeleteQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(deleteQuery);
        queryGroup.add(deleteQuery);

        queryGroup.execute(new TaskListener<Void>() {
            @SuppressWarnings("unchecked")
            @Override
            public synchronized void taskExecuted(Task<Void> task) {
                Dictionary<String, Object> result = (Dictionary<String, Object>)getQuery.getResult();

                System.out.println("GET result: "
                    + "username: " + result.get("username") + ", "
                    + "pathInfo: " + result.get("pathInfo") + ", "
                    + "queryString: " + result.get("queryString") + ", "
                    + "status: " + getQuery.getStatus());

                QueryDictionary responseHeaders = getQuery.getResponseHeaders();
                for (String headerName : responseHeaders) {
                    System.out.print(headerName + "=");

                    for (int i = 0, n = responseHeaders.getLength(headerName); i < n; i++) {
                        System.out.print(responseHeaders.get(headerName, i) + ";");
                    }

                    System.out.print("\n");
                }
                System.out.println("GET fault: " + getQuery.getFault());

                System.out.println("POST result: " + task.getResult());
                System.out.println("POST fault: " + postQuery.getFault());

                System.out.println("PUT fault: " + putQuery.getFault());
                System.out.println("DELETE fault: " + deleteQuery.getFault());
            }

            @Override
            public synchronized void executeFailed(Task<Void> task) {
                // No-op; task groups don't fail
            }
        });

        synchronized(queryGroup) {
            if (queryGroup.isPending()) {
                try {
                    queryGroup.wait(10000);
                } catch(InterruptedException exception) {
                    throw new RuntimeException(exception);
                }
            }
        }

        assertTrue(getQuery.getFault() == null
            && postQuery.getFault() == null
            && putQuery.getFault() == null
            && deleteQuery.getFault() == null);
    }
View Full Code Here

TOP

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

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.