org.cloudfoundry.multiapps.controller.process.steps.UpdateServiceMetadataStep Maven / Gradle / Ivy
package org.cloudfoundry.multiapps.controller.process.steps;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import jakarta.inject.Named;
import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudServiceInstanceExtended;
import org.cloudfoundry.multiapps.controller.core.util.OperationExecutionState;
import org.cloudfoundry.multiapps.controller.process.Messages;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import com.sap.cloudfoundry.client.facade.CloudControllerClient;
import com.sap.cloudfoundry.client.facade.CloudOperationException;
import com.sap.cloudfoundry.client.facade.domain.ServiceOperation;
@Named("updateServiceMetadataStep")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class UpdateServiceMetadataStep extends ServiceStep {
@Override
protected OperationExecutionState executeOperation(ProcessContext context, CloudControllerClient client,
CloudServiceInstanceExtended service) {
getStepLogger().debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0, service.getName(), service.getResourceName());
try {
UUID serviceGuid = client.getRequiredServiceInstanceGuid(service.getName());
client.updateServiceInstanceMetadata(serviceGuid, service.getV3Metadata());
getStepLogger().debug(Messages.UPDATING_METADATA_OF_SERVICE_INSTANCE_0_DONE, service.getName());
} catch (CloudOperationException e) {
String exceptionDescription = MessageFormat.format(Messages.COULD_NOT_UPDATE_METADATA_OF_SERVICE, service.getName(),
e.getDescription());
CloudOperationException cloudOperationException = new CloudOperationException(e.getStatusCode(),
e.getStatusText(),
exceptionDescription);
processServiceActionFailure(context, service, cloudOperationException);
return OperationExecutionState.FINISHED;
}
return OperationExecutionState.EXECUTING;
}
@Override
protected List getAsyncStepExecutions(ProcessContext context) {
return Collections.singletonList(new PollServiceCreateOrUpdateOperationsExecution(getServiceOperationGetter(),
getServiceProgressReporter()));
}
@Override
protected ServiceOperation.Type getOperationType() {
return ServiceOperation.Type.UPDATE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy