Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.acme.controller;

import io.quarkus.logging.Log;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.security.identity.SecurityIdentity;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
Expand All @@ -16,17 +18,21 @@
import org.acme.functions.AccountHooks;
import org.acme.model.dto.Auth.AccountHookRequest;
import org.acme.model.dto.Auth.AccountHookResponse;
import org.acme.service.ExampleScreenerExportService;

@Path("/api")
public class AccountResource {

@Inject
AccountHooks accountHooks;

@Inject
ExampleScreenerExportService exampleScreenerExportService;

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/account-hooks")
@Path("/account/hooks")
public Response accountHooks(@Context SecurityIdentity identity,
AccountHookRequest request) {

Expand Down Expand Up @@ -61,4 +67,47 @@ public Response accountHooks(@Context SecurityIdentity identity,

return Response.ok(responseBody).build();
}

@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/account/export-example-screener")
public Response exportExampleScreener(@Context SecurityIdentity identity) {
String userId = AuthUtils.getUserId(identity);

if (userId == null) {
return Response.status(Response.Status.UNAUTHORIZED)
.entity(new ApiError(true, "Unauthorized.")).build();
}

if (LaunchMode.current() != LaunchMode.DEVELOPMENT) {
return Response.status(Response.Status.NOT_FOUND).build();
}

try {
ExampleScreenerExportService.ExportSummary summary = exampleScreenerExportService
.exportForUser(userId);
return Response.ok(
Map.of(
"success",
true,
"outputPath",
summary.outputPath(),
"screenerCount",
summary.screenerCount(),
"firestoreDocuments",
summary.firestoreDocuments(),
"storageFiles",
summary.storageFiles()))
.build();
} catch (Exception e) {
Log.error(
"Failed to export example screener seed data for user "
+ userId,
e);
return Response.serverError().entity(
new ApiError(true,
"Failed to export example screener seed data."))
.build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import java.util.List;

import org.acme.service.ExampleScreenerImportService;

@ApplicationScoped
Expand All @@ -14,8 +16,11 @@ public class AccountHooks {
public Boolean addExampleScreenerToAccount(String userId) {
try {
Log.info("Running ADD_EXAMPLE_SCREENER hook for user: " + userId);
String screenerId = exampleScreenerImportService.importForUser(userId);
Log.info("Imported example screener " + screenerId + " for user " + userId);
List<String> screenerIds = exampleScreenerImportService
.importForUser(userId);
Log.info(
"Imported example screeners " + screenerIds + " for user "
+ userId);
return true;
} catch (Exception e) {
Log.error(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.acme.model.dto.ExampleScreener;

import java.util.List;

public record Manifest(List<ScreenerManifest> screeners,
List<String> workingCustomChecks, List<String> publishedCustomChecks,
List<String> dmnPaths) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.acme.model.dto.ExampleScreener;

import java.util.List;

public record ScreenerManifest(String screenerPath, List<String> benefits,
String formSchema) {
}
Loading