All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudfoundry.multiapps.controller.process.util.EnvironmentApplicationAttributeUpdater Maven / Gradle / Ivy

There is a newer version: 1.183.0
Show newest version
package org.cloudfoundry.multiapps.controller.process.util;

import java.util.Map;

import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudApplicationExtended;
import org.cloudfoundry.multiapps.controller.process.Messages;
import org.cloudfoundry.multiapps.controller.process.util.ElementUpdater.UpdateStrategy;

import com.sap.cloudfoundry.client.facade.domain.CloudApplication;

public class EnvironmentApplicationAttributeUpdater extends ApplicationAttributeUpdater {

    private final Map existingAppEnv;

    public EnvironmentApplicationAttributeUpdater(Context context, UpdateStrategy updateStrategy, Map appEnv) {
        super(context, updateStrategy);
        this.existingAppEnv = appEnv;
    }

    @Override
    protected boolean shouldUpdateAttribute(CloudApplication existingApplication, CloudApplicationExtended application) {
        Map env = application.getEnv();
        return !existingAppEnv.equals(env);
    }

    @Override
    protected void updateAttribute(CloudApplication existingApplication, CloudApplicationExtended application) {
        Map env = applyUpdateStrategy(application.getEnv());
        getControllerClient().updateApplicationEnv(application.getName(), env);
    }

    private Map applyUpdateStrategy(Map env) {
        getLogger().debug(Messages.APPLYING_UPDATE_STRATEGY_0_TO_ENV, updateStrategy);
        return getElementUpdater().updateMap(existingAppEnv, env);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy