All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.cp4waiops.connectors.sdk.KafkaTopicHelper Maven / Gradle / Ivy

There is a newer version: 2.2.8
Show newest version
package com.ibm.cp4waiops.connectors.sdk;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

public class KafkaTopicHelper {
    HashSet options = null;
    public static final String OPTION_INCIDENTS = "incidents";
    public static final String OPTION_CHANGES = "changes";

    static final String TOPIC_INPUT_ACTION_SNOW = "cp4waiops-cartridge.connector-snow-actions";
    static final String TOPIC_OUTPUT_ACTION_SNOW = "cp4waiops-cartridge.connector-snow-actions";
    static final String TOPIC_INPUT_LIFECYCLE_EVENTS = "cp4waiops-cartridge.lifecycle.input.events";
    static final String TOPIC_OUTPUT_INCIDENT = "cp4waiops-cartridge.incident";
    static final String TOPIC_OUTPUT_CHANGE_REQUEST = "cp4waiops-cartridge.changerequest";
    static final String TOPIC_OUTPUT_PROBLEM = "cp4waiops-cartridge.problem";
    static final String TOPIC_OUTPUT_ITSM_INCIDENT_RESPONSE = "cp4waiops-cartridge.itsmincidentresponse";
    static final String TOPIC_INPUT_SNOW_HANDLERS = "cp4waiops-cartridge.snow-handlers";

    public KafkaTopicHelper(HashSet options) {
        this.options = options;
    }

    public String[] addConsumeTopics(String[] currentTopics) {
        List arrList = null;
        if (currentTopics != null) {
            arrList = new ArrayList(Arrays.asList(currentTopics));
        } else {
            arrList = new ArrayList();
        }

        // 1. For incident and changes
        if (options.contains(OPTION_INCIDENTS) || options.contains(OPTION_CHANGES)) {
            if (!arrList.contains(TOPIC_INPUT_ACTION_SNOW))
                arrList.add(TOPIC_INPUT_ACTION_SNOW);
            if (!arrList.contains(TOPIC_INPUT_SNOW_HANDLERS))
                arrList.add(TOPIC_INPUT_SNOW_HANDLERS);
        }

        // Any future consume types can be added here

        return arrList.toArray(new String[arrList.size()]);
    }

    public String[] addProduceTopics(String[] currentTopics) {
        List arrList = null;
        if (currentTopics != null) {
            arrList = new ArrayList(Arrays.asList(currentTopics));
        } else {
            arrList = new ArrayList();
        }

        // 1. For incident and changes
        if (options.contains(OPTION_INCIDENTS) || options.contains(OPTION_CHANGES)) {
            if (!arrList.contains(TOPIC_OUTPUT_ACTION_SNOW))
                arrList.add(TOPIC_OUTPUT_ACTION_SNOW);
            if (!arrList.contains(TOPIC_OUTPUT_CHANGE_REQUEST))
                arrList.add(TOPIC_OUTPUT_CHANGE_REQUEST);
            if (!arrList.contains(TOPIC_OUTPUT_INCIDENT))
                arrList.add(TOPIC_OUTPUT_INCIDENT);
            if (!arrList.contains(TOPIC_OUTPUT_ITSM_INCIDENT_RESPONSE))
                arrList.add(TOPIC_OUTPUT_ITSM_INCIDENT_RESPONSE);
        }

        // Any future consume types can be added here

        return arrList.toArray(new String[arrList.size()]);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy