blob: 0433e409b4f6136d04bf02b93a4322fed2424d49 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/*******************************************************************************
* Copyright (c) 2007 Innoopract Informationssysteme GmbH
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Innoopract - initial API and implementation
*******************************************************************************/
package org.eclipse.epp.packaging.core.download;
import java.net.URL;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration;
import org.eclipse.epp.packaging.core.logging.MessageLogger;
import org.eclipse.update.core.IFeature;
import org.eclipse.update.core.VersionedIdentifier;
import org.eclipse.update.search.IUpdateSearchResultCollector;
/**
* Holds references to a list of update sites and provides the methods required
* for interaction.
*/
public class UpdateSiteManager implements IUpdateSiteManager {
private final URL[] listedSites;
private final VersionedIdentifier[] listedFeatures;
public UpdateSiteManager( final IPackagerConfiguration configuration ) {
this.listedSites = configuration.getUpdateSites();
this.listedFeatures = configuration.getRequiredFeatures();
MessageLogger.getInstance()
.log( "UpdateSiteManager.ListedSitesCount", listedSites.length ); //$NON-NLS-1$
}
public boolean areFeaturesPresent( final VersionedIdentifier[] identifiers )
throws CoreException
{
MessageLogger.getInstance()
.logBeginProcess( "UpdateSiteManager.FeatureLookup" ); //$NON-NLS-1$
FeatureVerifyingSearchCollector collector = new FeatureVerifyingSearchCollector( listedFeatures );
search( collector );
boolean result = collector.allFeaturesFound();
if( result ) {
MessageLogger.getInstance()
.logEndProcess( "UpdateSiteManager.FeaturesPresent" ); //$NON-NLS-1$
} else {
MessageLogger.getInstance()
.logEndProcess( "UpdateSiteManager.FeaturesMissing" ); //$NON-NLS-1$
for( VersionedIdentifier feature : collector.getMissingFeatures() ) {
MessageLogger.getInstance().log( feature.toString() );
}
}
return result;
}
public IFeature[] getFeatures() throws CoreException {
FeatureRetrievingSearchCollector collector = new FeatureRetrievingSearchCollector();
search( collector );
return collector.getFeatures();
}
private void search( final IUpdateSearchResultCollector collector )
throws CoreException
{
new FeatureSearcher( listedFeatures, listedSites ).run( collector );
}
}
|