Package org.apache.sling.installer.api

Examples of org.apache.sling.installer.api.InstallableResource


        final String[] types = new String[] {InstallableResource.TYPE_CONFIG,
                InstallableResource.TYPE_PROPERTIES,
                null, "zip"};

        for(int i=0;i<types.length; i++) {
            final InstallableResource instRes = new InstallableResource("1",
                    null, getSimpleDict(), null, types[i], null);

            final InternalResource ir = InternalResource.create(SCHEME,
                    instRes);
            assertEquals(SCHEME + ":1", ir.getURL());
View Full Code Here


        final String vInfo = (String)this.getAttribute(Constants.BUNDLE_VERSION);
        return (vInfo == null ? null : new Version(vInfo));
    }

    public RegisteredResourceImpl getRegisteredResourceImpl() throws IOException {
        final InstallableResource is = new InstallableResource((String)this.attributes.get(Constants.BUNDLE_SYMBOLICNAME),
                null,
                new Hashtable<String, Object>(),
                this.getDigest(),
                this.getType(),
                this.getPriority());
View Full Code Here

                        // we ignore this
                    }
                    logger.debug("Launchpad {} will be registered: {}", resourceType, path);
                    final String digest = (lastModified > 0 ? String.valueOf(lastModified) : null);
                    final InputStream stream = resourceProvider.getResourceAsStream(path);
                    installables.add(new InstallableResource(path, stream, dict, digest, resourceType, prio));
                }
            }
        }
        return count > 0;
    }
View Full Code Here

        if (data == null) {
            data = new Hashtable<String, Object>();
            data.put("foo", "bar");
        }
        new FileDataStore(new MockBundleContext());
        final InstallableResource r = new InstallableResource(url, null, data, digest, null, priority);
        final InternalResource internal = InternalResource.create("test", r);
        final RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
        TransformationResult[] tr = new DefaultTransformer().transform(rr);
        if ( tr == null ) {
            final TransformationResult result = new TransformationResult();
View Full Code Here

        // install configs
        //Following patterns work fine. Problem occurs one with windows seprator
        // - "c:/foo/bar/"
        // - "/foo/bar/"
        final String uri = "c:\\foo\bar\\";
        final InstallableResource result = new MockInstallableResource(uri + cfgPid, copy(cfgData), null, null, 100);
        final InstallableResource[] rsrc = new InstallableResource[] {result};
        installer.updateResources(URL_SCHEME, rsrc, null);

        Configuration cfg = waitForConfiguration("After installing", cfgPid, TIMEOUT, true);
        assertEquals("Config value must match", "bar", cfg.getProperties().get("foo"));
View Full Code Here

    protected InstallableResource[] getInstallableResource(File testBundle, String digest, int priority) throws IOException {
        final String url = testBundle.getAbsolutePath();
        if (digest == null) {
            digest = String.valueOf(testBundle.lastModified());
        }
        final InstallableResource result = new MockInstallableResource(url, new FileInputStream(testBundle), digest, null, priority);
        return new InstallableResource[] {result};
    }
View Full Code Here

    protected InstallableResource[] getInstallableResource(String configPid, Dictionary<String, Object> data) {
        return getInstallableResource(configPid, copy(data), InstallableResource.DEFAULT_PRIORITY);
    }

    protected InstallableResource[] getInstallableResource(String configPid, Dictionary<String, Object> data, int priority) {
        final InstallableResource result = new MockInstallableResource("/" + configPid, copy(data), null, null, priority);
        return new InstallableResource[] {result};
    }
View Full Code Here

                ArrayList<InstallableResource> updated = new ArrayList<InstallableResource>();
                while (resources.hasMoreElements()) {
                    URL url = resources.nextElement();
                    if(url != null){
                        log.debug("  > installable Resource {}",url);
                        InstallableResource resource = createInstallableResource(bundle, path, url);
                        if (resource != null) {
                            updated.add(resource);
                        }
                    }
                }
View Full Code Here

        String relPath = getInstallableResourceId(path, bundleResource);
        String name = FilenameUtils.getName(relPath);
        if (name == null || name.isEmpty()) {
            return null; //ignore directories!
        }
        InstallableResource resource;
        try {
            /*
             * Notes:
             *  - use <relativepath> as id
             *  - parse null as type to enable autodetection for configs as
             *    implemented by InternalReseouce.create(..)
             *  - we use the symbolic name and the modification date of the bundle as digest
             *  - the Dictionary will be ignored if an input stream is present
             *    so it is best to parse null
             *  - No idea how the priority is used by the Sling Installer. For
             *    now parse null than the default priority is used.
             */
            resource = new InstallableResource(relPath,
                    bundleResource.openStream(), null,
                    String.valueOf(bundle.getSymbolicName()+bundle.getLastModified()), null, null);
            log.info(" ... found installable resource " + bundleResource);
        } catch (IOException e) {
            log.error(String.format("Unable to process configuration File %s from Bundle %s",
View Full Code Here

                ArrayList<InstallableResource> updated = new ArrayList<InstallableResource>();
                while (resources.hasMoreElements()) {
                    URL url = resources.nextElement();
                    if(url != null){
                        log.debug("  > installable Resource {}",url);
                        InstallableResource resource = createInstallableResource(bundle, path, url);
                        if (resource != null) {
                            updated.add(resource);
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.sling.installer.api.InstallableResource

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.