Search in sources :

Example 1 with MulePolicyModelJsonSerializer

use of org.mule.runtime.api.deployment.persistence.MulePolicyModelJsonSerializer in project mule by mulesoft.

the class PolicyFileBuilder method doGetCustomResources.

@Override
protected List<ZipResource> doGetCustomResources() {
    final List<ZipResource> customResources = new LinkedList<>();
    if (mulePolicyModel != null) {
        final File jsonDescriptorFile = new File(getTempFolder(), META_INF + separator + MULE_ARTIFACT + separator + MULE_ARTIFACT_JSON_DESCRIPTOR);
        jsonDescriptorFile.deleteOnExit();
        String jsonDescriber = new MulePolicyModelJsonSerializer().serialize(mulePolicyModel);
        try {
            writeStringToFile(jsonDescriptorFile, jsonDescriber);
        } catch (IOException e) {
            throw new IllegalStateException("There was an issue generating the JSON file for " + this.getId(), e);
        }
        customResources.add(new ZipResource(jsonDescriptorFile.getAbsolutePath(), META_INF + "/" + MULE_ARTIFACT + "/" + MULE_ARTIFACT_JSON_DESCRIPTOR));
    }
    return customResources;
}
Also used : ZipResource(org.mule.tck.ZipUtils.ZipResource) MulePolicyModelJsonSerializer(org.mule.runtime.api.deployment.persistence.MulePolicyModelJsonSerializer) IOException(java.io.IOException) File(java.io.File) FileUtils.writeStringToFile(org.apache.commons.io.FileUtils.writeStringToFile) LinkedList(java.util.LinkedList)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 FileUtils.writeStringToFile (org.apache.commons.io.FileUtils.writeStringToFile)1 MulePolicyModelJsonSerializer (org.mule.runtime.api.deployment.persistence.MulePolicyModelJsonSerializer)1 ZipResource (org.mule.tck.ZipUtils.ZipResource)1