All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ning.api.client.access.impl.DefaultDeleter Maven / Gradle / Ivy

There is a newer version: 0.5.1
Show newest version
package com.ning.api.client.access.impl;

import com.ning.api.client.NingClientConfig;
import com.ning.api.client.access.NingConnection;
import com.ning.api.client.action.Deleter;
import com.ning.api.client.http.NingHttpDelete;
import com.ning.api.client.http.NingHttpException;
import com.ning.api.client.http.NingHttpResponse;
import com.ning.api.client.item.ContentItem;
import com.ning.api.client.item.Key;

public class DefaultDeleter>
    implements Deleter
{
    protected final NingConnection connection;

    protected NingClientConfig config;
    
    /**
     * Request end point used for fetching items
     */
    protected final String endpoint;

    protected final Key id;

    public DefaultDeleter(NingConnection connection, NingClientConfig config, String endpoint,
            String id)
    {
        this(connection, config, endpoint, new Key(id));
    }
    
    public DefaultDeleter(NingConnection connection, NingClientConfig config, String endpoint,
            Key id)
    {
        this.connection = connection;
        this.config = config;
        this.endpoint = endpoint;
        this.id = id;
    }

    public void delete() throws NingHttpException
    {
        NingHttpDelete deleter = buildRequest(id);
        // should we wait big longer for successful modification?
        NingHttpResponse  response = deleter.execute(config.getWriteTimeoutMsecs());
        response.verifyResponse();
    }

    protected NingHttpDelete buildRequest(Key id)
    {
        NingHttpDelete deleter = connection.prepareHttpDelete(endpoint);
        deleter = deleter.addAccept("*/*");
        deleter = deleter.addQueryParameter("id", id.toString());
        return deleter;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy