Commit 2bbd6e83 authored by Maxym Borodenko's avatar Maxym Borodenko
Browse files

MVC: view accession by UUID

parent bb2bebfd
......@@ -25,6 +25,7 @@ import java.util.UUID;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.genesys.blocks.auditlog.service.AuditTrailService;
import org.genesys.catalog.service.DatasetService;
import org.genesys.filerepository.InvalidRepositoryPathException;
......@@ -39,6 +40,7 @@ import org.genesys2.server.model.genesys.AccessionId;
import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.AccessionService;
import org.genesys2.server.service.DSService;
import org.genesys2.server.service.DownloadService;
import org.genesys2.server.service.FilterConstants;
......@@ -57,6 +59,7 @@ import org.springframework.http.MediaType;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -104,6 +107,9 @@ public class AccessionController extends BaseController {
@Autowired
private DatasetService datasetService;
@Autowired
private AccessionService accessionService;
@Value("${base.url}")
private String baseUrl;
......@@ -255,6 +261,20 @@ public class AccessionController extends BaseController {
return "/accession/resolve";
}
@GetMapping(value = "/{UUID:\\w{8}\\-\\w{4}.+}")
public String viewAccessionByUUID(final ModelMap model, @PathVariable("UUID") final UUID uuid) {
final Accession accession = accessionService.getByUuid(uuid);
if (accession == null) {
throw new ResourceNotFoundException();
}
if (StringUtils.isNotEmpty(accession.getDoi())) {
return "redirect:/" + accession.getDoi();
} else {
return "redirect:/acn/id/" + accession.getId();
}
}
/**
* View by Taxonomy
*
......
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