use of io.syndesis.server.api.generator.APIIntegration in project syndesis by syndesisio.
the class ApiGeneratorHelper method generateIntegrationUpdateFrom.
public static APIIntegration generateIntegrationUpdateFrom(final Integration existing, final APIFormData apiFormData, final DataManager dataManager, final APIGenerator apiGenerator) {
final APIIntegration newApiIntegration = generateIntegrationFrom(apiFormData, dataManager, apiGenerator);
final Integration newIntegration = newApiIntegration.getIntegration();
final Integration updatedIntegration = newIntegration.builder().id(existing.getId()).build();
return new APIIntegration(updatedIntegration, newApiIntegration.getSpec());
}
use of io.syndesis.server.api.generator.APIIntegration in project syndesis by syndesisio.
the class ApiHandler method updateIntegrationFromSpecification.
@PUT
@Path("/generator")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Operation(description = "Update the provided integration from a API specification. Does not store it in the database")
public Response updateIntegrationFromSpecification(@MultipartForm final APIUpdateFormData apiUpdateFormData) {
final DataManager dataManager = getDataManager();
final Integration existing = apiUpdateFormData.integration;
final APIIntegration apiIntegration = ApiGeneratorHelper.generateIntegrationUpdateFrom(existing, apiUpdateFormData, dataManager, apiGenerator);
final Integration givenIntegration = apiIntegration.getIntegration();
final Integration updated = ApiGeneratorHelper.updateFlowsAndStartAndEndDataShapes(existing, givenIntegration);
final OpenApi existingApiSpecification = ApiGeneratorHelper.specificationFrom(resourceManager, existing).orElse(null);
if (Objects.equals(existing.getFlows(), updated.getFlows()) && Objects.equals(existingApiSpecification, apiIntegration.getSpec())) {
// no changes were made to the flows or to the specification
return Response.notModified().build();
}
// store the OpenAPI resource, we keep the old one as it might
// be referenced from Integration's stored in IntegrationDeployent's
// this gives us a rollback mechanism
final OpenApi openApi = apiIntegration.getSpec();
dataManager.store(openApi, OpenApi.class);
return Response.accepted(updated).build();
}
Aggregations