RetractedDOIController.java
/*
* Copyright 2026 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys.server.api.v2.impl;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.genesys.blocks.annotations.PrettyEndpointPath;
import org.genesys.server.api.ApiBaseController;
import org.genesys.server.api.v2.FilteredCRUDController;
import org.genesys.server.api.v2.MultiOp;
import org.genesys.server.api.v2.facade.RetractedDOIApiService;
import org.genesys.server.api.v2.model.impl.RetractedDOIDTO;
import org.genesys.server.model.filters.RetractedDOIFilter;
import org.genesys.server.model.impl.RetractedDOI;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.HandlerMapping;
import io.swagger.v3.oas.annotations.Operation;
@RestController("doiApi2")
@RequestMapping(RetractedDOIController.CONTROLLER_URL)
@PreAuthorize("isAuthenticated()")
public class RetractedDOIController extends FilteredCRUDController<RetractedDOIDTO, RetractedDOI, RetractedDOIApiService, RetractedDOIFilter> {
public static final String CONTROLLER_URL = ApiBaseController.APIv2_BASE + "/doi";
/**
* Retract DOI will record the specified DOIs in the registry <b>and clear existing DOIs</b>
* of the accessions that use the newly retracted DOIs.
* @param retractedDOIs List of retractions
* @return the registered retractions
*/
@PostMapping(value = "/retract/details", consumes = MediaType.APPLICATION_JSON_VALUE)
public List<RetractedDOIDTO> retractWithDetails(@RequestBody List<RetractedDOIDTO> retractedDOIs) {
return serviceFacade.retractDOIWithDetails(retractedDOIs);
}
/**
* Retract DOI will record the specified DOIs in the registry <b>and clear existing DOIs</b>
* of the accessions that use the newly retracted DOIs.
* @param retractedDOIs List of DOIs to retract
* @return the registered retractions
*/
@PostMapping(value = "/retract", consumes = MediaType.APPLICATION_JSON_VALUE)
public List<RetractedDOIDTO> retract(@RequestBody List<String> retractedDOIs) {
return serviceFacade.retractDOI(retractedDOIs);
}
/**
* Check for retraction record for the specified DOI.
* @param doi the DOI
* @return 404 if no retraction exists for this DOI
*/
@GetMapping(value = "/retracted/10.{doi:[0-9]+}/**", produces = { MediaType.APPLICATION_JSON_VALUE })
@PrettyEndpointPath("/retracted/{*doi}")
public RetractedDOIDTO getRetracted(final HttpServletRequest request, @PathVariable("doi") String doi) {
final String doi1 = ((String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).substring((CONTROLLER_URL + "/retracted/").length());
return serviceFacade.get(doi1);
}
// Hide the unsupported endpoints
@Override
@Operation(hidden = true)
public RetractedDOIDTO create(@Valid @NotNull RetractedDOIDTO entity) {
return super.create(entity);
}
@Override
@Operation(hidden = true)
public MultiOp<RetractedDOIDTO> createMany(@Valid @NotNull List<RetractedDOIDTO> inserts) {
return super.createMany(inserts);
}
@Override
@Operation(hidden = true)
public RetractedDOIDTO update(RetractedDOIDTO entity) {
return super.update(entity);
}
@Override
@Operation(hidden = true)
public MultiOp<RetractedDOIDTO> updateMany(@Valid @NotNull List<RetractedDOIDTO> updates) {
return super.updateMany(updates);
}
@Override
@Operation(hidden = true)
public MultiOp<RetractedDOIDTO> upsertMany(@Valid @NotNull List<RetractedDOIDTO> updates) {
return super.upsertMany(updates);
}
}