Skip to content

Commit

Permalink
API Token: put "not found" message in bundle and update #2939
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Apr 27, 2016
1 parent 3b5503e commit 962997e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ shib.passwordRejected=<strong>Validation Error</strong> - Your account can only
# tab on dataverseuser.xhtml
apitoken.title=API Token
apitoken.message=Your API token is displayed below after it has been created. Check out our {0}API Guide{1} for more information on using your API token with the Dataverse APIs.
apitoken.notFound=API Token for {0} has not been created.
apitoken.generateBtn=Create Token
apitoken.regenerateBtn=Recreate Token

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/ApiTokenPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.authorization.users.ApiToken;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.util.BundleUtil;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.view.ViewScoped;
Expand Down Expand Up @@ -47,9 +50,12 @@ public String getApiToken() {
if (apiToken != null) {
return apiToken.getTokenString();
} else {
return "API token for " + au.getName() + " not found";
List<String> arguments = new ArrayList<>();
arguments.add(au.getName());
return BundleUtil.getStringFromBundle("apitoken.notFound", arguments);
}
} else {
// It should be impossible to get here from the UI.
return "Only authenticated users can have API tokens.";
}

Expand Down

0 comments on commit 962997e

Please sign in to comment.