use of org.ambraproject.wombat.identity.RequestedDoiVersion in project wombat by PLOS.
the class ArticleController method uploadPreprintRevision.
@RequestMapping(name = "uploadPreprintRevision", value = "/article/uploadPreprintRevision")
public String uploadPreprintRevision(HttpServletRequest request, Model model, @SiteParam Site site, @RequestParam("state") String state, @RequestParam("code") String code) throws IOException, URISyntaxException {
final byte[] decodedState = Base64.getDecoder().decode(state);
final String decodedJson = URLDecoder.decode(new String(decodedState), "UTF-8");
Map<String, Object> stateJson = gson.fromJson(decodedJson, HashMap.class);
String correspondingAuthorOrcidId = (String) stateJson.get("orcid_id");
String authenticatedOrcidId = "";
try {
authenticatedOrcidId = orcidApi.getOrcidIdFromAuthorizationCode(site, code);
} catch (OrcidAuthenticationTokenExpiredException | OrcidAuthenticationTokenReusedException e) {
model.addAttribute("orcidAuthenticationError", e.getMessage());
}
boolean isError = true;
if (correspondingAuthorOrcidId.equals(authenticatedOrcidId)) {
model.addAttribute("orcidId", correspondingAuthorOrcidId);
isError = false;
} else if (!Strings.isNullOrEmpty(authenticatedOrcidId)) {
model.addAttribute("orcidAuthenticationError", "ORCID IDs do not match. " + "Corresponding author ORCID ID must be used.");
}
if (isError) {
final RequestedDoiVersion articleId = RequestedDoiVersion.of((String) stateJson.get("doi"));
return renderArticle(request, model, site, articleId);
} else {
return site + "/ftl/article/uploadPreprintRevision";
}
}
use of org.ambraproject.wombat.identity.RequestedDoiVersion in project wombat by PLOS.
the class PeerReviewController method renderPeerReview.
/**
* Serves the peer review tab with a specific review expanded.
*
* @param model data to pass to the view
* @param site current site
* @param reviewDoi specifies the review
* @return path to the template
* @throws IOException
*/
@RequestMapping(name = "peerReview", value = "/peerReview")
public String renderPeerReview(HttpServletRequest request, Model model, @SiteParam Site site, RequestedDoiVersion reviewDoi) throws IOException {
RequestedDoiVersion articleDoi = getParentArticleDoiFromReviewDoi(reviewDoi);
articleMetadataFactory.get(site, articleDoi).validateVisibility("peerReview").populate(request, model);
model.addAttribute("reviewDoi", reviewDoi);
throwIfPeerReviewNotFound(model.asMap());
return site + "/ftl/article/peerReview";
}
Aggregations