Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e0e6fdd32d10b71fb98cb6bb48195c390d2c1dca (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
/*******************************************************************************
 * Copyright (c) 2011, 2015 Mia-Software, CEA LIST, Christian W. Damus, 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:
 *     Nicolas Bros (Mia-Software) - Bug 366567 - [Releng] Tool to update rmaps
 *     Camille Letavernier (CEA LIST) - Generalize to support POMs
 *     Christian W. Damus - Support updating of multiple selected files
 *******************************************************************************/
package org.eclipse.papyrus.releng.tools.internal.popup.actions;

import org.eclipse.core.resources.IFile;
import org.w3c.dom.Node;

/**
 * Updates a Buckminster rmap (XML file) from a B3 build model. The rmap is updated using
 * comments in the XML that reference the model elements from which the update sites must be copied.
 * <p>
 * These comments must appear before each "rm:uri" element which must be updated automatically, like this:
 *
 * <pre>
 * 	&lt;!-- updateFrom("Eclipse", 0) --&gt;
 * 	&lt;rm:uri format="http://download.eclipse.org/eclipse/updates/4.2milestones/S-4.2M3-201110281100"/&gt;
 * </pre>
 *
 * The first parameter in updateFrom is the label of a contribution, which you can find in the b3aggrcon files:
 *
 * <pre>
 * &lt;aggregator:Contribution ... label="xxx"&gt;
 * </pre>
 *
 * The second parameter is the index of the "repositories" element that must be used (in case there are several update sites defined on one contribution).
 */
public class MapUpdater extends XMLDependencyUpdater {

	public MapUpdater() {
		super();
	}

	@Override
	public boolean canUpdate(IFile file) {
		return "rmap".equals(file.getFileExtension()); //$NON-NLS-1$
	}

	@Override
	protected String getXpath() {
		return "/rmap/searchPath/provider[@readerType='p2']/uri"; //$NON-NLS-1$
	}

	@Override
	protected String getCurrentLocation(Node uri) {
		return uri.getAttributes().getNamedItem("format").getTextContent(); //$NON-NLS-1$
	}

	@Override
	protected void updateUri(Node uri, String location) {
		if (location.startsWith(PREFIX)) {
			location = "{0}/" + location.substring(PREFIX.length()); //$NON-NLS-1$
		}
		uri.getAttributes().getNamedItem("format").setTextContent(location); //$NON-NLS-1$
	}

}

Back to the top