/** * If S3Key filter is set make sure it has at least one rule */ private void validateS3KeyFilter(S3KeyFilter s3KeyFilter) { if (CollectionUtils.isNullOrEmpty(s3KeyFilter.getFilterRules())) { throw new SdkClientException("Cannot have an S3KeyFilter without any filter rules"); } }
@Override public URI getCredentialsEndpoint() throws URISyntaxException { String fullUri = System.getenv(CONTAINER_CREDENTIALS_FULL_URI); if (fullUri == null || fullUri.length() == 0) { throw new SdkClientException("The environment variable " + CONTAINER_CREDENTIALS_FULL_URI + " is empty"); } URI uri = new URI(fullUri); if (!ALLOWED_FULL_URI_HOSTS.contains(uri.getHost())) { throw new SdkClientException("The full URI (" + uri + ") contained withing environment variable " + CONTAINER_CREDENTIALS_FULL_URI + " has an invalid host. Host can only be one of [" + CollectionUtils.join(ALLOWED_FULL_URI_HOSTS, ", ") + "]"); } return uri; }
/** * Merge query parameters into the given request. */ private void mergeQueryParameters(Map<String, List<String>> params) { Map<String, List<String>> existingParams = request.getParameters(); for (Entry<String, List<String>> param : params.entrySet()) { String pName = param.getKey(); List<String> pValues = param.getValue(); existingParams.put(pName, CollectionUtils.mergeLists(existingParams.get(pName), pValues)); } }
/** * Joins a collection of strings with the given separator into a single string. * * @param toJoin Collection containing items to join. * @param separator String to join items with. * @return Empty string if collection is null or empty. Otherwise joins all strings in the collection with the separator. */ public static String join(Collection<String> toJoin, String separator) { if (isNullOrEmpty(toJoin)) { return ""; } StringBuilder joinedString = new StringBuilder(); int currentIndex = 0; for (String s : toJoin) { if(s != null) { joinedString.append(s); } if (currentIndex++ != toJoin.size() - 1) { joinedString.append(separator); } } return joinedString.toString(); } }
@SdkInternalApi void fillInStackTrace(Class<?> interfaceClass) { if (stackTraces != null) { final List<StackTraceElement> elements = new ArrayList<StackTraceElement>(); for (List<String> stackTrace : stackTraces) { final String methodName = CollectionUtils.join(stackTrace, ",").trim(); elements.add(new StackTraceElement(interfaceClass.getName(), methodName, null, -1)); } this.setStackTrace(elements.toArray(new StackTraceElement[elements.size()])); } if (getCause() != null) { getCause().fillInStackTrace(interfaceClass); } } }
/** * Merge query parameters into the given request. */ private void mergeQueryParameters(Map<String, List<String>> params) { Map<String, List<String>> existingParams = request.getParameters(); for (Entry<String, List<String>> param : params.entrySet()) { String pName = param.getKey(); List<String> pValues = param.getValue(); existingParams.put(pName, CollectionUtils.mergeLists(existingParams.get(pName), pValues)); } }
/** * Asserts the collection is not null and not empty, reporting to {@link ProblemReporter} with this context if it is. * * @param collection Collection to assert on. * @param propertyName Name of property. */ public void assertNotEmpty(Collection<?> collection, String propertyName) { if (CollectionUtils.isNullOrEmpty(collection)) { problemReporter.report(new Problem(this, String.format("%s requires one or more items", propertyName))); } }
@Override public URI getCredentialsEndpoint() throws URISyntaxException { String fullUri = System.getenv(CONTAINER_CREDENTIALS_FULL_URI); if (fullUri == null || fullUri.length() == 0) { throw new SdkClientException("The environment variable " + CONTAINER_CREDENTIALS_FULL_URI + " is empty"); } URI uri = new URI(fullUri); if (!ALLOWED_FULL_URI_HOSTS.contains(uri.getHost())) { throw new SdkClientException("The full URI (" + uri + ") contained withing environment variable " + CONTAINER_CREDENTIALS_FULL_URI + " has an invalid host. Host can only be one of [" + CollectionUtils.join(ALLOWED_FULL_URI_HOSTS, ", ") + "]"); } return uri; }
/** * Merge query parameters into the given request. */ private void mergeQueryParameters(Map<String, List<String>> params) { Map<String, List<String>> existingParams = request.getParameters(); for (Entry<String, List<String>> param : params.entrySet()) { String pName = param.getKey(); List<String> pValues = param.getValue(); existingParams.put(pName, CollectionUtils.mergeLists(existingParams.get(pName), pValues)); } }
private ApiCallMonitoringEvent generateApiCallMonitoringEvent(Request<?> request, Exception e) { ApiCallMonitoringEvent event = generateApiCallMonitoringEvent(request); AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (e instanceof ClientExecutionTimeoutException) { event.withApiCallTimeout(1); } if (metrics != null && !CollectionUtils.isNullOrEmpty(metrics.getProperty(MaxRetriesExceeded))) { boolean maxRetriesExceeded = (Boolean) metrics.getProperty(MaxRetriesExceeded).get(0); event.withMaxRetriesExceeded(maxRetriesExceeded ? 1 : 0); } return event; }
@Override public URI getCredentialsEndpoint() throws URISyntaxException { String fullUri = System.getenv(CONTAINER_CREDENTIALS_FULL_URI); if (fullUri == null || fullUri.length() == 0) { throw new SdkClientException("The environment variable " + CONTAINER_CREDENTIALS_FULL_URI + " is empty"); } URI uri = new URI(fullUri); if (!ALLOWED_FULL_URI_HOSTS.contains(uri.getHost())) { throw new SdkClientException("The full URI (" + uri + ") contained withing environment variable " + CONTAINER_CREDENTIALS_FULL_URI + " has an invalid host. Host can only be one of [" + CollectionUtils.join(ALLOWED_FULL_URI_HOSTS, ", ") + "]"); } return uri; }
private void addInventoryOptionalFields(XmlWriter xml, List<String> optionalFields) { if (CollectionUtils.isNullOrEmpty(optionalFields)) { return; } xml.start("OptionalFields"); for (String field : optionalFields) { xml.start("Field").value(field).end(); } xml.end(); }
@SdkInternalApi void fillInStackTrace(Class<?> interfaceClass) { if (stackTraces != null) { final List<StackTraceElement> elements = new ArrayList<StackTraceElement>(); for (List<String> stackTrace : stackTraces) { final String methodName = CollectionUtils.join(stackTrace, ",").trim(); elements.add(new StackTraceElement(interfaceClass.getName(), methodName, null, -1)); } this.setStackTrace(elements.toArray(new StackTraceElement[elements.size()])); } if (getCause() != null) { getCause().fillInStackTrace(interfaceClass); } } }
private static void assertStorage(Storage actual, StorageDescriptor expected) { assertEquals(actual.getLocation(), expected.getLocation()); assertEquals(actual.getStorageFormat().getSerDe(), expected.getSerdeInfo().getSerializationLibrary()); assertEquals(actual.getStorageFormat().getInputFormat(), expected.getInputFormat()); assertEquals(actual.getStorageFormat().getOutputFormat(), expected.getOutputFormat()); if (!isNullOrEmpty(expected.getBucketColumns())) { HiveBucketProperty bucketProperty = actual.getBucketProperty().get(); assertEquals(bucketProperty.getBucketedBy(), expected.getBucketColumns()); assertEquals(bucketProperty.getBucketCount(), expected.getNumberOfBuckets().intValue()); } } }
@Override public ResultStatus call() throws Exception { if (events == null || CollectionUtils.isNullOrEmpty(events.getEventList())) { throw new IllegalArgumentException("SequentialEvents does not contain any event to run"); } for (SingleEvent singleEvent : events.getEventList()) { new Backoff(singleEvent.getIntervalTimeInMs()).backoff(); singleEvent.getAction().execute(); } return ResultStatus.DONE; } });
/** * Joins a collection of strings with the given separator into a single string. * * @param toJoin Collection containing items to join. * @param separator String to join items with. * @return Empty string if collection is null or empty. Otherwise joins all strings in the collection with the separator. */ public static String join(Collection<String> toJoin, String separator) { if (isNullOrEmpty(toJoin)) { return ""; } StringBuilder joinedString = new StringBuilder(); int currentIndex = 0; for (String s : toJoin) { if(s != null) { joinedString.append(s); } if (currentIndex++ != toJoin.size() - 1) { joinedString.append(separator); } } return joinedString.toString(); } }
private ApiCallMonitoringEvent generateApiCallMonitoringEvent(Request<?> request, Exception e) { ApiCallMonitoringEvent event = generateApiCallMonitoringEvent(request); AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (e instanceof ClientExecutionTimeoutException) { event.withApiCallTimeout(1); } if (metrics != null && !CollectionUtils.isNullOrEmpty(metrics.getProperty(MaxRetriesExceeded))) { boolean maxRetriesExceeded = (Boolean) metrics.getProperty(MaxRetriesExceeded).get(0); event.withMaxRetriesExceeded(maxRetriesExceeded ? 1 : 0); } return event; }
public List<String> getSubnets() { return CollectionUtils.isNullOrEmpty(subnets) ? new ArrayList<String>() : subnets; }
public List<String> getSecurityGroups() { return CollectionUtils.isNullOrEmpty(securityGroups) ? new ArrayList<String>() : securityGroups; }
/** * Constructs a new <code>SourceSerializerChain</code> with the specified source serializers. * <p> * Use {@link SourceSerializerFactory#createSourceSerializerChain()} for default construction. * </p> * <p> * When source are required from this serializer, it will call each of these source serializers in the same order * specified here until one of them return {@link CloudTrailSource}. * </p> * * @param sourceSerializers A list of at least one {@link SourceSerializer} implementation instance. */ public SourceSerializerChain(List<? extends SourceSerializer> sourceSerializers) { if (CollectionUtils.isNullOrEmpty(sourceSerializers) || sourceSerializers.contains(null)) { throw new IllegalArgumentException("No source serializer specified or contains null serializers."); } this.sourceSerializers = new LinkedList<>(sourceSerializers); }