Commit d2408b1a authored by Sonia Zorba's avatar Sonia Zorba
Browse files

API endpoint refactoring: added /ui prefix to API dedicated to JavaScript...

API endpoint refactoring: added /ui prefix to API dedicated to JavaScript front-end; Added some unit tests
parent 0922b032
Loading
Loading
Loading
Loading
+19 −19
Original line number Original line Diff line number Diff line
@@ -54,7 +54,7 @@ function loading(value) {
export default {
export default {
  fetchHomePageModel(input) {
  fetchHomePageModel(input) {
    let url = BASE_API_URL +
    let url = BASE_API_URL +
      'home?groupId=' + input.selectedGroupId +
      'ui/home?groupId=' + input.selectedGroupId +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPage=' + input.paginatorPage;
      '&paginatorPage=' + input.paginatorPage;
    return apiRequest({
    return apiRequest({
@@ -70,7 +70,7 @@ export default {
  },
  },
  fetchGroupsTab(input) {
  fetchGroupsTab(input) {
    let url = BASE_API_URL +
    let url = BASE_API_URL +
      'groups?groupId=' + input.selectedGroupId +
      'ui/groups?groupId=' + input.selectedGroupId +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPage=' + input.paginatorPage +
      '&paginatorPage=' + input.paginatorPage +
      '&onlyPanel=false';
      '&onlyPanel=false';
@@ -90,7 +90,7 @@ export default {
  },
  },
  fetchGroupsPanel(input) {
  fetchGroupsPanel(input) {
    let url = BASE_API_URL +
    let url = BASE_API_URL +
      'groups?groupId=' + input.selectedGroupId +
      'ui/groups?groupId=' + input.selectedGroupId +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPage=' + input.paginatorPage +
      '&paginatorPage=' + input.paginatorPage +
      '&onlyPanel=true';
      '&onlyPanel=true';
@@ -110,7 +110,7 @@ export default {
  },
  },
  fetchMembersPanel(input) {
  fetchMembersPanel(input) {
    let url = BASE_API_URL +
    let url = BASE_API_URL +
      'members?groupId=' + input.selectedGroupId +
      'ui/members?groupId=' + input.selectedGroupId +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPage=' + input.paginatorPage;
      '&paginatorPage=' + input.paginatorPage;
    return apiRequest({
    return apiRequest({
@@ -126,7 +126,7 @@ export default {
  },
  },
  fetchPermissionsPanel(input) {
  fetchPermissionsPanel(input) {
    let url = BASE_API_URL +
    let url = BASE_API_URL +
      'permissions?groupId=' + input.selectedGroupId +
      'ui/permissions?groupId=' + input.selectedGroupId +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPage=' + input.paginatorPage;
      '&paginatorPage=' + input.paginatorPage;
    return apiRequest({
    return apiRequest({
@@ -141,7 +141,7 @@ export default {
    });
    });
  },
  },
  addGroup(newGroupName, leaf, input) {
  addGroup(newGroupName, leaf, input) {
    let url = BASE_API_URL + 'group';
    let url = BASE_API_URL + 'ui/group';
    return apiRequest({
    return apiRequest({
      method: 'POST',
      method: 'POST',
      url: url,
      url: url,
@@ -162,7 +162,7 @@ export default {
    }, true, true);
    }, true, true);
  },
  },
  updateGroup(groupId, newGroupName, leaf, input) {
  updateGroup(groupId, newGroupName, leaf, input) {
    let url = BASE_API_URL + 'group/' + groupId;
    let url = BASE_API_URL + 'ui/group/' + groupId;
    return apiRequest({
    return apiRequest({
      method: 'PUT',
      method: 'PUT',
      url: url,
      url: url,
@@ -182,7 +182,7 @@ export default {
    }, true, true);
    }, true, true);
  },
  },
  removeGroup(groupId, input) {
  removeGroup(groupId, input) {
    let url = BASE_API_URL + 'group/' + groupId +
    let url = BASE_API_URL + 'ui/group/' + groupId +
      '?paginatorPageSize=' + input.paginatorPageSize +
      '?paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPage=' + input.paginatorPage;
      '&paginatorPage=' + input.paginatorPage;
    if (input.searchFilter !== null) {
    if (input.searchFilter !== null) {
@@ -200,7 +200,7 @@ export default {
    });
    });
  },
  },
  searchUser(searchInput) {
  searchUser(searchInput) {
    let url = BASE_API_URL + 'users?search=' + searchInput;
    let url = BASE_API_URL + 'ui/users?search=' + searchInput;


    return apiRequest({
    return apiRequest({
      method: 'GET',
      method: 'GET',
@@ -213,7 +213,7 @@ export default {
    });
    });
  },
  },
  addPermission(userId, permission, input, override) {
  addPermission(userId, permission, input, override) {
    let url = BASE_API_URL + 'permission';
    let url = BASE_API_URL + 'ui/permission';


    return apiRequest({
    return apiRequest({
      method: 'POST',
      method: 'POST',
@@ -235,7 +235,7 @@ export default {
    });
    });
  },
  },
  updatePermission(groupId, userId, permission) {
  updatePermission(groupId, userId, permission) {
    let url = BASE_API_URL + 'permission';
    let url = BASE_API_URL + 'ui/permission';


    return apiRequest({
    return apiRequest({
      method: 'PUT',
      method: 'PUT',
@@ -254,7 +254,7 @@ export default {
    });
    });
  },
  },
  getPermission(groupId, userId) {
  getPermission(groupId, userId) {
    let url = BASE_API_URL + 'permission?groupId=' + groupId + '&userId=' + userId;
    let url = BASE_API_URL + 'ui/permission?groupId=' + groupId + '&userId=' + userId;


    return apiRequest({
    return apiRequest({
      method: 'GET',
      method: 'GET',
@@ -268,7 +268,7 @@ export default {
    });
    });
  },
  },
  addMember(userId, permission, input) {
  addMember(userId, permission, input) {
    let url = BASE_API_URL + 'member';
    let url = BASE_API_URL + 'ui/member';


    return apiRequest({
    return apiRequest({
      method: 'POST',
      method: 'POST',
@@ -289,7 +289,7 @@ export default {
    });
    });
  },
  },
  removeMember(userId, removeAlsoPermission, input) {
  removeMember(userId, removeAlsoPermission, input) {
    let url = BASE_API_URL + 'member' +
    let url = BASE_API_URL + 'ui/member' +
      '?groupId=' + input.selectedGroupId +
      '?groupId=' + input.selectedGroupId +
      '&userId=' + userId +
      '&userId=' + userId +
      '&removeAlsoPermission=' + removeAlsoPermission +
      '&removeAlsoPermission=' + removeAlsoPermission +
@@ -307,7 +307,7 @@ export default {
    });
    });
  },
  },
  removePermission(userId, input) {
  removePermission(userId, input) {
    let url = BASE_API_URL + 'permission' +
    let url = BASE_API_URL + 'ui/permission' +
      '?groupId=' + input.selectedGroupId +
      '?groupId=' + input.selectedGroupId +
      '&userId=' + userId +
      '&userId=' + userId +
      '&paginatorPageSize=' + input.paginatorPageSize +
      '&paginatorPageSize=' + input.paginatorPageSize +
@@ -324,7 +324,7 @@ export default {
    });
    });
  },
  },
  search(input) {
  search(input) {
    let url = BASE_API_URL + 'search?query=' + input.genericSearch.filter +
    let url = BASE_API_URL + 'ui/search?query=' + input.genericSearch.filter +
      '&paginatorPage=' + input.genericSearch.paginatorPage +
      '&paginatorPage=' + input.genericSearch.paginatorPage +
      '&paginatorPageSize=' + input.genericSearch.paginatorPageSize +
      '&paginatorPageSize=' + input.genericSearch.paginatorPageSize +
      '&users=' + input.genericSearch.users + "&groups=" + input.genericSearch.groups;
      '&users=' + input.genericSearch.users + "&groups=" + input.genericSearch.groups;
@@ -341,7 +341,7 @@ export default {
    });
    });
  },
  },
  openUserSearchResult(userId) {
  openUserSearchResult(userId) {
    let url = BASE_API_URL + 'search/user/' + userId;
    let url = BASE_API_URL + 'ui/search/user/' + userId;


    return apiRequest({
    return apiRequest({
      method: 'GET',
      method: 'GET',
@@ -355,7 +355,7 @@ export default {
    });
    });
  },
  },
  keepAlive() {
  keepAlive() {
    let url = BASE_API_URL + 'keepAlive';
    let url = BASE_API_URL + 'ui/keepAlive';


    return apiRequest({
    return apiRequest({
      method: 'GET',
      method: 'GET',
@@ -367,7 +367,7 @@ export default {
    }, false);
    }, false);
  },
  },
  deleteInvitedRegistration(requestId, groupId) {
  deleteInvitedRegistration(requestId, groupId) {
    let url = BASE_API_URL + 'registration?' +
    let url = BASE_API_URL + 'ui/registration?' +
      'request_id=' + requestId + '&group_id=' + groupId;
      'request_id=' + requestId + '&group_id=' + groupId;
    return apiRequest({
    return apiRequest({
      method: 'DELETE',
      method: 'DELETE',
+5 −5
Original line number Original line Diff line number Diff line
@@ -65,7 +65,7 @@ public class GroupsController {
    @Autowired
    @Autowired
    protected GroupNameService groupNameService;
    protected GroupNameService groupNameService;


    @GetMapping(value = "/groups", produces = MediaType.APPLICATION_JSON_VALUE)
    @GetMapping(value = "/ui/groups", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<?> getGroupsTab(@Valid GroupsRequest request) {
    public ResponseEntity<?> getGroupsTab(@Valid GroupsRequest request) {
        if (request.isOnlyPanel()) {
        if (request.isOnlyPanel()) {
            // Only groupsPanel
            // Only groupsPanel
@@ -77,7 +77,7 @@ public class GroupsController {
        }
        }
    }
    }


    @PostMapping(value = "/group", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/ui/group", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<PaginatedData<GroupNode>> createGroup(@Valid @RequestBody AddGroupRequest request) {
    public ResponseEntity<PaginatedData<GroupNode>> createGroup(@Valid @RequestBody AddGroupRequest request) {


        GroupEntity parent = groupsManager.getGroupById(request.getParentGroupId());
        GroupEntity parent = groupsManager.getGroupById(request.getParentGroupId());
@@ -89,7 +89,7 @@ public class GroupsController {
        return new ResponseEntity<>(groupsPanel, HttpStatus.CREATED);
        return new ResponseEntity<>(groupsPanel, HttpStatus.CREATED);
    }
    }


    @PutMapping(value = "/group/{groupId}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    @PutMapping(value = "/ui/group/{groupId}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<PaginatedData<GroupNode>> updateGroup(@PathVariable("groupId") String groupId, @Valid @RequestBody RenameGroupRequest request) {
    public ResponseEntity<PaginatedData<GroupNode>> updateGroup(@PathVariable("groupId") String groupId, @Valid @RequestBody RenameGroupRequest request) {


        GroupEntity updatedGroup = groupsManager.updateGroup(groupId, request.getNewGroupName(), request.isLeaf());
        GroupEntity updatedGroup = groupsManager.updateGroup(groupId, request.getNewGroupName(), request.isLeaf());
@@ -101,8 +101,8 @@ public class GroupsController {
        return ResponseEntity.ok(groupsPanel);
        return ResponseEntity.ok(groupsPanel);
    }
    }


    @DeleteMapping(value = "/group/{groupId}", produces = MediaType.APPLICATION_JSON_VALUE)
    @DeleteMapping(value = "/ui/group/{groupId}", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<?> deleteGroup(@PathVariable("groupId") String groupId, DeleteGroupRequest request) {
    public ResponseEntity<PaginatedData<GroupNode>> deleteGroup(@PathVariable("groupId") String groupId, DeleteGroupRequest request) {


        GroupEntity parent = groupsManager.deleteGroup(groupId);
        GroupEntity parent = groupsManager.deleteGroup(groupId);
        PaginatedData<GroupNode> groupsPanel = getGroupsPanel(parent, request);
        PaginatedData<GroupNode> groupsPanel = getGroupsPanel(parent, request);
+1 −1
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@ public class HomePageController {
    private InvitedRegistrationManager invitedRegistrationManager;
    private InvitedRegistrationManager invitedRegistrationManager;


    @ResponseBody
    @ResponseBody
    @GetMapping(value = "/home", produces = MediaType.APPLICATION_JSON_VALUE)
    @GetMapping(value = "/ui/home", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<HomePageResponse> getMainPage(@Valid GroupsRequest request) {
    public ResponseEntity<HomePageResponse> getMainPage(@Valid GroupsRequest request) {


        HomePageResponse response = new HomePageResponse();
        HomePageResponse response = new HomePageResponse();
+1 −1
Original line number Original line Diff line number Diff line
@@ -59,7 +59,7 @@ public class InvitedRegistrationController {
        }
        }
    }
    }


    @DeleteMapping(value = "/registration", produces = MediaType.APPLICATION_JSON_VALUE)
    @DeleteMapping(value = "/ui/registration", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<?> deleteInvitedRegistration(@RequestParam("request_id") String requestId, @RequestParam("group_id") String groupId) {
    public ResponseEntity<?> deleteInvitedRegistration(@RequestParam("request_id") String requestId, @RequestParam("group_id") String groupId) {
        invitedRegistrationManager.deleteInvitedRegistration(requestId, groupId);
        invitedRegistrationManager.deleteInvitedRegistration(requestId, groupId);
        return ResponseEntity.noContent().build();
        return ResponseEntity.noContent().build();
+1 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@ public class KeepAliveController {
        userManager = ServiceLocator.getInstance().getUserManager();
        userManager = ServiceLocator.getInstance().getUserManager();
    }
    }


    @GetMapping(value = "/keepAlive", produces = MediaType.APPLICATION_JSON_VALUE)
    @GetMapping(value = "/ui/keepAlive", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<?> keepAlive(HttpServletRequest request) {
    public ResponseEntity<?> keepAlive(HttpServletRequest request) {
        LOG.trace("Keepalive called");
        LOG.trace("Keepalive called");
        if (sessionData.getExpiresIn() < 60) {
        if (sessionData.getExpiresIn() < 60) {
Loading