From d3b377b3a78ee7cd70bb2bbec1a7a403e2757e9b Mon Sep 17 00:00:00 2001 From: Graham Triggs Date: Fri, 9 Aug 2019 14:29:00 +0100 Subject: [PATCH] [VIVO-1670] ORCID - Disable Step 2 and Internationalization (#130) * 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 --- .../mannlib/vivo/orcid/OrcidContextSetup.java | 5 + .../controller/OrcidAbstractHandler.java | 7 ++ .../config/example.runtime.properties | 7 ++ .../src/main/webapp/i18n/vivo_all.properties | 46 ++++++++- .../freemarker/body/orcid/orcidConfirm.ftl | 95 ++++++++----------- .../individual/individual-orcidInterface.ftl | 4 +- 6 files changed, 108 insertions(+), 56 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vivo/orcid/OrcidContextSetup.java b/api/src/main/java/edu/cornell/mannlib/vivo/orcid/OrcidContextSetup.java index 32f51646..6d8344cf 100644 --- a/api/src/main/java/edu/cornell/mannlib/vivo/orcid/OrcidContextSetup.java +++ b/api/src/main/java/edu/cornell/mannlib/vivo/orcid/OrcidContextSetup.java @@ -13,6 +13,7 @@ import javax.servlet.ServletContext; 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; @@ -54,6 +55,10 @@ public class OrcidContextSetup implements ServletContextListener { private void initializeOrcidClientContext(ConfigurationProperties props, StartupStatus ss) { try { + if (!"member".equalsIgnoreCase(props.getProperty("orcid.apiLevel", "member"))) { + OrcidAbstractHandler.setAPiLevelPublic(); + } + Map settings = new EnumMap<>(Setting.class); settings.put(CLIENT_ID, props.getProperty("orcid.clientId")); settings.put(CLIENT_SECRET, diff --git a/api/src/main/java/edu/cornell/mannlib/vivo/orcid/controller/OrcidAbstractHandler.java b/api/src/main/java/edu/cornell/mannlib/vivo/orcid/controller/OrcidAbstractHandler.java index 709f655c..df02b5e3 100644 --- a/api/src/main/java/edu/cornell/mannlib/vivo/orcid/controller/OrcidAbstractHandler.java +++ b/api/src/main/java/edu/cornell/mannlib/vivo/orcid/controller/OrcidAbstractHandler.java @@ -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(); @@ -121,7 +123,12 @@ public abstract class OrcidAbstractHandler { protected ResponseValues showConfirmationPage() { Map map = new HashMap<>(); map.put("orcidInfo", state.toMap()); + map.put("orcidApiLevel", apiLevel); return new TemplateResponseValues(TEMPLATE_CONFIRM, map); } + public static void setAPiLevelPublic() { + apiLevel = "public"; + } + } diff --git a/home/src/main/resources/config/example.runtime.properties b/home/src/main/resources/config/example.runtime.properties index 87fc9621..3bb6a644 100644 --- a/home/src/main/resources/config/example.runtime.properties +++ b/home/src/main/resources/config/example.runtime.properties @@ -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 # ----------------------------------------------------------------------------- diff --git a/webapp/src/main/webapp/i18n/vivo_all.properties b/webapp/src/main/webapp/i18n/vivo_all.properties index 08a11663..dec982fa 100644 --- a/webapp/src/main/webapp/i18n/vivo_all.properties +++ b/webapp/src/main/webapp/i18n/vivo_all.properties @@ -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 =
  • VIVO redirects you to ORCID's web site.
  • \ +
  • You log in to your ORCID account.
    • If you don't have an account, you can create one.
  • \ +
  • You tell ORCID that VIVO may read your ORCID record. (one-time permission)
  • \ +
  • VIVO reads your ORCID record.
  • \ +
  • VIVO notes that your ORCID iD is confirmed.
+ +orcid_step1_denied =

You denied VIVO's request to read your ORCID record.

\ +

Confirmation can't continue.

+ +orcid_step1_failed =

VIVO failed to read your ORCID record.

\ +

Confirmation can't continue.

+ +orcid_step1_confirmed =

Your ORCID iD is confirmed as {0}

+ +orcid_step2_heading = Step 2 (recommended): Linking your ORCID record to VIVO + +orcid_step2_description =
  • VIVO redirects you to ORCID's web site
  • \ +
  • You tell ORCID that VIVO may add an "external ID" to your ORCID record. (one-time permission)
  • \ +
  • VIVO adds the external ID.
+ +orcid_step2_already_present =

Your ORCID record already includes a link to VIVO.

+ +orcid_step2_denied =

You denied VIVO's request to add an External ID to your ORCID record.

\ +

Linking can't continue.

+ +orcid_step2_failed =

VIVO failed to add an External ID to your ORCID record.

\ +

Linking can't continue.

+ +orcid_step2_added =

Your ORCID record is linked to VIVO

+ +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
{0} @@ -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 \ No newline at end of file +claim_publications_by_pmid=PubMed ID diff --git a/webapp/src/main/webapp/templates/freemarker/body/orcid/orcidConfirm.ftl b/webapp/src/main/webapp/templates/freemarker/body/orcid/orcidConfirm.ftl index 5ed32b07..1f33e623 100644 --- a/webapp/src/main/webapp/templates/freemarker/body/orcid/orcidConfirm.ftl +++ b/webapp/src/main/webapp/templates/freemarker/body/orcid/orcidConfirm.ftl @@ -65,81 +65,70 @@ span.completed { } -<#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 /> <#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))/> +
-

Do you want to ${orcidTextOne} ORCID iD?

+

${orcidTitle}

<#if "START" == orcidInfo.progress> -

Step 1: ${orcidTextTwo} your ORCID iD

-
    -
  • VIVO redirects you to ORCID's web site.
  • -
  • You log in to your ORCID account. -
    • If you don't have an account, you can create one.
    -
  • -
  • You tell ORCID that VIVO may read your ORCID record. (one-time permission)
  • -
  • VIVO reads your ORCID record.
  • -
  • VIVO notes that your ORCID iD is confirmed.
  • -
+

${orcidStepHeading}

+ ${i18n().orcid_step1_description} <#elseif "DENIED_AUTHENTICATE" == orcidInfo.progress> -

Step 1: ${orcidTextTwo} your ORCID iD

-

You denied VIVO's request to read your ORCID record.

-

Confirmation can't continue.

+

${orcidStepHeading}

+ ${i18n().orcid_step1_denied} <#elseif "FAILED_AUTHENTICATE" == orcidInfo.progress> -

Step 1: ${orcidTextTwo} your ORCID iD

-

VIVO failed to read your ORCID record.

-

Confirmation can't continue.

+

${orcidStepHeading}

+ ${i18n().orcid_step1_failed} <#else> -

Step 1: ${orcidTextTwo} your ORCID iD (step completed)

-

Your ORCID iD is confirmed as ${orcidInfo.orcid}

-

View your ORCID record.

+

${orcidStepHeading} ${i18n().orcid_step_completed}

+ ${i18n().orcid_step1_confirmed(orcidInfo.orcid)} +

${i18n().orcid_view_orcid_record}

-
- <#if "ID_ALREADY_PRESENT" == orcidInfo.progress> -

Step 2 (recommended): Linking your ORCID record to VIVO (step completed)

-

Your ORCID record already includes a link to VIVO.

- <#elseif "DENIED_ID" == orcidInfo.progress> -

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

-

You denied VIVO's request to add an External ID to your ORCID record.

-

Linking can't continue.

- <#elseif "FAILED_ID" == orcidInfo.progress> -

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

-

VIVO failed to add an External ID to your ORCID record.

-

Linking can't continue.

- <#elseif "ADDED_ID" == orcidInfo.progress> -

Step 2 (recommended): Linking your ORCID record to VIVO (step completed)

-

Your ORCID record is linked to VIVO

-

View your ORCID record.

- <#else> -

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

-
    -
  • VIVO redirects you to ORCID's web site
  • -
  • You tell ORCID that VIVO may add an "external ID" to your ORCID record. (one-time permission)
  • -
  • VIVO adds the external ID.
  • -
- -
+ <#if orcidApiLevel == "member"> +
+ <#if "ID_ALREADY_PRESENT" == orcidInfo.progress> +

${i18n().orcid_step2_heading} ${i18n().orcid_step_completed}

+ ${i18n().orcid_step2_already_present} + <#elseif "DENIED_ID" == orcidInfo.progress> +

${i18n().orcid_step2_heading}

+ ${i18n().orcid_step2_denied} + <#elseif "FAILED_ID" == orcidInfo.progress> +

${i18n().orcid_step2_heading}

+ ${i18n().orcid_step2_failed} + <#elseif "ADDED_ID" == orcidInfo.progress> +

${i18n().orcid_step2_heading} ${i18n().orcid_step_completed}

+ ${i18n().orcid_step2_added} +

${i18n().orcid_view_orcid_record}

+ <#else> +

${i18n().orcid_step2_heading}

+ ${i18n().orcid_step2_description} + +
+ diff --git a/webapp/src/main/webapp/templates/freemarker/body/partials/individual/individual-orcidInterface.ftl b/webapp/src/main/webapp/templates/freemarker/body/partials/individual/individual-orcidInterface.ftl index f5777e9f..5896b019 100644 --- a/webapp/src/main/webapp/templates/freemarker/body/partials/individual/individual-orcidInterface.ftl +++ b/webapp/src/main/webapp/templates/freemarker/body/partials/individual/individual-orcidInterface.ftl @@ -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 orcidInfo.authorizedToConfirm>