Package gov.niem.tools.api.core.utils
Class CmfUtils
java.lang.Object
gov.niem.tools.api.core.utils.CmfUtils
CMF-related utility functions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkVersion
(File file) 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.
-
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
Checks that the given file contains the URI for the currently-supported version of CMF.- Throws:
IOException
-
checkVersion
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
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 modelpath
- Directory to save the file.filenameBase
- Filename without the extension.- Throws:
Exception
-
subpropertyMin
Get the subproperty min as a string. -
subpropertyMax
Get subproperty max as a string with either a numeric value or "unbounded".
-