List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:com.haulmont.cuba.gui.app.security.session.browse.SessionBrowser.java
public void kill() { Set<UserSessionEntity> selected = sessionsTable.getSelected(); if (selected.isEmpty()) return;/*from www . j a v a 2 s. com*/ showOptionDialog(messages.getMainMessage("dialogs.Confirmation"), messages.getMessage(getClass(), "killConfirm"), MessageType.CONFIRMATION, new Action[] { new DialogAction(Type.OK).withHandler(event -> { for (UserSessionEntity session : selected) { if (!session.getId().equals(userSessionSource.getUserSession().getId())) { uss.killSession(session.getId()); } else { showNotification(getMessage("killUnavailable"), NotificationType.WARNING); } } sessionsTable.getDatasource().refresh(); sessionsTable.requestFocus(); }), new DialogAction(Type.CANCEL, Status.PRIMARY) }); }
From source file:com.icesoft.faces.async.common.PushServerAdaptingServlet.java
public PushServerAdaptingServlet(final HttpSession httpSession, final String iceFacesId, final Collection synchronouslyUpdatedViews, final ViewQueue allUpdatedViews, final Configuration configuration, final CoreMessageService coreMessageService) throws MessageServiceException { blockingRequestHandlerContext = configuration.getAttribute("blockingRequestHandlerContext", "push-server"); allUpdatedViews.onPut(new Runnable() { public void run() { allUpdatedViews.removeAll(synchronouslyUpdatedViews); synchronouslyUpdatedViews.clear(); Set _viewIdentifierSet = new HashSet(allUpdatedViews); if (!_viewIdentifierSet.isEmpty()) { Long _sequenceNumber; synchronized (lock) { _sequenceNumber = (Long) httpSession.getAttribute(SEQUENCE_NUMBER_KEY); if (_sequenceNumber != null) { _sequenceNumber = new Long(_sequenceNumber.longValue() + 1); } else { _sequenceNumber = new Long(1); }//www. j av a 2 s .c om httpSession.setAttribute(SEQUENCE_NUMBER_KEY, _sequenceNumber); } String[] _viewIdentifiers = (String[]) _viewIdentifierSet .toArray(new String[_viewIdentifierSet.size()]); StringWriter _stringWriter = new StringWriter(); for (int i = 0; i < _viewIdentifiers.length; i++) { if (i != 0) { _stringWriter.write(','); } _stringWriter.write(_viewIdentifiers[i]); } Properties _messageProperties = new Properties(); _messageProperties.setStringProperty(Message.DESTINATION_SERVLET_CONTEXT_PATH, blockingRequestHandlerContext); coreMessageService.publish(iceFacesId + ";" + // ICEfaces ID _sequenceNumber + ";" + // Sequence Number _stringWriter.toString(), // Message Body _messageProperties, UPDATED_VIEWS_MESSAGE_TYPE, MessageServiceClient.PUSH_TOPIC_NAME); } } }); }
From source file:com.thoughtworks.go.plugin.access.secrets.SecretsExtension.java
public List<Secret> lookupSecrets(String pluginId, SecretConfig secretConfig, Set<String> keys) { final List<Secret> secrets = getVersionedSecretsExtension(pluginId).lookupSecrets(pluginId, secretConfig, keys);/*from w w w. j a v a 2 s.c o m*/ final Set<String> resolvedSecrets = secrets.stream().map(Secret::getKey).collect(Collectors.toSet()); final Set<String> additionalSecretsInResponse = SetUtils.difference(resolvedSecrets, keys).toSet(); if (!additionalSecretsInResponse.isEmpty()) { throw SecretResolutionFailureException.withUnwantedSecretParams(secretConfig.getId(), keys, additionalSecretsInResponse); } if (resolvedSecrets.containsAll(keys)) { return secrets; } final Set<String> missingSecrets = SetUtils.disjunction(resolvedSecrets, keys).toSet(); throw SecretResolutionFailureException.withMissingSecretParams(secretConfig.getId(), keys, missingSecrets); }
From source file:at.ac.univie.isc.asio.security.HttpMethodRestrictionFilter.java
@Override public void doFilter(final ServletRequest servletRequest, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) servletRequest; final Authentication authentication = org.springframework.security.core.context.SecurityContextHolder .getContext().getAuthentication(); if (authentication != null && HttpMethod.GET.name().equalsIgnoreCase(request.getMethod())) { logger.debug("applying " + RESTRICTION + " to " + authentication); Set<GrantedAuthority> restricted = RESTRICTION.mapAuthorities(authentication.getAuthorities()); if (restricted.isEmpty()) { // anonymous and remember me tokens require at least one authority restricted = Collections.<GrantedAuthority>singleton(Role.NONE); }// ww w. j ava 2 s. c o m if (!restricted.containsAll(authentication.getAuthorities())) { final AbstractAuthenticationToken replacement = copy(authentication, restricted); replacement.setDetails(authentication.getDetails()); logger.debug("injecting " + replacement); org.springframework.security.core.context.SecurityContextHolder.getContext() .setAuthentication(replacement); } else { logger.debug("skip restricting " + authentication + " as it contains no restricted authorities"); } } else { logger.debug("skip restricting " + authentication + " on HTTP method " + request.getMethod()); } chain.doFilter(request, response); }
From source file:se.uu.it.cs.recsys.semantic.ComputingDomainReasonerTest.java
/** * Test of getRelatedDomainIds method, of class ComputingDomainReasoner. *///from w w w . j a v a 2s . co m @Test public void testGetRelatedDomainIds_Empty_Result() throws Exception { final String dataMiningId = "10003351"; Set<String> result = this.reasoner.getRelatedDomainIds(dataMiningId); assertTrue(result.isEmpty()); }
From source file:com.glaf.base.tag.PermissionTag.java
public int doStartTag() { String userId = RequestUtils.getActorId((HttpServletRequest) super.pageContext.getRequest()); AuthorizeBean bean = new AuthorizeBean(); SysUser user = bean.getUser(userId); boolean hasPermission = false; StringTokenizer token = new StringTokenizer(key, ","); Collection<String> roleIds = new java.util.ArrayList<String>(); Collection<String> permissions = new java.util.ArrayList<String>(); if (user != null) { if (user.isSystemAdmin()) { return 1; }//ww w. j a v a 2 s . c om Set<SysDeptRole> roles = user.getRoles(); if (roles != null && !roles.isEmpty()) { for (SysDeptRole dr : roles) { if (dr.getRole() != null) { roleIds.add(dr.getRole().getCode()); } } } } logger.debug("roleIds:" + roleIds); logger.debug("permissions:" + permissions); logger.debug("key:" + key); if (operator != null) { if ((operator.equals("||") || operator.equals("or"))) { while (token.hasMoreTokens()) { String permKey = token.nextToken(); if (roleIds != null && permissions != null) { if (permissions.contains(permKey) || roleIds.contains(permKey)) { hasPermission = true; } } } } } else { if (roleIds != null && permissions != null) { while (token.hasMoreTokens()) { String permKey = token.nextToken(); if (permissions.contains(permKey) || roleIds.contains(permKey)) { hasPermission = true; } } } } return hasPermission ? 1 : 0; }
From source file:com.thinkbiganalytics.feedmgr.nifi.CleanupStaleFeedRevisions.java
private void stopPorts(Set<PortDTO> ports) { if (!ports.isEmpty()) { ports.stream().filter(portDTO -> !stoppedPorts.contains(portDTO)).forEach(portDTO1 -> { if (isInputPort(portDTO1)) { restClient.stopInputPort(portDTO1.getParentGroupId(), portDTO1.getId()); stoppedPorts.add(portDTO1); } else { restClient.stopOutputPort(portDTO1.getParentGroupId(), portDTO1.getId()); stoppedPorts.add(portDTO1); }//from ww w. j ava2 s. c om }); } }
From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreCoverageMeasurementFilter.java
@Override public boolean accept(final Resource resource, final Measure measure) { if (!ResourceUtils.isFile(resource)) { return true; }/* w w w .ja v a2 s . co m*/ if (!COVERAGE_METRICS.contains(measure.getMetric())) { return true; } final String resourceKey = resource.getKey(); final String metricKey = measure.getMetricKey(); for (final CoveragePattern pattern : patterns) { final WildcardPattern wildcardPattern = WildcardPattern.create(pattern.getResourcePattern()); if (!wildcardPattern.match(resourceKey)) { continue; } final Set<Integer> lines = pattern.getLines(); if (lines.isEmpty()) { // empty is any line => remove all measures LOGGER.info("measure of metric {} on resource {} filtered by {}", metricKey, resourceKey, pattern); return false; } LOGGER.info("measure of metric {} on resource {} modified by {}", metricKey, resourceKey, pattern); rewrite(measure, lines); } return true; }
From source file:ru.mystamps.web.service.StampsCatalogServiceImpl.java
@Override @Transactional//ww w . j a v a 2 s . c om @PreAuthorize(HasAuthority.CREATE_SERIES) public void add(Set<String> catalogNumbers) { Validate.isTrue(catalogNumbers != null, "%s numbers must be non null", catalogName); Validate.isTrue(!catalogNumbers.isEmpty(), "%s numbers must be non empty", catalogName); List<String> insertedNumbers = stampsCatalogDao.add(catalogNumbers); if (!insertedNumbers.isEmpty()) { LOG.info("{} numbers {} were created", catalogName, insertedNumbers); } }
From source file:io.klerch.alexa.tellask.model.wrapper.AlexaSpeechletServlet.java
/** * When this servlet is created it obtains supported application ids from overridden getter * or AlexaApplication-annotation and joins this set of ids with supported application ids * configured in system property 'com.amazon.speech.speechlet.servlet.supportedApplicationIds' */// w w w .j a va 2 s .c o m public AlexaSpeechletServlet() { super(); final Set<String> customSupportedApplicationIds = getSupportedApplicationIds(); if (!customSupportedApplicationIds.isEmpty()) { // add supported application ids to system variable final String systemSupportedApplicationIds = System .getProperty(Sdk.SUPPORTED_APPLICATION_IDS_SYSTEM_PROPERTY); if (systemSupportedApplicationIds != null) { customSupportedApplicationIds.addAll(Arrays.asList(systemSupportedApplicationIds.split(","))); } // update system property with appended application ids provided by this servlet System.setProperty(Sdk.SUPPORTED_APPLICATION_IDS_SYSTEM_PROPERTY, String.join(",", customSupportedApplicationIds)); } }