Skip to content

Commit

Permalink
MODEXPW-416 - Error parsing custom fields names with semicolon (#462)
Browse files Browse the repository at this point in the history
* MODEXPW-416 - Error parsing custom fields names with semicolon

* MODEXPW-416 - Error parsing custom fields names with semicolon
  • Loading branch information
khandramai committed May 30, 2023
1 parent 7fe9b4f commit 645ef6a
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/main/java/org/folio/dew/service/UserReferenceService.java
Expand Up @@ -110,25 +110,18 @@ public String getPatronGroupIdByName(String name) {

@Cacheable(cacheNames = "customFields")
public CustomField getCustomFieldByRefId(String refId) {

var customFields = customFieldsClient.getCustomFieldsByQuery(getModuleId(MOD_USERS),String.format("refId==\"%s\"", refId));
if (customFields.getCustomFields().isEmpty()) {
var msg = format("Custom field with refId=%s not found", refId);
log.error(msg);
throw new BulkEditException(msg);
}
return customFields.getCustomFields().get(0);
return customFieldsClient.getCustomFieldsByQuery(getModuleId(MOD_USERS),String.format("refId==\"%s\"", refId))
.getCustomFields().stream().filter(customField -> customField.getRefId().equals(refId))
.findFirst()
.orElseThrow(() -> new BulkEditException(format("Custom field with refId=%s not found", refId)));
}

@Cacheable(cacheNames = "customFields")
public CustomField getCustomFieldByName(String name) {
var customFields = customFieldsClient.getCustomFieldsByQuery(getModuleId(MOD_USERS), String.format("name==\"%s\"", name));
if (customFields.getCustomFields().isEmpty()) {
var msg = format("Custom field with name=%s not found", name);
log.error(msg);
throw new BulkEditException(msg);
}
return customFields.getCustomFields().get(0);
return customFieldsClient.getCustomFieldsByQuery(getModuleId(MOD_USERS), String.format("name==\"%s\"", name))
.getCustomFields().stream().filter(customField -> customField.getName().equals(name))
.findFirst()
.orElseThrow(() -> new BulkEditException(format("Custom field with name=%s not found", name)));
}

@Cacheable(cacheNames = "moduleIds")
Expand Down

0 comments on commit 645ef6a

Please sign in to comment.