Package gov.niem.tools.api.transform
Class TransformService
java.lang.Object
gov.niem.tools.api.transform.TransformService
Operations to support model transformations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckInput(TransformFrom from, TransformTo to, String inputExtension) Checks to make sure user input is valid.static voidcheckInputFileExtension(TransformFrom from, String inputExtension) Check if the input file has a valid extension for a transformation.byte[]generateOutput(org.mitre.niem.cmf.Model model, TransformTo to, String filenameBase, String inputExtension) Second pass of transformation.byte[]generateXsdOutput(org.mitre.niem.cmf.Model model, String filenameBase, Boolean returnSingleXsd) Second pass of transformation for XSD output.getOutputFilename(TransformTo to, String filenameBase, String inputExtension) Get the output filename with extension based on the kind of transformation and the original filename.org.springframework.http.MediaTypegetOutputMediaType(TransformTo to, String inputExtension) Get the content media type for the response based on the kind of transformation.org.mitre.niem.cmf.ModelloadInput(TransformFrom from, org.springframework.web.multipart.MultipartFile multipartInputFile, String inputExtension) Convert the input file from the given `from` format to the given `to` format.byte[]transform(TransformFrom from, TransformTo to, org.springframework.web.multipart.MultipartFile multipartInputFile) Convert the input file from the given 'from' format to the given 'to' format.
-
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 transformedto- - A supported NIEM model format to be transformed intomultipartInputFile- - 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 transformedto- - A supported NIEM model format to be transformed intoinputExtension- - 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 transformedinputExtension- - 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, String inputExtension) 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, Boolean returnSingleXsd) throws Exception Second pass of transformation for XSD output. Generate XML Schema files from a CMF model and zip the results.- Parameters:
returnSingleXsd- - True to return a single XSD file with the given name (filenameBase) instead of the full zip.- Throws:
Exception
-
getOutputFilename
public String getOutputFilename(TransformTo to, String filenameBase, String inputExtension) 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, String inputExtension) throws Exception Get the content media type for the response based on the kind of transformation.- Throws:
Exception
-