001package com.box.sdk; 002 003/** 004 * Global settings to apply to all API requests. 005 */ 006public final class BoxGlobalSettings { 007 private static int connectTimeout = 0; 008 private static int readTimeout = 0; 009 private static int maxRetryAttempts = BoxAPIConnection.DEFAULT_MAX_RETRIES; 010 011 private BoxGlobalSettings() { 012 } 013 014 /** 015 * Returns the current global connect timeout. 016 * @return connect timeout 017 */ 018 public static int getConnectTimeout() { 019 return connectTimeout; 020 } 021 022 /** 023 * Sets the global connect timeout. 024 * @param connectTimeout timeout in milliseconds 025 */ 026 public static void setConnectTimeout(int connectTimeout) { 027 BoxGlobalSettings.connectTimeout = connectTimeout; 028 } 029 030 /** 031 * Returns the current global read timeout. 032 * @return read timeout 033 */ 034 public static int getReadTimeout() { 035 return readTimeout; 036 } 037 038 /** 039 * Sets the global read timeout. 040 * @param readTimeout timeout in milliseconds 041 */ 042 public static void setReadTimeout(int readTimeout) { 043 BoxGlobalSettings.readTimeout = readTimeout; 044 } 045 046 /** 047 * Returns the global total maximum number of times an API request will be tried when error responses 048 * are received. 049 * @return max number of request attempts 050 * @deprecated getMaxRetryAttempts is preferred because it more clearly gets the number 051 * of times a request should be retried after an error response is received. 052 */ 053 @Deprecated 054 public static int getMaxRequestAttempts() { 055 return maxRetryAttempts + 1; 056 } 057 058 /** 059 * Sets the global total maximum number of times an API request will be tried when error responses 060 * are received. 061 * @param attempts maximum number of request attempts 062 * @deprecated setMaxRetryAttempts is preferred because it more clearly sets the number 063 * of times a request should be retried after an error response is received. 064 */ 065 @Deprecated 066 public static void setMaxRequestAttempts(int attempts) { 067 BoxGlobalSettings.maxRetryAttempts = attempts - 1; 068 } 069 070 /** 071 * Returns the global maximum number of times an API request will be retried after an error response 072 * is received. 073 * @return max number of request attempts 074 */ 075 public static int getMaxRetryAttempts() { 076 return maxRetryAttempts; 077 } 078 079 /** 080 * Sets the global maximum number of times an API request will be retried after an error response 081 * is received. 082 * @param attempts maximum number of request attempts 083 */ 084 public static void setMaxRetryAttempts(int attempts) { 085 BoxGlobalSettings.maxRetryAttempts = attempts; 086 } 087}