Skip to content

Commit e81ff23

Browse files
Remove temporary code
1 parent 9681f36 commit e81ff23

File tree

6 files changed

+69
-102
lines changed

6 files changed

+69
-102
lines changed

multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/context/ApplicationToUploadContext.java

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.List;
44

5-
import org.cloudfoundry.Nullable;
65
import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudApplicationExtended;
76
import org.cloudfoundry.multiapps.controller.process.util.ArchiveEntryWithStreamPositions;
87
import org.cloudfoundry.multiapps.controller.process.util.StepLogger;
@@ -30,6 +29,5 @@ public interface ApplicationToUploadContext {
3029

3130
String getAppArchiveId();
3231

33-
@Nullable // TODO: backwards compatibility for one tact
3432
List<ArchiveEntryWithStreamPositions> getArchiveEntries();
3533
}

multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/DetermineServiceCreateUpdateServiceActionsStep.java

+45-50
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package org.cloudfoundry.multiapps.controller.process.steps;
22

3-
import com.sap.cloudfoundry.client.facade.CloudControllerClient;
4-
import com.sap.cloudfoundry.client.facade.CloudOperationException;
5-
import com.sap.cloudfoundry.client.facade.domain.CloudServiceInstance;
6-
import com.sap.cloudfoundry.client.facade.domain.CloudServiceKey;
7-
import com.sap.cloudfoundry.client.facade.domain.ServiceOperation;
8-
import jakarta.inject.Inject;
9-
import jakarta.inject.Named;
3+
import java.io.ByteArrayInputStream;
4+
import java.io.IOException;
5+
import java.io.InputStream;
6+
import java.text.MessageFormat;
7+
import java.util.ArrayList;
8+
import java.util.Arrays;
9+
import java.util.Collections;
10+
import java.util.List;
11+
import java.util.Map;
12+
import java.util.Objects;
13+
1014
import org.apache.commons.collections4.CollectionUtils;
1115
import org.apache.commons.collections4.MapUtils;
1216
import org.apache.commons.lang3.ObjectUtils;
@@ -18,7 +22,6 @@
1822
import org.cloudfoundry.multiapps.controller.core.cf.v2.ResourceType;
1923
import org.cloudfoundry.multiapps.controller.core.helpers.MtaArchiveElements;
2024
import org.cloudfoundry.multiapps.controller.core.security.serialization.SecureSerialization;
21-
import org.cloudfoundry.multiapps.controller.persistence.services.FileStorageException;
2225
import org.cloudfoundry.multiapps.controller.process.Constants;
2326
import org.cloudfoundry.multiapps.controller.process.Messages;
2427
import org.cloudfoundry.multiapps.controller.process.util.ArchiveEntryExtractor;
@@ -28,21 +31,18 @@
2831
import org.cloudfoundry.multiapps.controller.process.util.ImmutableFileEntryProperties;
2932
import org.cloudfoundry.multiapps.controller.process.util.ServiceAction;
3033
import org.cloudfoundry.multiapps.controller.process.variables.Variables;
31-
import org.cloudfoundry.multiapps.mta.handlers.ArchiveHandler;
3234
import org.cloudfoundry.multiapps.mta.util.PropertiesUtil;
3335
import org.springframework.beans.factory.config.BeanDefinition;
3436
import org.springframework.context.annotation.Scope;
3537

36-
import java.io.ByteArrayInputStream;
37-
import java.io.IOException;
38-
import java.io.InputStream;
39-
import java.text.MessageFormat;
40-
import java.util.ArrayList;
41-
import java.util.Arrays;
42-
import java.util.Collections;
43-
import java.util.List;
44-
import java.util.Map;
45-
import java.util.Objects;
38+
import com.sap.cloudfoundry.client.facade.CloudControllerClient;
39+
import com.sap.cloudfoundry.client.facade.CloudOperationException;
40+
import com.sap.cloudfoundry.client.facade.domain.CloudServiceInstance;
41+
import com.sap.cloudfoundry.client.facade.domain.CloudServiceKey;
42+
import com.sap.cloudfoundry.client.facade.domain.ServiceOperation;
43+
44+
import jakarta.inject.Inject;
45+
import jakarta.inject.Named;
4646

4747
@Named("determineServiceCreateUpdateActionsStep")
4848
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@@ -76,17 +76,18 @@ protected StepPhase executeStep(ProcessContext context) throws Exception {
7676

7777
@Override
7878
protected String getStepErrorMessage(ProcessContext context) {
79-
return MessageFormat.format(Messages.ERROR_DETERMINING_ACTIONS_TO_EXECUTE_ON_SERVICE, context.getVariable(Variables.SERVICE_TO_PROCESS)
80-
.getName());
79+
return MessageFormat.format(Messages.ERROR_DETERMINING_ACTIONS_TO_EXECUTE_ON_SERVICE,
80+
context.getVariable(Variables.SERVICE_TO_PROCESS)
81+
.getName());
8182
}
8283

8384
private List<ServiceAction> determineActionsAndHandleExceptions(ProcessContext context, CloudServiceInstance existingService) {
8485
CloudServiceInstanceExtended service = context.getVariable(Variables.SERVICE_TO_PROCESS);
8586
try {
8687
return determineActions(context, service, existingService);
8788
} catch (CloudOperationException e) {
88-
String determineServiceActionsFailedMessage = MessageFormat.format(Messages.ERROR_DETERMINING_ACTIONS_TO_EXECUTE_ON_SERVICE, service.getName(),
89-
e.getStatusText());
89+
String determineServiceActionsFailedMessage = MessageFormat.format(Messages.ERROR_DETERMINING_ACTIONS_TO_EXECUTE_ON_SERVICE,
90+
service.getName(), e.getStatusText());
9091
throw new CloudOperationException(e.getStatusCode(), determineServiceActionsFailedMessage, e.getDescription(), e);
9192
}
9293
}
@@ -102,7 +103,8 @@ private boolean shouldResolveFileParameters(ProcessContext context) {
102103
return !context.getVariable(Variables.SHOULD_BACKUP_PREVIOUS_VERSION);
103104
}
104105

105-
private List<ServiceAction> determineActions(ProcessContext context, CloudServiceInstanceExtended service, CloudServiceInstance existingService) {
106+
private List<ServiceAction> determineActions(ProcessContext context, CloudServiceInstanceExtended service,
107+
CloudServiceInstance existingService) {
106108
List<ServiceAction> actions = new ArrayList<>();
107109
if (shouldUpdateKeys(service, existingService, context)) {
108110
getStepLogger().debug(Messages.SHOULD_UPDATE_SERVICE_KEY);
@@ -150,9 +152,11 @@ private List<ServiceAction> determineActions(ProcessContext context, CloudServic
150152
}
151153

152154
if (service.shouldSkipParametersUpdate()) {
153-
getStepLogger().warnWithoutProgressMessage(Messages.WILL_NOT_UPDATE_SERVICE_PARAMS_BECAUSE_PARAMETER_SKIP_SERVICE_UPDATES, service.getName());
155+
getStepLogger().warnWithoutProgressMessage(Messages.WILL_NOT_UPDATE_SERVICE_PARAMS_BECAUSE_PARAMETER_SKIP_SERVICE_UPDATES,
156+
service.getName());
154157
} else if (MapUtils.isEmpty(service.getCredentials())) {
155-
getStepLogger().warnWithoutProgressMessage(Messages.WILL_NOT_UPDATE_SERVICE_PARAMS_BECAUSE_UNDEFINED_OR_EMPTY, service.getName());
158+
getStepLogger().warnWithoutProgressMessage(Messages.WILL_NOT_UPDATE_SERVICE_PARAMS_BECAUSE_UNDEFINED_OR_EMPTY,
159+
service.getName());
156160
} else {
157161
getStepLogger().debug(Messages.WILL_UPDATE_SERVICE_PARAMETERS);
158162
getStepLogger().debug(Messages.NEW_SERVICE_PARAMETERS, SecureSerialization.toJson(service.getCredentials()));
@@ -185,8 +189,11 @@ private List<ServiceAction> determineActions(ProcessContext context, CloudServic
185189
}
186190

187191
private SLException getServiceRecreationNeededException(CloudServiceInstanceExtended service, CloudServiceInstance existingService) {
188-
return new SLException(Messages.ERROR_SERVICE_NEEDS_TO_BE_RECREATED_BUT_FLAG_NOT_SET, service.getResourceName(), buildServiceType(service),
189-
existingService.getName(), buildServiceType(existingService));
192+
return new SLException(Messages.ERROR_SERVICE_NEEDS_TO_BE_RECREATED_BUT_FLAG_NOT_SET,
193+
service.getResourceName(),
194+
buildServiceType(service),
195+
existingService.getName(),
196+
buildServiceType(existingService));
190197
}
191198

192199
private String buildServiceType(CloudServiceInstance service) {
@@ -218,32 +225,19 @@ private CloudServiceInstanceExtended prepareServiceParameters(ProcessContext con
218225
return service;
219226
}
220227

221-
private CloudServiceInstanceExtended setServiceParameters(ProcessContext context, CloudServiceInstanceExtended service, String fileName) {
228+
private CloudServiceInstanceExtended setServiceParameters(ProcessContext context, CloudServiceInstanceExtended service,
229+
String fileName) {
222230
String appArchiveId = context.getRequiredVariable(Variables.APP_ARCHIVE_ID);
223231
String spaceGuid = context.getVariable(Variables.SPACE_GUID);
224-
// TODO: backwards compatibility for one tact
225-
List<ArchiveEntryWithStreamPositions> archiveEntriesWithStreamPositions = context.getVariable(Variables.ARCHIVE_ENTRIES_POSITIONS);
226-
if (archiveEntriesWithStreamPositions == null) {
227-
try {
228-
return fileService.processFileContent(spaceGuid, appArchiveId, appArchiveStream -> {
229-
InputStream fileStream = ArchiveHandler.getInputStream(appArchiveStream, fileName, configuration.getMaxManifestSize());
230-
return mergeCredentials(service, fileStream);
231-
});
232-
} catch (FileStorageException e) {
233-
throw new SLException(e, e.getMessage());
234-
}
235-
}
236-
// TODO: backwards compatibility for one tact
237-
ArchiveEntryWithStreamPositions serviceBindingParametersEntry = ArchiveEntryExtractorUtil.findEntry(fileName, context.getVariable(
238-
Variables.ARCHIVE_ENTRIES_POSITIONS));
232+
ArchiveEntryWithStreamPositions serviceBindingParametersEntry = ArchiveEntryExtractorUtil.findEntry(fileName,
233+
context.getVariable(Variables.ARCHIVE_ENTRIES_POSITIONS));
239234
byte[] serviceBindingsParametersContent = archiveEntryExtractor.extractEntryBytes(ImmutableFileEntryProperties.builder()
240235
.guid(appArchiveId)
241-
.name(
242-
serviceBindingParametersEntry.getName())
236+
.name(serviceBindingParametersEntry.getName())
243237
.spaceGuid(spaceGuid)
244-
.maxFileSizeInBytes(
245-
configuration.getMaxManifestSize())
246-
.build(), serviceBindingParametersEntry);
238+
.maxFileSizeInBytes(configuration.getMaxManifestSize())
239+
.build(),
240+
serviceBindingParametersEntry);
247241
try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(serviceBindingsParametersContent)) {
248242
return mergeCredentials(service, byteArrayInputStream);
249243
} catch (IOException e) {
@@ -321,7 +315,8 @@ private boolean shouldUpdateSyslogUrl(CloudServiceInstance service, String exist
321315
return !Objects.equals(syslogDrainUrl, existingSyslogUrl);
322316
}
323317

324-
private void setServiceGuidIfPresent(ProcessContext context, List<ServiceAction> actions, CloudServiceInstance existingService, CloudServiceInstanceExtended serviceToProcess) {
318+
private void setServiceGuidIfPresent(ProcessContext context, List<ServiceAction> actions, CloudServiceInstance existingService,
319+
CloudServiceInstanceExtended serviceToProcess) {
325320
if (existingService != null && !actions.contains(ServiceAction.RECREATE)) {
326321
new DynamicResolvableParametersContextUpdater(context).updateServiceGuid(serviceToProcess, existingService);
327322
}

multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/util/ApplicationDigestCalculator.java

-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ public String calculateApplicationDigest(ApplicationArchiveContext applicationAr
4242
}
4343

4444
private void iterateApplicationArchive(ApplicationArchiveContext applicationArchiveContext) throws FileStorageException {
45-
// TODO: backwards compatibility for one tact
46-
if (applicationArchiveContext.getArchiveEntryWithStreamPositions() == null) {
47-
fileService.consumeFileContent(applicationArchiveContext.getSpaceId(), applicationArchiveContext.getAppArchiveId(),
48-
archiveStream -> calculateDigestFromDirectory(applicationArchiveContext, archiveStream));
49-
return;
50-
}
51-
// TODO: backwards compatibility for one tact
5245
if (ArchiveEntryExtractorUtil.containsDirectory(applicationArchiveContext.getModuleFileName(),
5346
applicationArchiveContext.getArchiveEntryWithStreamPositions())) {
5447
fileService.consumeFileContent(applicationArchiveContext.getSpaceId(), applicationArchiveContext.getAppArchiveId(),

multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/util/ApplicationZipBuilder.java

-6
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ public Path extractApplicationInNewArchive(ApplicationArchiveContext application
4545
Path appPath = null;
4646
try {
4747
appPath = createTempFile();
48-
// TODO: backwards compatibility for one tact
49-
if (applicationArchiveContext.getArchiveEntryWithStreamPositions() == null) {
50-
extractDirectoryContent(applicationArchiveContext, appPath);
51-
return appPath;
52-
}
53-
// TODO: backwards compatibility for one tact
5448
if (ArchiveEntryExtractorUtil.containsDirectory(applicationArchiveContext.getModuleFileName(),
5549
applicationArchiveContext.getArchiveEntryWithStreamPositions())) {
5650
LOGGER.info(MessageFormat.format(Messages.MODULE_0_CONTENT_IS_A_DIRECTORY, applicationArchiveContext.getModuleFileName()));

0 commit comments

Comments
 (0)