• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

smartsheet / smartsheet-java-sdk / #58

23 Sep 2025 06:13PM UTC coverage: 59.737% (-1.1%) from 60.803%
#58

push

github

web-flow
Add user downgrade seat type endpoint (#131)

* Add support for upgrade user seat type route

* Change return type

* Add support for the user downgrade seat type endpoint

* Remove * imports, replace switch with if statement, remove overload

* Update changelog and build.gradle

* Add user downgrade and upgrade API calls

* Add user downgrade and upgrade API calls

* Add user downgrade and upgrade API calls

* Add user downgrade and upgrade API calls

---------

Co-authored-by: Velihan Zelev <velihan.zelev@smartsheet.com>

12 of 13 new or added lines in 2 files covered. (92.31%)

192 existing lines in 7 files now uncovered.

4310 of 7215 relevant lines covered (59.74%)

0.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.19
/src/main/java/com/smartsheet/api/internal/AbstractResources.java
1
/*
2
 * Copyright (C) 2025 Smartsheet
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.smartsheet.api.internal;
18

19
import com.fasterxml.jackson.core.JsonParseException;
20
import com.fasterxml.jackson.databind.JsonMappingException;
21
import com.smartsheet.api.AuthorizationException;
22
import com.smartsheet.api.InvalidRequestException;
23
import com.smartsheet.api.ResourceNotFoundException;
24
import com.smartsheet.api.ServiceUnavailableException;
25
import com.smartsheet.api.SmartsheetException;
26
import com.smartsheet.api.SmartsheetRestException;
27
import com.smartsheet.api.internal.http.HttpEntity;
28
import com.smartsheet.api.internal.http.HttpMethod;
29
import com.smartsheet.api.internal.http.HttpRequest;
30
import com.smartsheet.api.internal.http.HttpResponse;
31
import com.smartsheet.api.internal.json.JSONSerializerException;
32
import com.smartsheet.api.internal.util.StreamUtil;
33
import com.smartsheet.api.internal.util.Util;
34
import com.smartsheet.api.models.Attachment;
35
import com.smartsheet.api.models.CopyOrMoveRowDirective;
36
import com.smartsheet.api.models.CopyOrMoveRowResult;
37
import com.smartsheet.api.models.PagedResult;
38
import com.smartsheet.api.models.Result;
39
import com.smartsheet.api.models.TokenPaginatedResult;
40
import com.fasterxml.jackson.databind.JsonDeserializer;
41
import org.apache.http.client.methods.CloseableHttpResponse;
42
import org.apache.http.client.methods.HttpPost;
43
import org.apache.http.entity.ContentType;
44
import org.apache.http.entity.mime.MultipartEntityBuilder;
45
import org.apache.http.impl.client.CloseableHttpClient;
46
import org.apache.http.impl.client.HttpClients;
47
import org.slf4j.Logger;
48
import org.slf4j.LoggerFactory;
49

50
import java.io.ByteArrayInputStream;
51
import java.io.ByteArrayOutputStream;
52
import java.io.IOException;
53
import java.io.InputStream;
54
import java.io.OutputStream;
55
import java.lang.reflect.InvocationTargetException;
56
import java.net.URI;
57
import java.net.URLEncoder;
58
import java.nio.charset.StandardCharsets;
59
import java.util.HashMap;
60
import java.util.List;
61
import java.util.Map;
62

63
/**
64
 * This is the base class of the Smartsheet REST API resources.
65
 * <p>
66
 * Thread Safety: This class is thread safe because it is immutable and the underlying SmartsheetImpl is thread safe.
67
 */
68
public abstract class AbstractResources {
69
    /**
70
     * this system property is used to control the number of characters logged from an API response in logs
71
     */
72
    public static final String PROPERTY_RESPONSE_LOG_CHARS = "Smartsheet.responseLogChars";
73

74
    private static final Logger log = LoggerFactory.getLogger(AbstractResources.class);
1✔
75

76
    /**
77
     * The Constant BUFFER_SIZE.
78
     */
79
    private static final int BUFFER_SIZE = 4098;
80

81
    private static final String JSON_CONTENT_TYPE = "application/json";
82
    private static final String HEADER_CONTENT_TYPE = "Content-Type";
83

84
    /**
85
     * The Enum ErrorCode.
86
     */
87
    public enum ErrorCode {
1✔
88
        BAD_REQUEST(400, InvalidRequestException.class),
1✔
89
        NOT_AUTHORIZED(401, AuthorizationException.class),
1✔
90
        FORBIDDEN(403, AuthorizationException.class),
1✔
91
        NOT_FOUND(404, ResourceNotFoundException.class),
1✔
92
        METHOD_NOT_SUPPORTED(405, InvalidRequestException.class),
1✔
93
        INTERNAL_SERVER_ERROR(500, InvalidRequestException.class),
1✔
94
        SERVICE_UNAVAILABLE(503, ServiceUnavailableException.class);
1✔
95

96
        /**
97
         * The error code.
98
         */
99
        int errorCode;
100

101
        /**
102
         * The Exception class.
103
         */
104
        Class<? extends SmartsheetRestException> exceptionClass;
105

106
        /**
107
         * Instantiates a new error code.
108
         *
109
         * @param errorCode      the error code
110
         * @param exceptionClass the Exception class
111
         */
112
        ErrorCode(int errorCode, Class<? extends SmartsheetRestException> exceptionClass) {
1✔
113
            this.errorCode = errorCode;
1✔
114
            this.exceptionClass = exceptionClass;
1✔
115
        }
1✔
116

117
        /**
118
         * Gets the error code.
119
         *
120
         * @param errorNumber the error number
121
         * @return the error code
122
         */
123
        public static ErrorCode getErrorCode(int errorNumber) {
124
            for (ErrorCode code : ErrorCode.values()) {
1✔
125
                if (code.errorCode == errorNumber) {
1✔
126
                    return code;
1✔
127
                }
128
            }
129

UNCOV
130
            return null;
×
131
        }
132

133
        /**
134
         * Gets the exception.
135
         *
136
         * @return the exception
137
         * @throws InstantiationException the instantiation exception
138
         * @throws IllegalAccessException the illegal access exception
139
         */
140
        public SmartsheetRestException getException() throws InstantiationException, IllegalAccessException {
UNCOV
141
            return exceptionClass.newInstance();
×
142
        }
143

144
        /**
145
         * Gets the exception.
146
         *
147
         * @param error the error
148
         * @return the exception
149
         * @throws SmartsheetException the smartsheet exception
150
         */
151
        public SmartsheetRestException getException(com.smartsheet.api.models.Error error) throws SmartsheetException {
152

153
            try {
154
                return exceptionClass.getConstructor(com.smartsheet.api.models.Error.class).newInstance(error);
1✔
155
            } catch (IllegalArgumentException e) {
×
156
                throw new SmartsheetException(e);
×
157
            } catch (SecurityException e) {
×
158
                throw new SmartsheetException(e);
×
159
            } catch (InstantiationException e) {
×
160
                throw new SmartsheetException(e);
×
161
            } catch (IllegalAccessException e) {
×
162
                throw new SmartsheetException(e);
×
163
            } catch (InvocationTargetException e) {
×
164
                throw new SmartsheetException(e);
×
UNCOV
165
            } catch (NoSuchMethodException e) {
×
UNCOV
166
                throw new SmartsheetException(e);
×
167
            }
168
        }
169
    }
170

171
    /**
172
     * Represents the SmartsheetImpl.
173
     * <p>
174
     * It will be initialized in constructor and will not change afterwards.
175
     */
176
    protected final SmartsheetImpl smartsheet;
177

178
    /**
179
     * Constructor.
180
     *
181
     * @param smartsheet the smartsheet
182
     */
183
    protected AbstractResources(SmartsheetImpl smartsheet) {
1✔
184
        Util.throwIfNull(smartsheet);
1✔
185

186
        this.smartsheet = smartsheet;
1✔
187
    }
1✔
188

189
    /**
190
     * Get a resource from Smartsheet REST API.
191
     * <p>
192
     * Parameters: - path : the relative path of the resource - objectClass : the resource object class
193
     * <p>
194
     * Returns: the resource (note that if there is no such resource, this method will throw ResourceNotFoundException
195
     * rather than returning null).
196
     * <p>
197
     * Exceptions: -
198
     * InvalidRequestException : if there is any problem with the REST API request
199
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
200
     * ResourceNotFoundException : if the resource can not be found
201
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
202
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
203
     * SmartsheetException : if there is any other error occurred during the operation
204
     *
205
     * @param <T>         the generic type
206
     * @param path        the relative path of the resource.
207
     * @param objectClass the object class
208
     * @return the resource
209
     * @throws SmartsheetException the smartsheet exception
210
     */
211
    protected <T> T getResource(String path, Class<T> objectClass) throws SmartsheetException {
212
        Util.throwIfNull(path, objectClass);
1✔
213

214
        if (path.isEmpty()) {
1✔
215
            com.smartsheet.api.models.Error error = new com.smartsheet.api.models.Error();
×
UNCOV
216
            error.setMessage("An empty path was provided.");
×
UNCOV
217
            throw new ResourceNotFoundException(error);
×
218
        }
219

220
        HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.GET);
1✔
221

222
        T obj = null;
1✔
223
        String content = null;
1✔
224
        try {
225
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
226
            InputStream inputStream = response.getEntity().getContent();
1✔
227
            switch (response.getStatusCode()) {
1✔
228
                case 200:
229
                    try {
230
                        if (log.isInfoEnabled()) {
1✔
231
                            ByteArrayOutputStream contentCopyStream = new ByteArrayOutputStream();
1✔
232
                            inputStream = StreamUtil.cloneContent(inputStream, response.getEntity().getContentLength(), contentCopyStream);
1✔
233
                            content = StreamUtil.toUtf8StringOrHex(contentCopyStream, getResponseLogLength());
1✔
234
                        }
235
                        obj = this.smartsheet.getJsonSerializer().deserialize(objectClass, inputStream);
1✔
236
                    } catch (JsonParseException e) {
×
237
                        log.info("failure parsing '{}'", content, e);
×
238
                        throw new SmartsheetException(e);
×
239
                    } catch (JsonMappingException e) {
×
240
                        log.info("failure mapping '{}'", content, e);
×
241
                        throw new SmartsheetException(e);
×
242
                    } catch (IOException e) {
×
UNCOV
243
                        log.info("failure loading '{}'", content, e);
×
UNCOV
244
                        throw new SmartsheetException(e);
×
245
                    }
1✔
246
                    break;
247
                default:
248
                    handleError(response);
×
249
            }
250
        } catch (JSONSerializerException jsx) {
×
UNCOV
251
            log.info("failed to parse '{}'", content, jsx);
×
UNCOV
252
            throw jsx;
×
253
        } finally {
254
            smartsheet.getHttpClient().releaseConnection();
1✔
255
        }
256
        return obj;
1✔
257
    }
258

259
    /**
260
     * Create a resource using Smartsheet REST API.
261
     * <p>
262
     * Exceptions:
263
     * IllegalArgumentException : if any argument is null, or path is empty string
264
     * InvalidRequestException : if there is any problem with the REST API request
265
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
266
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
267
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
268
     * SmartsheetException : if there is any other error occurred during the operation
269
     *
270
     * @param <T>         the generic type of object to return/deserialize
271
     * @param <S>         the generic type of object to serialize
272
     * @param path        the relative path of the resource collections
273
     * @param objectClass the resource object class
274
     * @param object      the object to create
275
     * @return the created resource
276
     * @throws SmartsheetException the smartsheet exception
277
     */
278
    protected <T, S> T createResource(String path, Class<T> objectClass, S object) throws SmartsheetException {
279
        Util.throwIfNull(path, object, objectClass);
1✔
280
        Util.throwIfEmpty(path);
1✔
281

282
        HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.POST);
1✔
283

284
        ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
1✔
285
        this.smartsheet.getJsonSerializer().serialize(object, objectBytesStream);
1✔
286
        HttpEntity entity = new HttpEntity();
1✔
287
        entity.setContentType(JSON_CONTENT_TYPE);
1✔
288
        entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
1✔
289
        entity.setContentLength(objectBytesStream.size());
1✔
290
        request.setEntity(entity);
1✔
291

292
        T obj = null;
1✔
293
        try {
294
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
295
            switch (response.getStatusCode()) {
1✔
296
                case 200: {
297
                    InputStream inputStream = response.getEntity().getContent();
1✔
298
                    String content = null;
1✔
299
                    try {
300
                        if (log.isInfoEnabled()) {
1✔
301
                            ByteArrayOutputStream contentCopyStream = new ByteArrayOutputStream();
1✔
302
                            inputStream = StreamUtil.cloneContent(inputStream, response.getEntity().getContentLength(), contentCopyStream);
1✔
303
                            content = StreamUtil.toUtf8StringOrHex(contentCopyStream, getResponseLogLength());
1✔
304
                        }
305
                        obj = this.smartsheet.getJsonSerializer().deserializeResult(objectClass, inputStream).getResult();
1✔
306
                    } catch (JSONSerializerException e) {
×
307
                        log.info("failure parsing '{}'", content, e);
×
308
                        throw new SmartsheetException(e);
×
309
                    } catch (IOException e) {
×
UNCOV
310
                        log.info("failure cloning content from inputStream '{}'", inputStream, e);
×
UNCOV
311
                        throw new SmartsheetException(e);
×
312
                    }
1✔
313
                    break;
314
                }
315
                default:
UNCOV
316
                    handleError(response);
×
317
            }
318
        } finally {
319
            smartsheet.getHttpClient().releaseConnection();
1✔
320
        }
321

322
        return obj;
1✔
323
    }
324

325
    /**
326
     * Create a resource using Smartsheet REST API.
327
     * <p>
328
     * Exceptions:
329
     * IllegalArgumentException : if any argument is null, or path is empty string
330
     * InvalidRequestException : if there is any problem with the REST API request
331
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
332
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
333
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
334
     * SmartsheetException : if there is any other error occurred during the operation
335
     *
336
     * @param <T>         the generic type
337
     * @param path        the relative path of the resource collections
338
     * @param objectClass the resource object class
339
     * @param object      the object to create
340
     * @return the created resource
341
     * @throws SmartsheetException the smartsheet exception
342
     */
343
    protected <T> T createResourceWithAttachment(
344
            String path,
345
            Class<T> objectClass,
346
            T object,
347
            String partName,
348
            InputStream inputStream,
349
            String contentType,
350
            String attachmentName
351
    ) throws SmartsheetException {
352
        Util.throwIfNull(path, object);
1✔
353
        Util.throwIfEmpty(path);
1✔
354

355
        HttpRequest request;
356
        final String boundary = "----" + System.currentTimeMillis();
1✔
357
        CloseableHttpClient httpClient = HttpClients.createDefault();
1✔
358
        HttpPost uploadFile = createHttpPost(this.getSmartsheet().getBaseURI().resolve(path));
1✔
359

360
        try {
361
            uploadFile.setHeader(HEADER_CONTENT_TYPE, "multipart/form-data; boundary=" + boundary);
1✔
UNCOV
362
        } catch (Exception e) {
×
UNCOV
363
            throw new RuntimeException(e);
×
364
        }
1✔
365

366
        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
1✔
367
        builder.setBoundary(boundary);
1✔
368
        builder.addTextBody(partName, this.getSmartsheet().getJsonSerializer().serialize(object), ContentType.APPLICATION_JSON);
1✔
369
        builder.addBinaryBody("file", inputStream, ContentType.create(contentType), attachmentName);
1✔
370
        org.apache.http.HttpEntity multipart = builder.build();
1✔
371

372
        uploadFile.setEntity(multipart);
1✔
373

374
        T obj = null;
1✔
375
        //implement switch case
376
        try {
377
            CloseableHttpResponse response = httpClient.execute(uploadFile);
1✔
378
            org.apache.http.HttpEntity responseEntity = response.getEntity();
1✔
379
            obj = this.getSmartsheet().getJsonSerializer().deserializeResult(objectClass,
1✔
380
                    responseEntity.getContent()).getResult();
1✔
UNCOV
381
        } catch (Exception e) {
×
UNCOV
382
            throw new RuntimeException(e);
×
383
        }
1✔
384
        return obj;
1✔
385
    }
386

387
    /**
388
     * Update a resource using Smartsheet REST API.
389
     * <p>
390
     * Exceptions:
391
     * IllegalArgumentException : if any argument is null, or path is empty string
392
     * InvalidRequestException : if there is any problem with the REST API request
393
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
394
     * ResourceNotFoundException : if the resource can not be found
395
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
396
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
397
     * SmartsheetException : if there is any other error occurred during the operation
398
     *
399
     * @param <T>         the generic type
400
     * @param path        the relative path of the resource
401
     * @param objectClass the resource object class
402
     * @param object      the object to create
403
     * @return the updated resource
404
     * @throws SmartsheetException the smartsheet exception
405
     */
406
    protected <T> T updateResource(String path, Class<T> objectClass, T object) throws SmartsheetException {
407
        Util.throwIfNull(path, object);
1✔
408
        Util.throwIfEmpty(path);
1✔
409

410
        HttpRequest request;
411
        request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.PUT);
1✔
412

413
        ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
1✔
414
        this.smartsheet.getJsonSerializer().serialize(object, objectBytesStream);
1✔
415
        HttpEntity entity = new HttpEntity();
1✔
416
        entity.setContentType(JSON_CONTENT_TYPE);
1✔
417
        entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
1✔
418
        entity.setContentLength(objectBytesStream.size());
1✔
419
        request.setEntity(entity);
1✔
420

421
        T obj = null;
1✔
422
        try {
423
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
424
            switch (response.getStatusCode()) {
1✔
425
                case 200:
426
                    obj = this.smartsheet.getJsonSerializer().deserializeResult(objectClass,
1✔
427
                            response.getEntity().getContent()).getResult();
1✔
428
                    break;
1✔
429
                default:
UNCOV
430
                    handleError(response);
×
431
            }
432
        } finally {
433
            smartsheet.getHttpClient().releaseConnection();
1✔
434
        }
435

436
        return obj;
1✔
437
    }
438

439
    /**
440
     * List resources using Smartsheet REST API.
441
     * <p>
442
     * Exceptions:
443
     * IllegalArgumentException : if any argument is null, or path is empty string
444
     * InvalidRequestException : if there is any problem with the REST API request
445
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
446
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
447
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
448
     * SmartsheetException : if there is any other error occurred during the operation
449
     *
450
     * @param <T>         the generic type
451
     * @param path        the relative path of the resource collections
452
     * @param objectClass the resource object class
453
     * @return the resources
454
     * @throws SmartsheetException if an error occurred during the operation
455
     */
456
    protected <T> List<T> listResources(String path, Class<T> objectClass) throws SmartsheetException {
UNCOV
457
        Util.throwIfNull(path, objectClass);
×
UNCOV
458
        Util.throwIfEmpty(path);
×
459

460
        HttpRequest request;
461
        request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.GET);
×
462

463
        List<T> obj = null;
×
464
        try {
UNCOV
465
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
×
466
            switch (response.getStatusCode()) {
×
467
                case 200:
468
                    obj = this.smartsheet.getJsonSerializer().deserializeList(objectClass,
×
UNCOV
469
                            response.getEntity().getContent());
×
470
                    break;
×
471
                default:
UNCOV
472
                    handleError(response);
×
473
            }
474
        } finally {
UNCOV
475
            smartsheet.getHttpClient().releaseConnection();
×
476
        }
477

UNCOV
478
        return obj;
×
479
    }
480

481
    /**
482
     * List resources Wrapper (supports paging info) using Smartsheet REST API.
483
     *
484
     * @throws IllegalArgumentException    : if any argument is null, or path is empty string
485
     * @throws InvalidRequestException     : if there is any problem with the REST API request
486
     * @throws AuthorizationException      : if there is any problem with the REST API authorization(access token)
487
     * @throws ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
488
     * @throws SmartsheetRestException     : if there is any other REST API related error occurred during the operation
489
     * @throws SmartsheetException         : if there is any other error occurred during the operation
490
     */
491
    protected <T> PagedResult<T> listResourcesWithWrapper(String path, Class<T> objectClass) throws SmartsheetException {
492
        Util.throwIfNull(path, objectClass);
1✔
493
        Util.throwIfEmpty(path);
1✔
494

495
        HttpRequest request;
496
        request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.GET);
1✔
497

498
        PagedResult<T> obj = null;
1✔
499
        try {
500
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
501
            switch (response.getStatusCode()) {
1✔
502
                case 200:
503
                    obj = this.smartsheet.getJsonSerializer().deserializeDataWrapper(objectClass,
1✔
504
                            response.getEntity().getContent());
1✔
505
                    break;
1✔
506
                default:
UNCOV
507
                    handleError(response);
×
508
            }
509
        } finally {
510
            smartsheet.getHttpClient().releaseConnection();
1✔
511
        }
512

513
        return obj;
1✔
514
    }
515

516
    /**
517
     * List resources with token-based pagination using a custom deserializer.
518
     * This generic method allows for flexible deserialization of paginated results.
519
     *
520
     * @param <T> the generic type of the data items
521
     * @param path the relative path of the resource collections
522
     * @param deserializer the custom deserializer for the data items
523
     * @return the token paginated result
524
     * @throws IllegalArgumentException : if any argument is null, or path is empty string
525
     * @throws InvalidRequestException : if there is any problem with the REST API request
526
     * @throws AuthorizationException : if there is any problem with the REST API authorization(access token)
527
     * @throws ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
528
     * @throws SmartsheetRestException : if there is any other REST API related error occurred during the operation
529
     * @throws SmartsheetException : if there is any other error occurred during the operation
530
     */
531
    protected <T> TokenPaginatedResult<T> listResourcesWithTokenPagination(String path,
532
                                                                            JsonDeserializer<List<T>> deserializer)
533
            throws SmartsheetException {
UNCOV
534
        Util.throwIfNull(path, deserializer);
×
UNCOV
535
        Util.throwIfEmpty(path);
×
536

UNCOV
537
        HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.GET);
×
538

UNCOV
539
        TokenPaginatedResult<T> obj = null;
×
540
        try {
UNCOV
541
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
×
UNCOV
542
            switch (response.getStatusCode()) {
×
543
                case 200:
UNCOV
544
                    obj = this.smartsheet.getJsonSerializer().deserializeTokenPaginatedResult(deserializer,
×
UNCOV
545
                            response.getEntity().getContent());
×
546
                    break;
×
547
                default:
UNCOV
548
                    handleError(response);
×
549
            }
550
        } finally {
UNCOV
551
            smartsheet.getHttpClient().releaseConnection();
×
552
        }
553

UNCOV
554
        return obj;
×
555
    }
556

557
    /**
558
     * Delete a resource from Smartsheet REST API.
559
     * <p>
560
     * Exceptions:
561
     * IllegalArgumentException : if any argument is null, or path is empty string
562
     * InvalidRequestException : if there is any problem with the REST API request
563
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
564
     * ResourceNotFoundException : if the resource can not be found
565
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
566
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
567
     * SmartsheetException : if there is any other error occurred during the operation
568
     *
569
     * @param <T>         the generic type
570
     * @param path        the relative path of the resource
571
     * @param objectClass the resource object class
572
     * @throws SmartsheetException the smartsheet exception
573
     */
574
    protected <T> void deleteResource(String path, Class<T> objectClass) throws SmartsheetException {
575
        Util.throwIfNull(path, objectClass);
1✔
576
        Util.throwIfEmpty(path);
1✔
577

578
        HttpRequest request;
579
        request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.DELETE);
1✔
580

581
        try {
582
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
583
            switch (response.getStatusCode()) {
1✔
584
                case 200:
585
                    this.smartsheet.getJsonSerializer().deserializeResult(objectClass,
1✔
586
                            response.getEntity().getContent());
1✔
587
                    break;
1✔
588
                default:
UNCOV
589
                    handleError(response);
×
590
            }
591
        } finally {
592
            smartsheet.getHttpClient().releaseConnection();
1✔
593
        }
594
    }
1✔
595

596
    /**
597
     * Delete resources and return a list from Smartsheet REST API.
598
     * <p>
599
     * Exceptions:
600
     * IllegalArgumentException : if any argument is null, or path is empty string
601
     * InvalidRequestException : if there is any problem with the REST API request
602
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
603
     * ResourceNotFoundException : if the resource can not be found
604
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
605
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
606
     * SmartsheetException : if there is any other error occurred during the operation
607
     *
608
     * @param <T>         the generic type
609
     * @param path        the relative path of the resource
610
     * @param objectClass the resource object class
611
     * @return List of ids deleted
612
     * @throws SmartsheetException the smartsheet exception
613
     */
614
    protected <T> List<T> deleteListResources(String path, Class<T> objectClass) throws SmartsheetException {
615
        Util.throwIfNull(path, objectClass);
1✔
616
        Util.throwIfEmpty(path);
1✔
617

618
        Result<List<T>> obj = null;
1✔
619
        HttpRequest request;
620
        request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.DELETE);
1✔
621
        try {
622
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
623
            switch (response.getStatusCode()) {
1✔
624
                case 200:
625
                    obj = this.smartsheet.getJsonSerializer().deserializeListResult(objectClass,
1✔
626
                            response.getEntity().getContent());
1✔
627
                    break;
1✔
628
                default:
UNCOV
629
                    handleError(response);
×
630
            }
631
        } finally {
632
            smartsheet.getHttpClient().releaseConnection();
1✔
633
        }
634
        return obj.getResult();
1✔
635
    }
636

637
    /**
638
     * Post an object to Smartsheet REST API and receive a list of objects from response.
639
     * <p>
640
     * Parameters: - path : the relative path of the resource collections - objectToPost : the object to post -
641
     * objectClassToReceive : the resource object class to receive
642
     * <p>
643
     * Returns: the object list
644
     * <p>
645
     * Exceptions:
646
     * IllegalArgumentException : if any argument is null, or path is empty string
647
     * InvalidRequestException : if there is any problem with the REST API request
648
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
649
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
650
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
651
     * SmartsheetException : if there is any other error occurred during the operation
652
     *
653
     * @param <T>                  the generic type
654
     * @param <S>                  the generic type
655
     * @param path                 the path
656
     * @param objectToPost         the object to post
657
     * @param objectClassToReceive the object class to receive
658
     * @return the list
659
     * @throws SmartsheetException the smartsheet exception
660
     */
661
    protected <T, S> List<S> postAndReceiveList(String path, T objectToPost, Class<S> objectClassToReceive) throws SmartsheetException {
662
        Util.throwIfNull(path, objectToPost, objectClassToReceive);
1✔
663
        Util.throwIfEmpty(path);
1✔
664

665
        HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.POST);
1✔
666

667
        ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
1✔
668
        this.smartsheet.getJsonSerializer().serialize(objectToPost, objectBytesStream);
1✔
669
        HttpEntity entity = new HttpEntity();
1✔
670
        entity.setContentType(JSON_CONTENT_TYPE);
1✔
671
        entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
1✔
672
        entity.setContentLength(objectBytesStream.size());
1✔
673
        request.setEntity(entity);
1✔
674

675
        List<S> obj = null;
1✔
676
        try {
677
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
678
            switch (response.getStatusCode()) {
1✔
679
                case 200:
680
                    obj = this.smartsheet.getJsonSerializer().deserializeListResult(objectClassToReceive,
1✔
681
                            response.getEntity().getContent()).getResult();
1✔
682
                    break;
1✔
683
                default:
UNCOV
684
                    handleError(response);
×
685
            }
686
        } finally {
687
            smartsheet.getHttpClient().releaseConnection();
1✔
688
        }
689

690
        return obj;
1✔
691
    }
692

693
    /**
694
     * Partially update a resource using Smartsheet REST API with PATCH method.
695
     * <p>
696
     * Exceptions:
697
     * IllegalArgumentException : if any argument is null, or path is empty string
698
     * InvalidRequestException : if there is any problem with the REST API request
699
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
700
     * ResourceNotFoundException : if the resource can not be found
701
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
702
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
703
     * SmartsheetException : if there is any other error occurred during the operation
704
     *
705
     * @param <T>         the generic type
706
     * @param path        the relative path of the resource
707
     * @param objectClass the resource object class
708
     * @param object      the object to patch
709
     * @return the updated resource
710
     * @throws SmartsheetException the smartsheet exception
711
     */
712
    protected <T> T patchResource(String path, Class<T> objectClass, Object object) throws SmartsheetException {
713
        Util.throwIfNull(path, object);
1✔
714
        Util.throwIfEmpty(path);
1✔
715

716
        HttpRequest request;
717
        request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.PATCH);
1✔
718

719
        ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
1✔
720
        this.smartsheet.getJsonSerializer().serialize(object, objectBytesStream);
1✔
721
        HttpEntity entity = new HttpEntity();
1✔
722
        entity.setContentType(JSON_CONTENT_TYPE);
1✔
723
        entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
1✔
724
        entity.setContentLength(objectBytesStream.size());
1✔
725
        request.setEntity(entity);
1✔
726

727
        T obj = null;
1✔
728
        try {
729
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
730
            if (response.getStatusCode() == 200) {
1✔
731
                obj = this.smartsheet.getJsonSerializer().deserialize(objectClass,
1✔
732
                        response.getEntity().getContent());
1✔
733
            } else {
UNCOV
734
                handleError(response);
×
735
            }
UNCOV
736
        } catch (IOException e) {
×
UNCOV
737
            throw new RuntimeException(e);
×
738
        } finally {
739
            smartsheet.getHttpClient().releaseConnection();
1✔
740
        }
741

742
        return obj;
1✔
743
    }
744

745
    /**
746
     * Post an object to Smartsheet REST API and receive a CopyOrMoveRowResult object from response.
747
     * <p>
748
     * Parameters: - path : the relative path of the resource collections - objectToPost : the object to post -
749
     * <p>
750
     * Returns: the object
751
     * <p>
752
     * Exceptions:
753
     * IllegalArgumentException : if any argument is null, or path is empty string
754
     * InvalidRequestException : if there is any problem with the REST API request
755
     * AuthorizationException : if there is any problem with the REST API authorization(access token)
756
     * ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
757
     * SmartsheetRestException : if there is any other REST API related error occurred during the operation
758
     * SmartsheetException : if there is any other error occurred during the operation
759
     *
760
     * @param path         the path
761
     * @param objectToPost the object to post
762
     * @return the result object
763
     * @throws SmartsheetException the smartsheet exception
764
     */
765
    protected CopyOrMoveRowResult postAndReceiveRowObject(String path, CopyOrMoveRowDirective objectToPost) throws SmartsheetException {
766
        Util.throwIfNull(path, objectToPost);
1✔
767
        Util.throwIfEmpty(path);
1✔
768

769
        HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.POST);
1✔
770

771
        ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
1✔
772
        this.smartsheet.getJsonSerializer().serialize(objectToPost, objectBytesStream);
1✔
773
        HttpEntity entity = new HttpEntity();
1✔
774
        entity.setContentType(JSON_CONTENT_TYPE);
1✔
775
        entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
1✔
776
        entity.setContentLength(objectBytesStream.size());
1✔
777
        request.setEntity(entity);
1✔
778

779
        CopyOrMoveRowResult obj = null;
1✔
780
        try {
781
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
782
            switch (response.getStatusCode()) {
1✔
783
                case 200:
784
                    obj = this.smartsheet.getJsonSerializer().deserializeCopyOrMoveRow(
1✔
785
                            response.getEntity().getContent());
1✔
786
                    break;
1✔
787
                default:
UNCOV
788
                    handleError(response);
×
789
            }
790
        } finally {
791
            smartsheet.getHttpClient().releaseConnection();
1✔
792
        }
793

794
        return obj;
1✔
795
    }
796

797
    /**
798
     * Put an object to Smartsheet REST API and receive a list of objects from response.
799
     *
800
     * @param <T>                  the generic type
801
     * @param <S>                  the generic type
802
     * @param path                 the relative path of the resource collections
803
     * @param objectToPut          the object to put
804
     * @param objectClassToReceive the resource object class to receive
805
     * @return the object list
806
     * @throws IllegalArgumentException    : if any argument is null, or path is empty string
807
     * @throws InvalidRequestException     : if there is any problem with the REST API request
808
     * @throws AuthorizationException      : if there is any problem with the REST API authorization(access token)
809
     * @throws ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
810
     * @throws SmartsheetRestException     : if there is any other REST API related error occurred during the operation
811
     * @throws SmartsheetException         : if there is any other error occurred during the operation
812
     */
813
    protected <T, S> List<S> putAndReceiveList(String path, T objectToPut, Class<S> objectClassToReceive)
814
            throws SmartsheetException {
815
        Util.throwIfNull(path, objectToPut, objectClassToReceive);
1✔
816
        Util.throwIfEmpty(path);
1✔
817

818
        HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.PUT);
1✔
819

820
        ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
1✔
821
        this.smartsheet.getJsonSerializer().serialize(objectToPut, objectBytesStream);
1✔
822
        HttpEntity entity = new HttpEntity();
1✔
823
        entity.setContentType(JSON_CONTENT_TYPE);
1✔
824
        entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
1✔
825
        entity.setContentLength(objectBytesStream.size());
1✔
826
        request.setEntity(entity);
1✔
827

828
        List<S> obj = null;
1✔
829
        try {
830
            HttpResponse response = this.smartsheet.getHttpClient().request(request);
1✔
831
            switch (response.getStatusCode()) {
1✔
832
                case 200:
833
                    obj = this.smartsheet.getJsonSerializer().deserializeListResult(
1✔
834
                            objectClassToReceive, response.getEntity().getContent()).getResult();
1✔
835
                    break;
1✔
836
                default:
UNCOV
837
                    handleError(response);
×
838
            }
839
        } finally {
840
            smartsheet.getHttpClient().releaseConnection();
1✔
841
        }
842

843
        return obj;
1✔
844
    }
845

846
    /**
847
     * Create an HttpRequest.
848
     *
849
     * @param uri    the URI
850
     * @param method the HttpMethod
851
     * @return the http request
852
     */
853
    protected HttpRequest createHttpRequest(URI uri, HttpMethod method) {
854
        HttpRequest request = new HttpRequest();
1✔
855
        request.setUri(uri);
1✔
856
        request.setMethod(method);
1✔
857

858
        // Set authorization header
859
        request.setHeaders(createHeaders());
1✔
860

861
        return request;
1✔
862
    }
863

864
    protected HttpPost createHttpPost(URI uri) {
865
        HttpPost httpPost = new HttpPost(uri);
1✔
866
        Map<String, String> headers = createHeaders();
1✔
867
        for (Map.Entry<String, String> entry : headers.entrySet()) {
1✔
868
            httpPost.addHeader(entry.getKey(), entry.getValue());
1✔
869
        }
1✔
870
        return httpPost;
1✔
871
    }
872

873
    /**
874
     * Attach a file
875
     */
876
    public Attachment attachFile(String url, InputStream inputStream, String contentType, long contentLength, String attachmentName)
877
            throws SmartsheetException {
878
        Util.throwIfNull(inputStream, contentType);
1✔
879
        HttpRequest request = createHttpRequest(this.getSmartsheet().getBaseURI().resolve(url), HttpMethod.POST);
1✔
880
        request.getHeaders().put(
1✔
881
                "Content-Disposition",
882
                "attachment; filename=\"" + URLEncoder.encode(attachmentName, StandardCharsets.UTF_8) + "\""
1✔
883
        );
884
        HttpEntity entity = new HttpEntity();
1✔
885
        entity.setContentType(contentType);
1✔
886
        entity.setContent(new LengthEnforcingInputStream(inputStream, contentLength));
1✔
887
        entity.setContentLength(contentLength);
1✔
888
        request.setEntity(entity);
1✔
889

890
        Attachment attachment = null;
1✔
891
        try {
892
            HttpResponse response = this.getSmartsheet().getHttpClient().request(request);
1✔
893
            switch (response.getStatusCode()) {
1✔
894
                case 200:
895
                    attachment = this.getSmartsheet().getJsonSerializer().deserializeResult(Attachment.class,
1✔
896
                            response.getEntity().getContent()).getResult();
1✔
897
                    break;
1✔
898
                default:
UNCOV
899
                    handleError(response);
×
900
            }
901
        } finally {
902
            this.getSmartsheet().getHttpClient().releaseConnection();
1✔
903
        }
904

905
        return attachment;
1✔
906
    }
907

908
    /**
909
     * Create a multipart upload request.
910
     *
911
     * @param url         the url
912
     * @param t           the object to create
913
     * @param partName    the name of the part
914
     * @param inputstream the file inputstream
915
     * @param contentType the type of the file to be attached
916
     * @return the http request
917
     * @throws SmartsheetException may be thrown in the method
918
     */
919
    public <T> Attachment attachFile(String url, T t, String partName, InputStream inputstream, String contentType, String attachmentName)
920
            throws SmartsheetException {
UNCOV
921
        Util.throwIfNull(inputstream, contentType);
×
UNCOV
922
        Attachment attachment = null;
×
923
        final String boundary = "----" + System.currentTimeMillis();
×
924

UNCOV
925
        CloseableHttpClient httpClient = HttpClients.createDefault();
×
UNCOV
926
        HttpPost uploadFile = createHttpPost(this.getSmartsheet().getBaseURI().resolve(url));
×
927

928
        try {
UNCOV
929
            uploadFile.setHeader(HEADER_CONTENT_TYPE, "multipart/form-data; boundary=" + boundary);
×
930
        } catch (Exception e) {
×
UNCOV
931
            throw new RuntimeException(e);
×
UNCOV
932
        }
×
933

UNCOV
934
        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
×
935
        builder.setBoundary(boundary);
×
936
        builder.addTextBody(partName, this.getSmartsheet().getJsonSerializer().serialize(t), ContentType.APPLICATION_JSON);
×
937
        builder.addBinaryBody("file", inputstream, ContentType.create(contentType), attachmentName);
×
938
        org.apache.http.HttpEntity multipart = builder.build();
×
939

UNCOV
940
        uploadFile.setEntity(multipart);
×
941

942
        try {
UNCOV
943
            CloseableHttpResponse response = httpClient.execute(uploadFile);
×
UNCOV
944
            org.apache.http.HttpEntity responseEntity = response.getEntity();
×
UNCOV
945
            attachment = this.getSmartsheet().getJsonSerializer().deserializeResult(Attachment.class,
×
UNCOV
946
                    responseEntity.getContent()).getResult();
×
UNCOV
947
        } catch (Exception e) {
×
UNCOV
948
            throw new RuntimeException(e);
×
UNCOV
949
        }
×
UNCOV
950
        return attachment;
×
951
    }
952

953
    /**
954
     * Handles an error HttpResponse (non-200) returned by Smartsheet REST API.
955
     *
956
     * @param response the HttpResponse
957
     * @throws SmartsheetException     the smartsheet exception
958
     * @throws SmartsheetRestException : the exception corresponding to the error
959
     */
960
    protected void handleError(HttpResponse response) throws SmartsheetException {
961

962
        com.smartsheet.api.models.Error error;
963
        try {
964
            error = this.smartsheet.getJsonSerializer().deserialize(
1✔
965
                    com.smartsheet.api.models.Error.class, response.getEntity().getContent());
1✔
UNCOV
966
        } catch (IOException e) {
×
UNCOV
967
            throw new SmartsheetException(e);
×
968
        }
1✔
969

970
        ErrorCode code = ErrorCode.getErrorCode(response.getStatusCode());
1✔
971

972
        if (code == null) {
1✔
UNCOV
973
            throw new SmartsheetRestException(error);
×
974
        }
975

976
        try {
977
            throw code.getException(error);
1✔
UNCOV
978
        } catch (IllegalArgumentException e) {
×
979
            throw new SmartsheetException(e);
×
980
        } catch (SecurityException e) {
×
UNCOV
981
            throw new SmartsheetException(e);
×
982
        }
983
    }
984

985
    /**
986
     * Gets the smartsheet.
987
     *
988
     * @return the smartsheet
989
     */
990
    public SmartsheetImpl getSmartsheet() {
991
        return smartsheet;
1✔
992
    }
993

994
    /**
995
     * Get a sheet as a file.
996
     *
997
     * @param path         the path
998
     * @param fileType     the output file type
999
     * @param outputStream the OutputStream to which the file will be written
1000
     * @throws InvalidRequestException     : if there is any problem with the REST API request
1001
     * @throws AuthorizationException      : if there is any problem with the REST API authorization(access token)
1002
     * @throws ResourceNotFoundException   : if the resource can not be found
1003
     * @throws ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
1004
     * @throws SmartsheetRestException     : if there is any other REST API related error occurred during the operation
1005
     * @throws SmartsheetException         : if there is any other error occurred during the operation
1006
     */
1007
    public void getResourceAsFile(String path, String fileType, OutputStream outputStream)
1008
            throws SmartsheetException {
1009
        Util.throwIfNull(outputStream, fileType);
1✔
1010

1011
        HttpRequest request;
1012
        request = createHttpRequest(this.getSmartsheet().getBaseURI().resolve(path), HttpMethod.GET);
1✔
1013
        request.getHeaders().put("Accept", fileType);
1✔
1014

1015
        try {
1016
            HttpResponse response = getSmartsheet().getHttpClient().request(request);
1✔
1017

1018
            switch (response.getStatusCode()) {
1✔
1019
                case 200:
1020
                    try {
1021
                        copyStream(response.getEntity().getContent(), outputStream);
1✔
UNCOV
1022
                    } catch (IOException e) {
×
UNCOV
1023
                        throw new SmartsheetException(e);
×
1024
                    }
1✔
1025
                    break;
1026
                default:
UNCOV
1027
                    handleError(response);
×
1028
            }
1029
        } finally {
1030
            getSmartsheet().getHttpClient().releaseConnection();
1✔
1031
        }
1032
    }
1✔
1033

1034
    /*
1035
     * Copy an input stream to an output stream.
1036
     *
1037
     * @param input The input stream to copy.
1038
     *
1039
     * @param output the output stream to write to.
1040
     *
1041
     * @throws IOException if there is trouble reading or writing to the streams.
1042
     */
1043

1044
    /**
1045
     * Copy stream.
1046
     *
1047
     * @param input  the input
1048
     * @param output the output
1049
     * @throws IOException Signals that an I/O exception has occurred.
1050
     * @deprecated replace with StreamUtil.copyContentIntoOutputStream()
1051
     */
1052
    @Deprecated(since = "2.0.0", forRemoval = true)
1053
    private static void copyStream(InputStream input, OutputStream output) throws IOException {
1054
        byte[] buffer = new byte[BUFFER_SIZE];
1✔
1055
        int len;
1056
        while ((len = input.read(buffer)) != -1) {
1✔
1057
            output.write(buffer, 0, len);
1✔
1058
        }
1059
    }
1✔
1060

1061
    /**
1062
     * @return a map of headers to be used when making requests.
1063
     */
1064
    Map<String, String> createHeaders() {
1065
        Map<String, String> headers = new HashMap<>();
1✔
1066
        headers.put("Authorization", "Bearer " + smartsheet.getAccessToken());
1✔
1067
        headers.put(HEADER_CONTENT_TYPE, JSON_CONTENT_TYPE);
1✔
1068

1069
        // Set assumed user
1070
        if (smartsheet.getAssumedUser() != null) {
1✔
UNCOV
1071
            headers.put("Assume-User", URLEncoder.encode(smartsheet.getAssumedUser(), StandardCharsets.UTF_8));
×
1072
        }
1073
        if (smartsheet.getChangeAgent() != null) {
1✔
1074
            headers.put("Smartsheet-Change-Agent", URLEncoder.encode(smartsheet.getChangeAgent(), StandardCharsets.UTF_8));
1✔
1075
        }
1076
        if (smartsheet.getUserAgent() != null) {
1✔
1077
            headers.put("User-Agent", smartsheet.getUserAgent());
1✔
1078
        }
1079
        return headers;
1✔
1080
    }
1081

1082
    int getResponseLogLength() {
1083
        // not cached to allow for it to be changed dynamically by client code
1084
        return Integer.getInteger(PROPERTY_RESPONSE_LOG_CHARS, 1024);
1✔
1085
    }
1086
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc