<commit_before>package org.ossim.omar.stager

import org.ossim.omar.core.HttpStatusMessage
import org.ossim.omar.core.HttpStatus
import org.springframework.context.ApplicationContextAware
import org.springframework.context.ApplicationContext

/**
 * DataManagerController supplies a simple API to add and remove raster
 * and video datasets to the OMAR tables.  Currently, only a filename argument is passed
 *
 * All controller methods will use the internal params variable to parse out
 * the required arguments.  All http parameters are stored as a Java HashMap type
 * in a variable called params.
 *
 * @see DataManagerService
 */
class DataManagerController implements ApplicationContextAware
{
  ApplicationContext applicationContext

  def index = {
  }

  def action = {
    def method = request.method.toUpperCase()
    def httpStatusMessage = new HttpStatusMessage()

    def pattern = /(add|update|remove|delete)(.*)/
    def matcher = params.opType =~ pattern
    def op = null
    def type = null

    if ( matcher )
    {
      op = matcher[0][1]
      type = matcher[0][2]
    }

    httpStatusMessage.status = HttpStatus.OK
    httpStatusMessage.message = ""

    switch ( method )
    {
    case "GET":

      return [opType: params.opType, op: op, type: type]
      break
    case "POST":
    case "DELETE":
      println "${op} ${type}"
      def serviceName = "${type[0].toLowerCase() + type.substring(1) }DataSetService"
      def service = applicationContext.getBean(serviceName)
      def status = service."${params.opType}"(httpStatusMessage, params)

      response.status = httpStatusMessage.status
      render(httpStatusMessage.message)
      break
    default:
      httpStatusMessage.status = HttpStatus.METHOD_NOT_ALLOWED
      httpStatusMessage.message = "Unsupported method ${method} for action ${params.opType} with filename ${filename}"
      httpStatusMessage.header.Allow = "GET, POST, DELETE"
      httpStatusMessage.initializeResponse(response)
      render(httpStatusMessage.message)
    }
  }

  void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
  {
    this.applicationContext = applicationContext
  }
}<commit_msg>Opps,  forgot to remove some debug code<commit_after>package org.ossim.omar.stager

import org.ossim.omar.core.HttpStatusMessage
import org.ossim.omar.core.HttpStatus
import org.springframework.context.ApplicationContextAware
import org.springframework.context.ApplicationContext

/**
 * DataManagerController supplies a simple API to add and remove raster
 * and video datasets to the OMAR tables.  Currently, only a filename argument is passed
 *
 * All controller methods will use the internal params variable to parse out
 * the required arguments.  All http parameters are stored as a Java HashMap type
 * in a variable called params.
 *
 * @see DataManagerService
 */
class DataManagerController implements ApplicationContextAware
{
  ApplicationContext applicationContext

  def index = {
  }

  def action = {
    def method = request.method.toUpperCase()
    def httpStatusMessage = new HttpStatusMessage()

    def pattern = /(add|update|remove|delete)(.*)/
    def matcher = params.opType =~ pattern
    def op = null
    def type = null

    if ( matcher )
    {
      op = matcher[0][1]
      type = matcher[0][2]
    }

    httpStatusMessage.status = HttpStatus.OK
    httpStatusMessage.message = ""

    switch ( method )
    {
    case "GET":

      return [opType: params.opType, op: op, type: type]
      break
    case "POST":
    case "DELETE":
      def serviceName = "${type[0].toLowerCase() + type.substring(1) }DataSetService"
      def service = applicationContext.getBean(serviceName)
      def status = service."${params.opType}"(httpStatusMessage, params)

      response.status = httpStatusMessage.status
      render(httpStatusMessage.message)
      break
    default:
      httpStatusMessage.status = HttpStatus.METHOD_NOT_ALLOWED
      httpStatusMessage.message = "Unsupported method ${method} for action ${params.opType} with filename ${filename}"
      httpStatusMessage.header.Allow = "GET, POST, DELETE"
      httpStatusMessage.initializeResponse(response)
      render(httpStatusMessage.message)
    }
  }

  void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
  {
    this.applicationContext = applicationContext
  }
}
{'fraction_non_alphanumeric': 0.08840909090909091, 'fraction_numerical': 0.0027272727272727275, 'mean_word_length': 3.6473072861668427, 'pattern_counts': {'":': 6, '<': 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': '424415', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1184, 'n_words': 331}