Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class Messages {

// WARN log messages

public static final String NO_OBJECTSTORE_PROVIDER_FOUND = "No ObjectStore provider found!";
public static final String NO_OBJECTSTORE_PROVIDER_FOUND_FOR_0 = "No ObjectStore provider found for {0}!";

// INFO log messages
public static final String ALM_SERVICE_ENV_INITIALIZED = "Deploy service environment initialized";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.cloudfoundry.multiapps.controller.persistence.util.EnvironmentServicesFinder;
import org.cloudfoundry.multiapps.controller.web.Constants;
import org.cloudfoundry.multiapps.controller.web.Messages;
import org.cloudfoundry.multiapps.controller.web.configuration.service.ImmutableObjectStoreServiceInfo;
import org.cloudfoundry.multiapps.controller.web.configuration.service.ObjectStoreServiceInfo;
import org.cloudfoundry.multiapps.controller.web.configuration.service.ObjectStoreServiceInfoCreator;
import org.jclouds.ContextBuilder;
Expand Down Expand Up @@ -92,11 +91,13 @@
private Optional<FileStorage> createObjectStoreBasedOnProvider(String objectStoreProviderName,
List<ObjectStoreServiceInfo> providersServiceInfo,
Map<String, Exception> exceptions) {
return switch (objectStoreProviderName) {
case Constants.AZURE -> tryToCreateSdkObjectStore(exceptions, Constants.AZUREBLOB);
case Constants.GCP -> tryToCreateSdkObjectStore(exceptions, Constants.GOOGLE_CLOUD_STORAGE);
default -> tryToCreateJCloudsObjectStore(objectStoreProviderName, providersServiceInfo, exceptions);
};
Optional<ObjectStoreServiceInfo> objectStoreServiceInfoOptional = getAppropriateProvider(objectStoreProviderName,
providersServiceInfo);
if (objectStoreServiceInfoOptional.isEmpty()) {
LOGGER.warn(MessageFormat.format(Messages.NO_OBJECTSTORE_PROVIDER_FOUND_FOR_0, objectStoreProviderName));

Check warning on line 97 in multiapps-controller-web/src/main/java/org/cloudfoundry/multiapps/controller/web/configuration/bean/factory/ObjectStoreFileStorageFactoryBean.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Invoke method(s) only conditionally.

See more on https://sonarcloud.io/project/issues?id=cloudfoundry_multiapps-controller&issues=AZ1IrQm9UwmeBQ8r-lg8&open=AZ1IrQm9UwmeBQ8r-lg8&pullRequest=1806
return Optional.empty();
}
return tryToCreateObjectStore(objectStoreServiceInfoOptional.get(), exceptions);
}

private Optional<ObjectStoreServiceInfo> getAppropriateProvider(String objectStoreProviderName,
Expand All @@ -107,25 +108,6 @@
.findFirst();
}

private Optional<FileStorage> tryToCreateJCloudsObjectStore(String objectStoreProviderName,
List<ObjectStoreServiceInfo> providersServiceInfo,
Map<String, Exception> exceptions) {
Optional<ObjectStoreServiceInfo> objectStoreServiceInfoOptional = getAppropriateProvider(objectStoreProviderName,
providersServiceInfo);
if (objectStoreServiceInfoOptional.isPresent()) {
ObjectStoreServiceInfo objectStoreServiceInfo = objectStoreServiceInfoOptional.get();
return tryToCreateObjectStore(objectStoreServiceInfo, exceptions);
}
LOGGER.warn(Messages.NO_OBJECTSTORE_PROVIDER_FOUND);
return Optional.empty();
}

private Optional<FileStorage> tryToCreateSdkObjectStore(Map<String, Exception> exceptions, String providerName) {
return tryToCreateObjectStore(ImmutableObjectStoreServiceInfo.builder()
.provider(providerName)
.build(), exceptions);
}

private Optional<FileStorage> tryToCreateObjectStore(ObjectStoreServiceInfo objectStoreServiceInfo,
Map<String, Exception> exceptions) {
try {
Expand Down
Loading