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 void
checkInput
(TransformFrom from, TransformTo to, String inputExtension) Checks to make sure user input is valid.static void
checkInputFileExtension
(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) Second pass of transformation.byte[]
generateXsdOutput
(org.mitre.niem.cmf.Model model, String filenameBase) Second pass of transformation for XSD output.getOutputFilename
(TransformTo to, String filenameBase) Get the output filename with extension based on the kind of transformation and the original filename.org.springframework.http.MediaType
Get the content media type for the response based on the kind of transformation.org.mitre.niem.cmf.Model
loadInput
(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) 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) throws Exception Second pass of transformation for XSD output. Generate XML Schema files from a CMF model and zip the results.- Throws:
Exception
-
getOutputFilename
Get the output filename with extension based on the kind of transformation and the original filename.- Throws:
Exception
-
getOutputMediaType
Get the content media type for the response based on the kind of transformation.- Throws:
Exception
-