Skip to content

Commit

Permalink
[VIVO-1670] ORCID - Disable Step 2 and Internationalization (#130)
Browse files Browse the repository at this point in the history
* Internationalize ORCiD add an iD
* ORCID Internationalization, allow Step 2 to be disabled if only a public API key

Resolves: https://jira.duraspace.org/browse/VIVO-1670
  • Loading branch information
grahamtriggs authored and Andrew Woods committed Aug 9, 2019
1 parent 06d266e commit d3b377b
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import edu.cornell.mannlib.vivo.orcid.controller.OrcidAbstractHandler;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -54,6 +55,10 @@ public void contextInitialized(ServletContextEvent sce) {
private void initializeOrcidClientContext(ConfigurationProperties props,
StartupStatus ss) {
try {
if (!"member".equalsIgnoreCase(props.getProperty("orcid.apiLevel", "member"))) {
OrcidAbstractHandler.setAPiLevelPublic();
}

Map<Setting, String> settings = new EnumMap<>(Setting.class);
settings.put(CLIENT_ID, props.getProperty("orcid.clientId"));
settings.put(CLIENT_SECRET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public abstract class OrcidAbstractHandler {
protected final OrcidConfirmationState state;
protected final UserAccount currentUser;

private static String apiLevel = "member";

protected OrcidAbstractHandler(VitroRequest vreq) {
this.vreq = vreq;
this.occ = OrcidClientContext.getInstance();
Expand Down Expand Up @@ -121,7 +123,12 @@ protected ResponseValues showConfirmationPage(Progress p,
protected ResponseValues showConfirmationPage() {
Map<String, Object> map = new HashMap<>();
map.put("orcidInfo", state.toMap());
map.put("orcidApiLevel", apiLevel);
return new TemplateResponseValues(TEMPLATE_CONFIRM, map);
}

public static void setAPiLevelPublic() {
apiLevel = "public";
}

}
7 changes: 7 additions & 0 deletions home/src/main/resources/config/example.runtime.properties
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ VitroConnection.DataSource.validationQuery = SELECT 1
# release, sandbox
# orcid.api = sandbox

# Specify the type of API access that you have - public or member
# public - only allows you to confirm ORCID IDs
# member - allows VIVO to write a link to the VIVO profile in the ORCID record
# If you only have a public API key, ensure that you have entered public here
#orcid.apiLevel = public


# -----------------------------------------------------------------------------
# OTHER OPTIONS
# -----------------------------------------------------------------------------
Expand Down
46 changes: 45 additions & 1 deletion webapp/src/main/webapp/i18n/vivo_all.properties
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,50 @@ role_in_presentation_capitalized=Role in Presentation
advisee_capitalized_first_name=First Name
advisee_capitalized_lastname=Last Name

add_orcid_id=Add an iD

orcid_title_add = Do you want to add an ORCID iD?
orcid_step1_add = Step 1: Adding your ORCID iD
orcid_title_confirm = Do you want to add an ORCID iD?
orcid_step1_confirm = Step 1: Adding your ORCID iD

orcid_step1_description = <ul><li>VIVO redirects you to ORCID's web site.</li> \
<li>You log in to your ORCID account. <ul class="inner"><li>If you don't have an account, you can create one.</li></ul></li> \
<li>You tell ORCID that VIVO may read your ORCID record. (one-time permission)</li> \
<li>VIVO reads your ORCID record.</li> \
<li>VIVO notes that your ORCID iD is confirmed.</li></ul>

orcid_step1_denied = <p>You denied VIVO's request to read your ORCID record.</p> \
<p>Confirmation can't continue.</p>

orcid_step1_failed = <p>VIVO failed to read your ORCID record.</p> \
<p>Confirmation can't continue.</p>

orcid_step1_confirmed = <p>Your ORCID iD is confirmed as {0}</p>

orcid_step2_heading = Step 2 (recommended): Linking your ORCID record to VIVO

orcid_step2_description = <ul><li>VIVO redirects you to ORCID's web site</li> \
<li>You tell ORCID that VIVO may add an "external ID" to your ORCID record. (one-time permission)</li> \
<li>VIVO adds the external ID.</li></ul>

orcid_step2_already_present = <p>Your ORCID record already includes a link to VIVO.</p>

orcid_step2_denied = <p>You denied VIVO's request to add an External ID to your ORCID record.</p> \
<p>Linking can't continue.</p>

orcid_step2_failed = <p>VIVO failed to add an External ID to your ORCID record.</p> \
<p>Linking can't continue.</p>

orcid_step2_added = <p>Your ORCID record is linked to VIVO</p>

orcid_button_step1 = Continue Step 1
orcid_button_step2 = Continue Step 2

orcid_step_completed = (step completed)
orcid_view_orcid_record = View your ORCID record.
orcid_return_to_vivo = Return to your VIVO profile page

# Messages for creating and linking resources (publications)
create_and_link_enter=Enter {0}:
create_and_link_claim_for=Claiming works for<br />{0}
Expand Down Expand Up @@ -861,4 +905,4 @@ create_and_link_type_thesis=Thesis
create_and_link_type_webpage=Webpage
claim_publications_by=Claim publications by
claim_publications_by_doi=DOI
claim_publications_by_pmid=PubMed ID
claim_publications_by_pmid=PubMed ID
Original file line number Diff line number Diff line change
Expand Up @@ -65,81 +65,70 @@ span.completed {
}
</style>

<#assign orcidTextOne = "add an" />
<#assign orcidTextTwo = "Adding" />
<#assign orcidTitle = i18n().orcid_title_add />
<#assign orcidStepHeading = i18n().orcid_step1_add />
<#if (orcidInfo.existingOrcids?size > 0) >
<#assign orcidTextOne = "confirm your" />
<#assign orcidTextTwo = "Confirming" />
<#assign orcidTitle = i18n().orcid_title_confirm />
<#assign orcidStepHeading = i18n().orcid_step1_confirm />
</#if>
<#assign step2dimmed = (["START", "FAILED_AUTHENTICATE", "DENIED_AUTHENTICATE"]?seq_contains(orcidInfo.progress))?string("dimmed", "") />
<#assign continueAppears = (["START", "GOT_PROFILE"]?seq_contains(orcidInfo.progress))/>
<#assign continueAppears = (["START"]?seq_contains(orcidInfo.progress))/>
<#if orcidApiLevel == "member">
<#assign continueAppears = (["START", "GOT_PROFILE"]?seq_contains(orcidInfo.progress))/>
</#if>

<div>

<section id="orcid-offer" role="region">
<h2>Do you want to ${orcidTextOne} ORCID iD?</h2>
<h2>${orcidTitle}</h2>

<div class="step">
<#if "START" == orcidInfo.progress>
<h2>Step 1: ${orcidTextTwo} your ORCID iD</h2>
<ul>
<li>VIVO redirects you to ORCID's web site.</li>
<li>You log in to your ORCID account.
<ul class="inner"><li>If you don't have an account, you can create one.</li></ul>
</li>
<li>You tell ORCID that VIVO may read your ORCID record. (one-time permission)</li>
<li>VIVO reads your ORCID record.</li>
<li>VIVO notes that your ORCID iD is confirmed.</li>
</ul>
<h2>${orcidStepHeading}</h2>
${i18n().orcid_step1_description}
<#elseif "DENIED_AUTHENTICATE" == orcidInfo.progress>
<h2>Step 1: ${orcidTextTwo} your ORCID iD</h2>
<p>You denied VIVO's request to read your ORCID record.</p>
<p>Confirmation can't continue.</p>
<h2>${orcidStepHeading}</h2>
${i18n().orcid_step1_denied}
<#elseif "FAILED_AUTHENTICATE" == orcidInfo.progress>
<h2>Step 1: ${orcidTextTwo} your ORCID iD</h2>
<p>VIVO failed to read your ORCID record.</p>
<p>Confirmation can't continue.</p>
<h2>${orcidStepHeading}</h2>
${i18n().orcid_step1_failed}
<#else>
<h2>Step 1: ${orcidTextTwo} your ORCID iD <span class="completed">(step completed)</span></h2>
<p>Your ORCID iD is confirmed as ${orcidInfo.orcid}</p>
<p><a href="${orcidInfo.orcidUri}" target="_blank">View your ORCID record.</a></p>
<h2>${orcidStepHeading} <span class="completed">${i18n().orcid_step_completed}</span></h2>
${i18n().orcid_step1_confirmed(orcidInfo.orcid)}
<p><a href="${orcidInfo.orcidUri}" target="_blank">${i18n().orcid_view_orcid_record}</a></p>
</#if>
</div>

<div class="step ${step2dimmed}">
<#if "ID_ALREADY_PRESENT" == orcidInfo.progress>
<h2>Step 2 (recommended): Linking your ORCID record to VIVO <span class="completed">(step completed)</span></h2>
<p>Your ORCID record already includes a link to VIVO.</p>
<#elseif "DENIED_ID" == orcidInfo.progress>
<h2>Step 2 (recommended): Linking your ORCID record to VIVO</h2>
<p>You denied VIVO's request to add an External ID to your ORCID record.</p>
<p>Linking can't continue.</p>
<#elseif "FAILED_ID" == orcidInfo.progress>
<h2>Step 2 (recommended): Linking your ORCID record to VIVO</h2>
<p>VIVO failed to add an External ID to your ORCID record.</p>
<p>Linking can't continue.</p>
<#elseif "ADDED_ID" == orcidInfo.progress>
<h2>Step 2 (recommended): Linking your ORCID record to VIVO <span class="completed">(step completed)</span></h2>
<p>Your ORCID record is linked to VIVO</p>
<p><a href="${orcidInfo.orcidUri}" target="_blank">View your ORCID record.</a></p>
<#else>
<h2>Step 2 (recommended): Linking your ORCID record to VIVO</h2>
<ul>
<li>VIVO redirects you to ORCID's web site</li>
<li>You tell ORCID that VIVO may add an "external ID" to your ORCID record. (one-time permission)</li>
<li>VIVO adds the external ID.</li>
</ul>
</#if>
</div>
<#if orcidApiLevel == "member">
<div class="step ${step2dimmed}">
<#if "ID_ALREADY_PRESENT" == orcidInfo.progress>
<h2>${i18n().orcid_step2_heading} <span class="completed">${i18n().orcid_step_completed}</span></h2>
${i18n().orcid_step2_already_present}
<#elseif "DENIED_ID" == orcidInfo.progress>
<h2>${i18n().orcid_step2_heading}</h2>
${i18n().orcid_step2_denied}
<#elseif "FAILED_ID" == orcidInfo.progress>
<h2>${i18n().orcid_step2_heading}</h2>
${i18n().orcid_step2_failed}
<#elseif "ADDED_ID" == orcidInfo.progress>
<h2>${i18n().orcid_step2_heading} <span class="completed">${i18n().orcid_step_completed}</span></h2>
${i18n().orcid_step2_added}
<p><a href="${orcidInfo.orcidUri}" target="_blank">${i18n().orcid_view_orcid_record}</a></p>
<#else>
<h2>${i18n().orcid_step2_heading}</h2>
${i18n().orcid_step2_description}
</#if>
</div>
</#if>

<div class=links>
<form method="GET" action="${orcidInfo.progressUrl}">
<p>
<#if continueAppears>
<input type="submit" name="submit" value="Continue <#if "START" == orcidInfo.progress>Step 1<#else>Step 2</#if>" class="submit"/>
or
<input type="submit" name="submit" value="<#if "START" == orcidInfo.progress>${i18n().orcid_button_step1}<#else>${i18n().orcid_button_step1}</#if>" class="submit"/>
or
</#if>
<a class="cancel" href="${orcidInfo.profilePage}">Return to your VIVO profile page</a>
<a class="cancel" href="${orcidInfo.profilePage}">${i18n().orcid_return_to_vivo}</a>
</p>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

<#list orcidInfo.orcids?keys as key>
<#if "no" == orcidInfo.orcids[key]?string("yes","no") >
<#assign confirmThis = "Confirm the ID" />
<#assign confirmThis = i18n().confirm_orcid_id />
</#if>
</#list>

<#if orcidInfo.authorizedToConfirm>
<script>
$(document).ready(function(){
$('#orcidId a.add-orcidId').replaceWith("<a class='add-orcidId' style='padding-left:20px' href='${orcidInfo.orcidUrl}'><#if orcidInfo.orcids?size == 0>Add an iD<#else>${confirmThis}</#if></a> ");
$('#orcidId a.add-orcidId').replaceWith("<a class='add-orcidId' style='padding-left:20px' href='${orcidInfo.orcidUrl}'><#if orcidInfo.orcids?size == 0>${i18n().add_orcid_id}<#else>${confirmThis}</#if></a> ");
});
</script>
</#if>
Expand Down

0 comments on commit d3b377b

Please sign in to comment.