@RequestMapping(value = "/auth/{domain}/permissions/check", method = RequestMethod.GET) public ResponseEntity<Object> checkPermissions(@PathVariable String domain, @RequestParam List<String> permissions) { if(!"SYSTEM".equals(domain.toUpperCase())) { throw new IllegalArgumentException("invalid domain name : " + domain); } Map<String, Object> result = Maps.newHashMap(); if(CollectionUtils.isNotEmpty(permissions)) { List<String> userPerms = AuthUtils.getPermissions(); result.put("hasPermission", CollectionUtils.containsAll(userPerms, permissions)); } else { result.put("hasPermission", false); } return ResponseEntity.ok(result); }
/** * * @param workbookId * @param workspaceId * @return */ public boolean checkWorkBookCopyToWorkspace(String workbookId, String workspaceId) { List<String> dataSourceIdInWorkbook = dataSourceRepository.findIdsByWorkbookInNotPublic(workbookId); List<String> dataSourceIdInWorkspace = dataSourceRepository.findIdsByWorkspaceIn(workspaceId); return CollectionUtils.containsAll(dataSourceIdInWorkspace, dataSourceIdInWorkbook); }
@Override public void doHandleChildChange(String barrierParticipantPath, List<String> participantIds) { if (participantIds == null) { LOG.info("Received notification with null participants for barrier: {}. Ignoring it.", barrierParticipantPath); return; } LOG.info(String.format("Current participants in barrier version: %s = %s.", barrierVersion, participantIds)); LOG.info(String.format("Expected participants in barrier version: %s = %s.", barrierVersion, expectedParticipantIds)); // check if all the expected participants are in if (participantIds.size() == expectedParticipantIds.size() && CollectionUtils.containsAll(participantIds, expectedParticipantIds)) { debounceTimer.scheduleAfterDebounceTime(ACTION_NAME, 0, () -> { String barrierStatePath = keyBuilder.getBarrierStatePath(barrierVersion); State barrierState = zkUtils.getZkClient().readData(barrierStatePath); if (Objects.equals(barrierState, State.NEW)) { LOG.info(String.format("Expected participants has joined the barrier version: %s. Marking the barrier state: %s as %s.", barrierVersion, barrierStatePath, State.DONE)); zkUtils.writeData(barrierStatePath, State.DONE); // this will trigger notifications } else { LOG.debug(String.format("Barrier version: %s is at: %s state. Not marking barrier as %s.", barrierVersion, barrierState, State.DONE)); } LOG.info("Unsubscribing child changes on the path: {} for barrier version: {}.", barrierParticipantPath, barrierVersion); zkUtils.unsubscribeChildChanges(barrierParticipantPath, this); }); } } }
@Override public void doHandleChildChange(String barrierParticipantPath, List<String> participantIds) { if (participantIds == null) { LOG.info("Received notification with null participants for barrier: {}. Ignoring it.", barrierParticipantPath); return; } LOG.info(String.format("Current participants in barrier version: %s = %s.", barrierVersion, participantIds)); LOG.info(String.format("Expected participants in barrier version: %s = %s.", barrierVersion, expectedParticipantIds)); // check if all the expected participants are in if (participantIds.size() == expectedParticipantIds.size() && CollectionUtils.containsAll(participantIds, expectedParticipantIds)) { debounceTimer.scheduleAfterDebounceTime(ACTION_NAME, 0, () -> { String barrierStatePath = keyBuilder.getBarrierStatePath(barrierVersion); State barrierState = zkUtils.getZkClient().readData(barrierStatePath); if (Objects.equals(barrierState, State.NEW)) { LOG.info(String.format("Expected participants has joined the barrier version: %s. Marking the barrier state: %s as %s.", barrierVersion, barrierStatePath, State.DONE)); zkUtils.writeData(barrierStatePath, State.DONE); // this will trigger notifications } else { LOG.debug(String.format("Barrier version: %s is at: %s state. Not marking barrier as %s.", barrierVersion, barrierState, State.DONE)); } LOG.info("Unsubscribing child changes on the path: {} for barrier version: {}.", barrierParticipantPath, barrierVersion); zkUtils.unsubscribeChildChanges(barrierParticipantPath, this); }); } } }
@Override public void doHandleChildChange(String barrierParticipantPath, List<String> participantIds) { if (participantIds == null) { LOG.info("Received notification with null participants for barrier: {}. Ignoring it.", barrierParticipantPath); return; } LOG.info(String.format("Current participants in barrier version: %s = %s.", barrierVersion, participantIds)); LOG.info(String.format("Expected participants in barrier version: %s = %s.", barrierVersion, expectedParticipantIds)); // check if all the expected participants are in if (participantIds.size() == expectedParticipantIds.size() && CollectionUtils.containsAll(participantIds, expectedParticipantIds)) { debounceTimer.scheduleAfterDebounceTime(ACTION_NAME, 0, () -> { String barrierStatePath = keyBuilder.getBarrierStatePath(barrierVersion); State barrierState = zkUtils.getZkClient().readData(barrierStatePath); if (Objects.equals(barrierState, State.NEW)) { LOG.info(String.format("Expected participants has joined the barrier version: %s. Marking the barrier state: %s as %s.", barrierVersion, barrierStatePath, State.DONE)); zkUtils.writeData(barrierStatePath, State.DONE); // this will trigger notifications } else { LOG.debug(String.format("Barrier version: %s is at: %s state. Not marking barrier as %s.", barrierVersion, barrierState, State.DONE)); } LOG.info("Unsubscribing child changes on the path: {} for barrier version: {}.", barrierParticipantPath, barrierVersion); zkUtils.unsubscribeChildChanges(barrierParticipantPath, this); }); } } }
@Override public void doHandleChildChange(String barrierParticipantPath, List<String> participantIds) { if (participantIds == null) { LOG.info("Received notification with null participants for barrier: {}. Ignoring it.", barrierParticipantPath); return; } LOG.info(String.format("Current participants in barrier version: %s = %s.", barrierVersion, participantIds)); LOG.info(String.format("Expected participants in barrier version: %s = %s.", barrierVersion, expectedParticipantIds)); // check if all the expected participants are in if (participantIds.size() == expectedParticipantIds.size() && CollectionUtils.containsAll(participantIds, expectedParticipantIds)) { debounceTimer.scheduleAfterDebounceTime(ACTION_NAME, 0, () -> { String barrierStatePath = keyBuilder.getBarrierStatePath(barrierVersion); State barrierState = zkUtils.getZkClient().readData(barrierStatePath); if (Objects.equals(barrierState, State.NEW)) { LOG.info(String.format("Expected participants has joined the barrier version: %s. Marking the barrier state: %s as %s.", barrierVersion, barrierStatePath, State.DONE)); zkUtils.writeData(barrierStatePath, State.DONE); // this will trigger notifications } else { LOG.debug(String.format("Barrier version: %s is at: %s state. Not marking barrier as %s.", barrierVersion, barrierState, State.DONE)); } LOG.info("Unsubscribing child changes on the path: {} for barrier version: {}.", barrierParticipantPath, barrierVersion); zkUtils.unsubscribeChildChanges(barrierParticipantPath, this); }); } } }
@Override public void doHandleChildChange(String barrierParticipantPath, List<String> participantIds) { if (participantIds == null) { LOG.info("Received notification with null participants for barrier: {}. Ignoring it.", barrierParticipantPath); return; } LOG.info(String.format("Current participants in barrier version: %s = %s.", barrierVersion, participantIds)); LOG.info(String.format("Expected participants in barrier version: %s = %s.", barrierVersion, expectedParticipantIds)); // check if all the expected participants are in if (participantIds.size() == expectedParticipantIds.size() && CollectionUtils.containsAll(participantIds, expectedParticipantIds)) { debounceTimer.scheduleAfterDebounceTime(ACTION_NAME, 0, () -> { String barrierStatePath = keyBuilder.getBarrierStatePath(barrierVersion); State barrierState = zkUtils.getZkClient().readData(barrierStatePath); if (Objects.equals(barrierState, State.NEW)) { LOG.info(String.format("Expected participants has joined the barrier version: %s. Marking the barrier state: %s as %s.", barrierVersion, barrierStatePath, State.DONE)); zkUtils.writeData(barrierStatePath, State.DONE); // this will trigger notifications } else { LOG.debug(String.format("Barrier version: %s is at: %s state. Not marking barrier as %s.", barrierVersion, barrierState, State.DONE)); } LOG.info("Unsubscribing child changes on the path: {} for barrier version: {}.", barrierParticipantPath, barrierVersion); zkUtils.unsubscribeChildChanges(barrierParticipantPath, this); }); } } }
&& CollectionUtils.containsAll(requiredKeys, projectionKeys)) { return; if (!CollectionUtils.containsAll(filterKeys, requiredKeys)) { throw new IllegalArgumentException("Required Filter(" + StringUtils.join(requiredKeys, ",") + ") did not set.");
assertTrue(list instanceof List); assertEquals(2, ((List) list).size()); assertTrue(CollectionUtils.containsAll((List) list, Lists.newArrayList("alien", "fastconnect"))); assertTrue(list instanceof List); assertEquals(2, ((List) list).size()); assertTrue(CollectionUtils.containsAll((List) list, Lists.newArrayList("manual_alien", "manual_fastconnect"))); assertTrue(list instanceof List); assertEquals(2, ((List) list).size()); assertTrue(CollectionUtils.containsAll((List) list, Lists.newArrayList("alien", "fastconnect")));