Java Code Examples for org.cloudfoundry.client.lib.domain.CloudApplication#getEnv()

The following examples show how to use org.cloudfoundry.client.lib.domain.CloudApplication#getEnv() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UploadAppStep.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
private boolean detectApplicationFileDigestChanges(ProcessContext context, CloudApplication appWithUpdatedEnvironment,
                                                   CloudControllerClient client, String newApplicationDigest) {
    ApplicationFileDigestDetector digestDetector = new ApplicationFileDigestDetector(appWithUpdatedEnvironment.getEnv());
    String currentApplicationDigest = digestDetector.detectCurrentAppFileDigest();
    boolean contentChanged = !newApplicationDigest.equals(currentApplicationDigest);
    if (contentChanged) {
        attemptToUpdateApplicationDigest(client, appWithUpdatedEnvironment, newApplicationDigest);
    }
    setAppContentChanged(context, contentChanged);
    return contentChanged;
}
 
Example 2
Source File: EnvMtaMetadataParser.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
public DeployedMtaApplication parseDeployedMtaApplication(CloudApplication application) {
    envMtaMetadataValidator.validate(application);
    Map<String, String> env = application.getEnv();
    String moduleName = parseNameAttribute(env, Constants.ENV_MTA_MODULE_METADATA);
    List<String> providedDependencyNames = parseModuleProvidedDependencies(application.getName(), env,
                                                                           Constants.ENV_MTA_MODULE_PUBLIC_PROVIDED_DEPENDENCIES);
    List<String> services = parseList(env, Constants.ENV_MTA_SERVICES);
    return ImmutableDeployedMtaApplication.builder()
                                          .from(application)
                                          .moduleName(moduleName)
                                          .boundMtaServices(services)
                                          .providedDependencyNames(providedDependencyNames)
                                          .build();
}
 
Example 3
Source File: UpdateSubscribersStep.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
private CloudApplication attemptToUpdateSubscriber(ProcessContext context, CloudControllerClient client,
                                                   ConfigurationSubscription subscription) {
    HandlerFactory handlerFactory = new HandlerFactory(MAJOR_SCHEMA_VERSION);

    DeploymentDescriptor dummyDescriptor = buildDummyDescriptor(subscription, handlerFactory);
    getStepLogger().debug(com.sap.cloud.lm.sl.cf.core.Messages.DEPLOYMENT_DESCRIPTOR, SecureSerialization.toJson(dummyDescriptor));

    ConfigurationReferencesResolver resolver = handlerFactory.getConfigurationReferencesResolver(configurationEntryService,
                                                                                                 new DummyConfigurationFilterParser(subscription.getFilter()),
                                                                                                 new CloudTarget(context.getVariable(Variables.ORGANIZATION_NAME),
                                                                                                                 context.getVariable(Variables.SPACE_NAME)),
                                                                                                 configuration);
    resolver.resolve(dummyDescriptor);
    getStepLogger().debug(Messages.RESOLVED_DEPLOYMENT_DESCRIPTOR, SecureSerialization.toJson(dummyDescriptor));
    dummyDescriptor = handlerFactory.getDescriptorReferenceResolver(dummyDescriptor, new ResolverBuilder(), new ResolverBuilder(),
                                                                    new ResolverBuilder())
                                    .resolve();
    getStepLogger().debug(Messages.RESOLVED_DEPLOYMENT_DESCRIPTOR, SecureSerialization.toJson(dummyDescriptor));

    ApplicationCloudModelBuilder applicationCloudModelBuilder = handlerFactory.getApplicationCloudModelBuilder(dummyDescriptor,
                                                                                                               shouldUsePrettyPrinting(),
                                                                                                               null, "",
                                                                                                               context.getVariable(Variables.MTA_NAMESPACE),
                                                                                                               getStepLogger());

    Module module = dummyDescriptor.getModules()
                                   .get(0);

    CloudApplicationExtended application = applicationCloudModelBuilder.build(module, moduleToDeployHelper);
    CloudApplication existingApplication = client.getApplication(subscription.getAppName());

    Map<String, String> updatedEnvironment = application.getEnv();
    Map<String, String> currentEnvironment = new LinkedHashMap<>(existingApplication.getEnv());

    boolean neededToBeUpdated = updateCurrentEnvironment(currentEnvironment, updatedEnvironment,
                                                         getPropertiesToTransfer(subscription, resolver));

    if (!neededToBeUpdated) {
        return null;
    }

    getStepLogger().info(Messages.UPDATING_SUBSCRIBER, subscription.getAppName(), subscription.getMtaId(),
                         getRequiredDependency(subscription).getName());
    client.updateApplicationEnv(existingApplication.getName(), currentEnvironment);
    return existingApplication;
}
 
Example 4
Source File: EnvironmentApplicationAttributeUpdater.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean shouldUpdateAttribute(CloudApplication existingApplication, CloudApplication application) {
    Map<String, String> env = application.getEnv();
    Map<String, String> existingEnv = existingApplication.getEnv();
    return !existingEnv.equals(env);
}
 
Example 5
Source File: ApplicationAttributes.java    From multiapps-controller with Apache License 2.0 4 votes vote down vote up
private static Map<String, Object> parseAttributes(CloudApplication app) {
    Map<String, String> env = app.getEnv();
    Map<String, Object> attributes = parseAttributes(app, env.get(Constants.ENV_DEPLOY_ATTRIBUTES));
    return attributes == null ? Collections.emptyMap() : attributes;
}