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

com.kaltura.client.Configuration Maven / Gradle / Ivy

Go to download

KalturaClient is a library of Java classes that can be used to interact with the Kaltura REST API. More information about the REST API can be found at http://corp.kaltura.com/Products/Kaltura-API Many of the Java classes in this library are auto-generated from a schema that defines the objects that are used to interect with the API. The current schema can be found at http://www.kaltura.com/api_v3/api_schema.php

There is a newer version: 19.3.0
Show newest version
// ===================================================================================================
//                           _  __     _ _
//                          | |/ /__ _| | |_ _  _ _ _ __ _
//                          | ' .
//
// @ignore
// ===================================================================================================
package com.kaltura.client;

import com.kaltura.client.utils.request.ConnectionConfiguration;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * This class holds information needed by the Kaltura client to establish a session.
 * 
 * @author jpotts
 *
 */
public class Configuration implements Serializable, ConnectionConfiguration {

	private static final long serialVersionUID = 2096581946429839651L;
	
	public final static String EndPoint = "endpoint";
	public final static String ConnectTimeout = "connectTimeout";
	public final static String ReadTimeout = "readTimeout";
	public final static String WriteTimeout = "writeTimeout";
	public final static String MaxRetry = "maxRetry";
	public final static String AcceptGzipEncoding = "acceptGzipEncoding";
	public final static String ResponseTypeFormat = "responseTypeFormat";

	/*private String endpoint = "";
	private int connectTimeout = 20000;
	private int readTimeout = connectTimeout;
	private int writeTimeout = 30000;
	private int maxRequestRetry = 3;
    private KalturaServiceResponseTypeFormat serviceFormat = KalturaServiceResponseTypeFormat.RESPONSE_TYPE_JSON;
	private Map params;*/

	private Map params;

	public static ConnectionConfiguration getDefaults(){
		return new Configuration();
	}

	public Configuration(){
		initDefaults();
	}

	public Configuration(Map config){
		initDefaults();
		params.putAll(config);
	}

	public Configuration(ConnectionConfiguration config) {
		params = new HashMap();
		params.put(ConnectTimeout, config.getConnectTimeout());
		params.put(ReadTimeout, config.getReadTimeout());
		params.put(WriteTimeout, config.getWriteTimeout());
		params.put(MaxRetry, config.getMaxRetry(2));
		params.put(AcceptGzipEncoding, config.getAcceptGzipEncoding());
		params.put(ResponseTypeFormat, config.getTypeFormat());
		params.put(EndPoint, config.getEndpoint());
	}

	private void initDefaults() {
		params = new HashMap();
		params.put(ConnectTimeout, 20000);
		params.put(ReadTimeout, 20000);
		params.put(WriteTimeout, 30000);
		params.put(MaxRetry, 3);
		params.put(AcceptGzipEncoding, false);
		params.put(ResponseTypeFormat, ServiceResponseTypeFormat.RESPONSE_TYPE_JSON.getValue());
		params.put(EndPoint, "http://www.kaltura.com/");
	}


	public String getEndpoint() {
		return (String) params.get(EndPoint);
	}

	@Override
	public int getTypeFormat() {
		return (int) params.get(ResponseTypeFormat);
	}

	public void setEndpoint(String endpoint) {
		this.params.put(EndPoint, endpoint);
	}

	public Map getParams() {
		return params;
	}

	public void setParams(Map params) {
		this.params = params;
	}

	public void setParam(String key, Object value){
		params.put(key, value);
	}

	public Object getParam(String key){
		return params.get(key);
	}

	public Object getParam(String key, Object defaultValue){
		return params.containsKey(key) ? params.get(key) : defaultValue;
	}

	public int getConnectTimeout() {
		return (int) params.get(ConnectTimeout);
	}

	public void setConnectTimeout(int connectTimeout) {
		params.put(ConnectTimeout, connectTimeout);
	}

	public int getReadTimeout() {
		return (int) params.get(ReadTimeout);
	}

	public void setReadTimeout(int readTimeout) {
		params.put(ReadTimeout, readTimeout);
	}

	public int getWriteTimeout() {
		return (int) params.get(WriteTimeout);
	}

	public void setWriteTimeout(int writeTimeout) {
		params.put(WriteTimeout, writeTimeout);
	}

	/**
	 * Return whether to accept GZIP encoding, that is, whether to
	 * send the HTTP "Accept-Encoding" header with "gzip" as value.
	 */
	public boolean getAcceptGzipEncoding(){
		return (boolean) params.get(AcceptGzipEncoding);
	}

	/**
	 * Set whether to accept GZIP encoding, that is, whether to
	 * send the HTTP "Accept-Encoding" header with "gzip" as value.
	 * 

Default is "true". Turn this flag off if you do not want * GZIP response compression even if enabled on the HTTP server. * * @param accept accept or not */ public void setAcceptGzipEncoding(boolean accept){ params.put(AcceptGzipEncoding, accept); } public void setServiceResponseTypeFormat(ServiceResponseTypeFormat format) { params.put(ResponseTypeFormat, format.getValue()); } public ServiceResponseTypeFormat getServiceResponseTypeFormat() { return ServiceResponseTypeFormat.get((int) params.get(ResponseTypeFormat)); } public void setMaxRetry(int retry) { params.put(MaxRetry, retry); } public int getMaxRetry(int defaultVal) { return params.containsKey(MaxRetry) ? (int) params.get(MaxRetry) : defaultVal; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy