Package org.apache.sling.installer.api.tasks

Examples of org.apache.sling.installer.api.tasks.TransformationResult


        // Factory?
        if (factoryPid != null) {
            attr.put(ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid);
        }

        final TransformationResult tr = new TransformationResult();
        final String id = (factoryPid == null ? "" : factoryPid + ".") + configPid;
        tr.setId(id);
        tr.setResourceType(InstallableResource.TYPE_CONFIG);
        tr.setAttributes(attr);

        return new TransformationResult[] {tr};
    }
View Full Code Here


                        final String v = m.getMainAttributes().getValue(DEPLOYMENTPACKAGE_VERSION);
                        if (v != null) {
                            final Map<String, Object> attr = new HashMap<String, Object>();
                            attr.put(DEPLOYMENTPACKAGE_SYMBOLICMAME, sn);

                            final TransformationResult tr = new TransformationResult();
                            tr.setId(sn);
                            tr.setVersion(new Version(v));
                            tr.setResourceType(TYPE_DP);
                            tr.setAttributes(attr);

                            return new TransformationResult[] {tr};
                        }
                    }
                }
View Full Code Here

                    if ( validVersion ) {
                        final Map<String, Object> attr = new HashMap<String, Object>();
                        attr.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, headers.symbolicName);
                        attr.put(SubsystemConstants.SUBSYSTEM_VERSION, headers.version);

                        final TransformationResult tr = new TransformationResult();
                        tr.setId(headers.symbolicName);
                        tr.setResourceType(TYPE_SUBSYSTEM);
                        tr.setAttributes(attr);
                        tr.setVersion(new Version(headers.version));

                        return new TransformationResult[] {tr};
                    }

                } else {
View Full Code Here

        final RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
        final TransformationResult[] tr = new DefaultTransformer().transform(rr);
        if ( tr != null ) {
            return rr.clone(tr[0]);
        } else if ( is.getId().startsWith("configuration:") ) {
            final TransformationResult result = new TransformationResult();
            result.setId(is.getId().substring(14));
            result.setResourceType(InstallableResource.TYPE_CONFIG);
            result.setAttributes(Collections.singletonMap(Constants.SERVICE_PID, (Object)result.getId()));
            return rr.clone(result);
        }
        return rr;
    }
View Full Code Here

        final InternalResource internal = InternalResource.create("test",
                new InstallableResource(url, null, new Hashtable<String, Object>(), null, null, null));
        RegisteredResourceImpl rr = RegisteredResourceImpl.create(internal);
        TransformationResult[] tr = new DefaultTransformer().transform(rr);
        if ( tr == null ) {
            final TransformationResult result = new TransformationResult();
            result.setId(url);
            result.setResourceType(InstallableResource.TYPE_CONFIG);
            tr = new TransformationResult[] {
                      result
            };
        }
        rr = (RegisteredResourceImpl)rr.clone(tr[0]);
View Full Code Here

                // check for activation policy
                if ( headers.activationPolicy != null ) {
                    attr.put(Constants.BUNDLE_ACTIVATIONPOLICY, headers.activationPolicy);
                }

                final TransformationResult tr = new TransformationResult();
                tr.setId(headers.symbolicName);
                tr.setResourceType(InstallableResource.TYPE_BUNDLE);
                tr.setAttributes(attr);

                return new TransformationResult[] {tr};
            }
        }
        return null;
View Full Code Here

                                            data.getDigest(result.getURL(), result.getDigest()),
                                            result.getPriority(),
                                            data.getDataFile(),
                                            null);
                                    final RegisteredResource rr = this.persistentList.addOrUpdate(internalResource);
                                    final TransformationResult transRes = new TransformationResult();
                                    // use the old entity id
                                    final int pos = erl.getResourceId().indexOf(':');
                                    transRes.setId(erl.getResourceId().substring(pos + 1));
                                    transRes.setResourceType(resourceType);
                                    if ( attributes != null ) {
                                        transRes.setAttributes(attributes);
                                    }
                                    this.persistentList.transform(rr, new TransformationResult[] {
                                            transRes
                                    });
                                    final EntityResourceList newGroup = this.persistentList.getEntityResourceList(key);
                                    newGroup.setFinishState(ResourceState.INSTALLED);
                                    newGroup.compact();
                                } else {
                                    // resource has been updated or moved
                                    ((RegisteredResourceImpl)tr).update(
                                            data.getDataFile(), data.getDictionary(),
                                            data.getDigest(result.getURL(), result.getDigest()),
                                            result.getPriority(),
                                            result.getURL());
                                    // We first set the state of the resource to install to make setFinishState work in all cases
                                    ((RegisteredResourceImpl)tr).setState(ResourceState.INSTALL);
                                    erl.setFinishState(ResourceState.INSTALLED);
                                    erl.compact();
                                }
                                updated = true;
                            }
                        } finally {
                            if ( localIS != null ) {
                                // always close the input stream!
                                try {
                                    localIS.close();
                                } catch (final IOException ignore) {
                                    // ignore
                                }
                            }
                        }
                    }

                }

                boolean created = false;
                if ( !updated ) {
                    // create
                    final List<UpdateHandler> handlerList = this.updateHandlerTracker.getSortedServices();
                    for(final UpdateHandler handler : handlerList) {
                        final InputStream localIS = data.getInputStream();
                        try {
                            final UpdateResult result = (localIS == null ? handler.handleUpdate(resourceType, entityId, null, data.getDictionary(), attributes)
                                    : handler.handleUpdate(resourceType, entityId, null, localIS, attributes));
                            if ( result != null ) {
                                final InternalResource internalResource = new InternalResource(result.getScheme(),
                                        result.getResourceId(),
                                        null,
                                        data.getDictionary(),
                                        (data.getDictionary() != null ? InstallableResource.TYPE_PROPERTIES : InstallableResource.TYPE_FILE),
                                        data.getDigest(result.getURL(), result.getDigest()),
                                        result.getPriority(),
                                        data.getDataFile(),
                                        null);
                                final RegisteredResource rr = this.persistentList.addOrUpdate(internalResource);
                                final TransformationResult transRes = new TransformationResult();
                                transRes.setId(entityId);
                                transRes.setResourceType(resourceType);
                                if ( attributes != null ) {
                                    transRes.setAttributes(attributes);
                                }
                                this.persistentList.transform(rr, new TransformationResult[] {
                                        transRes
                                });
                                final EntityResourceList newGroup = this.persistentList.getEntityResourceList(key);
View Full Code Here

        final InternalResource ir = InternalResource.create(this.getScheme(), is);
        RegisteredResourceImpl rr = RegisteredResourceImpl.create(ir);
        for(final Map.Entry<String, Object> e : this.attributes.entrySet()) {
            rr.setAttribute(e.getKey(), e.getValue());
        }
        final TransformationResult tr = new TransformationResult();
        tr.setId((String)this.attributes.get(Constants.BUNDLE_SYMBOLICNAME));
        tr.setResourceType(this.getType());
        tr.setVersion(this.getVersion());
        rr = (RegisteredResourceImpl)rr.clone(tr);
        rr.setState(this.getState());

        return rr;
    }
View Full Code Here

                            RESTART_ACTIVE_BUNDLES_ID,
                            null,
                            new Hashtable<String, Object>(),
                            InstallableResource.TYPE_PROPERTIES, "1",
                            null, null, null));
            final TransformationResult result = new TransformationResult();
            result.setId(RESTART_ACTIVE_BUNDLES_ID);
            result.setResourceType(RESTART_ACTIVE_BUNDLES_TYPE);
            this.transform(rr, new TransformationResult[] {result});
        }
    }
View Full Code Here

        // remove resource from unknown list
        this.untransformedResources.remove(resource);
        try {
            for(int i=0; i<result.length; i++) {
                // check the result
                final TransformationResult tr = result[i];
                if ( tr == null ) {
                    logger.warn("Ignoring null result for {}", resource);
                    continue;
                }
                if ( tr.getResourceType() != null && tr.getId() == null) {
                    logger.error("Result for {} contains new resource type {} but no unique id!",
                            resource, tr.getResourceType());
                    continue;
                }
                final RegisteredResourceImpl clone =  (RegisteredResourceImpl)((RegisteredResourceImpl)resource).clone(result[i]);
                this.checkInstallable(clone);
            }
View Full Code Here

TOP

Related Classes of org.apache.sling.installer.api.tasks.TransformationResult

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.