net.aequologica.neo.buildhub.jaxrs.Resource Maven / Gradle / Ivy
package net.aequologica.neo.buildhub.jaxrs;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.aequologica.neo.buildhub.neo.document.BuildSerializer;
import net.aequologica.neo.buildhub.persist.model.Build;
import net.aequologica.neo.buildhub.service.BuildService;
@Singleton
@javax.ws.rs.Path("v1")
public class Resource {
@Inject
BuildService buildService;
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(Resource.class);
@POST
@javax.ws.rs.Path("archive")
@Produces(MediaType.APPLICATION_JSON)
public Response archiveAll() throws IOException {
try {
buildService.archiveAll();
return Response.noContent().build();
} catch (IOException e) {
throw new WebApplicationException("error archiving", e, Status.INTERNAL_SERVER_ERROR);
}
}
@POST
@javax.ws.rs.Path("store/{buildId: [\\-a-zA-Z_0-9]+}")
@Produces(MediaType.APPLICATION_JSON)
public Response archive(@PathParam("buildId") final String buildIdAsAString) throws IOException {
try {
final UUID buildId = BuildSerializer.uuidFromString(buildIdAsAString);
buildService.archive(buildId);
return Response.noContent().build();
} catch (IOException e) {
throw new WebApplicationException("error archiving", e, Status.INTERNAL_SERVER_ERROR);
}
}
@GET
@javax.ws.rs.Path("history")
@Produces(MediaType.APPLICATION_JSON)
public List all() throws IOException {
return buildService.all();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy