Search in sources :

Example 1 with SubsystemLocalizationHeader

use of org.apache.aries.subsystem.core.archive.SubsystemLocalizationHeader in project aries by apache.

the class RawSubsystemResource method computeTranslations.

private Collection<TranslationFile> computeTranslations(IDirectory directory) throws IOException {
    SubsystemManifest manifest = getSubsystemManifest();
    SubsystemLocalizationHeader header = manifest.getSubsystemLocalizationHeader();
    String directoryName = header.getDirectoryName();
    // TODO Assumes the ZIP file includes directory entries. Issues?
    IFile file = directoryName == null ? directory : directory.getFile(directoryName);
    if (file == null || !file.isDirectory())
        return Collections.emptyList();
    List<IFile> files = file.convert().listFiles();
    if (files == null || files.isEmpty())
        return Collections.emptyList();
    ArrayList<TranslationFile> result = new ArrayList<TranslationFile>(files.size());
    for (IFile f : files) {
        Properties properties = new Properties();
        InputStream is = f.open();
        try {
            properties.load(is);
            result.add(new TranslationFile(f.getName(), properties));
        } finally {
            is.close();
        }
    }
    result.trimToSize();
    return result;
}
Also used : IFile(org.apache.aries.util.filesystem.IFile) SubsystemManifest(org.apache.aries.subsystem.core.archive.SubsystemManifest) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) SubsystemLocalizationHeader(org.apache.aries.subsystem.core.archive.SubsystemLocalizationHeader) Properties(java.util.Properties)

Aggregations

InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 SubsystemLocalizationHeader (org.apache.aries.subsystem.core.archive.SubsystemLocalizationHeader)1 SubsystemManifest (org.apache.aries.subsystem.core.archive.SubsystemManifest)1 IFile (org.apache.aries.util.filesystem.IFile)1