Search in sources :

Example 1 with NamespacesId

use of org.eclipse.winery.common.ids.admin.NamespacesId in project winery by eclipse.

the class CsarExporter method addNamespacePrefixes.

/**
 * Writes the configured mapping namespaceprefix -> namespace to the archive
 * <p>
 * This is kind of a quick hack. TODO: during the import, the prefixes should be extracted using JAXB and stored in
 * the NamespacesResource
 */
private void addNamespacePrefixes(ArchiveOutputStream zos, IRepository repository) throws IOException {
    Configuration configuration = repository.getConfiguration(new NamespacesId());
    if (configuration instanceof PropertiesConfiguration) {
        // Quick hack: direct serialization only works for PropertiesConfiguration
        PropertiesConfiguration pconf = (PropertiesConfiguration) configuration;
        ArchiveEntry archiveEntry = new ZipArchiveEntry(CsarExporter.PATH_TO_NAMESPACES_PROPERTIES);
        zos.putArchiveEntry(archiveEntry);
        try {
            pconf.save(zos);
        } catch (ConfigurationException e) {
            CsarExporter.LOGGER.debug(e.getMessage(), e);
            zos.write("#Could not export properties".getBytes());
            zos.write(("#" + e.getMessage()).getBytes());
        }
        zos.closeArchiveEntry();
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) NamespacesId(org.eclipse.winery.common.ids.admin.NamespacesId) ConfigurationException(org.apache.commons.configuration.ConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ZipArchiveEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry) ZipArchiveEntry(org.apache.commons.compress.archivers.zip.ZipArchiveEntry) ArchiveEntry(org.apache.commons.compress.archivers.ArchiveEntry) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Aggregations

TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 ArchiveEntry (org.apache.commons.compress.archivers.ArchiveEntry)1 ZipArchiveEntry (org.apache.commons.compress.archivers.zip.ZipArchiveEntry)1 Configuration (org.apache.commons.configuration.Configuration)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)1 NamespacesId (org.eclipse.winery.common.ids.admin.NamespacesId)1