Skip to content

Commit

Permalink
modify how parameters are obtained
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yonkov-yonkov authored and ikasarov committed May 14, 2024
1 parent c72f32d commit 0f4b353
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,31 @@
import org.cloudfoundry.multiapps.mta.model.DeploymentDescriptor;
import org.cloudfoundry.multiapps.mta.model.NamedParametersContainer;

@Named
@Named("readOnlyParametersChecker")
public class ReadOnlyParametersChecker {

public void check(DeploymentDescriptor descriptor) {
Map<String, Set<String>> detectedReadOnlyParameters = new LinkedHashMap<>();
checkForCommonParameters(new GlobalParameters(descriptor), READ_ONLY_SYSTEM_PARAMETERS, detectedReadOnlyParameters);
checkCollectionForCommonParameters(descriptor.getModules(), READ_ONLY_MODULE_PARAMETERS, detectedReadOnlyParameters);
checkCollectionForCommonParameters(descriptor.getResources(), READ_ONLY_RESOURCE_PARAMETERS, detectedReadOnlyParameters);
checkForCommonParameters(new GlobalParameters(descriptor), getReadOnlySystemParameters(), detectedReadOnlyParameters);
checkCollectionForCommonParameters(descriptor.getModules(), getReadOnlyModuleParameters(), detectedReadOnlyParameters);
checkCollectionForCommonParameters(descriptor.getResources(), getReadOnlyResourceParameters(), detectedReadOnlyParameters);
if (!detectedReadOnlyParameters.isEmpty()) {
throw new SLException(getFormattedOutput(detectedReadOnlyParameters));
}
}

protected Set<String> getReadOnlySystemParameters() {
return READ_ONLY_SYSTEM_PARAMETERS;
}

protected Set<String> getReadOnlyModuleParameters() {
return READ_ONLY_MODULE_PARAMETERS;
}

protected Set<String> getReadOnlyResourceParameters() {
return READ_ONLY_RESOURCE_PARAMETERS;
}

private void checkForCommonParameters(NamedParametersContainer namedParametersContainer, Set<String> readOnlyParameters,
Map<String, Set<String>> commonReadOnlyParameters) {
Set<String> commonParameters = SetUtils.intersection(namedParametersContainer.getParameters()
Expand Down

0 comments on commit 0f4b353

Please sign in to comment.