blob: 00f4c193c8bce701e5f9f3680a9704b7fe1ab140 (
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
74
|
/*******************************************************************************
* Copyright (c) 2008, 2015 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.tools.ant.BuildException;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
/**
* Ant task to remove a specific child repository (or all the children repositories)
* from a composite metadata repository.
*/
public class RemoveChildTask extends AbstractMDRTask {
URI location; // location of the composite repository
URI child; // address of the child to be removed
boolean allChildren; // should we remove all the children?
/* (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) getAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new BuildException("Unable to aquire metadata repository manager service.");
CompositeMetadataRepository repo;
try {
repo = (CompositeMetadataRepository) manager.loadRepository(location, null);
} catch (ProvisionException e) {
throw new BuildException("Error occurred while loading repository.", e);
}
// remove all the children repositories if requested, otherwise
// just remove the specific child
if (allChildren)
repo.removeAllChildren();
else
repo.removeChild(child);
}
/*
* Set the location of the composite repository.
*/
public void setLocation(String value) throws URISyntaxException {
location = URIUtil.fromString(value);
}
/*
* Set the location of the child repository to remove.
*/
public void setChild(String value) throws URISyntaxException {
child = URIUtil.fromString(value);
}
/*
* Set whether or not we should remove all the children.
*/
public void setAllChildren(String value) {
allChildren = Boolean.parseBoolean(value);
}
}
|