Class TransformService

java.lang.Object
gov.niem.tools.api.transform.TransformService

@Service public class TransformService extends Object
Operations to support model transformations.
  • Constructor Details

    • TransformService

      public TransformService()
  • Method Details

    • transform

      public byte[] transform(TransformFrom from, TransformTo to, org.springframework.web.multipart.MultipartFile multipartInputFile) throws Exception
      Convert the input file from the given 'from' format to the given 'to' format. Saves the output to a temporary directory.
      Parameters:
      from - - A supported NIEM model format to be transformed
      to - - A supported NIEM model format to be transformed into
      multipartInputFile - - A file or files to be transformed
      Throws:
      Exception
    • checkInput

      public static void checkInput(TransformFrom from, TransformTo to, String inputExtension) throws BadRequestException
      Checks to make sure user input is valid.
      Parameters:
      from - - A supported NIEM model format to be transformed
      to - - A supported NIEM model format to be transformed into
      inputExtension - - The file extension of the model to be transformed
      Throws:
      BadRequestException
    • checkInputFileExtension

      public static void checkInputFileExtension(TransformFrom from, String inputExtension) throws BadRequestException
      Check if the input file has a valid extension for a transformation. Throw a BadRequestException if the check fails.
      Parameters:
      from - - A supported NIEM model format to be transformed
      inputExtension - - The file extension of the model to be transformed
      Throws:
      BadRequestException
    • loadInput

      public org.mitre.niem.cmf.Model loadInput(TransformFrom from, org.springframework.web.multipart.MultipartFile multipartInputFile, String inputExtension) throws Exception
      Convert the input file from the given `from` format to the given `to` format.
      Throws:
      Exception
    • generateOutput

      public byte[] generateOutput(org.mitre.niem.cmf.Model model, TransformTo to, String filenameBase) throws Exception
      Second pass of transformation. Convert the input file from the given `from` format to the given `to` format.
      Throws:
      Exception
    • generateXsdOutput

      public byte[] generateXsdOutput(org.mitre.niem.cmf.Model model, String filenameBase) throws Exception
      Second pass of transformation for XSD output. Generate XML Schema files from a CMF model and zip the results.
      Throws:
      Exception
    • getOutputFilename

      public String getOutputFilename(TransformTo to, String filenameBase) throws Exception
      Get the output filename with extension based on the kind of transformation and the original filename.
      Throws:
      Exception
    • getOutputMediaType

      public org.springframework.http.MediaType getOutputMediaType(TransformTo to) throws Exception
      Get the content media type for the response based on the kind of transformation.
      Throws:
      Exception