Skip to content

Commit

Permalink
Merge pull request mvnpm#1551 from phillip-kruger/main
Browse files Browse the repository at this point in the history
Use buld status check
  • Loading branch information
phillip-kruger authored Nov 10, 2023
2 parents 3dd192c + c3651b5 commit 2bc2f56
Show file tree
Hide file tree
Showing 25 changed files with 585 additions and 354 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.mvnpm</groupId>
<artifactId>mvnpm</artifactId>
<version>3.0.2-SNAPSHOT</version>
<version>3.0.6-SNAPSHOT</version>

<name>mvnpm</name>
<description>Maven on NPM</description>
Expand Down Expand Up @@ -56,7 +56,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.5.0</quarkus.platform.version>
<quarkus.platform.version>3.5.1</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<formatter.plugin.version>2.23.0</formatter.plugin.version>
Expand Down
22 changes: 9 additions & 13 deletions src/main/java/io/mvnpm/log/EventLogApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam;

import io.mvnpm.mavencentral.sync.*;
import io.mvnpm.mavencentral.sync.CentralSyncItem;
import io.quarkus.logging.Log;
import io.quarkus.panache.common.Sort;
import io.quarkus.vertx.ConsumeEvent;
Expand Down Expand Up @@ -67,30 +67,21 @@ private void broadcast(EventLogEntry eventLogEntry) {
@Transactional
public void stateChange(CentralSyncItem centralSyncItem) {
EventLogEntry eventLogEntry = EventLogEntryUtil.toEventLogEntry(centralSyncItem);
eventLogEntry.persistAndFlush();
broadcast(eventLogEntry);
}

@ConsumeEvent("error-in-workflow")
@Blocking
@Transactional
public void error(CentralSyncItem centralSyncItem) {
EventLogEntry eventLogEntry = EventLogEntryUtil.toEventLogEntry(centralSyncItem, "error in workflow", "red");
eventLogEntry.persistAndFlush();
eventLogEntry.persist();
broadcast(eventLogEntry);
}

@ConsumeEvent("exception-in-code")
@Blocking
@Transactional
public void exception(EventLogEntry eventLogEntry) {
eventLogEntry.persistAndFlush();
eventLogEntry.persist();
broadcast(eventLogEntry);
}

@GET
@Path("/top")
public List<EventLogEntry> getTop(@QueryParam("limit") @DefaultValue("2000") int limit) {
public List<EventLogEntry> getTop(@QueryParam("limit") @DefaultValue("999") int limit) {
return EventLogEntry.findAll(Sort.by("time")).range(0, limit).list();
}

Expand All @@ -100,4 +91,9 @@ public List<EventLogEntry> getGavLog(@PathParam("groupId") String groupId, @Path
@PathParam("version") String version) {
return EventLogEntry.findByGav(groupId, artifactId, version);
}

@Transactional
public void clearLog() {
EventLogEntry.deleteAll();
}
}
19 changes: 10 additions & 9 deletions src/main/java/io/mvnpm/log/EventLogEntryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static io.mvnpm.mavencentral.sync.Stage.UPLOADING;

import io.mvnpm.mavencentral.sync.CentralSyncItem;
import io.mvnpm.mavencentral.sync.Stage;

public class EventLogEntryUtil {

Expand All @@ -17,7 +16,7 @@ private EventLogEntryUtil() {

public static EventLogEntry toEventLogEntry(CentralSyncItem centralSyncItem) {
return EventLogEntryUtil.toEventLogEntry(centralSyncItem,
EventLogEntryUtil.generateMessage(centralSyncItem.stage));
EventLogEntryUtil.generateMessage(centralSyncItem));
}

public static EventLogEntry toEventLogEntry(CentralSyncItem centralSyncItem, String message) {
Expand All @@ -37,15 +36,17 @@ public static EventLogEntry toEventLogEntry(CentralSyncItem centralSyncItem, Str
return eventLogEntry;
}

private static String generateMessage(Stage stage) {
return switch (stage) {
private static String generateMessage(CentralSyncItem centralSyncItem) {
return switch (centralSyncItem.stage) {
case INIT -> "Syncing initialized";
case UPLOADING -> "Uploading to OSS sonatype";
case UPLOADED -> "Uploaded to OSS sonatype, now validating";
case CLOSED -> "Closed and validated. Will be auto releasing soon";
case RELEASING -> "Closed, now releasing to Maven central";
case UPLOADING -> "Uploading to OSS sonatype (" + centralSyncItem.uploadAttempts + ")";
case UPLOADED -> "Uploaded to OSS sonatype, now validating (" + centralSyncItem.promotionAttempts + ")";
case CLOSED -> "Closed and validated. Will be auto releasing soon (" + centralSyncItem.promotionAttempts + ")";
case RELEASING -> "Closed, now releasing to Maven central (" + centralSyncItem.promotionAttempts + ")";
case RELEASED -> "Released to Maven central";
default -> stage.name().toLowerCase();
case ERROR -> "Error in workflow after " + centralSyncItem.uploadAttempts + " upload and "
+ centralSyncItem.promotionAttempts + " promotion attempts";
default -> centralSyncItem.stage.name().toLowerCase();
};

}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/mvnpm/mavencentral/RepoStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public enum RepoStatus {
open,
closed,
released
released,
error
}
24 changes: 24 additions & 0 deletions src/main/java/io/mvnpm/mavencentral/SearchException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.mvnpm.mavencentral;

public class SearchException extends Exception {

public SearchException() {
}

public SearchException(String message) {
super(message);
}

public SearchException(String message, Throwable cause) {
super(message, cause);
}

public SearchException(Throwable cause) {
super(cause);
}

public SearchException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

}
27 changes: 0 additions & 27 deletions src/main/java/io/mvnpm/mavencentral/SearchMavenClient.java

This file was deleted.

18 changes: 18 additions & 0 deletions src/main/java/io/mvnpm/mavencentral/SonatypeClient.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package io.mvnpm.mavencentral;

import java.time.temporal.ChronoUnit;

import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.eclipse.microprofile.faulttolerance.Timeout;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import io.vertx.core.json.JsonObject;
Expand All @@ -25,6 +29,7 @@ public interface SonatypeClient {
@POST
@Path("/service/local/staging/bundle_upload")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Timeout(unit = ChronoUnit.SECONDS, value = 240)
public Response uploadBundle(@HeaderParam("Authorization") String authorization, byte[] b);

@GET
Expand All @@ -33,6 +38,11 @@ public interface SonatypeClient {
public Response uploadBundleStatus(@HeaderParam("Authorization") String authorization,
@PathParam("stagingRepoId") String stagingRepoId);

@GET
@Path("/service/local/staging/profile_repositories")
@Produces(MediaType.APPLICATION_JSON)
public Response uploadBundleStatuses(@HeaderParam("Authorization") String authorization);

@POST
@Path("/service/local/staging/profiles/{profileId}/promote")
@Consumes(MediaType.APPLICATION_JSON)
Expand All @@ -46,4 +56,12 @@ public Response releaseToCentral(@HeaderParam("Authorization") String authorizat
public Response getStagingProfileRepos(@HeaderParam("Authorization") String authorization,
@PathParam("profileId") String profileId);

@GET
@Path("/service/local/lucene/search")
@Produces(MediaType.APPLICATION_JSON)
public Response search(@HeaderParam("Authorization") String authorization,
@QueryParam("g") String g,
@QueryParam("a") String a,
@QueryParam("v") String v);

}
Loading

0 comments on commit 2bc2f56

Please sign in to comment.