Search in sources :

Example 11 with RequestedDoiVersion

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";
    }
}
Also used : RequestedDoiVersion(org.ambraproject.wombat.identity.RequestedDoiVersion) OrcidAuthenticationTokenReusedException(org.ambraproject.wombat.service.remote.orcid.OrcidAuthenticationTokenReusedException) OrcidAuthenticationTokenExpiredException(org.ambraproject.wombat.service.remote.orcid.OrcidAuthenticationTokenExpiredException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with RequestedDoiVersion

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";
}
Also used : RequestedDoiVersion(org.ambraproject.wombat.identity.RequestedDoiVersion) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestedDoiVersion (org.ambraproject.wombat.identity.RequestedDoiVersion)12 Map (java.util.Map)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 LinkedTreeMap (com.google.gson.internal.LinkedTreeMap)4 ArticlePointer (org.ambraproject.wombat.identity.ArticlePointer)4 Test (org.junit.Test)4 AssetPointer (org.ambraproject.wombat.identity.AssetPointer)3 CommentService (org.ambraproject.wombat.service.CommentService)3 EntityNotFoundException (org.ambraproject.wombat.service.EntityNotFoundException)3 UserApi (org.ambraproject.wombat.service.remote.UserApi)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 CharMatcher (com.google.common.base.CharMatcher)1 Charsets (com.google.common.base.Charsets)1 Splitter (com.google.common.base.Splitter)1 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 ByteStreams (com.google.common.io.ByteStreams)1 Gson (com.google.gson.Gson)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1