use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class IntegrationHandler method delete.
@Override
public void delete(String id) {
Integration existing = getIntegration(id);
// Set all integration status to Undeployed.
Set<String> deploymentIds = getDataManager().fetchIdsByPropertyValue(IntegrationDeployment.class, "integrationId", existing.getId().get());
if (deploymentIds != null && !deploymentIds.isEmpty()) {
deploymentIds.stream().map(i -> getDataManager().fetch(IntegrationDeployment.class, i)).filter(r -> r != null).map(r -> r.unpublishing()).forEach(r -> getDataManager().update(r));
}
Integration updatedIntegration = new Integration.Builder().createFrom(existing).updatedAt(System.currentTimeMillis()).isDeleted(true).build();
openShiftService.delete(existing.getName());
Updater.super.update(id, updatedIntegration);
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class IntegrationSupportHandler method importIntegrations.
private void importIntegrations(SecurityContext sec, JsonDbDao<Integration> export, List<ChangeEvent> result) {
for (Integration integration : export.fetchAll().getItems()) {
Integration.Builder builder = new Integration.Builder().createFrom(integration).isDeleted(false).updatedAt(System.currentTimeMillis());
// Do we need to create it?
String id = integration.getId().get();
Integration previous = dataManager.fetch(Integration.class, id);
if (previous == null) {
LOG.info("Creating integration: {}", integration.getName());
integrationHandler.create(sec, builder.build());
result.add(ChangeEvent.of("created", integration.getKind().getModelName(), id));
} else {
LOG.info("Updating integration: {}", integration.getName());
integrationHandler.update(id, builder.version(previous.getVersion() + 1).build());
result.add(ChangeEvent.of("updated", integration.getKind().getModelName(), id));
}
}
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class IntegrationSupportHandler method export.
@GET
@Path("/export.zip")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
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);
}
LinkedHashSet<String> extensions = new LinkedHashSet<>();
CloseableJsonDB memJsonDB = MemorySqlJsonDB.create(jsonDB.getIndexes());
if (ids.contains("all")) {
ids = new ArrayList<>();
for (Integration integration : dataManager.fetchAll(Integration.class)) {
ids.add(integration.getId().get());
}
}
for (String id : ids) {
Integration integration = integrationHandler.getIntegration(id);
addToExport(memJsonDB, integration);
resourceManager.collectDependencies(integration.getSteps(), true).stream().filter(Dependency::isExtension).map(Dependency::getId).forEach(extensions::add);
}
LOG.debug("Extensions: {}", extensions);
return out -> {
try (ZipOutputStream tos = new ZipOutputStream(out)) {
ModelExport exportObject = ModelExport.of(Schema.VERSION);
addEntry(tos, EXPORT_MODEL_INFO_FILE_NAME, Json.writer().writeValueAsBytes(exportObject));
addEntry(tos, EXPORT_MODEL_FILE_NAME, memJsonDB.getAsByteArray("/"));
memJsonDB.close();
for (String extensionId : extensions) {
addEntry(tos, "extensions/" + Names.sanitize(extensionId) + ".jar", IOUtils.toByteArray(extensionDataManager.getExtensionBinaryFile(extensionId)));
}
}
};
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class TestSupportHandler method deleteDeployments.
@GET
@Path("/delete-deployments")
public void deleteDeployments() {
LOG.warn("user {} is deleting all integration deploymets", context.getRemoteUser());
List<Integration> integrations = dataMgr.fetchAll(Integration.class).getItems();
for (Integration i : integrations) {
if (openShiftService.exists(i.getName())) {
openShiftService.delete(i.getName());
LOG.debug("Deleting integration \"{}\"", i.getName());
} else {
LOG.debug("Skipping integration named \"{}\". No such deployment found.", i.getName());
}
}
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class UniquePropertyValidatorTest method parameters.
@Parameters
public static Iterable<Object[]> parameters() {
final Connection existingNameNoId = new Connection.Builder().name("Existing").build();
final Connection existingNameWithSameId = new Connection.Builder().name("Existing").id("same").build();
final Connection existingNameWithDifferentId = new Connection.Builder().name("Existing").id("different").build();
final Connection uniqueNameNoId = new Connection.Builder().name("Unique").build();
final Integration existingButDeleted = new Integration.Builder().name("Existing").id("different").build();
return //
Arrays.asList(//
new Object[] { existingNameNoId, false }, //
new Object[] { existingNameWithSameId, true }, //
new Object[] { existingNameWithDifferentId, false }, //
new Object[] { uniqueNameNoId, true }, //
new Object[] { existingButDeleted, true });
}
Aggregations