import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
-import eu.etaxonomy.taxeditor.TaxonomicEditorPlugin;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.util.ApplicationUtil;
*/
public class P2Util {
- //private static String LOCAL_UPDATE_SITE = "file:///path/.../to/Development/EDIT/taxeditor/eu.etaxonomy.taxeditor/target/repository/";
-
private static String EDIT_NIGHTLY_UPDATE_SITE = "http://cybertaxonomy.eu/download/taxeditor/update/nightly/";
private static String EDIT_NIGHTLY_UPDATE_SITE_NAME = "Taxonomic Editor Nightly";
- private static String EDIT_SNAPSHOT_UPDATE_SITE = "http://cybertaxonomy.eu/download/taxeditor/update/snapshot/";
- private static String EDIT_SNAPSHOT_UPDATE_SITE_NAME = "Taxonomic Editor Snapshot";
-
private static String EDIT_STABLE_UPDATE_SITE = "http://cybertaxonomy.eu/download/taxeditor/update/stable/";
private static String EDIT_STABLE_UPDATE_SITE_NAME = "Taxonomic Editor Stable";
*/
@SuppressWarnings("restriction")
public static void setP2UpdateRepositories() {
- String updateSite = EDIT_NIGHTLY_UPDATE_SITE;
- String updateSiteName = EDIT_NIGHTLY_UPDATE_SITE_NAME;
-
- if(ApplicationUtil.isStable()) {
- updateSite = EDIT_STABLE_UPDATE_SITE;
- updateSiteName = EDIT_STABLE_UPDATE_SITE_NAME;
- }
List<MetadataRepositoryElement> repoElements = new ArrayList<MetadataRepositoryElement>();
- List<MetadataRepositoryElement> savedRepoElements = PreferencesUtil.getP2Repositories();
- if(savedRepoElements.isEmpty()) {
- // we always need an update site, so we add the default one
- try {
- MetadataRepositoryElement element = new MetadataRepositoryElement(null, new URI(updateSite), true);
- element.setNickname(updateSiteName);
- repoElements.add(element);
- } catch (URISyntaxException e) {
- MessagingUtils.errorDialog("Invalid update site URI",
- P2Util.class,
- "The update site URI has an invalid syntax",
- TaxonomicEditorPlugin.PLUGIN_ID,
- e,
- false);
- }
- }
+ List<MetadataRepositoryElement> savedRepoElements = new ArrayList<>();
+
+ MetadataRepositoryElement mre = new MetadataRepositoryElement(null, getP2UpdateRepository(), true);
+ mre.setNickname(getP2UpdateRepositoryName());
+ savedRepoElements.add(mre);
+
repoElements.addAll(savedRepoElements);
ElementUtils.updateRepositoryUsingElements(ProvisioningUI.getDefaultUI(),repoElements
}
+ public static String getP2UpdateRepositoryName(){
+ return ApplicationUtil.isStable()?EDIT_STABLE_UPDATE_SITE_NAME:EDIT_NIGHTLY_UPDATE_SITE_NAME;
+ }
+
+ public static URI getP2UpdateRepository(){
+ try {
+ return ApplicationUtil.isStable()?new URI(EDIT_STABLE_UPDATE_SITE):new URI(EDIT_NIGHTLY_UPDATE_SITE);
+ } catch (URISyntaxException e) {
+ MessagingUtils.error(P2Util.class, e);
+ }
+ return null;
+ }
+
/**
* {@link org.eclipse.equinox.p2.ui.RepositoryManipulationPage} which handles the repsitory site list
* in preferences does not create a preference store and hence the changes are not saved. This means