fix: Integration exporting was breaking on integrations with an extension.
@@ -110,10 +110,9 @@ public class IntegrationSupportHandler {
@GET
@Path("/export.zip")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
- public StreamingOutput export(@NotNull @QueryParam("id") @ApiParam(required = true) List<String> ids) throws IOException {
-
- System.out.println("ids: "+ids);
+ public StreamingOutput export(@NotNull @QueryParam("id") @ApiParam(required = true) List<String> requestedIds) throws IOException {
+ List<String> ids = requestedIds;
if ( ids ==null || ids.isEmpty() ) {
throw new ClientErrorException("No 'integration' query parameter specified.", Response.Status.BAD_REQUEST);
}
@@ -122,38 +121,19 @@ public class IntegrationSupportHandler {
LinkedHashSet<String> extensions = new LinkedHashSet<>();
if( ids.contains("all") ) {
- List<Integration> allIntegrations = dataManager.fetchAll(Integration.class).getItems();
- for (Integration integration : allIntegrations) {
-
- List<IntegrationDeployment> deployments = dataManager.fetchIdsByPropertyValue(IntegrationDeployment.class, "integrationId", integration.getId().get()).stream()
- .map(i -> dataManager.fetch(IntegrationDeployment.class, i))
- .collect(Collectors.toList());
-
- addToExport(export, integration, deployments);
-
- ProjectGeneratorHelper.collectDependencies(resourceManager, integration.getSteps()).stream()
- .filter(Dependency::isExtension)
- .map(Dependency::getId)
- .forEach(extensions::add);
+ ids = new ArrayList<>();
+ for (Integration integration : dataManager.fetchAll(Integration.class).getItems()) {
+ ids.add(integration.getId().get());
+ }
}
- } else {
for (String id : ids) {
Integration integration = integrationHandler.get(id);
- List<IntegrationDeployment> deployments = dataManager.fetchIdsByPropertyValue(IntegrationDeployment.class, "integrationId", integration.getId().get()).stream()
- .map(i -> dataManager.fetch(IntegrationDeployment.class, i))
- .collect(Collectors.toList());
-
- addToExport(export, integration, deployments);
-
- deployments.forEach(
- deployment -> {
- ProjectGeneratorHelper.collectDependencies(resourceManager, deployment).stream()
+ addToExport(export, integration);
+ ProjectGeneratorHelper.collectDependencies(resourceManager, integration.getSteps()).stream()
+ .filter(Dependency::isExtension)
.map(Dependency::getId)
.forEach(extensions::add);
}
- );
- }
- }
System.out.println("Extensions: "+extensions);
@@ -171,14 +151,9 @@ public class IntegrationSupportHandler {
};
}
- private void addToExport(LinkedHashMap<String, ModelData<?>> export, Integration integration, List<IntegrationDeployment> deployments) {
+ private void addToExport(LinkedHashMap<String, ModelData<?>> export, Integration integration) {
addToExport(export, new ModelData<Integration>(Kind.Integration, integration));
-
- for (IntegrationDeployment deployment : deployments) {
-
- addToExport(export, new ModelData<IntegrationDeployment>(Kind.IntegrationDeployment, deployment));
-
- for (Step step : deployment.getSpec().getSteps()) {
+ for (Step step : integration.getSteps()) {
Optional<Connection> c = step.getConnection();
if (c.isPresent()) {
Connection connection = c.get();
@@ -195,7 +170,6 @@ public class IntegrationSupportHandler {
}
}
}
- }
private void addToExport(LinkedHashMap<String, ModelData<?>> export, ModelData<?> model) {
try {
@@ -324,7 +298,6 @@ public class IntegrationSupportHandler {
break;
}
default: {
-
if (LOG.isInfoEnabled()) {
LOG.info("Cannot import unsupported model kind: " + model.getKind());
}
