Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
Taras Kunyk edited this page May 13, 2015 · 5 revisions

Do my entities have to be inherited from AbstractDrupalEntity?

No, you can just wrap your objects with DrupalEntityContainer or AbstractDrupalArrayEntity to get full api functionality without inheriting AbstractDrupalEntity.

How to perform requests which are not binded to entities?

DrupalArrayEntity - container, implementing collection interface. Can manage drupal and non-drupal entities, providing them with all DrupalEntity methods like post, push, pull, delete.

DrupalEntityContainer - wrapper object, able to contain drupal or non-drupal entities providing them with all DrupalEntity methods like post, push, pull, delete.

Note: in case of raw content item types deserialization issues may occur.

You shouldn’t store instances of this class (or subclasses) as serializable fields: objects, containing subclasses of this entity container won’t be able to deserialize them correctly.

How to implement global authentication?

Implement ILoginManager interface and pass to DrupalClient constructor.

How to cancel request?

You can use drupal client instance to cancel all pending requests

DrupalClient drupalClient = ...
drupalClient.cancelAll();

Or cancel requests by tag/listener

DrupalClient drupalClient = ...
drupalClient.cancelAllRequestsForListener(OnResponseListener, tag);

Also it is possible to cancel requests related to specific entity

drupalEntity.cancellAllRequests().

How to track active requests count?

DrupalClient drupalClient = ...
drupalClient.setProgressListener(new DrupalClient.RequestProgressListener() {
	@Override
	public void onRequestStarted(DrupalClient theClient, int activeRequests) {
		if (activeRequests > 0) {
			// show progress
		}
	}

	@Override
	public void onRequestFinished(DrupalClient theClient, int activeRequests) {
		if (activeRequests == 0) {
			// hide progress
		}
	}
});

How to handle non-json requests and responses?

You have to specify request format you need while creating DrupalClient or in AbstractBaseDrupalEntity class:

@override
protected RequestConfig getRequestConfig(RequestMethod method,Object resultClass)
{
	RequestConfig config = super.getRequestConfig(method,resultClass);
	config.setRequestFormat(RequestFormat.XML);
	return config;
}

and implement IResponseItem and IPostableItem interfaces by your class drupal class or container to customize object serialization and deserialization.

Can I use your client without any drupal entities?

Yes, you can just create BaseRequest objects and deal with them, using our api as simple networking library:

RequestConfig config = new RequestConfig(respTypeSpec);
BaseRequest request = new BaseRequest(RequestMethod.GET,
						"some/relative/url",config);
myClient.performRequest(request,myTag,myListener,synchronous);