Commit 80d02015 authored by Matija Obreza's avatar Matija Obreza

Fixed APIv1 /acn/details/{DOI} paths

parent 424c8e37
......@@ -22,8 +22,6 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.genesys.blocks.model.JsonViews;
import org.genesys.catalog.api.FilteredPage;
import org.genesys.catalog.model.dataset.Dataset;
......@@ -47,8 +45,14 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.HandlerMapping;
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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.core.JsonParseException;
......@@ -111,13 +115,10 @@ public class AccessionController {
* @param uuid the uuid
* @return the subset
*/
@RequestMapping(value = "/10.{dummy:[0-9]+}/**", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/10.{doi1:[0-9]+}/{doi2:.+}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
@JsonView({ JsonViews.Protected.class })
public Accession getByDoi(HttpServletRequest request) {
final String fullpath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
final String doi = fullpath.substring(API_BASE.length() + 1);
return accessionService.getByDoi(doi);
public Accession getByDoi(@PathVariable("doi1") String doi1, @PathVariable("doi2") String doi2) {
return accessionService.getByDoi("10." + doi1 + "/" + doi2);
}
/**
......@@ -172,6 +173,7 @@ public class AccessionController {
/**
* Converts AccessionIdentifiers to UUID
*
* @param identifiers accession identifiers to lookup in DB
* @return map with UUIDs and related AccessionIdentifiers
*/
......@@ -180,18 +182,14 @@ public class AccessionController {
return accessionService.toUUID(identifiers);
}
@RequestMapping(value = "/details/10.{dummy:[0-9]+}/**}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/details/10.{doi1:[0-9]+}/{doi2:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@JsonView(JsonViews.Public.class)
public AccessionDetailsJson getAccessionDetailsByDoi(HttpServletRequest request) {
final String fullPath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
final String doi = fullPath.substring(API_BASE.length() + 1);
Accession accession = accessionService.getByDoi(doi);
return getAccessionDetails(accession);
public AccessionDetailsJson getAccessionDetailsByDoi(@PathVariable("doi1") String doi1, @PathVariable("doi2") String doi2) {
Accession accession = accessionService.getByDoi("10." + doi1 + "/" + doi2);
return getAccessionDetails(accession);
}
@GetMapping(value="/details/{UUID}", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "/details/{UUID:\\w{8}\\-\\w{4}.+}", produces = MediaType.APPLICATION_JSON_VALUE)
@JsonView(JsonViews.Public.class)
public AccessionDetailsJson getAccessionDetailsByUUID(@PathVariable("UUID") final UUID uuid) {
Accession accession = accessionService.getByUuid(uuid);
......@@ -259,7 +257,7 @@ public class AccessionController {
}
if (filter.holder != null) {
AccessionFilter modifiedFilter = copyFilter(filter);
AccessionFilter modifiedFilter = copyFilter(filter);
modifiedFilter.holder = null;
termResults.putAll(elasticsearchService.termStatisticsAuto(Accession.class, modifiedFilter, 10, "institute.code", "institute.country.code3"));
}
......
......@@ -34,6 +34,7 @@ log4j.category.liquibase=debug
#log4j.category.org.hibernate.cfg.Configuration=debug
#log4j.category.org.hibernate.search=debug
#log4j.category.org.apache.tomcat.jdbc.pool=debug
#log4j.category.org.springframework.web.servlet.mvc=trace
#log4j.category.org.springframework.jdbc.core.JdbcTemplate=debug
#log4j.category.org.springframework.security.oauth2=trace
#log4j.category.org.springframework.security.access=trace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment