Skip to content

Commit e3c5f83

Browse files
committed
activated spotless
1 parent a28bb75 commit e3c5f83

File tree

93 files changed

+2421
-1950
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2421
-1950
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# activated spotless
2+
535bf0438ac4d43258d92771d225817bb849554a

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ limitations under the License.
6060
<jenkins.baseline>2.492</jenkins.baseline>
6161
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
6262
<gitHubRepo>jenkinsci/jclouds-plugin</gitHubRepo>
63+
<spotless.check.skip>false</spotless.check.skip>
6364
</properties>
6465

6566
<developers>

src/main/java/jenkins/plugins/jclouds/blobstore/BlobStoreEntry.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import hudson.Extension;
1919
import hudson.model.AbstractDescribableImpl;
2020
import hudson.model.Descriptor;
21-
2221
import org.kohsuke.stapler.DataBoundConstructor;
2322

2423
/**
@@ -59,8 +58,13 @@ public final class BlobStoreEntry extends AbstractDescribableImpl<BlobStoreEntry
5958
public final boolean onlyIfSuccessful;
6059

6160
@DataBoundConstructor
62-
public BlobStoreEntry(final String container, final String path, final String sourceFile,
63-
final boolean keepHierarchy, final boolean allowEmptyFileset, final boolean onlyIfSuccessful) {
61+
public BlobStoreEntry(
62+
final String container,
63+
final String path,
64+
final String sourceFile,
65+
final boolean keepHierarchy,
66+
final boolean allowEmptyFileset,
67+
final boolean onlyIfSuccessful) {
6468
this.container = container;
6569
this.path = path;
6670
this.sourceFile = sourceFile;

src/main/java/jenkins/plugins/jclouds/blobstore/BlobStoreLogger.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@
1515
*/
1616
package jenkins.plugins.jclouds.blobstore;
1717

18-
import java.util.logging.Logger;
19-
20-
import static org.jclouds.Constants.LOGGER_HTTP_WIRE;
2118
import static org.jclouds.Constants.LOGGER_HTTP_HEADERS;
19+
import static org.jclouds.Constants.LOGGER_HTTP_WIRE;
2220
import static org.jclouds.blobstore.reference.BlobStoreConstants.BLOBSTORE_LOGGER;
2321

22+
import java.util.logging.Logger;
23+
2424
/**
2525
* bumps {@code jclouds.blobstore} logging category debug to info.
2626
*/
2727
class BlobStoreLogger extends org.jclouds.logging.jdk.JDKLogger {
2828

2929
public static class Factory extends JDKLoggerFactory {
3030
public org.jclouds.logging.Logger getLogger(String category) {
31-
if (category.equals(BLOBSTORE_LOGGER) || category.equals(LOGGER_HTTP_WIRE) && logWire ||
32-
category.equals(LOGGER_HTTP_HEADERS) && logHeaders) {
31+
if (category.equals(BLOBSTORE_LOGGER)
32+
|| category.equals(LOGGER_HTTP_WIRE) && logWire
33+
|| category.equals(LOGGER_HTTP_HEADERS) && logHeaders) {
3334
return new BlobStoreLogger(Logger.getLogger(category));
3435
} else {
3536
return super.getLogger(category);
@@ -51,7 +52,7 @@ protected void logDebug(String message) {
5152
super.logInfo(message);
5253
}
5354

54-
private final static String LOGPREFIX = BlobStoreLogger.class.getPackage().getName();
55-
private final static boolean logHeaders = Boolean.getBoolean(LOGPREFIX + ".headerLogging");
56-
private final static boolean logWire = Boolean.getBoolean(LOGPREFIX + ".wireLogging");
55+
private static final String LOGPREFIX = BlobStoreLogger.class.getPackage().getName();
56+
private static final boolean logHeaders = Boolean.getBoolean(LOGPREFIX + ".headerLogging");
57+
private static final boolean logWire = Boolean.getBoolean(LOGPREFIX + ".wireLogging");
5758
}

src/main/java/jenkins/plugins/jclouds/blobstore/BlobStoreProfile.java

Lines changed: 87 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,14 @@
1515
*/
1616
package jenkins.plugins.jclouds.blobstore;
1717

18-
import java.io.IOException;
19-
import java.util.Properties;
20-
import java.util.Set;
21-
import java.util.logging.Level;
22-
import java.util.logging.Logger;
23-
import java.security.DigestInputStream;
24-
import java.security.MessageDigest;
25-
import java.security.NoSuchAlgorithmException;
26-
18+
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
19+
import com.cloudbees.plugins.credentials.common.StandardUsernameListBoxModel;
2720
import com.google.common.collect.ImmutableSet;
2821
import com.google.common.collect.ImmutableSet.Builder;
2922
import com.google.common.collect.ImmutableSortedSet;
3023
import com.google.common.collect.Iterables;
3124
import com.google.inject.Module;
32-
25+
import com.thoughtworks.xstream.converters.UnmarshallingContext;
3326
import hudson.Extension;
3427
import hudson.FilePath;
3528
import hudson.Util;
@@ -43,9 +36,18 @@
4336
import hudson.util.ListBoxModel;
4437
import hudson.util.Secret;
4538
import hudson.util.XStream2;
46-
39+
import java.io.IOException;
40+
import java.security.DigestInputStream;
41+
import java.security.MessageDigest;
42+
import java.security.NoSuchAlgorithmException;
43+
import java.util.Properties;
44+
import java.util.Set;
45+
import java.util.logging.Level;
46+
import java.util.logging.Logger;
4747
import jenkins.model.Jenkins;
48-
48+
import jenkins.plugins.jclouds.internal.CredentialsHelper;
49+
import jenkins.plugins.jclouds.internal.LocationHelper;
50+
import jenkins.plugins.jclouds.modules.JenkinsConfigurationModule;
4951
import org.jclouds.Constants;
5052
import org.jclouds.ContextBuilder;
5153
import org.jclouds.apis.Apis;
@@ -55,30 +57,19 @@
5557
import org.jclouds.domain.Location;
5658
import org.jclouds.logging.jdk.config.JDKLoggingModule;
5759
import org.jclouds.providers.Providers;
58-
60+
import org.kohsuke.accmod.Restricted;
61+
import org.kohsuke.accmod.restrictions.DoNotUse;
5962
import org.kohsuke.stapler.AncestorInPath;
6063
import org.kohsuke.stapler.DataBoundConstructor;
6164
import org.kohsuke.stapler.QueryParameter;
6265
import org.kohsuke.stapler.verb.POST;
6366

64-
import org.kohsuke.accmod.Restricted;
65-
import org.kohsuke.accmod.restrictions.DoNotUse;
66-
67-
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
68-
import com.cloudbees.plugins.credentials.common.StandardUsernameListBoxModel;
69-
70-
import com.thoughtworks.xstream.converters.UnmarshallingContext;
71-
72-
import jenkins.plugins.jclouds.internal.CredentialsHelper;
73-
import jenkins.plugins.jclouds.internal.LocationHelper;
74-
import jenkins.plugins.jclouds.modules.JenkinsConfigurationModule;
75-
7667
/**
7768
* Model class for Blobstore profile. User can configure multiple profiles to upload artifacts to different providers.
7869
*
7970
* @author Vijay Kiran
8071
*/
81-
public class BlobStoreProfile extends AbstractDescribableImpl<BlobStoreProfile> {
72+
public class BlobStoreProfile extends AbstractDescribableImpl<BlobStoreProfile> {
8273

8374
private static final Logger LOGGER = Logger.getLogger(BlobStoreProfile.class.getName());
8475

@@ -97,8 +88,13 @@ public class BlobStoreProfile extends AbstractDescribableImpl<BlobStoreProfile>
9788
private final transient String credential;
9889

9990
@DataBoundConstructor
100-
public BlobStoreProfile(final String profileName, final String providerName, final String credentialsId,
101-
final String endPointUrl, final String locationId, final boolean trustAll) {
91+
public BlobStoreProfile(
92+
final String profileName,
93+
final String providerName,
94+
final String credentialsId,
95+
final String endPointUrl,
96+
final String locationId,
97+
final boolean trustAll) {
10298
this.profileName = profileName;
10399
this.providerName = providerName;
104100
this.credentialsId = credentialsId;
@@ -161,20 +157,23 @@ public String getLocationId() {
161157
return locationId;
162158
}
163159

164-
static final Iterable<Module> MODULES = ImmutableSet.<Module>of(new JDKLoggingModule() {
165-
@Override
166-
public org.jclouds.logging.Logger.LoggerFactory createLoggerFactory() {
167-
return new BlobStoreLogger.Factory();
168-
}
169-
}, new JenkinsConfigurationModule());
170-
160+
static final Iterable<Module> MODULES = ImmutableSet.<Module>of(
161+
new JDKLoggingModule() {
162+
@Override
163+
public org.jclouds.logging.Logger.LoggerFactory createLoggerFactory() {
164+
return new BlobStoreLogger.Factory();
165+
}
166+
},
167+
new JenkinsConfigurationModule());
171168

172169
private static BlobStoreContext ctx(final String provider, final String credId, final Properties overrides) {
173170
// correct the classloader so that extensions can be found
174171
Thread.currentThread().setContextClassLoader(Apis.class.getClassLoader());
175172
CredentialsHelper.setProject(credId, overrides);
176173
return CredentialsHelper.setCredentials(ContextBuilder.newBuilder(provider), credId)
177-
.overrides(overrides).modules(MODULES).buildView(BlobStoreContext.class);
174+
.overrides(overrides)
175+
.modules(MODULES)
176+
.buildView(BlobStoreContext.class);
178177
}
179178

180179
private static Properties buildJCloudsOverrides(final String url, final boolean relaxed) {
@@ -202,7 +201,8 @@ static BlobStoreContext ctx(final String provider, final String credId, final St
202201
* @throws IOException if an IO error occurs.
203202
* @throws InterruptedException If the upload gets interrupted.
204203
*/
205-
public void upload(final String container, final String path, final FilePath filePath) throws IOException, InterruptedException {
204+
public void upload(final String container, final String path, final FilePath filePath)
205+
throws IOException, InterruptedException {
206206
if (filePath.isDirectory()) {
207207
throw new IOException(filePath + " is a directory");
208208
}
@@ -232,8 +232,11 @@ public void upload(final String container, final String path, final FilePath fil
232232
MessageDigest md5 = MessageDigest.getInstance("MD5");
233233
DigestInputStream dis = new DigestInputStream(filePath.read(), md5);
234234

235-
Blob blob = blobStore.blobBuilder(destPath)
236-
.payload(dis).contentLength(filePath.length()).build();
235+
Blob blob = blobStore
236+
.blobBuilder(destPath)
237+
.payload(dis)
238+
.contentLength(filePath.length())
239+
.build();
237240
blobStore.putBlob(container, blob);
238241
bsc.close();
239242
String md5local = Util.toHexString(md5.digest()).toLowerCase();
@@ -242,12 +245,17 @@ public void upload(final String container, final String path, final FilePath fil
242245
try (BlobStoreContext bsc2 = ctx(providerName, credentialsId, endPointUrl, trustAll)) {
243246
blobStore = bsc2.getBlobStore();
244247
LOGGER.info("Fetching remote MD5sum for " + destPath);
245-
String md5remote = blobStore.blobMetadata(container, destPath)
246-
.getContentMetadata().getContentMD5AsHashCode().toString();
248+
String md5remote = blobStore
249+
.blobMetadata(container, destPath)
250+
.getContentMetadata()
251+
.getContentMD5AsHashCode()
252+
.toString();
247253
if (md5local.equals(md5remote)) {
248-
LOGGER.info("Published " + destPath + " to container " + container + " with profile " + profileName);
254+
LOGGER.info("Published " + destPath + " to container " + container + " with profile "
255+
+ profileName);
249256
} else {
250-
LOGGER.warning("MD5 mismatch while publishing " + destPath + " to container " + container + " with profile " + profileName);
257+
LOGGER.warning("MD5 mismatch while publishing " + destPath + " to container " + container
258+
+ " with profile " + profileName);
251259
throw new IOException("MD5 mismatch while publishing");
252260
}
253261
break;
@@ -289,20 +297,23 @@ public FormValidation doCheckEndPointUrl(@QueryParameter String value) {
289297
}
290298

291299
@POST
292-
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) {
293-
if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.get()).hasPermission(Computer.CONFIGURE)) {
300+
public ListBoxModel doFillCredentialsIdItems(
301+
@AncestorInPath ItemGroup context, @QueryParameter String currentValue) {
302+
if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.get())
303+
.hasPermission(Computer.CONFIGURE)) {
294304
return new StandardUsernameListBoxModel().includeCurrentValue(currentValue);
295305
}
296306
return new StandardUsernameListBoxModel()
297-
.includeAs(ACL.SYSTEM2, context, StandardUsernameCredentials.class).includeCurrentValue(currentValue);
307+
.includeAs(ACL.SYSTEM2, context, StandardUsernameCredentials.class)
308+
.includeCurrentValue(currentValue);
298309
}
299310

300311
ImmutableSortedSet<String> getAllProviders() {
301312
// correct the classloader so that extensions can be found
302313
Thread.currentThread().setContextClassLoader(Apis.class.getClassLoader());
303314
// TODO: apis need endpoints, providers don't; do something smarter
304315
// with this stuff :)
305-
Builder<String> builder = ImmutableSet.<String> builder();
316+
Builder<String> builder = ImmutableSet.<String>builder();
306317
builder.addAll(Iterables.transform(Apis.viewableAs(BlobStoreContext.class), Apis.idFunction()));
307318
builder.addAll(Iterables.transform(Providers.viewableAs(BlobStoreContext.class), Providers.idFunction()));
308319
return ImmutableSortedSet.copyOf(builder.build());
@@ -323,28 +334,31 @@ public ListBoxModel doFillProviderNameItems(@AncestorInPath ItemGroup context) {
323334
}
324335

325336
@POST
326-
public FormValidation doTestConnection(@QueryParameter("providerName") final String provider,
327-
@QueryParameter("credentialsId") final String credId,
328-
@QueryParameter("endPointUrl") final String url,
329-
@QueryParameter("trustAll") final boolean relaxed) throws IOException {
330-
337+
public FormValidation doTestConnection(
338+
@QueryParameter("providerName") final String provider,
339+
@QueryParameter("credentialsId") final String credId,
340+
@QueryParameter("endPointUrl") final String url,
341+
@QueryParameter("trustAll") final boolean relaxed)
342+
throws IOException {
331343

332344
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
333345
if (null == Util.fixEmptyAndTrim(credId)) {
334346
return FormValidation.error("BlobStore credentials not specified.");
335347
}
336348
FormValidation res = FormValidation.ok("Connection succeeded!");
337-
try (BlobStoreContext ctx = ctx(Util.fixEmptyAndTrim(provider), credId, Util.fixEmptyAndTrim(url), relaxed)) {
349+
try (BlobStoreContext ctx =
350+
ctx(Util.fixEmptyAndTrim(provider), credId, Util.fixEmptyAndTrim(url), relaxed)) {
338351
ctx.getBlobStore().list();
339352
} catch (Exception ex) {
340-
res = FormValidation.error("Cannot connect to specified BlobStore, please check the credentials: "
341-
+ ex.getMessage());
353+
res = FormValidation.error(
354+
"Cannot connect to specified BlobStore, please check the credentials: " + ex.getMessage());
342355
}
343356
return res;
344357
}
345358

346359
@POST
347-
public ListBoxModel doFillLocationIdItems(@QueryParameter String providerName,
360+
public ListBoxModel doFillLocationIdItems(
361+
@QueryParameter String providerName,
348362
@QueryParameter String credentialsId,
349363
@QueryParameter String endPointUrl) {
350364

@@ -367,7 +381,8 @@ public ListBoxModel doFillLocationIdItems(@QueryParameter String providerName,
367381
}
368382

369383
@POST
370-
public FormValidation doValidateLocationId(@QueryParameter("providerName") final String provider,
384+
public FormValidation doValidateLocationId(
385+
@QueryParameter("providerName") final String provider,
371386
@QueryParameter("credentialsId") final String credId,
372387
@QueryParameter("endPointUrl") final String url,
373388
@QueryParameter("locationId") final String locId) {
@@ -390,14 +405,18 @@ public FormValidation doValidateLocationId(@QueryParameter("providerName") final
390405
for (Location location : locations) {
391406
if (!location.getId().equals(testLoc)) {
392407
if (location.getId().contains(testLoc)) {
393-
return FormValidation.warning("Sorry cannot find the location id, " + "Did you mean: " + location.getId() + "?\n" + location);
408+
return FormValidation.warning("Sorry cannot find the location id, " + "Did you mean: "
409+
+ location.getId() + "?\n" + location);
394410
}
395411
} else {
396412
return FormValidation.ok("Location Id is valid.");
397413
}
398414
}
399415
} catch (Exception ex) {
400-
res = FormValidation.error("Unable to check the location id, " + "please check if the credentials you provided are correct.", ex);
416+
res = FormValidation.error(
417+
"Unable to check the location id, "
418+
+ "please check if the credentials you provided are correct.",
419+
ex);
401420
}
402421
return res;
403422
}
@@ -411,11 +430,15 @@ public ConverterImpl(XStream2 xstream) {
411430
super(xstream);
412431
}
413432

414-
@Override protected void callback(BlobStoreProfile bsp, UnmarshallingContext context) {
415-
if ((null == bsp.getCredentialsId() || bsp.getCredentialsId().isEmpty()) && null != bsp.identity && !bsp.identity.isEmpty()) {
416-
final String description = "JClouds BlobStore " + bsp.profileName + " - auto-migrated";
417-
bsp.setCredentialsId(CredentialsHelper.convertCredentials(description, bsp.identity, Secret.fromString(bsp.credential)));
418-
}
433+
@Override
434+
protected void callback(BlobStoreProfile bsp, UnmarshallingContext context) {
435+
if ((null == bsp.getCredentialsId() || bsp.getCredentialsId().isEmpty())
436+
&& null != bsp.identity
437+
&& !bsp.identity.isEmpty()) {
438+
final String description = "JClouds BlobStore " + bsp.profileName + " - auto-migrated";
439+
bsp.setCredentialsId(CredentialsHelper.convertCredentials(
440+
description, bsp.identity, Secret.fromString(bsp.credential)));
441+
}
419442
}
420443
}
421444
}

0 commit comments

Comments
 (0)