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 Proxy = null;
	public final static String ProxyPort = "0";
	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";
	public final static String IgnoreSslDomainVerification = "ignoreSslDomainVerification";

	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(IgnoreSslDomainVerification, config.getIgnoreSslDomainVerification());
		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(IgnoreSslDomainVerification, false);
		params.put(EndPoint, "http://www.kaltura.com/");
	}


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

	public String getProxy() {
		return (String) params.get(Proxy);
	}
	public int getProxyPort() {
		return (int) params.get(ProxyPort);
	}

	@Override
	public boolean getIgnoreSslDomainVerification() {
		return (boolean) params.get(IgnoreSslDomainVerification);
	}

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

	public void setProxy(String proxy) {
		params.put(Proxy, proxy);
	}

	public void setProxyPort(int proxyPort) {
		params.put(ProxyPort, proxyPort);
	}


	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 setIgnoreSslDomainVerification(boolean ignore) { params.put(IgnoreSslDomainVerification, ignore); } 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