aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Weber2013-08-09 10:47:13 (EDT)
committerJan Sievers2013-09-03 09:34:37 (EDT)
commit2e5c55e705f670ff7b589f1c4f1f63c1e63286c4 (patch)
treebf91b478d4f7191de98219df714f551d892a446f
parentc532878647d1910a5b4816ee2892dab15bf2723e (diff)
downloadorg.eclipse.tycho.nexus-2e5c55e705f670ff7b589f1c4f1f63c1e63286c4.zip
org.eclipse.tycho.nexus-2e5c55e705f670ff7b589f1c4f1f63c1e63286c4.tar.gz
org.eclipse.tycho.nexus-2e5c55e705f670ff7b589f1c4f1f63c1e63286c4.tar.bz2
411239 adapt to Nexus version 2.6.0-05refs/changes/19/15319/4
- Nexus has a new startup behaviour. We set the master repository on NexusStartedEvent. - new constructor for ItemNotFoundException - removed some calls of deprecated functions to reduce warnings Change-Id: I84d20dc1f6aa01c39a58521d6bacd527042c54da Signed-off-by: Stephan Weber <stephan.weber@sap.com> Bug: 411239
-rw-r--r--pom.xml8
-rw-r--r--src/main/java/org/eclipse/tycho/nexus/internal/plugin/DefaultUnzipRepository.java31
-rw-r--r--src/main/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryResourceBundle.java4
-rw-r--r--src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestReleaseRequest.java10
-rw-r--r--src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestVersionRequest.java14
-rw-r--r--src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/ParsedRequest.java19
-rw-r--r--src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/RequestPathConverter.java4
-rw-r--r--src/main/java/org/eclipse/tycho/nexus/internal/plugin/storage/ZippedItem.java3
8 files changed, 52 insertions, 41 deletions
diff --git a/pom.xml b/pom.xml
index b3244c4..36d67f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,7 +71,7 @@
</description>
<properties>
- <nexus-version>2.3.0</nexus-version>
+ <nexus-version>2.6.0-05</nexus-version>
</properties>
<repositories>
@@ -175,12 +175,6 @@
<!-- Basic testing -->
<dependency>
- <groupId>org.sonatype.nexus</groupId>
- <artifactId>nexus-plugin-test-api</artifactId>
- <version>${nexus-version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
diff --git a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/DefaultUnzipRepository.java b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/DefaultUnzipRepository.java
index 05b45d4..b416bdf 100644
--- a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/DefaultUnzipRepository.java
+++ b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/DefaultUnzipRepository.java
@@ -137,12 +137,12 @@ public class DefaultUnzipRepository extends AbstractShadowRepository implements
* meantime the master repository id will be stored without availability, compatibility checks
* avoiding error logs.
*/
- @SuppressWarnings("deprecation")
@Override
public void setMasterRepositoryId(final String id) throws NoSuchRepositoryException,
IncompatibleMasterRepositoryException {
try {
- super.setMasterRepositoryId(id);
+ Repository repository = getRepositoryRegistry().getRepository(id);
+ super.setMasterRepository(repository);
isMasterAvailable = true;
} catch (final NoSuchRepositoryException e) {
if (isNexusStarted) {
@@ -157,35 +157,48 @@ public class DefaultUnzipRepository extends AbstractShadowRepository implements
// see comment at setMasterRepositoryId(String id)
@Override
public void setMasterRepository(final Repository masterRepository) throws IncompatibleMasterRepositoryException {
- isMasterAvailable = true;
super.setMasterRepository(masterRepository);
+ isMasterAvailable = true;
}
// see comment at setMasterRepositoryId(String id)
@Override
public Repository getMasterRepository() {
- if (isNexusStarted || isMasterAvailable) {
+ if (isNexusStarted && isMasterAvailable) {
return super.getMasterRepository();
- } else {
- return null;
}
+ return null;
+
}
// see comment at setMasterRepositoryId(String id)
@Override
public LocalStatus getLocalStatus() {
- if (isNexusStarted || isMasterAvailable) {
+ if (isNexusStarted && isMasterAvailable) {
return super.getLocalStatus();
} else {
- if (getCurrentConfiguration(false).getLocalStatus() == null) {
+ String localStatus = getCurrentConfiguration(false).getLocalStatus();
+ if (localStatus == null) {
return LocalStatus.OUT_OF_SERVICE;
}
- return LocalStatus.valueOf(getCurrentConfiguration(false).getLocalStatus());
+ return LocalStatus.valueOf(localStatus);
}
}
@Subscribe
public void onNexusStartedEvent(NexusStartedEvent evt) {
+ if (!isMasterAvailable) {
+ String repositoryId = getExternalConfiguration(false).getMasterRepositoryId();
+ try {
+ getLogger().info("setting master repository with id '" + repositoryId + "'");
+ setMasterRepositoryId(repositoryId);
+ } catch (NoSuchRepositoryException e) {
+ getLogger().error("[" + repositoryId + "] " + "cannot set master repository " + e.getMessage());
+
+ } catch (IncompatibleMasterRepositoryException e) {
+ getLogger().error("[" + repositoryId + "] " + "cannot set master repository " + e.getMessage());
+ }
+ }
isNexusStarted = true;
}
diff --git a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryResourceBundle.java b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryResourceBundle.java
index 4e766cd..13afda5 100644
--- a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryResourceBundle.java
+++ b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/UnzipRepositoryResourceBundle.java
@@ -14,16 +14,14 @@ import java.util.ArrayList;
import java.util.List;
import org.codehaus.plexus.component.annotations.Component;
-import org.sonatype.nexus.plugins.rest.AbstractNexusResourceBundle;
import org.sonatype.nexus.plugins.rest.DefaultStaticResource;
import org.sonatype.nexus.plugins.rest.NexusResourceBundle;
import org.sonatype.nexus.plugins.rest.StaticResource;
@Component(role = NexusResourceBundle.class, hint = "UnzipRepositoryResourceBundle")
-public class UnzipRepositoryResourceBundle extends AbstractNexusResourceBundle {
+public class UnzipRepositoryResourceBundle implements NexusResourceBundle {
public static final String JS_SCRIPT_PATH = "js/unzip/unzip-repo.js";
- @Override
public List<StaticResource> getContributedResouces() {
final List<StaticResource> result = new ArrayList<StaticResource>();
diff --git a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestReleaseRequest.java b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestReleaseRequest.java
index 3da8293..00d3474 100644
--- a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestReleaseRequest.java
+++ b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestReleaseRequest.java
@@ -14,19 +14,20 @@ import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.versioning.VersionRange;
import org.sonatype.nexus.proxy.ItemNotFoundException;
import org.sonatype.nexus.proxy.LocalStorageException;
+import org.sonatype.nexus.proxy.ResourceStoreRequest;
import org.sonatype.nexus.proxy.repository.Repository;
public class LatestReleaseRequest extends ParsedRequest {
- private final String requestPath;
+ private final ResourceStoreRequest request;
private final String groupArtifactPath;
private final String artifactNameStart;
private final String artifactNameEnd;
private final VersionRange versionRange;
- public LatestReleaseRequest(final String requestPath, final String groupArtifactPath,
+ public LatestReleaseRequest(final ResourceStoreRequest request, final String groupArtifactPath,
final String artifactNameStart, final String artifactNameEnd, final VersionRange versionRange) {
- this.requestPath = requestPath;
+ this.request = request;
this.groupArtifactPath = groupArtifactPath;
this.artifactNameStart = artifactNameStart;
this.artifactNameEnd = artifactNameEnd;
@@ -35,6 +36,7 @@ public class LatestReleaseRequest extends ParsedRequest {
@Override
ConversionResult resolve(final Repository repository) throws LocalStorageException {
+ final String requestPath = request.getRequestPath();
try {
final Versioning versioning = getVersioning(repository, metadataPath(groupArtifactPath + "/"));
final String releaseVersion = versioning.getRelease();
@@ -42,7 +44,7 @@ public class LatestReleaseRequest extends ParsedRequest {
return new ConversionResult(requestPath);
}
- final String selectedVersion = selectVersion(versioning, versionRange, false);
+ final String selectedVersion = selectVersion(request, versioning, versionRange, false);
final String releaseVersionDirectory = groupArtifactPath + "/" + selectedVersion + "/";
diff --git a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestVersionRequest.java b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestVersionRequest.java
index 047c731..452d9b5 100644
--- a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestVersionRequest.java
+++ b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/LatestVersionRequest.java
@@ -15,6 +15,7 @@ import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.versioning.VersionRange;
import org.sonatype.nexus.proxy.ItemNotFoundException;
import org.sonatype.nexus.proxy.LocalStorageException;
+import org.sonatype.nexus.proxy.ResourceStoreRequest;
import org.sonatype.nexus.proxy.repository.Repository;
public class LatestVersionRequest extends ParsedRequest {
@@ -36,15 +37,15 @@ public class LatestVersionRequest extends ParsedRequest {
* /org/eclipse/tycho/example/org.eclipse.tycho.example.p2repo/0.1.0/org.eclipse.tycho.example.
* p2repo-0.1.0-assembly.zip-unzip/
*/
- private final String requestPath;
+ final ResourceStoreRequest request;
private final String groupArtifactPath;
private final String artifactNameStart;
private final String artifactNameEnd;
private final VersionRange versionRange;
- public LatestVersionRequest(final String requestPath, final String groupArtifactPath,
+ public LatestVersionRequest(final ResourceStoreRequest request, final String groupArtifactPath,
final String artifactNameStart, final String artifactNameEnd, final VersionRange versionRange) {
- this.requestPath = requestPath;
+ this.request = request;
this.groupArtifactPath = groupArtifactPath;
this.artifactNameStart = artifactNameStart;
this.artifactNameEnd = artifactNameEnd;
@@ -53,10 +54,11 @@ public class LatestVersionRequest extends ParsedRequest {
@Override
ConversionResult resolve(final Repository repository) throws LocalStorageException {
+ final String requestPath = request.getRequestPath();
try {
final Versioning versioning = getVersioning(repository, metadataPath(groupArtifactPath + "/"));
- final String selectedVersion = selectVersion(versioning, versionRange, true);
+ final String selectedVersion = selectVersion(request, versioning, versionRange, true);
final String latestVersionDirectory = groupArtifactPath + "/" + selectedVersion + "/";
if (selectedVersion.endsWith("-SNAPSHOT")) {
@@ -86,8 +88,8 @@ public class LatestVersionRequest extends ParsedRequest {
latestVersion.length() - "-SNAPSHOT".length());
final String pathUpToVersion = latestVersionDirectory + artifactNameStart + "-" + latestVersionWithoutSnapshot;
final String convertedPath = pathUpToVersion + "-" + latestTimestampVersion + artifactNameEnd;
- return new ConversionResult(requestPath, convertedPath, latestVersion + "-" + latestTimestampVersion,
- pathUpToVersion);
+ return new ConversionResult(request.getRequestPath(), convertedPath, latestVersion + "-"
+ + latestTimestampVersion, pathUpToVersion);
}
}
diff --git a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/ParsedRequest.java b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/ParsedRequest.java
index 4ec69da..3a50abd 100644
--- a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/ParsedRequest.java
+++ b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/ParsedRequest.java
@@ -66,11 +66,10 @@ abstract class ParsedRequest {
}
}
- @SuppressWarnings("deprecation")
- String selectVersion(final Versioning versioning, final VersionRange versionRange, final boolean findSnapshots)
- throws ItemNotFoundException {
+ String selectVersion(final ResourceStoreRequest request, final Versioning versioning,
+ final VersionRange versionRange, final boolean findSnapshots) throws ItemNotFoundException {
// do not rely on LATEST and RELEASE tag, because they not necessarily correspond to highest version number
- String selectedVersion = getLatestVersion(versioning, findSnapshots);
+ String selectedVersion = getLatestVersion(request, versioning, findSnapshots);
if (versionRange != null && !versionRange.containsVersion(new DefaultArtifactVersion(selectedVersion))) {
final List<ArtifactVersion> versions = new ArrayList<ArtifactVersion>();
@@ -83,15 +82,16 @@ abstract class ParsedRequest {
if (matchedVersion != null) {
selectedVersion = matchedVersion.toString();
} else {
- throw new ItemNotFoundException("No version found within range");
+ throw new ItemNotFoundException(ItemNotFoundException.reasonFor(request,
+ "No version found within range"));
+
}
}
return selectedVersion;
}
- @SuppressWarnings("deprecation")
- private static String getLatestVersion(final Versioning versioning, final boolean findSnapshots)
- throws ItemNotFoundException {
+ private static String getLatestVersion(final ResourceStoreRequest request, final Versioning versioning,
+ final boolean findSnapshots) throws ItemNotFoundException {
final List<ArtifactVersion> artifactVersions = new ArrayList<ArtifactVersion>();
for (final String version : versioning.getVersions()) {
if (!findSnapshots && !version.trim().endsWith("-SNAPSHOT")) {
@@ -103,7 +103,8 @@ abstract class ParsedRequest {
ArtifactVersion maxVersion = null;
if (artifactVersions.isEmpty()) {
- throw new ItemNotFoundException("maven-metadata.xml does not contain any version");
+ throw new ItemNotFoundException(ItemNotFoundException.reasonFor(request,
+ "maven-metadata.xml does not contain any version"));
}
maxVersion = Collections.max(artifactVersions);
return ((DefaultArtifactVersion) maxVersion).toString();
diff --git a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/RequestPathConverter.java b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/RequestPathConverter.java
index b759db4..597e950 100644
--- a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/RequestPathConverter.java
+++ b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/cache/RequestPathConverter.java
@@ -78,7 +78,7 @@ public class RequestPathConverter {
final VersionRange versionRange = parseVersionRange(request);
- return new LatestVersionRequest(requestPath, groupArtifactPath, artifactNameStart, artifactNameEnd,
+ return new LatestVersionRequest(request, groupArtifactPath, artifactNameStart, artifactNameEnd,
versionRange);
}
@@ -89,7 +89,7 @@ public class RequestPathConverter {
final String artifactNameStart = matchResult.group(1);
final String artifactNameEnd = requestPath.substring(matchResult.end() - 1);
final VersionRange versionRange = parseVersionRange(request);
- return new LatestReleaseRequest(requestPath, groupArtifactPath, artifactNameStart, artifactNameEnd,
+ return new LatestReleaseRequest(request, groupArtifactPath, artifactNameStart, artifactNameEnd,
versionRange);
}
}
diff --git a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/storage/ZippedItem.java b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/storage/ZippedItem.java
index c9efb05..fe60216 100644
--- a/src/main/java/org/eclipse/tycho/nexus/internal/plugin/storage/ZippedItem.java
+++ b/src/main/java/org/eclipse/tycho/nexus/internal/plugin/storage/ZippedItem.java
@@ -242,7 +242,8 @@ public class ZippedItem {
}
}
- throw new ItemNotFoundException(new ResourceStoreRequest(getPath()));
+ throw new ItemNotFoundException(ItemNotFoundException.reasonFor(new ResourceStoreRequest(getPath()),
+ "the path within the zip file does not point to an existing zip entry"));
}
/**