Skip to content

Commit 551f864

Browse files
committed
MODLD-923: Set LINK of the identity resource based on FOLIO configuration
1 parent 1b931c4 commit 551f864

File tree

14 files changed

+171
-7
lines changed

14 files changed

+171
-7
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
- MOCKED_RESOURCE type handling and validation [MODLD-789](https://folio-org.atlassian.net/browse/MODLD-789)
8181
- Preserve ACCESSIBILITY_NOTE (MARC 532) when an Instance is saved [MODLD-728](https://folio-org.atlassian.net/browse/MODLD-728)
8282
- Allow Import of Authority Records Without LCCN [MODLD-940](https://folio-org.atlassian.net/browse/MODLD-940)
83+
- Set LINK of the identity resource based on FOLIO configuration [MODLD-923](https://folio-org.atlassian.net/browse/MODLD-923)
8384

8485
## 1.0.4 (04-24-2025)
8586
- Work Edit form - Instance read-only section: "Notes about the instance" data is not shown [MODLD-716](https://folio-org.atlassian.net/browse/MODLD-716)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ To run mod-linked-data in standalone mode, set the value of the environment vari
7070
| CACHE_TTL_SPEC_RULES_MS | 18000000 | Specifies time to live for `spec-rules` cache |
7171
| CACHE_TTL_SETTINGS_ENTRIES_MS | 18000000 | Specifies time to live for `settings-entries` cache |
7272
| CACHE_TTL_MODULE_STATE_MS | 18000000 | Specifies time to live for `module-state` cache |
73+
| CACHE_TTL_AUTHORITY_SOURCE_FILES_MS | 18000000 | Specifies time to live for `authority-source-files` cache |
74+
| AUTHORITY_SOURCE_FILES_LIMIT | 50 | Count of authority source files to be fetched from FOLIO for computing the base URI of an authority |
75+
7376
* Applicable only in FOLIO mode
7477
## REST API
7578
Full list of APIs are documented in [src/main/resources/swagger.api/mod-linked-data.yaml](https://github.com/folio-org/mod-linked-data/blob/master/src/main/resources/swagger.api/mod-linked-data.yaml).

descriptors/ModuleDescriptor-template.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"specification-storage.specifications.collection.get",
3131
"specification-storage.specification.rules.collection.get",
3232
"mod-settings.global.read.ui-quick-marc.lccn-duplicate-check.manage",
33-
"mod-settings.entries.collection.get"
33+
"mod-settings.entries.collection.get",
34+
"inventory-storage.authority-source-files.collection.get"
3435
]
3536
},
3637
{
@@ -81,7 +82,8 @@
8182
"specification-storage.specifications.collection.get",
8283
"specification-storage.specification.rules.collection.get",
8384
"mod-settings.global.read.ui-quick-marc.lccn-duplicate-check.manage",
84-
"mod-settings.entries.collection.get"
85+
"mod-settings.entries.collection.get",
86+
"inventory-storage.authority-source-files.collection.get"
8587
]
8688
},
8789
{
@@ -228,6 +230,10 @@
228230
{
229231
"id": "settings",
230232
"version": "1.1"
233+
},
234+
{
235+
"id": "authority-source-files",
236+
"version": "2.2"
231237
}
232238
],
233239
"permissionSets": [
@@ -382,7 +388,9 @@
382388
{ "name": "KAFKA_LINKED_DATA_IMPORT_RESULT_TOPIC", "value": "" },
383389
{ "name": "CACHE_TTL_SPEC_RULES_MS", "value": "18000000" },
384390
{ "name": "CACHE_TTL_SETTINGS_ENTRIES_MS", "value": "18000000" },
385-
{ "name": "CACHE_TTL_MODULE_STATE_MS", "value": "18000000" }
391+
{ "name": "CACHE_TTL_MODULE_STATE_MS", "value": "18000000" },
392+
{ "name": "CACHE_TTL_AUTHORITY_SOURCE_FILES_MS", "value": "18000000" },
393+
{ "name": "AUTHORITY_SOURCE_FILES_LIMIT", "value": "50" }
386394
]
387395
}
388396
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.folio.linked.data.integration.rest.authoritysource;
2+
3+
import static org.folio.linked.data.util.Constants.STANDALONE_PROFILE;
4+
5+
import java.util.Optional;
6+
import lombok.RequiredArgsConstructor;
7+
import org.folio.linked.data.domain.dto.AuthoritySourceFile;
8+
import org.folio.marc4ld.service.marc2ld.authority.identifier.IdentifierUrlProvider;
9+
import org.springframework.beans.factory.annotation.Value;
10+
import org.springframework.context.annotation.Profile;
11+
import org.springframework.stereotype.Service;
12+
13+
@Service("identifierUrlProvider")
14+
@RequiredArgsConstructor
15+
@Profile("!" + STANDALONE_PROFILE)
16+
public class AuthorityFileIdentifierUrlProvider implements IdentifierUrlProvider {
17+
private final AuthoritySourceFilesClient authoritySourceFilesClient;
18+
@Value("${mod-linked-data.authority-source-files.limit}")
19+
private int authoritySourceFilesLimit;
20+
21+
@Override
22+
public Optional<String> getBaseUrl(String identifierPrefix) {
23+
var authoritySourceFiles = authoritySourceFilesClient.getAuthoritySourceFiles(authoritySourceFilesLimit);
24+
25+
return authoritySourceFiles.getAuthoritySourceFiles().stream()
26+
.filter(source -> source.getCodes().stream().anyMatch(identifierPrefix::equals))
27+
.map(AuthoritySourceFile::getBaseUrl)
28+
.findFirst();
29+
}
30+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.folio.linked.data.integration.rest.authoritysource;
2+
3+
import static org.folio.linked.data.util.Constants.Cache.AUTHORITY_SOURCE_FILES;
4+
import static org.folio.linked.data.util.Constants.STANDALONE_PROFILE;
5+
6+
import org.folio.linked.data.domain.dto.AuthoritySourceFiles;
7+
import org.springframework.cache.annotation.Cacheable;
8+
import org.springframework.cloud.openfeign.FeignClient;
9+
import org.springframework.context.annotation.Profile;
10+
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.RequestParam;
12+
13+
@FeignClient(name = "authority-source-files")
14+
@Profile("!" + STANDALONE_PROFILE)
15+
public interface AuthoritySourceFilesClient {
16+
17+
@SuppressWarnings("java:S7180")
18+
@Cacheable(cacheNames = AUTHORITY_SOURCE_FILES, key = "@folioExecutionContext.tenantId + '_' + #limit")
19+
@GetMapping
20+
AuthoritySourceFiles getAuthoritySourceFiles(@RequestParam("limit") int limit);
21+
}

src/main/java/org/folio/linked/data/job/CacheCleaningJob.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.folio.linked.data.job;
22

3+
import static org.folio.linked.data.util.Constants.Cache.AUTHORITY_SOURCE_FILES;
34
import static org.folio.linked.data.util.Constants.Cache.MODULE_STATE;
45
import static org.folio.linked.data.util.Constants.Cache.SETTINGS_ENTRIES;
56
import static org.folio.linked.data.util.Constants.Cache.SPEC_RULES;
@@ -31,4 +32,10 @@ public void emptySettingsEntries() {
3132
public void emptyModuleState() {
3233
log.info(EMPTY_CACHE_MSG, MODULE_STATE);
3334
}
35+
36+
@CacheEvict(value = AUTHORITY_SOURCE_FILES, allEntries = true)
37+
@Scheduled(fixedRateString = "${mod-linked-data.cache.ttl.authority-source-files}")
38+
public void emptyAuthoritySourceFiles() {
39+
log.info(EMPTY_CACHE_MSG, AUTHORITY_SOURCE_FILES);
40+
}
3441
}

src/main/java/org/folio/linked/data/service/resource/marc/ResourceMarcAuthorityServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private Resource createResourceFromSrs(String srsId) {
121121
.map(SaveGraphResult::rootResource)
122122
.orElseThrow(() -> notFoundException(srsId));
123123
} catch (FeignException.NotFound e) {
124-
log.error("Authority with srsId [{}] not found in SRS", srsId);
124+
log.error("Failed to convert authority with srsId [{}] into graph resource", srsId, e);
125125
throw notFoundException(srsId);
126126
}
127127
}

src/main/java/org/folio/linked/data/util/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ public static class Cache {
2929
public static final String SETTINGS_ENTRIES = "settings-entries";
3030
public static final String MODULE_STATE = "module-state";
3131
public static final String PROFILES = "profiles";
32+
public static final String AUTHORITY_SOURCE_FILES = "authority-source-files";
3233
}
3334
}

src/main/resources/application.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ folio:
8282
replicationFactor: ${KAFKA_HUB_SEARCH_INDEX_TOPIC_REPLICATION_FACTOR:}
8383

8484
mod-linked-data:
85+
authority-source-files:
86+
limit: ${AUTHORITY_SOURCE_FILES_LIMIT:50}
8587
reindex:
8688
page-size: 1000
8789
search:
@@ -97,6 +99,7 @@ mod-linked-data:
9799
spec-rules: ${CACHE_TTL_SPEC_RULES_MS:18000000}
98100
settings-entries: ${CACHE_TTL_SETTINGS_ENTRIES_MS:18000000}
99101
module-state: ${CACHE_TTL_MODULE_STATE_MS:18000000}
102+
authority-source-files: ${CACHE_TTL_AUTHORITY_SOURCE_FILES_MS:18000000}
100103

101104
management:
102105
endpoints:

src/main/resources/swagger.api/folio-modules.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ components:
3636
$ref: folio-modules/ld-import/importOutputEvent.json
3737
importResultEvent:
3838
$ref: folio-modules/ld-import/result/importResultEvent.json
39+
authoritySourceFiles:
40+
$ref: folio-modules/authority-sources/authoritySourceFiles.json

0 commit comments

Comments
 (0)