com.kaltura.client.Configuration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kalturaApiClient Show documentation
Show all versions of kalturaApiClient Show documentation
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
// ===================================================================================================
// _ __ _ _
// | |/ /__ _| | |_ _ _ _ _ __ _
// | ' _` | | _| || | '_/ _` |
// |_|\_\__,_|_|\__|\_,_|_| \__,_|
//
// This file is part of the Kaltura Collaborative Media Suite which allows users
// to do with audio, video, and animation what Wiki platfroms allow them to do with
// text.
//
// Copyright (C) 2006-2011 Kaltura Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
//
// @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;
}
}