Skip to content

Commit d76e494

Browse files
committed
Fix identifer typo in code
Just in case code outside this project is referencing the old methods, I created deprecated versions.
1 parent 3c98c7d commit d76e494

12 files changed

Lines changed: 85 additions & 40 deletions

File tree

src/main/java/edu/harvard/iq/dataverse/DatasetVersionServiceBean.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,24 @@ private DatasetVersion getDatasetVersionByQuery(String queryString){
495495
}
496496
} // end getDatasetVersionByQuery
497497

498-
499-
500-
501-
public DatasetVersion retrieveDatasetVersionByIdentiferClause(String identifierClause, String version){
498+
/**
499+
* @deprecated because of a typo; use {@link #retrieveDatasetVersionByIdentifierClause(String, String) retrieveDatasetVersionByIdentifierClause} instead
500+
* @see #retrieveDatasetVersionByIdentifierClause(String, String)
501+
* @param identifierClause
502+
* @param version
503+
* @return a DatasetVersion if found, or {@code null} otherwise
504+
*/
505+
@Deprecated
506+
public DatasetVersion retrieveDatasetVersionByIdentiferClause(String identifierClause, String version) {
507+
return retrieveDatasetVersionByIdentifierClause(identifierClause, version);
508+
}
509+
510+
/**
511+
* @param identifierClause
512+
* @param version
513+
* @return a DatasetVersion if found, or {@code null} otherwise
514+
*/
515+
public DatasetVersion retrieveDatasetVersionByIdentifierClause(String identifierClause, String version) {
502516

503517
if (identifierClause == null){
504518
return null;
@@ -620,7 +634,7 @@ public RetrieveDatasetVersionResponse retrieveDatasetVersionByPersistentId(Strin
620634
identifierClause += " AND ds.identifier = '" + parsedId.getIdentifier() + "'";
621635

622636

623-
DatasetVersion ds = retrieveDatasetVersionByIdentiferClause(identifierClause, version);
637+
DatasetVersion ds = retrieveDatasetVersionByIdentifierClause(identifierClause, version);
624638

625639
if (ds != null){
626640
msg("retrieved dataset: " + ds.getId() + " semantic: " + ds.getSemanticVersion());
@@ -718,7 +732,7 @@ public DatasetVersion getDatasetVersionById(Long datasetId, String version){
718732

719733
String identifierClause = this.getIdClause(datasetId);
720734

721-
DatasetVersion ds = retrieveDatasetVersionByIdentiferClause(identifierClause, version);
735+
DatasetVersion ds = retrieveDatasetVersionByIdentifierClause(identifierClause, version);
722736

723737
return ds;
724738

src/main/java/edu/harvard/iq/dataverse/Shib.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Arrays;
2525
import java.util.Date;
2626
import java.util.List;
27+
import java.util.logging.Level;
2728
import java.util.logging.Logger;
2829
import jakarta.ejb.EJB;
2930
import jakarta.ejb.EJBException;
@@ -62,7 +63,7 @@ public class Shib implements java.io.Serializable {
6263
HttpServletRequest request;
6364

6465
private String userPersistentId;
65-
private String internalUserIdentifer;
66+
private String internalUserIdentifier;
6667
AuthenticatedUserDisplayInfo displayInfo;
6768
/**
6869
* @todo Remove this boolean some day? Now the mockups show a popup. Should
@@ -210,8 +211,8 @@ public void init() {
210211
}
211212

212213
String usernameAssertion = getValueFromAssertion(ShibUtil.usernameAttribute);
213-
internalUserIdentifer = ShibUtil.generateFriendlyLookingUserIdentifer(usernameAssertion, emailAddress);
214-
logger.fine("friendly looking identifer (backend will enforce uniqueness):" + internalUserIdentifer);
214+
internalUserIdentifier = ShibUtil.generateFriendlyLookingUserIdentifier(usernameAssertion, emailAddress);
215+
logger.log(Level.FINE, "friendly looking identifier (backend will enforce uniqueness): {0}", internalUserIdentifier);
215216

216217
String shibAffiliationAttribute = settingsService.getValueForKey(SettingsServiceBean.Key.ShibAffiliationAttribute);
217218
String affiliation = (StringUtils.isNotBlank(shibAffiliationAttribute))
@@ -326,7 +327,7 @@ public String confirmAndCreateAccount() {
326327
AuthenticatedUser au = null;
327328
try {
328329
au = authSvc.createAuthenticatedUser(
329-
new UserRecordIdentifier(shibAuthProvider.getId(), lookupStringPerAuthProvider), internalUserIdentifer, displayInfo, true);
330+
new UserRecordIdentifier(shibAuthProvider.getId(), lookupStringPerAuthProvider), internalUserIdentifier, displayInfo, true);
330331
} catch (EJBException ex) {
331332
/**
332333
* @todo Show the ConstraintViolationException, if any.
@@ -354,7 +355,7 @@ public String confirmAndConvertAccount() {
354355
visibleTermsOfUse = false;
355356
ShibAuthenticationProvider shibAuthProvider = new ShibAuthenticationProvider();
356357
String lookupStringPerAuthProvider = userPersistentId;
357-
UserIdentifier userIdentifier = new UserIdentifier(lookupStringPerAuthProvider, internalUserIdentifer);
358+
UserIdentifier userIdentifier = new UserIdentifier(lookupStringPerAuthProvider, internalUserIdentifier);
358359
logger.fine("builtin username: " + builtinUsername);
359360
AuthenticatedUser builtInUserToConvert = authSvc.canLogInAsBuiltinUser(builtinUsername, builtinPassword);
360361
if (builtInUserToConvert != null) {

src/main/java/edu/harvard/iq/dataverse/api/datadeposit/CollectionListManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public Feed listCollectionContents(IRI iri, AuthCredentials authCredentials, Swo
9494
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Could not find dataverse: " + dvAlias);
9595
}
9696
} else {
97-
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Couldn't determine target type or identifer from URL: " + iri);
97+
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Couldn't determine target type or identifier from URL: " + iri);
9898
}
9999
}
100100

src/main/java/edu/harvard/iq/dataverse/api/datadeposit/MediaResourceManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public void deleteMediaResource(String uri, AuthCredentials authCredentials, Swo
219219
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Unsupported file type found in URL: " + uri);
220220
}
221221
} else {
222-
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Target or identifer not specified in URL: " + uri);
222+
throw new SwordError(UriRegistry.ERROR_BAD_REQUEST, "Target or identifier not specified in URL: " + uri);
223223
}
224224
}
225225

src/main/java/edu/harvard/iq/dataverse/authorization/AuthenticationServiceBean.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ public boolean updateProvider( AuthenticatedUser authenticatedUser, String authe
580580
* {@code userDisplayInfo}, a lookup entry for them based
581581
* UserIdentifier.getLookupStringPerAuthProvider (within the supplied
582582
* authentication provider), and internal user identifier (used for role
583-
* assignments, etc.) based on UserIdentifier.getInternalUserIdentifer.
583+
* assignments, etc.) based on UserIdentifier.getInternalUserIdentifier.
584584
*
585585
* @param userRecordId
586586
* @param proposedAuthenticatedUserIdentifier
@@ -605,20 +605,20 @@ public AuthenticatedUser createAuthenticatedUser(UserRecordIdentifier userRecord
605605
proposedAuthenticatedUserIdentifier = proposedAuthenticatedUserIdentifier.trim();
606606
}
607607
// we now select a username for the generated AuthenticatedUser, or give up
608-
String internalUserIdentifer = proposedAuthenticatedUserIdentifier;
608+
String internalUserIdentifier = proposedAuthenticatedUserIdentifier;
609609
// TODO should lock table authenticated users for write here
610-
if ( identifierExists(internalUserIdentifer) ) {
610+
if ( identifierExists(internalUserIdentifier) ) {
611611
if ( ! generateUniqueIdentifier ) {
612612
return null;
613613
}
614614
int i=1;
615-
String identifier = internalUserIdentifer + i;
615+
String identifier = internalUserIdentifier + i;
616616
while ( identifierExists(identifier) ) {
617617
i += 1;
618618
}
619619
authenticatedUser.setUserIdentifier(identifier);
620620
} else {
621-
authenticatedUser.setUserIdentifier(internalUserIdentifer);
621+
authenticatedUser.setUserIdentifier(internalUserIdentifier);
622622
}
623623
authenticatedUser = save( authenticatedUser );
624624
// TODO should unlock table authenticated users for write here

src/main/java/edu/harvard/iq/dataverse/authorization/UserIdentifier.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,31 @@ public class UserIdentifier {
2525
/**
2626
* The String used in the permission system to assign roles, for example.
2727
*/
28-
String internalUserIdentifer;
28+
String internalUserIdentifier;
2929

30-
public UserIdentifier(String lookupStringPerAuthProvider, String internalUserIdentifer) {
30+
public UserIdentifier(String lookupStringPerAuthProvider, String internalUserIdentifier) {
3131
this.lookupStringPerAuthProvider = lookupStringPerAuthProvider;
32-
this.internalUserIdentifer = internalUserIdentifer;
32+
this.internalUserIdentifier = internalUserIdentifier;
3333
}
3434

3535
public String getLookupStringPerAuthProvider() {
3636
return lookupStringPerAuthProvider;
3737
}
3838

39+
/**
40+
* @deprecated because of a typo; use {@link #getInternalUserIdentifier()} instead
41+
* @see #getInternalUserIdentifier()
42+
* @return the internal user identifier
43+
*/
44+
@Deprecated
3945
public String getInternalUserIdentifer() {
40-
return internalUserIdentifer;
46+
return getInternalUserIdentifier();
47+
}
48+
49+
/**
50+
* @return the internal user identifier
51+
*/
52+
public String getInternalUserIdentifier() {
53+
return internalUserIdentifier;
4154
}
4255
}

src/main/java/edu/harvard/iq/dataverse/authorization/providers/shib/ShibUtil.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,24 @@ public static String findSingleValue(String mayHaveMultipleValues) {
133133
return singleValue;
134134
}
135135

136+
/**
137+
* @deprecated because of a typo; use {@link #generateFriendlyLookingUserIdentifier(String, String)} instead
138+
* @see #generateFriendlyLookingUserIdentifier(String, String)
139+
* @param usernameAssertion
140+
* @param email
141+
* @return a friendly-looking user identifier based on the asserted username or email, or a UUID as fallback
142+
*/
143+
@Deprecated
136144
public static String generateFriendlyLookingUserIdentifer(String usernameAssertion, String email) {
145+
return generateFriendlyLookingUserIdentifier(usernameAssertion, email);
146+
}
147+
148+
/**
149+
* @param usernameAssertion
150+
* @param email
151+
* @return a friendly-looking user identifier based on the asserted username or email, or a UUID as fallback
152+
*/
153+
public static String generateFriendlyLookingUserIdentifier(String usernameAssertion, String email) {
137154
if (usernameAssertion != null && !usernameAssertion.isEmpty()) {
138155
return usernameAssertion;
139156
}

src/main/java/edu/harvard/iq/dataverse/batch/jobs/importer/filesystem/FileRecordJobListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ private void loadChecksumManifest() {
450450
// We probably want package files to be able to use specific stores instead.
451451
// More importantly perhaps, the approach above does not take into account
452452
// if the dataset may have an AlternativePersistentIdentifier, that may be
453-
// designated isStorageLocationDesignator() - i.e., if a different identifer
453+
// designated isStorageLocationDesignator() - i.e., if a different identifier
454454
// needs to be used to name the storage directory, instead of the main/current
455455
// persistent identifier above.
456456
getJobLogger().log(Level.INFO, "Reading checksum manifest: " + manifestAbsolutePath);

src/main/java/edu/harvard/iq/dataverse/batch/jobs/importer/filesystem/FileRecordReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void open(Serializable checkpoint) throws Exception {
109109
// We probably want package files to be able to use specific stores instead.
110110
// More importantly perhaps, the approach above does not take into account
111111
// if the dataset may have an AlternativePersistentIdentifier, that may be
112-
// designated isStorageLocationDesignator() - i.e., if a different identifer
112+
// designated isStorageLocationDesignator() - i.e., if a different identifier
113113
// needs to be used to name the storage directory, instead of the main/current
114114
// persistent identifier above.
115115
getJobLogger().log(Level.INFO, "Reading dataset directory: " + directory.getAbsolutePath()

src/main/java/edu/harvard/iq/dataverse/engine/command/impl/ImportFromFileSystemCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public JsonObject execute(CommandContext ctxt) throws CommandException {
8383
// We probably want package files to be able to use specific stores instead.
8484
// More importantly perhaps, the approach above does not take into account
8585
// if the dataset may have an AlternativePersistentIdentifier, that may be
86-
// designated isStorageLocationDesignator() - i.e., if a different identifer
86+
// designated isStorageLocationDesignator() - i.e., if a different identifier
8787
// needs to be used to name the storage directory, instead of the main/current
8888
// persistent identifier above.
8989
if (!isValidDirectory(directory)) {

0 commit comments

Comments
 (0)