com.tinkerpop.rexster.extension.AbstractRexsterExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rexster-core Show documentation
Show all versions of rexster-core Show documentation
Core components for extending Rexster.
The newest version!
package com.tinkerpop.rexster.extension;
import com.tinkerpop.rexster.Tokens;
import org.codehaus.jettison.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
* Base class for extensions. Consider using this class a starting point for extension creation.
*
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public abstract class AbstractRexsterExtension implements RexsterExtension {
/**
* By default this returns true. Overriding classes should evaluate the configuration to determine
* if it is correct.
*/
public boolean isConfigurationValid(ExtensionConfiguration extensionConfiguration) {
return true;
}
protected JSONObject generateErrorJson() {
return this.generateErrorJson(null);
}
/**
* Generates a standard JSON object with error information.
*
* @param api Adds an API element to the error output. If null the key will not be added.
*/
protected JSONObject generateErrorJson(JSONObject api) {
Map map = new HashMap();
map.put(Tokens.SUCCESS, false);
if (api != null) {
map.put(Tokens.API, api);
}
return new JSONObject(map);
}
}