@POST @Produces(MediaType.APPLICATION_JSON) @Path("/{id}/deployments/{version}/targetState") @SuppressFBWarnings("UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD") public void setTargetStatus( @NotNull @PathParam("id") @ApiParam(required = true) String id, @NotNull @PathParam("version") @ApiParam(required = true) Integer version, TargetStateRequest request) { String compositeId = IntegrationDeployment.compositeId(id, version); IntegrationDeployment deployment = getDataManager().fetch(IntegrationDeployment.class, compositeId); deployment = new IntegrationDeployment.Builder().createFrom(deployment).targetState(request.targetState).build(); getDataManager().update(deployment); }
@PUT @Produces(MediaType.APPLICATION_JSON) @Path("/{id}/deployments") public IntegrationDeployment putDeployment(@Context SecurityContext sec, @NotNull @PathParam("id") @ApiParam(required = true) String id) { Integration integration = Getter.super.get(id); int nextDeploymentVersion = 1; // Update previous deployments targetState=Undeployed and make sure nextDeploymentVersion is larger than all previous ones. Set<String> deploymentIds = getDataManager().fetchIdsByPropertyValue(IntegrationDeployment.class, "integrationId", id); if (deploymentIds != null && !deploymentIds.isEmpty()) { Stream<IntegrationDeployment> deployments = deploymentIds.stream() .map(i -> getDataManager().fetch(IntegrationDeployment.class, i)) .filter(r -> r != null); for (IntegrationDeployment d : deployments.toArray(IntegrationDeployment[]::new)) { nextDeploymentVersion = Math.max(nextDeploymentVersion, d.getVersion()+1); getDataManager().update(d.withTargetState(IntegrationDeploymentState.Unpublished)); } } IntegrationDeployment deployment = new IntegrationDeployment.Builder() .id(IntegrationDeployment.compositeId(id, nextDeploymentVersion)) .spec(integration) .version(nextDeploymentVersion) // .userId(SecurityContextHolder.getContext().getAuthentication().getName()) .userId(sec.getUserPrincipal().getName()) .build(); deployment = getDataManager().create(deployment); return deployment; }
dataManager.update(new IntegrationDeployment.Builder() .createFrom(current) .currentState(IntegrationDeploymentState.Error)
IntegrationDeployment updated = new IntegrationDeployment.Builder() .createFrom(current) dataManager.update(new IntegrationDeployment.Builder() .createFrom(current) .currentState(IntegrationDeploymentState.Error)
return new IntegrationDeployment.Builder() .createFrom(integrationDeployment) .spec(builder.steps(steps).build())
protected IntegrationDeployment newIntegration(Step... steps) { for (int i = 0; i < steps.length; i++) { steps[i].getConnection().filter(r -> r.getId().isPresent()).ifPresent( resource -> resourceManager.put(resource.getId().get(), resource) ); steps[i].getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).filter(r -> r.getId().isPresent()).ifPresent( resource -> resourceManager.put(resource.getId().get(), resource) ); steps[i].getExtension().filter(r -> r.getId().isPresent()).ifPresent( resource -> resourceManager.put(resource.getId().get(), resource) ); if (steps[i] instanceof SimpleStep) { steps[i] = new SimpleStep.Builder().createFrom(steps[i]).putMetadata(Step.METADATA_STEP_INDEX, Integer.toString(i + 1)).build(); } else if (steps[i] instanceof ExpressionFilterStep) { steps[i] = new ExpressionFilterStep.Builder().createFrom(steps[i]).putMetadata(Step.METADATA_STEP_INDEX, Integer.toString(i + 1)).build(); } else if (steps[i] instanceof RuleFilterStep) { steps[i] = new RuleFilterStep.Builder().createFrom(steps[i]).putMetadata(Step.METADATA_STEP_INDEX, Integer.toString(i + 1)).build(); } } return new IntegrationDeployment.Builder() .integrationId("test-integration") .name("Test Integration") .spec(new IntegrationDeploymentSpec.Builder() .description("This is a test integration!") .steps(Arrays.asList(steps)) .build()) .lastUpdated(new Date(0)) .lastUpdated(new Date(0)) .build(); }
@Override public StateUpdate execute(IntegrationDeployment integrationDeployment) { IntegrationDeploymentState currentState = !openShiftService().exists(integrationDeployment.getSpec().getName()) || openShiftService().delete(integrationDeployment.getSpec().getName()) ? IntegrationDeploymentState.Unpublished : IntegrationDeploymentState.Pending; if (currentState == IntegrationDeploymentState.Unpublished) { logInfo(integrationDeployment,"Deleted"); IntegrationDeployment updated = new IntegrationDeployment.Builder().createFrom(integrationDeployment).addAllStepsDone(Collections.emptyList()).build(); dataManager.update(updated); } return new StateUpdate(currentState); }
private static IntegrationDeployment newDeployment(List<Step> steps) { return new IntegrationDeployment.Builder().spec(new IntegrationDeploymentSpec.Builder().steps(steps).build()).currentState(IntegrationDeploymentState.Active).build(); } }
public IntegrationDeployment encrypt(IntegrationDeployment integrationDeployment) { return new IntegrationDeployment.Builder() .createFrom(integrationDeployment) .spec(new IntegrationDeploymentSpec.Builder().createFrom(integrationDeployment.getSpec()).steps(encrypt(integrationDeployment.getSpec().getSteps())).build()) .build(); }