Package dk.i2m.drupal.util

Examples of dk.i2m.drupal.util.URLBuilder$QueryParam


        this.username = username;
        this.password = password;
    }

    public void login() throws HttpResponseException, IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.add("login");

        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("username", username));
        nvps.add(new BasicNameValuePair("password", password));

        HttpPost method = new HttpPost(builder.toURI());
        method.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));

        ResponseHandler<String> handler = new BasicResponseHandler();
        getDc().getHttpClient().execute(method, handler);
    }
View Full Code Here


        ResponseHandler<String> handler = new BasicResponseHandler();
        getDc().getHttpClient().execute(method, handler);
    }

    public void logout() throws HttpResponseException, IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.add("logout");

        HttpPost method = new HttpPost(builder.toURI());

        ResponseHandler<String> handler = new BasicResponseHandler();
        getDc().getHttpClient().execute(method, handler);
    }
View Full Code Here

        super(dc);
    }

    public NodeMessage create(UrlEncodedFormEntity uefe) throws
            HttpResponseException, IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());

        HttpPost method = new HttpPost(builder.toURI());
        method.setEntity(uefe);

        ResponseHandler<String> handler = new BasicResponseHandler();
        String response = getDc().getHttpClient().execute(method, handler);
View Full Code Here

        return new Gson().fromJson(response, NodeMessage.class);
    }

    public NodeMessage retrieve(Long id) throws HttpResponseException,
            IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.add(id);

        HttpGet method = new HttpGet(builder.toURI());

        ResponseHandler<String> handler = new BasicResponseHandler();
        String response = getDc().getHttpClient().execute(method, handler);

        return new Gson().fromJson(response, NodeMessage.class);
View Full Code Here

        return new Gson().fromJson(response, NodeMessage.class);
    }

    public NodeMessage update(Long id, UrlEncodedFormEntity uefe) throws
            HttpResponseException, IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.add(id);

        HttpPut method = new HttpPut(builder.toURI());
        method.setEntity(uefe);

        ResponseHandler<String> handler = new BasicResponseHandler();
        String response = getDc().getHttpClient().execute(method, handler);
View Full Code Here

        return new Gson().fromJson(response, NodeMessage.class);
    }

    public boolean delete(Long id) throws HttpResponseException, IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.add(id);

        HttpDelete method = new HttpDelete(builder.toURI());

        ResponseHandler<String> handler = new BasicResponseHandler();
        String response = getDc().getHttpClient().execute(method, handler);

        return Boolean.valueOf(response);
View Full Code Here

        return Boolean.valueOf(response);
    }

    public List<NodeMessage> index(Map<Object, Object> params) throws
            HttpResponseException, IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.addQuery(params);

        HttpGet method = new HttpGet(builder.toURI());

        ResponseHandler<String> handler = new BasicResponseHandler();
        String response = getDc().getHttpClient().execute(method, handler);

        return new Gson().fromJson(response,
View Full Code Here

                }.getType());
    }

    public List<FileMessage> loadFiles(Long id) throws HttpResponseException,
            IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.add(id);
        builder.add("files");
        builder.add(0); // Do not return the file contents (base64)

        HttpGet method = new HttpGet(builder.toURI());

        ResponseHandler<String> handler = new BasicResponseHandler();
        String response = getDc().getHttpClient().execute(method, handler);

        return new Gson().fromJson(response,
View Full Code Here

    }

    public List<FileMessage> attachFiles(Long id, Map<File, String> files,
            String fieldName, boolean attach) throws HttpResponseException,
            MimeTypeException, IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.add(id);
        builder.add("attach_file");

        MultipartEntity entity = EntityUtils.getMultipartEntity(files);
        entity.addPart("field_name", new StringBody(fieldName));
        entity.addPart("attach", new StringBody((attach ? "1" : "0")));

        HttpPost method = new HttpPost(builder.toURI());
        method.setEntity(entity);

        ResponseHandler<String> handler = new BasicResponseHandler();
        String response = getDc().getHttpClient().execute(method, handler);
View Full Code Here

        super(dc);
    }

    public List<FileMessage> createRaw(Map<File, String> files) throws
            HttpResponseException, MimeTypeException, IOException {
        URLBuilder builder = new URLBuilder(getDc().getHostname());
        builder.add(getDc().getEndpoint());
        builder.add(getAlias());
        builder.add("create_raw");

        HttpPost method = new HttpPost(builder.toURI());
        method.setEntity(EntityUtils.getMultipartEntity(files));

        ResponseHandler<String> handler = new BasicResponseHandler();
        String response = getDc().getHttpClient().execute(method, handler);
View Full Code Here

TOP

Related Classes of dk.i2m.drupal.util.URLBuilder$QueryParam

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.