Skip to content

Commit 6ff0abc

Browse files
authored
Merge pull request DSpace#12291 from 4Science/task/main/DURACOM-473
[DURACOM-473] Fix on vocabulary browse with anonymous
2 parents ece63b5 + 6a63c76 commit 6ff0abc

3 files changed

Lines changed: 79 additions & 0 deletions

File tree

dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,19 @@ public String getLabel(String key, String locale) {
217217
}
218218
}
219219

220+
/**
221+
* Value-pairs from submission forms are always considered public.
222+
* They contain static, non-sensitive dropdown options (e.g., document
223+
* types, languages, OpenAIRE vocabularies) that must be browsable
224+
* by anonymous users in submission vocabulary lookups.
225+
*
226+
* @return always {@code true}
227+
*/
228+
@Override
229+
public boolean isPublic() {
230+
return true;
231+
}
232+
220233
@Override
221234
public boolean isScrollable() {
222235
return true;

dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ public DSpaceControlledVocabulary() {
8787
super();
8888
}
8989

90+
/**
91+
* Controlled vocabulary XML files are always considered public.
92+
* They contain static, non-sensitive classification data (e.g., subject
93+
* taxonomies like SRSC or NSI) that must be browsable by anonymous users
94+
* in submission vocabulary lookups.
95+
*
96+
* @return always {@code true}
97+
*/
98+
@Override
99+
public boolean isPublic() {
100+
return true;
101+
}
102+
90103
@Override
91104
public boolean storeAuthorityInMetadata() {
92105
init(null);

dspace-server-webapp/src/test/java/org/dspace/app/rest/VocabularyRestRepositoryIT.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,59 @@ public void correctSrscQueryTest() throws Exception {
213213
.andExpect(jsonPath("$.page.size", Matchers.is(2)));
214214
}
215215

216+
/**
217+
* Verifies that anonymous users can browse entries from a
218+
* {@link org.dspace.content.authority.DSpaceControlledVocabulary}-backed
219+
* vocabulary (XML hierarchical taxonomy like SRSC).
220+
* These vocabularies are public and must not require authentication.
221+
*/
222+
@Test
223+
public void correctSrscQueryAnonymousUserTest() throws Exception {
224+
getClient().perform(
225+
get("/api/submission/vocabularies/srsc/entries")
226+
.param("filter", "Research")
227+
.param("size", "2"))
228+
.andExpect(status().isOk())
229+
.andExpect(jsonPath("$._embedded.entries", Matchers.containsInAnyOrder(
230+
VocabularyMatcher.matchVocabularyEntry(
231+
"Research Subject Categories", "", "vocabularyEntry"),
232+
VocabularyMatcher.matchVocabularyEntry(
233+
"Family research",
234+
"SOCIAL SCIENCES::Social sciences::Social work"
235+
+ "::Family research",
236+
"vocabularyEntry"))))
237+
.andExpect(jsonPath("$.page.totalElements", Matchers.is(26)))
238+
.andExpect(jsonPath("$.page.totalPages", Matchers.is(13)))
239+
.andExpect(jsonPath("$.page.size", Matchers.is(2)));
240+
}
241+
242+
/**
243+
* Verifies that anonymous users can browse entries from a
244+
* {@link DCInputAuthority}-backed vocabulary (value-pairs).
245+
* These vocabularies are public and must not require authentication.
246+
*/
247+
@Test
248+
public void correctCommonTypesQueryAnonymousUserTest() throws Exception {
249+
getClient().perform(
250+
get("/api/submission/vocabularies/common_types/entries")
251+
.param("filter", "Book")
252+
.param("size", "2"))
253+
.andExpect(status().isOk())
254+
.andExpect(jsonPath("$._embedded.entries",
255+
Matchers.containsInAnyOrder(
256+
VocabularyMatcher.matchVocabularyEntry(
257+
"Book", "Book", "vocabularyEntry"),
258+
VocabularyMatcher.matchVocabularyEntry(
259+
"Book chapter", "Book chapter",
260+
"vocabularyEntry"))))
261+
.andExpect(jsonPath("$.page.totalElements",
262+
Matchers.is(2)))
263+
.andExpect(jsonPath("$.page.totalPages",
264+
Matchers.is(1)))
265+
.andExpect(jsonPath("$.page.size",
266+
Matchers.is(2)));
267+
}
268+
216269
@Test
217270
public void notScrollableVocabularyRequiredQueryTest() throws Exception {
218271
String token = getAuthToken(admin.getEmail(), password);

0 commit comments

Comments
 (0)