Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e455fb3459fabe655776fb402765a2498a9b6bc4 (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
71
72
73
/*******************************************************************************
 * Copyright (c) 2008 Code 9 and others. 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: 
 *   Code 9 - initial API and implementation
 *   IBM - ongoing development
 ******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.directorywatcher;

import java.io.File;
import java.net.URL;
import java.util.Map;
import java.util.Properties;
import org.eclipse.equinox.internal.p2.update.Site;
import org.eclipse.equinox.p2.publisher.eclipse.*;
import org.osgi.framework.Version;

/**
 * Entry advice captures the name, location, modified time, shape etc of something
 * discovered by the repository listener.  It is a simplified structure intended to represent
 * only one entry at a time and that entry is the the only entry being published.  
 */
public class EntryAdvice implements IFeatureAdvice, IBundleAdvice {
	private Properties metadataProps = new Properties();
	private Properties artifactProps = new Properties();

	public Properties getIUProperties(Feature feature) {
		return metadataProps;
	}

	public Properties getArtifactProperties(Feature feature) {
		return artifactProps;
	}

	public boolean isApplicable(String configSpec, boolean includeDefault, String id, Version version) {
		return true;
	}

	public Properties getIUProperties(File location) {
		return metadataProps;
	}

	public Properties getArtifactProperties(File location) {
		return artifactProps;
	}

	void setProperties(File location, long timestamp, URL reference) {
		setProperties(location, timestamp, reference, null);
	}

	void setProperties(File location, long timestamp, URL reference, String linkFile) {
		if (reference == null)
			artifactProps.remove(RepositoryListener.ARTIFACT_REFERENCE);
		else
			artifactProps.setProperty(RepositoryListener.ARTIFACT_REFERENCE, reference.toExternalForm());
		if (location.isDirectory())
			artifactProps.setProperty(RepositoryListener.ARTIFACT_FOLDER, Boolean.TRUE.toString());
		else
			artifactProps.remove(RepositoryListener.ARTIFACT_FOLDER);
		artifactProps.setProperty(RepositoryListener.FILE_NAME, location.getAbsolutePath());
		metadataProps.setProperty(RepositoryListener.FILE_NAME, location.getAbsolutePath());
		metadataProps.setProperty(RepositoryListener.FILE_LAST_MODIFIED, Long.toString(timestamp));
		if (linkFile != null)
			metadataProps.setProperty(Site.PROP_LINK_FILE, linkFile);
	}

	public Map getInstructions(File location) {
		return null;
	}
}

Back to the top