diff options
author | Pascal Rapicault | 2009-04-09 18:30:40 +0000 |
---|---|---|
committer | Pascal Rapicault | 2009-04-09 18:30:40 +0000 |
commit | 841bac5066fb24f2714292feee7bedafda612ee0 (patch) | |
tree | 9f1c9c997244ae744aeb98066911c7a05dcdffe3 /bundles/org.eclipse.equinox.p2.repository | |
parent | e7c9243cf945517962716929f9ebda2cdb8c275f (diff) | |
download | rt.equinox.p2-841bac5066fb24f2714292feee7bedafda612ee0.tar.gz rt.equinox.p2-841bac5066fb24f2714292feee7bedafda612ee0.tar.xz rt.equinox.p2-841bac5066fb24f2714292feee7bedafda612ee0.zip |
Bug 265550 - Review Ant task consistency
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository')
4 files changed, 65 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF index 5712dd35f..f55386dcd 100644 --- a/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.repository/META-INF/MANIFEST.MF @@ -33,7 +33,8 @@ Export-Package: org.eclipse.equinox.internal.p2.persistence;x-friends:="org.ecli x-friends:="org.eclipse.equinox.p2.artifact.repository, org.eclipse.equinox.p2.exemplarysetup, org.eclipse.equinox.p2.metadata.repository, - org.eclipse.equinox.p2.updatesite"; + org.eclipse.equinox.p2.updatesite, + org.eclipse.equinox.p2.repository.tools"; uses:="org.eclipse.equinox.internal.provisional.p2.core.eventbus, org.eclipse.equinox.internal.provisional.p2.core.repository, org.osgi.service.prefs, diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/Messages.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/Messages.java index 9683889af..3fd3d49c7 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/Messages.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/Messages.java @@ -31,5 +31,6 @@ class Messages extends NLS { public static String repoMan_internalError; public static String repoMan_notExists; public static String repoMan_unknownType; + public static String DestinationNotModifiable; } diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/RepositoryHelper.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/RepositoryHelper.java new file mode 100644 index 000000000..64c725a19 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/RepositoryHelper.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2009 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.repository.helpers; + +import java.io.File; +import java.net.URI; +import org.eclipse.core.runtime.URIUtil; +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; +import org.eclipse.osgi.util.NLS; + +public class RepositoryHelper { + protected static final String FILE_SCHEME = "file"; //$NON-NLS-1$ + + /** + * If the provided URI can be interpreted as representing a local address (no schema, or one letter schema) + * but is missing the file schema, a new URI is created which represents the local file. + * + * @param location the URI to convert + * @return the converted URI, or the original + */ + public static URI localRepoURIHelper(URI location) { + if (location == null) + return null; + if (location.getScheme() == null) + // Probably a local path: /home/user/repo + location = (new File(location.getPath())).getAbsoluteFile().toURI(); + else if (location.getScheme().length() == 1) + // Probably a windows path: C:\repo + location = (new File(URIUtil.toUnencodedString(location))).toURI(); + else if (!FILE_SCHEME.equalsIgnoreCase(location.getScheme())) + // This else must occur last! + return location; + + // Zipped repository? + String lowerCase = location.toString().toLowerCase(); + if (lowerCase.endsWith(".jar") || lowerCase.endsWith(".zip")) //$NON-NLS-1$//$NON-NLS-2$ + return URIUtil.toJarURI(location, null); + return location; + } + + /** + * Determine if the repository could be used as a valid destination (eg, it is modifiable) + * @param repository the repository to test + * @return the repository + * @throws ProvisionException if the repository is not valid + */ + public static IRepository validDestinationRepository(IRepository repository) { + if (!repository.isModifiable()) + throw new IllegalStateException(NLS.bind(Messages.DestinationNotModifiable, repository.getLocation())); + return repository; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/messages.properties b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/messages.properties index 72d4fafc4..65fb75efa 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/messages.properties +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/messages.properties @@ -15,3 +15,4 @@ repoMan_failedRead=The repository could not be read: {0}. repoMan_internalError=Internal error. repoMan_notExists=No repository found at {0}. repoMan_unknownType=Unknown repository type at {0}. +DestinationNotModifiable=Destination repository is not modifiable: {0}
\ No newline at end of file |