|
Lines 11-18
Link Here
|
| 11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
| 12 |
package org.eclipse.equinox.internal.p2.reconciler.dropins; |
12 |
package org.eclipse.equinox.internal.p2.reconciler.dropins; |
| 13 |
|
13 |
|
| 14 |
import org.eclipse.equinox.p2.query.QueryUtil; |
|
|
| 15 |
|
| 16 |
import java.io.*; |
14 |
import java.io.*; |
| 17 |
import java.net.URI; |
15 |
import java.net.URI; |
| 18 |
import java.net.URISyntaxException; |
16 |
import java.net.URISyntaxException; |
|
Lines 28-33
Link Here
|
| 28 |
import org.eclipse.equinox.p2.core.ProvisionException; |
26 |
import org.eclipse.equinox.p2.core.ProvisionException; |
| 29 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
27 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
| 30 |
import org.eclipse.equinox.p2.query.IQueryResult; |
28 |
import org.eclipse.equinox.p2.query.IQueryResult; |
|
|
29 |
import org.eclipse.equinox.p2.query.QueryUtil; |
| 31 |
import org.eclipse.equinox.p2.repository.IRepository; |
30 |
import org.eclipse.equinox.p2.repository.IRepository; |
| 32 |
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; |
31 |
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; |
| 33 |
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; |
32 |
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; |
|
Lines 43-48
Link Here
|
| 43 |
private static final String LINK = ".link"; //$NON-NLS-1$ |
42 |
private static final String LINK = ".link"; //$NON-NLS-1$ |
| 44 |
private static final String ZIP = ".zip"; //$NON-NLS-1$ |
43 |
private static final String ZIP = ".zip"; //$NON-NLS-1$ |
| 45 |
private static final String LINKS_PATH = "path"; //$NON-NLS-1$ |
44 |
private static final String LINKS_PATH = "path"; //$NON-NLS-1$ |
|
|
45 |
private static final String LINK_IS_OPTIONAL = "optional"; //$NON-NLS-1$ |
| 46 |
private static final String DROPIN_ARTIFACT_REPOSITORIES = "dropin.artifactRepositories"; //$NON-NLS-1$ |
46 |
private static final String DROPIN_ARTIFACT_REPOSITORIES = "dropin.artifactRepositories"; //$NON-NLS-1$ |
| 47 |
private static final String DROPIN_METADATA_REPOSITORIES = "dropin.metadataRepositories"; //$NON-NLS-1$ |
47 |
private static final String DROPIN_METADATA_REPOSITORIES = "dropin.metadataRepositories"; //$NON-NLS-1$ |
| 48 |
private static final String PIPE = "|"; //$NON-NLS-1$ |
48 |
private static final String PIPE = "|"; //$NON-NLS-1$ |
|
Lines 50-55
Link Here
|
| 50 |
private List<IMetadataRepository> metadataRepositories = new ArrayList<IMetadataRepository>(); |
50 |
private List<IMetadataRepository> metadataRepositories = new ArrayList<IMetadataRepository>(); |
| 51 |
private List<IArtifactRepository> artifactRepositories = new ArrayList<IArtifactRepository>(); |
51 |
private List<IArtifactRepository> artifactRepositories = new ArrayList<IArtifactRepository>(); |
| 52 |
|
52 |
|
|
|
53 |
static class LinkedRepository { |
| 54 |
LinkedRepository(File location) { |
| 55 |
super(); |
| 56 |
if (location == null) |
| 57 |
throw new IllegalArgumentException("Repository location cannot be null."); //$NON-NLS-1$ |
| 58 |
this.location = location; |
| 59 |
} |
| 60 |
|
| 61 |
boolean exists() { |
| 62 |
return location.exists(); |
| 63 |
} |
| 64 |
|
| 65 |
File getLocation() { |
| 66 |
return location; |
| 67 |
} |
| 68 |
|
| 69 |
boolean isOptional() { |
| 70 |
return optional; |
| 71 |
} |
| 72 |
|
| 73 |
void setOptional(boolean optional) { |
| 74 |
this.optional = optional; |
| 75 |
} |
| 76 |
|
| 77 |
private File location; |
| 78 |
private boolean optional = false; |
| 79 |
} |
| 80 |
|
| 53 |
public DropinsRepositoryListener(IProvisioningAgent agent, String repositoryName) { |
81 |
public DropinsRepositoryListener(IProvisioningAgent agent, String repositoryName) { |
| 54 |
super(repositoryName, true); |
82 |
super(repositoryName, true); |
| 55 |
this.agent = agent; |
83 |
this.agent = agent; |
|
Lines 81-86
Link Here
|
| 81 |
|
109 |
|
| 82 |
private void addRepository(File file) { |
110 |
private void addRepository(File file) { |
| 83 |
URI repoLocation = createRepositoryLocation(file); |
111 |
URI repoLocation = createRepositoryLocation(file); |
|
|
112 |
if (repoLocation == null) |
| 113 |
return; |
| 84 |
Map<String, String> properties = new HashMap<String, String>(); |
114 |
Map<String, String> properties = new HashMap<String, String>(); |
| 85 |
// if the file pointed to a link file, keep track of the attribute |
115 |
// if the file pointed to a link file, keep track of the attribute |
| 86 |
// so we can add it to the repo later |
116 |
// so we can add it to the repo later |
|
Lines 89-105
Link Here
|
| 89 |
if (linkLocation != null) |
119 |
if (linkLocation != null) |
| 90 |
properties.put(Site.PROP_LINK_FILE, file.getAbsolutePath()); |
120 |
properties.put(Site.PROP_LINK_FILE, file.getAbsolutePath()); |
| 91 |
} |
121 |
} |
| 92 |
if (repoLocation != null) { |
122 |
getMetadataRepository(repoLocation, properties); |
| 93 |
getMetadataRepository(repoLocation, properties); |
123 |
getArtifactRepository(repoLocation, properties); |
| 94 |
getArtifactRepository(repoLocation, properties); |
|
|
| 95 |
} |
| 96 |
} |
124 |
} |
| 97 |
|
125 |
|
| 98 |
/* |
126 |
/* |
| 99 |
* Return the file pointed to by the given link file. Return null if there is a problem |
127 |
* Return the file pointed to by the given link file. Return null if there is a problem |
| 100 |
* reading the file or resolving the location. |
128 |
* reading the file or resolving the location. |
| 101 |
*/ |
129 |
*/ |
| 102 |
static File getLinkedFile(File file) { |
130 |
static LinkedRepository getLinkedRepository(File file) { |
| 103 |
Properties links = new Properties(); |
131 |
Properties links = new Properties(); |
| 104 |
try { |
132 |
try { |
| 105 |
InputStream input = new BufferedInputStream(new FileInputStream(file)); |
133 |
InputStream input = new BufferedInputStream(new FileInputStream(file)); |
|
Lines 133-139
Link Here
|
| 133 |
linkedFile = new File(root, path); |
161 |
linkedFile = new File(root, path); |
| 134 |
} |
162 |
} |
| 135 |
try { |
163 |
try { |
| 136 |
return linkedFile.getCanonicalFile(); |
164 |
LinkedRepository result = new LinkedRepository(linkedFile.getCanonicalFile()); |
|
|
165 |
// Check if the link target is marked as optional. |
| 166 |
// If link is optional, then the link target may not exist. |
| 167 |
// So IF link is marked as optional AND does not exist, simply ignore it. |
| 168 |
String optional = links.getProperty(LINK_IS_OPTIONAL); |
| 169 |
result.setOptional(Boolean.valueOf(optional).booleanValue()); |
| 170 |
return result; |
| 137 |
} catch (IOException e) { |
171 |
} catch (IOException e) { |
| 138 |
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.error_resolving_link, linkedFile.getAbsolutePath(), file.getAbsolutePath()), e)); |
172 |
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.error_resolving_link, linkedFile.getAbsolutePath(), file.getAbsolutePath()), e)); |
| 139 |
return null; |
173 |
return null; |
|
Lines 179-191
Link Here
|
| 179 |
} |
213 |
} |
| 180 |
|
214 |
|
| 181 |
private URI getLinkRepository(File file, boolean logMissingLink) { |
215 |
private URI getLinkRepository(File file, boolean logMissingLink) { |
| 182 |
File repo = getLinkedFile(file); |
216 |
LinkedRepository repo = getLinkedRepository(file); |
| 183 |
if (repo == null) { |
217 |
if (repo == null) { |
| 184 |
if (logMissingLink) |
218 |
if (logMissingLink) |
| 185 |
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Unable to determine link location from file: " + file.getAbsolutePath())); //$NON-NLS-1$ |
219 |
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Unable to determine link location from file: " + file.getAbsolutePath())); //$NON-NLS-1$ |
| 186 |
return null; |
220 |
return null; |
| 187 |
} |
221 |
} |
| 188 |
return repo.toURI(); |
222 |
return repo.isOptional() && !repo.exists() ? null : repo.getLocation().toURI(); |
| 189 |
} |
223 |
} |
| 190 |
|
224 |
|
| 191 |
public void getMetadataRepository(URI repoURL, Map<String, String> properties) { |
225 |
public void getMetadataRepository(URI repoURL, Map<String, String> properties) { |