Skip to content
Snippets Groups Projects
Commit 1ac76814 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Improved error message when attempting to open forbidden node

parent a53b47d1
No related branches found
No related tags found
No related merge requests found
Pipeline #7734 failed
......@@ -10,7 +10,9 @@ import it.inaf.ia2.vospace.ui.client.VOSpaceClient;
import it.inaf.ia2.vospace.ui.data.Job;
import it.inaf.ia2.vospace.ui.data.ListNodeData;
import it.inaf.ia2.vospace.ui.data.MoveOrCopyRequest;
import it.inaf.ia2.vospace.ui.exception.PermissionDeniedException;
import it.inaf.ia2.vospace.ui.exception.VOSpaceException;
import it.inaf.ia2.vospace.ui.exception.VOSpaceStatusException;
import it.inaf.ia2.vospace.ui.service.MainNodesHtmlGenerator;
import it.inaf.ia2.vospace.ui.service.MoveOrCopyNodeModalHtmlGenerator;
import it.inaf.oats.vospace.datamodel.NodeUtils;
......@@ -72,7 +74,19 @@ public class NodesController extends BaseController {
ListNodeData listNodeData = new ListNodeData();
Node node = client.getNode(path);
Node node;
try {
node = client.getNode(path);
} catch (VOSpaceStatusException ex) {
if (ex.getHttpStatus() == 403) {
String message = "You cannot access this node";
if (principal.getAccessToken() != null && principal.isTokenExpired()) {
message += ". Token is expired, please repeat the login.";
}
throw new PermissionDeniedException(message);
}
throw ex;
}
listNodeData.setWritable(NodeUtils.checkIfWritable(node, principal.getName(), principal.getGroups()));
......
......@@ -66,7 +66,7 @@ export default {
headers: {
'Cache-Control': 'no-cache'
}
}, (typeof loading !== 'undefined') ? loading : true, true);
}, (typeof loading !== 'undefined') ? loading : true, true, true);
},
loadJobs() {
let url = BASE_API_URL + 'jobs';
......
......@@ -145,12 +145,22 @@ export default new Vuex.Store({
},
actions: {
setPath({ state, commit, dispatch }, path) {
let previousPath = state.path;
commit('setPath', path);
commit('setNodesLoading', true);
client.getNode(state.path)
.then(res => {
dispatch('setNodes', res);
})
.catch(error => {
if (error.response && error.response.data) {
main.showError(error.response.data.message);
} else {
main.showError('Error while accessing node');
}
commit('setPath', previousPath);
commit('setLoading', false);
})
.finally(() => commit('setNodesLoading', false));
},
setNodes({ commit, dispatch }, res) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment