/**
 * Hub JIRA Plugin
 *
 * Copyright (C) 2017 Black Duck Software, Inc.
 * http://www.blackducksoftware.com/
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.blackducksoftware.integration.jira.task.conversion;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import org.apache.log4j.Logger;

import com.blackducksoftware.integration.hub.dataservice.notification.item.PolicyOverrideContentItem;
import com.blackducksoftware.integration.hub.dataservice.notification.item.PolicyViolationClearedContentItem;
import com.blackducksoftware.integration.hub.dataservice.notification.item.PolicyViolationContentItem;
import com.blackducksoftware.integration.hub.dataservice.notification.item.VulnerabilityContentItem;
import com.blackducksoftware.integration.hub.exception.HubIntegrationException;
import com.blackducksoftware.integration.hub.notification.processor.ListProcessorCache;
import com.blackducksoftware.integration.hub.notification.processor.NotificationProcessor;
import com.blackducksoftware.integration.hub.notification.processor.event.NotificationEvent;
import com.blackducksoftware.integration.hub.service.HubServicesFactory;
import com.blackducksoftware.integration.jira.common.HubJiraLogger;
import com.blackducksoftware.integration.jira.common.HubProjectMappings;
import com.blackducksoftware.integration.jira.common.JiraContext;
import com.blackducksoftware.integration.jira.common.exception.ConfigurationException;
import com.blackducksoftware.integration.jira.config.HubJiraFieldCopyConfigSerializable;
import com.blackducksoftware.integration.jira.task.JiraSettingsService;
import com.blackducksoftware.integration.jira.task.issue.JiraServices;

public class JiraNotificationProcessor extends NotificationProcessor<List<NotificationEvent>> {
    private final HubJiraLogger logger = new HubJiraLogger(Logger.getLogger(this.getClass().getName()));

    // private final ConverterLookupTable converterTable;

    public JiraNotificationProcessor(final HubProjectMappings mapping,
            final HubJiraFieldCopyConfigSerializable fieldCopyConfig,
            final JiraServices jiraServices,
            final JiraContext jiraContext, final JiraSettingsService jiraSettingsService,
            final HubServicesFactory hubServicesFactory,
            final boolean createVulnerabilityIssues)
            throws ConfigurationException {
        final ListProcessorCache cache = new ListProcessorCache();
        getCacheList().add(cache);

        final NotificationToEventConverter policyViolationNotificationConverter = new PolicyViolationNotificationConverter(cache,
                mapping, fieldCopyConfig, jiraServices, jiraContext, jiraSettingsService, hubServicesFactory.createMetaService(logger));

        final NotificationToEventConverter policyViolationClearedNotificationConverter = new PolicyViolationClearedNotificationConverter(cache,
                mapping, fieldCopyConfig, jiraServices, jiraContext, jiraSettingsService, hubServicesFactory.createMetaService(logger));
        final NotificationToEventConverter policyOverrideNotificationConverter = new PolicyOverrideNotificationConverter(cache,
                mapping, fieldCopyConfig, jiraServices, jiraContext, jiraSettingsService, hubServicesFactory.createMetaService(logger));

        getProcessorMap().put(PolicyViolationContentItem.class, policyViolationNotificationConverter);
        getProcessorMap().put(PolicyViolationClearedContentItem.class, policyViolationClearedNotificationConverter);
        getProcessorMap().put(PolicyOverrideContentItem.class, policyOverrideNotificationConverter);
        if (createVulnerabilityIssues) {
            logger.info("Creation of vulnerability issues has been enabled.");
            final NotificationToEventConverter vulnerabilityNotificationConverter = new VulnerabilityNotificationConverter(cache,
                    mapping, fieldCopyConfig,
                    jiraServices, jiraContext, jiraSettingsService,
                    hubServicesFactory, hubServicesFactory.createMetaService(logger));
            getProcessorMap().put(VulnerabilityContentItem.class, vulnerabilityNotificationConverter);
        } else {
            logger.info("Creation of vulnerability issues has been disabled. No vulnerability issues will be created.");
        }

        // converterTable = new ConverterLookupTable(mapping, fieldCopyConfig, jiraServices, jiraContext,
        // jiraSettingsService,
        // hubServicesFactory);
    }
    //
    // public List<NotificationEvent> generateEvents(final SortedSet<NotificationContentItem> notifications)
    // throws HubIntegrationException {
    // final List<NotificationEvent> allEvents = new ArrayList<>();
    //
    // logger.debug("JiraNotificationFilter.extractJiraReadyNotifications(): Sifting through " + notifications.size()
    // + " notifications");
    // for (final NotificationContentItem notif : notifications) {
    // logger.debug("Notification: " + notif);
    //
    // List<NotificationEvent> notifEvents;
    // try {
    // notifEvents = generateEvents(notif);
    // } catch (final Exception e) {
    // throw new HubIntegrationException("Error converting notifications to issues", e);
    // }
    // if (notifEvents != null) {
    // allEvents.addAll(notifEvents);
    // }
    // }
    // return allEvents;
    // }
    //
    // private List<NotificationEvent> generateEvents(final NotificationContentItem notif)
    // throws HubIntegrationException {
    // final NotificationToEventConverter converter = converterTable.getConverter(notif);
    // final List<NotificationEvent> events = converter.generateEvents(notif);
    // return events;
    // }

    @Override
    public List<NotificationEvent> processEvents(final Collection<NotificationEvent> eventCollection) throws HubIntegrationException {
        final LinkedList<NotificationEvent> list = new LinkedList<>(eventCollection);
        return list;
    }
}

@@ -2660,67 +2660,8 @@
 );%0A%0A
-    // private final ConverterLookupTable converterTable;%0A%0A
     
@@ -5031,1378 +5031,11 @@
   %7D%0A
-%0A
    
-     // converterTable = new ConverterLookupTable(mapping, fieldCopyConfig, jiraServices, jiraContext,%0A        // jiraSettingsService,%0A        // hubServicesFactory);%0A    %7D%0A    //%0A    // public List%3CNotificationEvent%3E generateEvents(final SortedSet%3CNotificationContentItem%3E notifications)%0A    // throws HubIntegrationException %7B%0A    // final List%3CNotificationEvent%3E allEvents = new ArrayList%3C%3E();%0A    //%0A    // logger.debug(%22JiraNotificationFilter.extractJiraReadyNotifications(): Sifting through %22 + notifications.size()%0A    // + %22 notifications%22);%0A    // for (final NotificationContentItem notif : notifications) %7B%0A    // logger.debug(%22Notification: %22 + notif);%0A    //%0A    // List%3CNotificationEvent%3E notifEvents;%0A    // try %7B%0A    // notifEvents = generateEvents(notif);%0A    // %7D catch (final Exception e) %7B%0A    // throw new HubIntegrationException(%22Error converting notifications to issues%22, e);%0A    // %7D%0A    // if (notifEvents != null) %7B%0A    // allEvents.addAll(notifEvents);%0A    // %7D%0A    // %7D%0A    // return allEvents;%0A    // %7D%0A    //%0A    // private List%3CNotificationEvent%3E generateEvents(final NotificationContentItem notif)%0A    // throws HubIntegrationException %7B%0A    // final NotificationToEventConverter converter = converterTable.getConverter(notif);%0A    // final List%3CNotificationEvent%3E events = converter.generateEvents(notif);%0A    // return events;%0A    //
  %7D%0A%0A

Remove dead code