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
    Check that the file extension of the given file has a valid CMF extension.
    static void
    checkFileExtension(String fileExtension)
    Check that the given CMF file has a valid file extension.
    static void
    checkFileExtension(org.springframework.web.multipart.MultipartFile multipartFile)
    Check that the file extension of the given file has a valid CMF extension.
    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 String
    getAugmentationClassName(String augmentedTypeName)
    Returns the augmentation type name for the given type name being augmented.
    static String
    getAugmentationClassQname(String augmentationPrefix, String augmentedTypeName)
    Returns the qualified augmentation type name with the given namespace prefix as is, and the given augmentedTypeName converted to an augmentation type name.
    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 cmfModel, Path path, String filenameBase)
    Write a CMF model to an XML file.
    static String
    subpropertyMax(org.mitre.niem.cmf.PropertyAssociation propertyAssociation)
    Get subproperty max as a string with either a numeric value or "unbounded".
    static String
    subpropertyMin(org.mitre.niem.cmf.PropertyAssociation propertyAssociation)
    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 Exception
      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:
      Exception
    • 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
    • checkFileExtension

      public static void checkFileExtension(org.springframework.web.multipart.MultipartFile multipartFile)
      Check that the file extension of the given file has a valid CMF extension.
    • checkFileExtension

      public static void checkFileExtension(File file)
      Check that the file extension of the given file has a valid CMF extension.
    • checkFileExtension

      public static void checkFileExtension(String fileExtension) throws BadRequestException
      Check that the given CMF file has a valid file extension.
      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 cmfModel, Path path, String filenameBase) throws Exception
      Write a CMF model to an XML file.
      Parameters:
      cmfModel - CMF model
      path - Directory to save the file.
      filenameBase - Filename without the extension.
      Throws:
      Exception
    • subpropertyMin

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

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

      public static String getAugmentationClassName(String augmentedTypeName)
      Returns the augmentation type name for the given type name being augmented.

      For example, returns "PersonAugmentationType" when given "PersonType".

    • getAugmentationClassQname

      public static String getAugmentationClassQname(String augmentationPrefix, String augmentedTypeName)
      Returns the qualified augmentation type name with the given namespace prefix as is, and the given augmentedTypeName converted to an augmentation type name.

      For example, given prefix "j" and type name "PersonType", returns "j:PersonAugmentationType".