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 voidcheckFileExtension(File file) Check that the file extension of the given file has a valid CMF extension.static voidcheckFileExtension(String fileExtension) Check that the given CMF file has a valid file extension.static voidcheckFileExtension(org.springframework.web.multipart.MultipartFile multipartFile) Check that the file extension of the given file has a valid CMF extension.static voidcheckVersion(File file) Checks that the given file contains the URI for the currently-supported version of CMF.static voidcheckVersion(String cmfString) Checks that the given CMF string contains the URI for the currently-supported version of CMF.static voidcheckVersion(org.springframework.web.multipart.MultipartFile multipartFile) Checks that the given file contains the URI for the currently-supported version of CMF.static StringgenerateString(org.mitre.niem.cmf.Model model) Generate the given CMF model as a CMF XML string.static StringgenerateString(org.mitre.niem.cmf.Model model, Config.AppMediaType mediaType) Generate the given CMF model as a CMF XML or JSON string.static StringgetAugmentationClassName(String augmentedTypeName) Returns the augmentation type name for the given type name being augmented.static StringgetAugmentationClassQname(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.ModelloadCmf(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 FilesaveCmfModel(org.mitre.niem.cmf.Model cmfModel, Path path, String filenameBase) Write a CMF model to an XML file.static StringsubpropertyMax(org.mitre.niem.cmf.PropertyAssociation propertyAssociation) Get subproperty max as a string with either a numeric value or "unbounded".static StringsubpropertyMin(org.mitre.niem.cmf.PropertyAssociation propertyAssociation) 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 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:
IOExceptionBadRequestException
-
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
-
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
Check that the file extension of the given file has a valid CMF extension. -
checkFileExtension
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
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 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". -
getAugmentationClassName
Returns the augmentation type name for the given type name being augmented.For example, returns "PersonAugmentationType" when given "PersonType".
-
getAugmentationClassQname
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".
-