locationURL = contributionRepository.store(contributionURI, sourceURL, contributionStream);
            }
        }
        //initialize contribution based on it's metadata if available
        Contribution contribution = readContributionMetadata(locationURL);
        // Create contribution model resolver
        if (modelResolver == null) {
            //FIXME Remove this domain resolver, visibility of policy declarations should be handled by
            // the contribution import/export mechanism instead of this domainResolver hack.
            modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories, domainResolver);
        }
        //set contribution initial information
        contribution.setURI(contributionURI.toString());
        contribution.setLocation(locationURL.toString());
        contribution.setModelResolver(modelResolver);
        
        List<URI> contributionArtifacts = null;
        //NOTE: if a contribution is stored on the repository
        //the stream would be consumed at this point
        if (storeInRepository || contributionStream == null) {
            URLConnection connection = sourceURL.openConnection();
            connection.setUseCaches(false);
            contributionStream = connection.getInputStream();
            try {
                // process the contribution
                contributionArtifacts = this.packageProcessor.getArtifacts(locationURL, contributionStream);
            } finally {
                IOHelper.closeQuietly(contributionStream);
                contributionStream = null;
            }
        } else {
            // process the contribution
            contributionArtifacts = this.packageProcessor.getArtifacts(locationURL, contributionStream);
        }
        
        // Read all artifacts in the contribution
        try {
            processReadPhase(contribution, contributionArtifacts);
        } catch ( Exception e ) {
            throw new ContributionException(e);
        }
        //
        this.contributionListener.contributionAdded(this.contributionRepository, contribution);
        // Resolve them
        processResolvePhase(contribution);
        // Add all composites under META-INF/sca-deployables to the
        // list of deployables
        String prefix = Contribution.SCA_CONTRIBUTION_DEPLOYABLES;
        for (Artifact artifact : contribution.getArtifacts()) {
            if (artifact.getModel() instanceof Composite) {
                if (artifact.getURI().startsWith(prefix)) {
                    Composite composite = (Composite)artifact.getModel();
                    if (!contribution.getDeployables().contains(composite)) {
                        contribution.getDeployables().add(composite);
                    }
                }
            }
        }