class CamelKPublishHandler extends BaseCamelKHandler implements StateChangeHandler {

    @SuppressWarnings({"PMD.ExcessiveMethodLength"})
    protected io.syndesis.server.controller.integration.camelk.crd.Integration createIntegrationCR(IntegrationDeployment integrationDeployment) {
        final Integration integration = integrationDeployment.getSpec();

        String username = integrationDeployment.getUserId().get();
        String integrationId = integrationDeployment.getIntegrationId().get();
        String version = Integer.toString(integrationDeployment.getVersion());
        String integrationDeploymentId = integrationDeployment.getId().get();

        io.syndesis.server.controller.integration.camelk.crd.Integration result = new io.syndesis.server.controller.integration.camelk.crd.Integration();
        //add CR metadata
        result.getMetadata().setName(CamelKSupport.integrationName(integration.getName()));
        result.getMetadata().setLabels(new HashMap<>());
        result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_ID_LABEL, Labels.sanitize(integrationId));
        result.getMetadata().getLabels().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version);
        result.getMetadata().getLabels().put(OpenShiftService.USERNAME_LABEL, Labels.sanitize(username));
        result.getMetadata().getLabels().put(OpenShiftService.COMPONENT_LABEL, "integration");
        result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_NAME_LABEL, Labels.sanitize(integration.getName()));
        result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_TYPE_LABEL, OpenShiftService.INTEGRATION_TYPE_LABEL_VALUE);
        result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_APP_LABEL, OpenShiftService.INTEGRATION_APP_LABEL_VALUE);
        result.getMetadata().setAnnotations(new HashMap<>());
        result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_NAME_ANNOTATION, integration.getName());
        result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_ID_LABEL, integrationId);
        result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version);
        result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_ID_ANNOTATION, integrationDeploymentId);
        result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_PORT_ANNOTATION, "9779");
        result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_SCRAPE_ANNOTATION, "true");

        ImmutableIntegrationSpec.Builder integrationSpecBuilder = new IntegrationSpec.Builder();

        Collection<String> customizers = configuration.getCamelk().getCustomizers();

        integrationSpecBuilder.addResources(new ResourceSpec.Builder()
            .dataSpec(new DataSpec.Builder()
                .name("prometheus-config.yml")
                .contentRef("syndesis-prometheus-agent-config")
                .contentKey("prometheus-config.yml")
                .build())
            .mountPath("/etc/camel/resources")
            .type("data")
            .build());

        this.configuration.getCamelk().getEnvironment().forEach((k, v) -> {
            integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder().type("env").value(k + "=" + v).build());
        });

        for (String customizerId: customizers) {
            integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder()
                .type("property")
                .value("customizer." + customizerId + ".enabled=true")
                .build());
        }
        //TODO: make all this configurable, where makes sense
        integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder()
            .type("env")
            .value("AB_JMX_EXPORTER_CONFIG=/etc/camel/resources/prometheus-config.yml")
            .build());
        integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder()
            .type("property")
            .value("camel.context.streamCaching=true")
            .build());
        integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder()
            .type("secret")
            .value(CamelKSupport.integrationName(integration.getName()))
            .build());

        try {
            addMappingRules(integration, integrationSpecBuilder);
            addIntegrationSource(integration, integrationSpecBuilder);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }

        result.setSpec(integrationSpecBuilder.build());
        return result;
    }

    public  CamelKPublishHandler(
        OpenShiftService openShiftService,
        IntegrationDao iDao,
        IntegrationDeploymentDao idDao,
        IntegrationProjectGenerator projectGenerator,
        IntegrationPublishValidator validator,
        IntegrationResourceManager resourceManager,
        List<CamelKIntegrationCustomizer> customizers,
        ControllersConfigurationProperties configuration,
        ExposureHelper exposureHelper);

}