CrudLug3Resource.java
/*
* Copyright © 2026 The CTAN Team and individual authors
*
* This file is distributed under the 3-clause BSD license.
* See file LICENSE for details.
*/
package org.ctan.site.resources.admin;
import org.ctan.site.domain.site.Lug;
import org.ctan.site.stores.LugStore;
import org.ctan.site.stores.base.GeneralPage;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.dropwizard.hibernate.UnitOfWork;
import jakarta.ws.rs.GET;
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 lombok.NonNull;
/**
* The class <code>CrudLug3Resource</code> contains the CRUD controller for the
* LUGs resource.
*
* @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
*/
@Path("/3.0/admin")
@Produces(MediaType.APPLICATION_JSON)
// TODO @RolesAllowed("ADMIN")
public class CrudLug3Resource {
/**
* The field <code>store</code> contains the underlying store.
*/
private LugStore store;
/**
* This is the constructor for the class <code>CrudLug3Resource</code>.
*
* @param store the underlying store
*/
@SuppressFBWarnings(value = {"CT_CONSTRUCTOR_THROW", "EI_EXPOSE_REP2"})
public CrudLug3Resource(@NonNull LugStore store) {
this.store = store;
}
/*
* The method <code>create</code> provides an end-point to create a stop
* word.
*
* @param lug the LUG to store
*
* @return the updated LUG
*/
// @POST
// @Path("/lug")
// @UnitOfWork(value = "siteDb")
// public Lug create(@NonNull Lug lug) {
//
// return store.save(lug);
// }
/**
* The method <code>retrieve</code> provides means to retrieve a stop word.
*
* @param code the code
* @return {@code true} iff the user exists
*/
@GET
@Path("/lug/{code}")
@UnitOfWork(value = "siteDb")
public Lug get(@NonNull @PathParam("code") String code) {
return store.getByKey(code);
}
/**
* The method <code>list</code> provides means to retrieve a page of LUGs.
*
* @param q the name pattern
* @param page the page
* @param size the page size
* @param orderBy the order
* @param asc the indicator for ascending
* @return the page for the LUGs or {@code null}
*/
@GET
@Path("/lugs")
@UnitOfWork(value = "siteDb")
public GeneralPage list(@QueryParam("q") String q,
@QueryParam("page") int page,
@QueryParam("size") int size,
@QueryParam("order") String orderBy,
@QueryParam("asc") boolean asc) {
return store.list(q, page - 1, size, orderBy, asc);
}
/*
* The method <code>remove</code> provides an end-point to remove a LUG.
*
* @param id the id
*
* @return {@code true} iff the LUG has existed
*/
// @DELETE
// @Path("/lug/{id}")
// @UnitOfWork(value = "siteDb")
// public boolean remove(@NonNull @PathParam("id") Long id) {
//
// return store.remove(id);
// }
}