Package com.volantis.mcs.accessors.xml

Examples of com.volantis.mcs.accessors.xml.ZipArchive$ZipArchiveEntry


     */
    private Identification loadIdentification(final String zipFileName)
            throws RepositoryException {

        try {
            final ZipArchive archive = new ZipArchive(zipFileName);
            final InputStream stream = archive.getInputFrom(
                DeviceRepositoryConstants.IDENTIFICATION_XML);
            Object object = null;
            if (stream != null) {
                final BinaryContentInput content =
                    new BinaryContentInput(stream);
View Full Code Here


     */
    private String populateProperties(String prefix, Properties properties,
                                      Locale locale)
            throws RepositoryException {

        ZipArchive zipArchive;
        try {
            zipArchive = getZipArchive();
        } catch (IOException e) {
            throw new RepositoryException(
                EXCEPTION_LOCALIZER.format("device-repository-access-failure"));
        }

        // the language will be either a 2 character identifier or an empty
        // string
        String language = locale.getLanguage();
        // the country will be either a 2 character identifier or an empty
        // string
        String country = locale.getCountry();
        // the country will be an empty string or some other identifier
        String variant = locale.getVariant();

        String localeFound = null;
        String propertiesFile = null;
        // see if we have a properites file with the following suffix
        // _LANGUAGE_COUNTRY_VARIANT.properties
        if (language.length() != 0 &&
                country.length() != 0 &&
                variant.length() != 0) {
            String checkPath =
                    getPropertiesPath(prefix, language, country, variant);
            if (zipArchive.exists(checkPath)) {
                localeFound = language + "_" + country + "_" + variant;
                propertiesFile = checkPath;
            }
        }
        // If we haven't found the properties file then we try the less
        // specific suffix _LANGUAGE_COUNTRY.properites
        if (propertiesFile == null &&
                language.length() != 0 &&
                country.length() != 0) {
            String checkPath =
                    getPropertiesPath(prefix, language, country, null);
            if (zipArchive.exists(checkPath)) {
                localeFound = language + "_" + country + "_";
                propertiesFile = checkPath;
            }
        }
        // If we haven't found the properties file then we try the less
        // specific suffix _LANGUAGE.properites
        if (propertiesFile == null && language.length() != 0) {
            String checkPath = getPropertiesPath(prefix, language, null, null);
            if (zipArchive.exists(checkPath)) {
                localeFound = language + "__";
                propertiesFile = checkPath;
            }
        }
        // If we haven't found the properties file then we try the
        // .properties
        if (propertiesFile == null) {
            String checkPath = getPropertiesPath(prefix, null, null, null);
            if (zipArchive.exists(checkPath)) {
                localeFound = "__";
                propertiesFile = checkPath;
            }
        }
        if (propertiesFile != null) {
            // if we found a properties file the load its contents into the
            // properties instance
            try {
                properties.load(zipArchive.getInputFrom(propertiesFile));
            } catch (IOException e) {
                throw new RepositoryException(EXCEPTION_LOCALIZER.format(
                        "device-repository-file-missing", propertiesFile));
            }
        } else if (logger.isDebugEnabled()) {
View Full Code Here

    private ZipArchive getZipArchive()
            throws IOException {

        if (zipArchive == null) {
            String archiveFileName = getRepositoryFilename();
            zipArchive = new ZipArchive(archiveFileName);
        }
        return zipArchive;
    }
View Full Code Here

    private Object loadZipObject(final String filename,
                                 final Class expectedClass)
            throws RepositoryException {

        try {
            ZipArchive archive = getZipArchive();
            InputStream stream = archive.getInputFrom(filename);
            Object object = null;
            if (stream != null) {
                BinaryContentInput content = new BinaryContentInput(stream);
                JiBXReader jibxReader = new JiBXReader(expectedClass,
                        schemaValidation ? deviceSchemaValidator : null);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.accessors.xml.ZipArchive$ZipArchiveEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.