Package org.apache.pivot.web

Examples of org.apache.pivot.web.GetQuery


            }
        }

        // Execute the query
        if (symbols.getLength() > 0) {
            getQuery = new GetQuery(SERVICE_HOSTNAME, SERVICE_PATH);

            StringBuilder symbolsArgumentBuilder = new StringBuilder();
            for (int i = 0, n = symbols.getLength(); i < n; i++) {
                if (i > 0) {
                    symbolsArgumentBuilder.append(",");
View Full Code Here


            throw new IllegalStateException();
        }

        String country = Locale.getDefault().getCountry().toLowerCase();

        getQuery = new GetQuery(QUERY_HOSTNAME, BASE_QUERY_PATH);
        getQuery.getParameters().put("term", term);
        getQuery.getParameters().put("country", country);
        getQuery.getParameters().put("media", MEDIA);
        getQuery.getParameters().put("limit", Integer.toString(LIMIT));
        getQuery.getParameters().put("output", "json");
View Full Code Here

                return false;
            }
        });

        GetQuery getQuery = new GetQuery("feeds.dzone.com", "/javalobby/frontpage");
        getQuery.setSerializer(new XMLSerializer());
        getQuery.getParameters().put("format", "xml");

        getQuery.execute(new TaskAdapter<Object>(new TaskListener<Object>() {
            @Override
            public void taskExecuted(Task<Object> task) {
                Element root = (Element)task.getResult();
                feedListView.setListData(XML.getElements(root, "channel", "item"));
                cardPane.setSelectedIndex(1);
View Full Code Here

        assertNotNull(location);

        String path = location.getPath();

        // Read
        GetQuery getQuery = new GetQuery(hostname, port, path, secure);

        Object result = getQuery.execute();
        assertEquals(JSON.get(contact, "address.street"), JSON.get(result, "address.street"));
        assertEquals(contact, result);

        // Update
        JSON.put(contact, "name", "Joseph User");
        PutQuery putQuery = new PutQuery(hostname, port, path, secure);
        putQuery.setValue(contact);
        boolean created = putQuery.execute();

        assertFalse(created);
        assertEquals(contact, getQuery.execute());

        // Delete
        DeleteQuery deleteQuery = new DeleteQuery(hostname, port, path, secure);
        deleteQuery.execute();
View Full Code Here

        assertEquals(deleteQuery.getStatus(), Query.Status.NO_CONTENT);
    }

    @Test(expected=QueryException.class)
    public void testException() throws IOException, SerializationException, QueryException {
        GetQuery getQuery = new GetQuery(hostname, port, "/pivot-demos/rest_demo/foo", secure);
        getQuery.execute();
    }
View Full Code Here

        } catch (UnsupportedEncodingException exception) {
            throw new RuntimeException(exception);
        }

        // Create query
        suggestionQuery = new GetQuery("search.yahooapis.com", "/WebSearchService/V1/relatedSuggestion");
        suggestionQuery.getParameters().put("appid", getClass().getName());
        suggestionQuery.getParameters().put("query", text);
        suggestionQuery.getParameters().put("output", "json");

        suggestionQuery.execute(new TaskAdapter<Object>(new TaskListener<Object>() {
View Full Code Here

        refreshExpenseList();
    }

    private void refreshExpenseList() {
        Expenses expensesApplication = Expenses.getInstance();
        GetQuery expenseListQuery = new GetQuery(expensesApplication.getHostname(),
            expensesApplication.getPort(), "/pivot-tutorials/expenses",
            expensesApplication.isSecure());

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

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

        listView = (ListView)wtkxSerializer.get("listView");
        loadingLabel = (Label)wtkxSerializer.get("loadingLabel");

        // Execute the query:
        // http://pipes.yahoo.com/pipes/pipe.run?_id=43115761f2da5af5341ae2e56a93d646&_render=json
        GetQuery getQuery = new GetQuery("pipes.yahoo.com", "/pipes/pipe.run");
        getQuery.getParameters().put("_id", "43115761f2da5af5341ae2e56a93d646");
        getQuery.getParameters().put("_render", "json");

        getQuery.execute(new TaskAdapter<Object>(new TaskListener<Object>() {
            @Override
            public void taskExecuted(Task<Object> task) {
                listView.setListData(JSON.getList(task.getResult(), "value.items"));
                loadingLabel.setVisible(false);
            }
View Full Code Here

        final BasicAuthentication authentication = new BasicAuthentication("foo", "bar");

        TaskGroup queryGroup = new TaskGroup();

        // GET
        final GetQuery getQuery = new GetQuery(HOSTNAME, PORT, PATH, SECURE);
        getQuery.getParameters().put("a", "b");
        getQuery.setSerializer(new BinarySerializer());
        getQuery.getRequestHeaders().add("bar", "hello");
        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

    public void resume() {
    }

    @SuppressWarnings("unchecked")
    private void refreshTable() {
        getQuery = new GetQuery(SERVICE_HOSTNAME, SERVICE_PATH);

        StringBuilder symbolsArgumentBuilder = new StringBuilder();
        for (int i = 0, n = symbols.getLength(); i < n; i++) {
            if (i > 0) {
                symbolsArgumentBuilder.append(",");
View Full Code Here

TOP

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

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.