Skip to content

Commit

Permalink
Comply with modernizer
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Dec 30, 2024
1 parent d564bb3 commit d4dd52e
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import java.awt.Desktop;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -101,8 +102,8 @@ public static void main(final String[] args) {
sa.run(args);
}

private void getConfigurationMap(final File clientJson) throws IOException, URISyntaxException {
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new FileReader(clientJson));
private void getConfigurationMap(final Path clientJson) throws IOException, URISyntaxException {
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, Files.newBufferedReader(clientJson));
CONFIG_MAP.put("clientId", clientSecrets.getDetails().getClientId());
CONFIG_MAP.put("clientSecret", clientSecrets.getDetails().getClientSecret());

Expand Down Expand Up @@ -142,12 +143,12 @@ public ServletRegistrationBean codeProcessorServlet() {
@Override
public void run(final String... args) throws IOException, URISyntaxException {
if (args.length == 1) {
File clientJson = new File(args[0]);
if (clientJson.isDirectory()) {
clientJson = new File(clientJson, CLIENTSECRETS_LOCATION);
Path clientJson = Paths.get(args[0]);
if (Files.isDirectory(clientJson)) {
clientJson = clientJson.resolve(CLIENTSECRETS_LOCATION);
}

if (clientJson.exists() && clientJson.isFile()) {
if (Files.isReadable(clientJson) && Files.isRegularFile(clientJson)) {
getConfigurationMap(clientJson);
} else {
LOG.error("Invalid client secret path: {}", clientJson);
Expand Down

0 comments on commit d4dd52e

Please sign in to comment.