<commit_before>package com.thinkbiganalytics.feedmgr.rest.controller;

import com.thinkbiganalytics.feedmgr.nifi.NifiFlowCache;
import com.thinkbiganalytics.metadata.api.MetadataAccess;
import com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStatisticsProvider;
import com.thinkbiganalytics.metadata.rest.model.nifi.NiFiFlowCacheSync;
import com.thinkbiganalytics.security.AccessController;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import io.swagger.annotations.Api;

@Api(value = "nifi-provenance", produces = "application/json",
     description = "Used by the NiFi KyloProvenanceEventReportingTask.  Provides information about the flows and the max event id processed by kylo")
@Path("/metadata/nifi-provenance")
@Component
public class NifiProvenanceRestController {

    @Inject
    private MetadataAccess metadataAccess;

    @Inject
    private AccessController accessController;

    @Autowired
    private NifiFeedProcessorStatisticsProvider statsProvider;


    private static final Logger log = LoggerFactory.getLogger(NifiProvenanceRestController.class);

    @Inject
    NifiFlowCache nifiFlowCache;

    @GET
    @Path("/nifi-flow-cache/get-flow-updates")
    @Produces({MediaType.APPLICATION_JSON})
    public Response getFlowUpdates(@QueryParam("syncId") String syncId) {
        NiFiFlowCacheSync updates = nifiFlowCache.syncAndReturnUpdates(syncId);
        return Response.ok(updates).build();
    }

    @GET
    @Path("/nifi-flow-cache/get-cache")
    @Produces({MediaType.APPLICATION_JSON})
    public Response getCache(@QueryParam("syncId") String syncId) {
        NiFiFlowCacheSync cache = nifiFlowCache.getCache(syncId);
        return Response.ok(cache).build();
    }

    @GET
    @Path("/nifi-flow-cache/preview-flow-updates")
    @Produces({MediaType.APPLICATION_JSON})
    public Response previewFlowUpdates(@QueryParam("syncId") String syncId) {
        NiFiFlowCacheSync updates = nifiFlowCache.previewUpdates(syncId);
        return Response.ok(updates).build();
    }

    @GET
    @Path("/nifi-flow-cache/cache-summary")
    @Produces({MediaType.APPLICATION_JSON})
    public Response previewFlowUpdates() {
        NifiFlowCache.CacheSummary summary = nifiFlowCache.cacheSummary();
        return Response.ok(summary).build();
    }

    @GET
    @Path("/nifi-flow-cache/reset-flow-updates")
    @Produces({MediaType.APPLICATION_JSON})
    public Response getSyncUpdates(@QueryParam("syncId") String syncId) {
        NiFiFlowCacheSync updates = nifiFlowCache.refreshAll(syncId);
        return Response.ok(updates).build();
    }

    @GET
    @Path("/nifi-flow-cache/reset-cache")
    @Produces({MediaType.APPLICATION_JSON})
    public Response resetCache() {
        nifiFlowCache.rebuildAll();
        return Response.ok("Rest the Cache").build();
    }


    @GET
    @Path("/nifi-flow-cache/available")<commit_msg>fix spelling<commit_after>package com.thinkbiganalytics.feedmgr.rest.controller;

import com.thinkbiganalytics.feedmgr.nifi.NifiFlowCache;
import com.thinkbiganalytics.metadata.api.MetadataAccess;
import com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorStatisticsProvider;
import com.thinkbiganalytics.metadata.rest.model.nifi.NiFiFlowCacheSync;
import com.thinkbiganalytics.security.AccessController;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import io.swagger.annotations.Api;

@Api(value = "nifi-provenance", produces = "application/json",
     description = "Used by the NiFi KyloProvenanceEventReportingTask.  Provides information about the flows and the max event id processed by kylo")
@Path("/metadata/nifi-provenance")
@Component
public class NifiProvenanceRestController {

    @Inject
    private MetadataAccess metadataAccess;

    @Inject
    private AccessController accessController;

    @Autowired
    private NifiFeedProcessorStatisticsProvider statsProvider;


    private static final Logger log = LoggerFactory.getLogger(NifiProvenanceRestController.class);

    @Inject
    NifiFlowCache nifiFlowCache;

    @GET
    @Path("/nifi-flow-cache/get-flow-updates")
    @Produces({MediaType.APPLICATION_JSON})
    public Response getFlowUpdates(@QueryParam("syncId") String syncId) {
        NiFiFlowCacheSync updates = nifiFlowCache.syncAndReturnUpdates(syncId);
        return Response.ok(updates).build();
    }

    @GET
    @Path("/nifi-flow-cache/get-cache")
    @Produces({MediaType.APPLICATION_JSON})
    public Response getCache(@QueryParam("syncId") String syncId) {
        NiFiFlowCacheSync cache = nifiFlowCache.getCache(syncId);
        return Response.ok(cache).build();
    }

    @GET
    @Path("/nifi-flow-cache/preview-flow-updates")
    @Produces({MediaType.APPLICATION_JSON})
    public Response previewFlowUpdates(@QueryParam("syncId") String syncId) {
        NiFiFlowCacheSync updates = nifiFlowCache.previewUpdates(syncId);
        return Response.ok(updates).build();
    }

    @GET
    @Path("/nifi-flow-cache/cache-summary")
    @Produces({MediaType.APPLICATION_JSON})
    public Response previewFlowUpdates() {
        NifiFlowCache.CacheSummary summary = nifiFlowCache.cacheSummary();
        return Response.ok(summary).build();
    }

    @GET
    @Path("/nifi-flow-cache/reset-flow-updates")
    @Produces({MediaType.APPLICATION_JSON})
    public Response getSyncUpdates(@QueryParam("syncId") String syncId) {
        NiFiFlowCacheSync updates = nifiFlowCache.refreshAll(syncId);
        return Response.ok(updates).build();
    }

    @GET
    @Path("/nifi-flow-cache/reset-cache")
    @Produces({MediaType.APPLICATION_JSON})
    public Response resetCache() {
        nifiFlowCache.rebuildAll();
        return Response.ok("Reset the Cache").build();
    }


    @GET
    @Path("/nifi-flow-cache/available")
{'fraction_non_alphanumeric': 0.11179361179361179, 'fraction_numerical': 0.0009213759213759214, 'mean_word_length': 4.356085526315789, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2568534', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1983, 'n_words': 326}