Contribution contribution = contributionFactory.createContribution();
contribution.setURI(contributionURI.toString());
if (contributionURL != null) {
contribution.setLocation(contributionURL.toString());
}
ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
contribution.setModelResolver(modelResolver);
contribution.setUnresolved(true);
Monitor monitor = context.getMonitor();
monitor.pushContext("Contribution: " + contribution.getURI());
Contribution old = context.setContribution(contribution);
try {
if (contributionURL != null) {
// Create a contribution scanner
ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
if (scanner == null) {
File file = toFile(contributionURL);
if (file != null && file.isDirectory()) {
scanner = new DirectoryContributionScanner(contributionFactory);
} else {
scanner = new JarContributionScanner(contributionFactory);
}
}
// Scan the contribution and list the artifacts contained in it
boolean contributionMetadata = false;
List<Artifact> artifacts = scanner.scan(contribution);
for (Artifact artifact : artifacts) {
// Add the deployed artifact model to the contribution
modelResolver.addModel(artifact, context);
monitor.pushContext("Artifact: " + artifact.getURI());
Artifact oldArtifact = context.setArtifact(artifact);
try {
// Read each artifact
URL artifactLocationURL = null;
try {
artifactLocationURL = new URL(artifact.getLocation());
} catch (MalformedURLException e) {
//ignore
}
Object model =
artifactProcessor.read(contributionURL,
URI.create(artifact.getURI()),
artifactLocationURL,
context);
if (model != null) {
artifact.setModel(model);
// Add the loaded model to the model resolver
modelResolver.addModel(model, context);
// Merge contribution metadata into the contribution model
if (model instanceof ContributionMetadata) {
contributionMetadata = true;
ContributionMetadata c = (ContributionMetadata)model;