Examples of ZipArchive


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

     */
    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

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

     */
    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

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

    private ZipArchive getZipArchive()
            throws IOException {

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

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

    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

Examples of org.apache.jackrabbit.vault.fs.io.ZipArchive

        clean(ARCHIVE_ROOT);
    }

    @Test
    public void testImport() throws IOException, RepositoryException, ConfigurationException {
        ZipArchive archive = new ZipArchive(getTempFile("testpackages/tmp.zip"));
        archive.open(true);
        Node rootNode = admin.getRootNode();
        ImportOptions opts = getDefaultOptions();
        Importer importer = new Importer(opts);
        importer.run(archive, rootNode);
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.io.ZipArchive

        assertNodeExists("/tmp/foo/bar/tobi");
    }

    @Test
    public void testFilteredImport() throws IOException, RepositoryException, ConfigurationException {
        ZipArchive archive = new ZipArchive(getTempFile("testpackages/filtered_package.zip"));
        archive.open(true);
        Node rootNode = admin.getRootNode();
        ImportOptions opts = getDefaultOptions();

        Importer importer = new Importer(opts);
        importer.run(archive, rootNode);
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.io.ZipArchive

        assertNodeMissing("/tmp/foo/bar/tom");
    }

    @Test
    public void testUnFilteredImport() throws IOException, RepositoryException, ConfigurationException {
        ZipArchive archive = new ZipArchive(getTempFile("testpackages/unfiltered_package.zip"));
        archive.open(true);
        Node rootNode = admin.getRootNode();
        ImportOptions opts = getDefaultOptions();

        Importer importer = new Importer(opts);
        importer.run(archive, rootNode);
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.io.ZipArchive

        assertNodeExists("/tmp/foo/bar/tom");
    }

    @Test
    public void testRelativeImport() throws IOException, RepositoryException, ConfigurationException {
        ZipArchive archive = new ZipArchive(getTempFile("testpackages/tmp.zip"));

        admin.getRootNode().addNode(TEST_ROOT.substring(1, TEST_ROOT.length()));
        admin.save();

        archive.open(true);
        Node rootNode = admin.getNode(TEST_ROOT);
        ImportOptions opts = getDefaultOptions();
        // manually creating filterPaths with correct coverage
        WorkspaceFilter filter = archive.getMetaInf().getFilter();
        for (PathFilterSet pathFilterSet : filter.getFilterSets()) {
            pathFilterSet.setRoot(TEST_ROOT + pathFilterSet.getRoot());
        }
        opts.setFilter(filter);
        Importer importer = new Importer(opts);
View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.io.ZipArchive

     * Imports an empty package with a filter "/testnode" relative to "/testnode". Since this is a relative import,
     * the "/testnode" would map to "/testnode/testnode". So the import should not remove "/testnode".
     */
    @Test
    public void testRelativeEmptyImport() throws IOException, RepositoryException, ConfigurationException {
        ZipArchive archive = new ZipArchive(getTempFile("testpackages/empty_testnode.zip"));

        admin.getRootNode().addNode(TEST_ROOT.substring(1, TEST_ROOT.length()));
        admin.save();

        archive.open(true);
        Node rootNode = admin.getNode(TEST_ROOT);
        ImportOptions opts = getDefaultOptions();
        Importer importer = new Importer(opts);
        importer.run(archive, rootNode);

View Full Code Here

Examples of org.apache.jackrabbit.vault.fs.io.ZipArchive

        assertNodeMissing(TEST_ROOT + "dummy");
    }

    @Test
    public void testConcurrentModificationHandling() throws IOException, RepositoryException, PackageException, ConfigurationException {
        ZipArchive archive = new ZipArchive(getTempFile("testpackages/tags.zip"));
        archive.open(true);
        Node rootNode = admin.getRootNode();
        ImportOptions opts = getDefaultOptions();
        opts.setAutoSaveThreshold(7);
        Importer importer = new Importer(opts);
        importer.setDebugFailAfterSave(2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.