Class CmfUtils

java.lang.Object
gov.niem.tools.api.core.utils.CmfUtils

public class CmfUtils extends Object
CMF-related utility functions.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Checks that the given file contains the URI for the currently-supported version of CMF.
    static void
    checkVersion(String cmfString)
    Checks that the given CMF string contains the URI for the currently-supported version of CMF.
    static void
    checkVersion(org.springframework.web.multipart.MultipartFile multipartFile)
    Checks that the given file contains the URI for the currently-supported version of CMF.
    static String
    generateString(org.mitre.niem.cmf.Model model)
    Generate the given CMF model as a CMF XML string.
    static String
    generateString(org.mitre.niem.cmf.Model model, Config.AppMediaType mediaType)
    Generate the given CMF model as a CMF XML or JSON string.
    static org.mitre.niem.cmf.Model
    loadCmf(org.springframework.web.multipart.MultipartFile multipartFile)
    Checks that the given file contains the URI for the currently-supported version of CMF, and if so, loads it into a CMF Model object.
    static File
    saveCmfModel(org.mitre.niem.cmf.Model cmf, Path path, String filenameBase)
    Write a CMF model to an XML file.
    static String
    subpropertyMax(org.mitre.niem.cmf.HasProperty hasProperty)
    Get subproperty max as a string with either a numeric value or "unbounded".
    static String
    subpropertyMin(org.mitre.niem.cmf.HasProperty hasProperty)
    Get the subproperty min as a string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CmfUtils

      public CmfUtils()
  • Method Details

    • loadCmf

      public static org.mitre.niem.cmf.Model loadCmf(org.springframework.web.multipart.MultipartFile multipartFile) throws IOException, BadRequestException
      Checks that the given file contains the URI for the currently-supported version of CMF, and if so, loads it into a CMF Model object.
      Throws:
      IOException
      BadRequestException
    • checkVersion

      public static void checkVersion(org.springframework.web.multipart.MultipartFile multipartFile) throws IOException, BadRequestException
      Checks that the given file contains the URI for the currently-supported version of CMF.
      Throws:
      IOException
      BadRequestException
    • checkVersion

      public static void checkVersion(File file) throws IOException
      Checks that the given file contains the URI for the currently-supported version of CMF.
      Throws:
      IOException
    • checkVersion

      public static void checkVersion(String cmfString) throws BadRequestException
      Checks that the given CMF string contains the URI for the currently-supported version of CMF.
      Throws:
      BadRequestException
    • generateString

      public static String generateString(org.mitre.niem.cmf.Model model, Config.AppMediaType mediaType) throws Exception
      Generate the given CMF model as a CMF XML or JSON string.
      Throws:
      Exception
    • generateString

      public static String generateString(org.mitre.niem.cmf.Model model) throws Exception
      Generate the given CMF model as a CMF XML string.
      Throws:
      Exception
    • saveCmfModel

      public static File saveCmfModel(org.mitre.niem.cmf.Model cmf, Path path, String filenameBase) throws Exception
      Write a CMF model to an XML file.
      Parameters:
      cmf - CMF model
      path - Directory to save the file.
      filenameBase - Filename without the extension.
      Throws:
      Exception
    • subpropertyMin

      public static String subpropertyMin(org.mitre.niem.cmf.HasProperty hasProperty)
      Get the subproperty min as a string.
    • subpropertyMax

      public static String subpropertyMax(org.mitre.niem.cmf.HasProperty hasProperty)
      Get subproperty max as a string with either a numeric value or "unbounded".