Skip to content

Commit fa94299

Browse files
authored
Merge pull request #142 from mcanoy/migrate-engagements
Migrate engagements
2 parents ce15a84 + 314ecc9 commit fa94299

File tree

7 files changed

+202
-104
lines changed

7 files changed

+202
-104
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
<maven.compiler.target>11</maven.compiler.target>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
17-
<quarkus-plugin.version>1.11.3.Final</quarkus-plugin.version>
17+
<quarkus-plugin.version>1.13.7.Final</quarkus-plugin.version>
1818
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
1919
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
20-
<quarkus.platform.version>1.11.3.Final</quarkus.platform.version>
20+
<quarkus.platform.version>1.13.7.Final</quarkus.platform.version>
2121
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
2222
<lombok.version>1.18.12</lombok.version>
2323
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

src/main/java/com/redhat/labs/lodestar/resource/EngagementResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public Response findAllEngagements(@Context UriInfo uriInfo, @QueryParam("pagina
8888
includeCommits);
8989
builder.entity(ePage.getEngagements());
9090
builder.links(ePage.getLinks(uriInfo.getAbsolutePathBuilder()));
91-
ePage.getHeaders().entrySet().stream().forEach(e -> builder.header(e.getKey(), e.getValue()));
91+
ePage.getHeaders().entrySet().forEach(e -> builder.header(e.getKey(), e.getValue()));
9292

9393
} else {
9494
builder.entity(engagementService.getAllEngagements(includeStatus, includeCommits));

src/main/java/com/redhat/labs/lodestar/resource/MigrationResource.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,46 @@
33
import javax.inject.Inject;
44
import javax.ws.rs.PUT;
55
import javax.ws.rs.Path;
6+
import javax.ws.rs.Produces;
67
import javax.ws.rs.QueryParam;
78
import javax.ws.rs.core.Response;
89

910
import org.eclipse.microprofile.metrics.MetricUnits;
10-
import org.eclipse.microprofile.metrics.annotation.Counted;
1111
import org.eclipse.microprofile.metrics.annotation.Timed;
1212
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
1313

1414
import com.redhat.labs.lodestar.service.MigrationService;
15+
import org.slf4j.Logger;
16+
import org.slf4j.LoggerFactory;
17+
18+
import java.util.List;
1519

1620
@Path("/api/migrate")
17-
@Tag(name = "Migration", description = "Migratiion services")
21+
@Tag(name = "Migration", description = "Migration services")
1822
public class MigrationResource {
23+
private static final Logger LOGGER = LoggerFactory.getLogger(MigrationResource.class);
1924

2025
@Inject
2126
MigrationService migrationService;
2227

2328
@PUT
24-
@Counted(name = "migration", description = "How many migation requests have been invoked")
2529
@Timed(name = "performedMigration", description = "How much time it takes to migrate", unit = MetricUnits.MILLISECONDS)
30+
@Produces("application/json")
2631
public Response migrate(@QueryParam(value = "participants") boolean migrateParticipants,
27-
@QueryParam(value = "artifacts") boolean migrateArtifacts,
28-
@QueryParam(value = "uuids") boolean migrateUuids, @QueryParam(value = "hosting") boolean migrateHosting) {
29-
30-
migrationService.migrate(migrateUuids, migrateParticipants, migrateArtifacts, migrateHosting);
32+
@QueryParam("artifacts") boolean migrateArtifacts,
33+
@QueryParam("projects") boolean migrateUuids,
34+
@QueryParam("hosting") boolean migrateHosting,
35+
@QueryParam("engagements") boolean migrateEngagements,
36+
@QueryParam("overwrite") boolean overwrite,
37+
@QueryParam("uuids") List<String> uuids) {
38+
39+
try {
40+
migrationService.migrate(migrateUuids, migrateParticipants, migrateArtifacts, migrateHosting, migrateEngagements,
41+
overwrite, uuids);
42+
} catch (Exception ex) {
43+
LOGGER.error("Migration did not complete successfully", ex);
44+
return Response.status(Response.Status.BAD_REQUEST).entity("{ \"message\": \"Migration did not complete successfully\"}").build();
45+
}
3146

3247
return Response.ok().build();
3348

src/main/java/com/redhat/labs/lodestar/service/FileService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ public Optional<File> createFile(Integer projectId, String filePath, File file)
5252
// create multiple files
5353
public boolean createFiles(Integer projectId, CommitMultiple commit) {
5454

55-
Response response = null;
56-
5755
// encode actions in commit
5856
commit.encodeActions();
5957

6058
// call gitlab api to commit
61-
response = gitLabService.commitMultipleFiles(projectId, commit);
59+
Response response = gitLabService.commitMultipleFiles(projectId, commit);
6260

6361
// decode actions in commit
6462
commit.decodeActions();
@@ -105,7 +103,7 @@ public Optional<File> deleteFile(Integer projectId, String filePath, String ref)
105103
// set branch
106104
file.setBranch(ref);
107105
// add commit message
108-
file.setCommitMessage(String.format("git api deleted file. {}", filePath));
106+
file.setCommitMessage(String.format("git api deleted file. %s", filePath));
109107

110108
gitLabService.deleteFile(projectId, filePath, file);
111109
}

0 commit comments

Comments
 (0)