Address Checkstyle violations

pull/583/head
Andrew Gaul 2023-12-26 13:45:42 +09:00 zatwierdzone przez Andrew Gaul
rodzic e5fb3619df
commit 1dac9ccd12
20 zmienionych plików z 50 dodań i 53 usunięć

Wyświetl plik

@ -17,7 +17,6 @@
package org.gaul.s3proxy;
import static java.util.Objects.requireNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import java.util.HashMap;

Wyświetl plik

@ -17,7 +17,6 @@
package org.gaul.s3proxy;
import static java.util.Objects.requireNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import java.util.Deque;

Wyświetl plik

@ -250,7 +250,7 @@ public final class Main {
ImmutableList<Map.Entry<Pattern, String>> regexs = RegexBlobStore.parseRegexs(
properties);
if (!regexs.isEmpty()){
if (!regexs.isEmpty()) {
System.err.println("Using regex backend");
blobStore = RegexBlobStore.newRegexBlobStore(blobStore, regexs);
}

Wyświetl plik

@ -1,3 +1,19 @@
/*
* Copyright 2014-2021 Andrew Gaul <andrew@gaul.org>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gaul.s3proxy;
import static com.google.common.base.Preconditions.checkArgument;
@ -15,6 +31,8 @@ import java.util.concurrent.ExecutorService;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.google.common.collect.ImmutableList;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobAccess;
@ -25,8 +43,6 @@ import org.jclouds.blobstore.util.ForwardingBlobStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
/**
* This class implements a middleware to apply regex to blob names.
* The regex are configured as:
@ -39,37 +55,38 @@ import com.google.common.collect.ImmutableList;
* end,
* stopping as soon as the first regex matches.
*/
public class RegexBlobStore extends ForwardingBlobStore {
private final ImmutableList<Entry<Pattern, String>> regexs;
public final class RegexBlobStore extends ForwardingBlobStore {
private static final Logger logger = LoggerFactory.getLogger(RegexBlobStore.class);
static BlobStore newRegexBlobStore(BlobStore delegate, ImmutableList<Entry<Pattern, String>> regexs) {
return new RegexBlobStore(delegate, regexs);
}
private final ImmutableList<Entry<Pattern, String>> regexs;
private RegexBlobStore(BlobStore blobStore, ImmutableList<Entry<Pattern, String>> regexs) {
super(blobStore);
this.regexs = requireNonNull(regexs);
}
static BlobStore newRegexBlobStore(BlobStore delegate, ImmutableList<Entry<Pattern, String>> regexs) {
return new RegexBlobStore(delegate, regexs);
}
public static ImmutableList<Map.Entry<Pattern, String>> parseRegexs(Properties properties) {
List<Entry<String, String>> config_regex = new ArrayList<>();
List<Entry<String, String>> configRegex = new ArrayList<>();
List<Entry<Pattern, String>> regexs = new ArrayList<>();
for (String key : properties.stringPropertyNames()) {
if (key.startsWith(S3ProxyConstants.PROPERTY_REGEX_BLOBSTORE)) {
String prop_key = key.substring(S3ProxyConstants.PROPERTY_REGEX_BLOBSTORE.length() + 1);
String propKey = key.substring(S3ProxyConstants.PROPERTY_REGEX_BLOBSTORE.length() + 1);
String value = properties.getProperty(key);
config_regex.add(new SimpleEntry<>(prop_key, value));
configRegex.add(new SimpleEntry<>(propKey, value));
}
}
for (Entry<String, String> entry : config_regex) {
for (Entry<String, String> entry : configRegex) {
String key = entry.getKey();
if (key.startsWith(S3ProxyConstants.PROPERTY_REGEX_BLOBSTORE_MATCH)) {
String regex_name = key.substring(S3ProxyConstants.PROPERTY_REGEX_BLOBSTORE_MATCH.length() + 1);
String regexName = key.substring(S3ProxyConstants.PROPERTY_REGEX_BLOBSTORE_MATCH.length() + 1);
String regex = entry.getValue();
Pattern pattern = Pattern.compile(regex);
@ -78,14 +95,14 @@ public class RegexBlobStore extends ForwardingBlobStore {
".",
S3ProxyConstants.PROPERTY_REGEX_BLOBSTORE,
S3ProxyConstants.PROPERTY_REGEX_BLOBSTORE_REPLACE,
regex_name));
regexName));
checkArgument(
replace != null,
"Regex %s has no replace property associated",
regex_name);
regexName);
logger.info("Adding new regex with name {} replaces with {} to {}", regex_name, regex, replace);
logger.info("Adding new regex with name {} replaces with {} to {}", regexName, regex, replace);
regexs.add(new SimpleEntry<>(pattern, replace));
}

Wyświetl plik

@ -17,7 +17,6 @@
package org.gaul.s3proxy;
import static java.util.Objects.requireNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import java.net.URI;

Wyświetl plik

@ -78,8 +78,7 @@ public class DecryptionInputStream extends FilterInputStream {
*/
public DecryptionInputStream(InputStream is, SecretKey key,
TreeMap<Integer, PartPadding> parts, int skipParts,
long skipPartBytes)
throws IOException {
long skipPartBytes) throws IOException {
super(is);
in = is;
this.parts = parts;

Wyświetl plik

@ -44,7 +44,6 @@ import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.options.PutOptions;
import org.jclouds.io.Payloads;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

Wyświetl plik

@ -35,7 +35,6 @@ import com.amazonaws.services.s3.model.S3Object;
import com.google.common.io.ByteSource;
import org.jclouds.blobstore.BlobStoreContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

Wyświetl plik

@ -96,12 +96,10 @@ import com.google.common.collect.Maps;
import com.google.common.io.ByteSource;
import org.assertj.core.api.Fail;
import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.rest.HttpClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;

Wyświetl plik

@ -40,7 +40,6 @@ import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.google.common.io.ByteSource;
import com.google.common.net.HttpHeaders;
@ -59,10 +58,8 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

Wyświetl plik

@ -40,7 +40,6 @@ import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.google.common.io.ByteSource;
import com.google.common.net.HttpHeaders;
@ -59,10 +58,8 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

Wyświetl plik

@ -32,7 +32,6 @@ import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.junit.Before;
import org.junit.Test;

Wyświetl plik

@ -20,23 +20,17 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.io.InputStream;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.regex.Pattern;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hashing;
import com.google.common.io.ByteSource;
import com.google.inject.Module;
import java.util.AbstractMap.SimpleEntry;
import org.assertj.core.api.Assertions;
import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStore;
@ -44,6 +38,9 @@ import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public final class RegexBlobStoreTest {
private BlobStoreContext context;

Wyświetl plik

@ -35,7 +35,6 @@ import org.jclouds.blobstore.domain.PageSet;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.options.CopyOptions;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

Wyświetl plik

@ -34,7 +34,6 @@ import com.google.common.io.Resources;
import com.google.inject.Module;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.jclouds.Constants;
import org.jclouds.ContextBuilder;
import org.jclouds.JcloudsVersion;