Skip to content

Commit

Permalink
Merge pull request #1860 from UNC-Libraries/bxc-4182
Browse files Browse the repository at this point in the history
BXC-4182- Move all controllers in access app under /api/ path
  • Loading branch information
sharonluong authored Jan 14, 2025
2 parents 67c570d + f3b9278 commit f77644d
Show file tree
Hide file tree
Showing 27 changed files with 56 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class EndpointIT {

protected final static String USERNAME = "test_user";
protected final static AccessGroupSet GROUPS = new AccessGroupSetImpl("adminGroup");
protected final static String ACCESS_URL = "http://localhost:48080/access";
protected final static String ACCESS_URL = "http://localhost:48080/access/api";

protected CloseableHttpClient httpClient;
protected CollectionObject collection;
Expand Down
6 changes: 3 additions & 3 deletions static/js/vue-cdr-access/src/components/advancedSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<header-small/>
<div class="container py-5">
<h2 class="title is-3 has-text-centered">{{ $t('adv_search.advanced') }}</h2>
<form id="advanced-search-form">
<form id="advanced-search-form" action="/api/advancedSearch" method="get">
<div class="lightest columns container">
<div class="column has-background-white-bis p-4">
<h3 class="subtitle is-5">{{ $t('adv_search.search_for') }}</h3>
Expand Down Expand Up @@ -182,15 +182,15 @@ export default {
methods: {
getCollections() {
get('/advancedSearch/collectionsJson').then((response) => {
get('/api/advancedSearch/collectionsJson').then((response) => {
this.collections = response.data;
}).catch(function (error) {
console.log(error);
});
},
getFormats() {
get('/advancedSearch/formats').then((response) => {
get('/api/advancedSearch/formats').then((response) => {
this.formats = response.data;
}).catch(function (error) {
console.log(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Top level component used for the collection browse page

methods: {
retrieveData() {
get('collectionsJson').then((response) => {
get('api/collectionsJson').then((response) => {
this.records = response.data.metadata;
this.is_loading = false;
}).catch((error) => {
Expand Down
4 changes: 2 additions & 2 deletions static/js/vue-cdr-access/src/components/displayWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Top level component for full record pages with searching/browsing, including Adm
retrieveSearchResults() {
let param_string = this.formatParamsString(this.updateParams()) + '&getFacets=true';
this.uuid = location.pathname.split('/')[2];
get(`/${this.search_method}/${this.uuid}${param_string}`).then((response) => {
get(`/api/${this.search_method}/${this.uuid}${param_string}`).then((response) => {
this.record_count = response.data.resultCount;
this.record_list = response.data.metadata;
this.facet_list = response.data.facetFields;
Expand All @@ -205,7 +205,7 @@ Top level component for full record pages with searching/browsing, including Adm
link += '/';
}

return get(`${link}json`).then((response) => {
return get(`/api${link}json`).then((response) => {
this.emptyJsonResponseCheck(response);
this.container_info = response.data;

Expand Down
2 changes: 1 addition & 1 deletion static/js/vue-cdr-access/src/components/frontPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default {
methods: {
getCollectionStats() {
get('/collectionStats').then((response) => {
get('/api/collectionStats').then((response) => {
this.collectionStats = response.data;
}).catch(function (error) {
console.log(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
// File objects don't have any child metadata, so wrap the file object in an array
ajaxOptions() {
return {
url: `/listJson/${this.workId}?rows=10`,
url: `/api/listJson/${this.workId}?rows=10`,
dataSrc: (d) => this.resourceType === 'Work' ? d.metadata : [d.container],
data: (d) => {
const sorts = ['title', 'fileFormatDescription', 'fileSize'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {
methods: {
loadMetadata() {
get(`/record/${this.uuid}/metadataView`).then((response) => {
get(`/api/record/${this.uuid}/metadataView`).then((response) => {
this.metadata = response.data;
this.hasLoaded = true;
}).catch((error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default {
methods: {
viewer(viewer_type) {
return `/record/${this.recordData.briefObject.id}/${viewer_type}Viewer`;
return `/api/record/${this.recordData.briefObject.id}/${viewer_type}Viewer`;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<div class="search-row search-row-large">
<div class="columns container">
<form method="get" action="basicSearch" class="column">
<form method="get" action="api/basicSearch" class="column">
<input name="queryType" type="hidden" value="anywhere">
<label for="hsearch_text" class="is-sr-only">Search the Digital Collections Repository</label>
<div class="field has-addons">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</div>

<div class="search-row columns container">
<form method="get" action="basicSearch" class="column">
<form method="get" action="api/basicSearch" class="column">
<input name="queryType" type="hidden" value="anywhere">
<label for="hsearch_text" class="is-sr-only">Search the Digital Collections Repository</label>
<div class="field has-addons">
Expand Down
2 changes: 1 addition & 1 deletion static/js/vue-cdr-access/src/components/modalMetadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Displays the MODS descriptive record for an object inside of a modal

methods: {
loadMetadata() {
get(`/record/${this.uuid}/metadataView`).then((response) => {
get(`/api/record/${this.uuid}/metadataView`).then((response) => {
this.metadata = response.data;
this.hasLoaded = true;
}).catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion static/js/vue-cdr-access/src/components/searchWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Top level component wrapper for search pages
let search_path = 'searchJson';
this.collection = this.routeHasPathId ? this.$route.path.split('/')[2] : '';

get(`${search_path}/${param_string}`).then((response) => {
get(`api/${search_path}/${param_string}`).then((response) => {
this.emptyJsonResponseCheck(response);
this.records = response.data.metadata;
this.total_records = response.data.resultCount;
Expand Down
2 changes: 1 addition & 1 deletion static/js/vue-cdr-access/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const router = createRouter({
router.beforeEach((to, from) => {
const store = useAccessStore();

axios.head('/userInformation').then((response) => {
axios.head('/api/userInformation').then((response) => {
store.setUsername(response.headers['username']);
store.setIsLoggedIn();
store.setViewAdmin(response.headers['can-view-admin']);
Expand Down
4 changes: 2 additions & 2 deletions static/js/vue-cdr-access/tests/unit/advancedSearch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('advancedSearch.vue', () => {
],
"id":"fc77a9be-b49d-4f4e-b656-1644c9e964fc", "title":"testCollection"
}];
moxios.stubRequest('/advancedSearch/collectionsJson', {
moxios.stubRequest('/api/advancedSearch/collectionsJson', {
status: 200,
response: JSON.stringify(collections)
});
Expand All @@ -100,7 +100,7 @@ describe('advancedSearch.vue', () => {
"Video"
];

moxios.stubRequest('/advancedSearch/formats', {
moxios.stubRequest('/api/advancedSearch/formats', {
status: 200,
response: JSON.stringify(formats)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('collectionBrowseWrapper.vue', () => {
});

it("retrieves data", (done) => {
moxios.stubRequest('collectionsJson', {
moxios.stubRequest('api/collectionsJson', {
status: 200,
response: JSON.stringify(response)
});
Expand All @@ -86,7 +86,7 @@ describe('collectionBrowseWrapper.vue', () => {
});

it("displays a '503 page' if JSON responds with an error", (done) => {
moxios.stubRequest('collectionsJson', {
moxios.stubRequest('api/collectionsJson', {
status: 503,
response: JSON.stringify({ message: 'bad stuff happened' })
});
Expand Down
28 changes: 14 additions & 14 deletions static/js/vue-cdr-access/tests/unit/displayWrapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('displayWrapper.vue', () => {
}

it("retrieves data", async () => {
stubQueryResponse(`listJson/${response.container.id}?.+`, response);
stubQueryResponse(`api/listJson/${response.container.id}?.+`, response);
await router.push(`/record/${response.container.id}`);
mountApp();
wrapper.vm.getBriefObject();
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('displayWrapper.vue', () => {
});

it("uses the correct parameters for admin unit browse", async () => {
stubQueryResponse(`listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+`, response);
stubQueryResponse(`api/listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+`, response);
await router.push('/record/73bc003c-9603-4cd9-8a65-93a22520ef6a?works_only=false');
mountApp({
container_info: {
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('displayWrapper.vue', () => {
});

it("displays a 'works only' option if the 'works only' box is checked and no records are works", async () => {
stubQueryResponse(`searchJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+`, response);
stubQueryResponse(`api/searchJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+`, response);
await router.push('/record/73bc003c-9603-4cd9-8a65-93a22520ef6a?works_only=true');
mountApp();

Expand All @@ -183,8 +183,8 @@ describe('displayWrapper.vue', () => {
});

it("adjusts facets retrieved for admin unit", async () => {
stubQueryResponse(`listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+&facetSelect=collection%2Cformat%2Cgenre%2Clanguage%2Csubject%2Clocation%2CcreatedYear%2CcreatorContributor%2Cpublisher&.*`, response);
stubQueryResponse(`record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`,
stubQueryResponse(`api/listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+&facetSelect=collection%2Cformat%2Cgenre%2Clanguage%2Csubject%2Clocation%2CcreatedYear%2CcreatorContributor%2Cpublisher&.*`, response);
stubQueryResponse(`api/record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`,
{
'briefObject': {
type: 'AdminUnit',
Expand Down Expand Up @@ -220,8 +220,8 @@ describe('displayWrapper.vue', () => {
});

it("adjusts facets retrieved for collection object", async () => {
stubQueryResponse(`listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+&facetSelect=format%2Cgenre%2Clanguage%2Csubject%2Clocation%2CcreatedYear%2CcreatorContributor%2Cpublisher&.*`, response);
stubQueryResponse(`record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`,
stubQueryResponse(`api/listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+&facetSelect=format%2Cgenre%2Clanguage%2Csubject%2Clocation%2CcreatedYear%2CcreatorContributor%2Cpublisher&.*`, response);
stubQueryResponse(`api/record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`,
{
'briefObject': briefObjectData.briefObject,
'resourceType': 'Collection',
Expand All @@ -240,8 +240,8 @@ describe('displayWrapper.vue', () => {
});

it("adjusts facets retrieved for folder object", async () => {
stubQueryResponse(`listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+&facetSelect=format%2Cgenre%2Clanguage%2Csubject%2Clocation%2CcreatedYear%2CcreatorContributor%2Cpublisher&.*`, response);
stubQueryResponse(`record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`,
stubQueryResponse(`api/listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+&facetSelect=format%2Cgenre%2Clanguage%2Csubject%2Clocation%2CcreatedYear%2CcreatorContributor%2Cpublisher&.*`, response);
stubQueryResponse(`api/record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`,
{
'briefObject': {
type: 'Folder',
Expand Down Expand Up @@ -281,8 +281,8 @@ describe('displayWrapper.vue', () => {
});

it("adjusts facets retrieved for admin unit and maintains them after checking works only", async () => {
stubQueryResponse(`listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+&facetSelect=collection%2Cformat%2Cgenre%2Clanguage%2Csubject%2Clocation%2CcreatedYear%2CcreatorContributor%2Cpublisher&.*`, response);
stubQueryResponse(`record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`,
stubQueryResponse(`api/listJson/73bc003c-9603-4cd9-8a65-93a22520ef6a?.+&facetSelect=collection%2Cformat%2Cgenre%2Clanguage%2Csubject%2Clocation%2CcreatedYear%2CcreatorContributor%2Cpublisher&.*`, response);
stubQueryResponse(`api/record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`,
{
'briefObject': {
type: 'AdminUnit',
Expand Down Expand Up @@ -323,7 +323,7 @@ describe('displayWrapper.vue', () => {
});

it("shows a 'not found' message if no data is returned", async () => {
stubQueryResponse(`/record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`, '');
stubQueryResponse(`/api/record/73bc003c-9603-4cd9-8a65-93a22520ef6a/json`, '');
await router.push('/record/73bc003c-9603-4cd9-8a65-93a22520ef6a/?browse_type=list-display');
mountApp();

Expand All @@ -332,7 +332,7 @@ describe('displayWrapper.vue', () => {
});

it("shows a 'not found' message if a 4xx status code is returned", async () => {
moxios.stubRequest('/record/73bc003c-9603-4cd9-8a65-93a22520ef6b/json', {
moxios.stubRequest('/api/record/73bc003c-9603-4cd9-8a65-93a22520ef6b/json', {
status: 404,
response: JSON.stringify({ message: 'Nothing to see here' })
});
Expand All @@ -344,7 +344,7 @@ describe('displayWrapper.vue', () => {
});

it("displays a '503 page' if JSON responds with an error", async () => {
moxios.stubRequest('/record/73bc003c-9603-4cd9-8a65-93a22520ef6b/json', {
moxios.stubRequest('/api/record/73bc003c-9603-4cd9-8a65-93a22520ef6b/json', {
status: 503,
response: JSON.stringify({ message: 'bad stuff happened' })
});
Expand Down
2 changes: 1 addition & 1 deletion static/js/vue-cdr-access/tests/unit/frontPage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('frontPage.vue', () => {
{"text":"46936"}
]
};
moxios.stubRequest('/collectionStats', {
moxios.stubRequest('/api/collectionStats', {
status: 200,
response: JSON.stringify(collectionStats)
});
Expand Down
4 changes: 2 additions & 2 deletions static/js/vue-cdr-access/tests/unit/metadataDisplay.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('metadataDisplay.vue', () => {

it("loads record MODS metadata as html", (done) => {
const html_data = "<table><tr><th>Title</th><td><p>Listen for real</p></td></tr></table>";
const url = `record/${record.uuid}/metadataView`;
const url = `api/record/${record.uuid}/metadataView`;
moxios.stubRequest(new RegExp(url), {
status: 200,
response: html_data
Expand All @@ -67,7 +67,7 @@ describe('metadataDisplay.vue', () => {

it("does not load record MODS metadata if empty", (done) => {
const html_data = "";
const url = `record/${record.uuid}/metadataView`;
const url = `api/record/${record.uuid}/metadataView`;
moxios.stubRequest(new RegExp(url), {
status: 200,
response: html_data
Expand Down
2 changes: 1 addition & 1 deletion static/js/vue-cdr-access/tests/unit/modalMetadata.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('modalMetadata.vue', () => {

it("fetches the record metadata when the modal is opened", () => {
moxios.install();
moxios.stubRequest(`record/${updated_uuid}/metadataView`, {
moxios.stubRequest(`api/record/${updated_uuid}/metadataView`, {
status: 200,
responseText: {
data: response
Expand Down
10 changes: 5 additions & 5 deletions static/js/vue-cdr-access/tests/unit/searchWrapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('searchWrapper.vue', () => {
});

it("displays facets if facets but no results", (done) => {
moxios.stubRequest(`searchJson/?anywhere=&getFacets=true`, {
moxios.stubRequest(`api/searchJson/?anywhere=&getFacets=true`, {
status: 200,
response: JSON.stringify(facets_no_results)
});
Expand All @@ -177,7 +177,7 @@ describe('searchWrapper.vue', () => {

it("does not display facets if there are no facets and no results", (done) => {
wrapper.vm.retrieveData();
moxios.stubRequest(`searchJson/?anywhere=&getFacets=true`, {
moxios.stubRequest(`api/searchJson/?anywhere=&getFacets=true`, {
status: 200,
response: JSON.stringify(no_results)
});
Expand All @@ -197,7 +197,7 @@ describe('searchWrapper.vue', () => {
});

it("displays a 'page not found' message if JSON response is an empty", (done) => {
moxios.stubRequest(`searchJson/?anywhere=&getFacets=true`, {
moxios.stubRequest(`api/searchJson/?anywhere=&getFacets=true`, {
status: 200,
response: JSON.stringify('')
});
Expand All @@ -210,7 +210,7 @@ describe('searchWrapper.vue', () => {
});

it("displays a '503 page' if JSON responds with an error", (done) => {
moxios.stubRequest(`searchJson/?anywhere=&getFacets=true`, {
moxios.stubRequest(`api/searchJson/?anywhere=&getFacets=true`, {
status: 503,
response: JSON.stringify({ message: 'bad stuff happened' })
});
Expand All @@ -230,7 +230,7 @@ describe('searchWrapper.vue', () => {
});

function loadFullData() {
moxios.stubRequest(`searchJson/?anywhere=&getFacets=true`, {
moxios.stubRequest(`api/searchJson/?anywhere=&getFacets=true`, {
status: 200,
response: JSON.stringify(response)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ public class AdvancedSearchFormController extends AbstractErrorHandlingSearchCon
.sorted()
.collect(Collectors.toList());

@RequestMapping(path = "/advancedSearch/collectionsJson", produces = APPLICATION_JSON_VALUE)
@RequestMapping(path = "/api/advancedSearch/collectionsJson", produces = APPLICATION_JSON_VALUE)
public @ResponseBody String getCollections() {
AccessGroupSet accessGroups = GroupsThreadStore.getPrincipals();
SearchResultResponse collectionResultResponse = queryLayer.getCollectionList(accessGroups);
return SerializationUtil.resultsToJSON(collectionResultResponse, accessGroups);
}

@RequestMapping(path = "/advancedSearch/formats", produces = APPLICATION_JSON_VALUE)
@RequestMapping(path = "/api/advancedSearch/formats", produces = APPLICATION_JSON_VALUE)
public @ResponseBody String getFormats() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(FORMAT_VALUES);
}

@RequestMapping(path = "/advancedSearch", method = RequestMethod.GET)
@RequestMapping(path = "/api/advancedSearch", method = RequestMethod.GET)
public String handleRequest(Model model, HttpServletRequest request) {
// If the user has submitted the search form, then generate a search state
// and forward them to the search servlet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @author bbpennel
*/
@Controller
@RequestMapping("/basicSearch")
@RequestMapping("/api/basicSearch")
public class BasicSearchFormController extends AbstractErrorHandlingSearchController {
private static final Logger LOG = LoggerFactory.getLogger(BasicSearchFormController.class);
@Autowired
Expand Down
Loading

0 comments on commit f77644d

Please sign in to comment.