List of usage examples for java.util Set retainAll
boolean retainAll(Collection<?> c);
From source file:org.openmrs.module.webservices.rest.web.api.impl.RestServiceImpl.java
/** * @see org.openmrs.module.webservices.rest.web.api.RestService#getSearchHandler(java.lang.String, * java.util.Map)//from www .j a va 2s . c o m * @should throw exception if no handler with id * @should return handler by id if exists * @should throw ambiguous exception if case 1 * @should return handler if case 2 */ @Override public SearchHandler getSearchHandler(String resourceName, Map<String, String[]> parameters) throws APIException { initializeSearchHandlers(); String[] searchIds = parameters.get(RestConstants.REQUEST_PROPERTY_FOR_SEARCH_ID); if (searchIds != null && searchIds.length > 0) { SearchHandler searchHandler = searchHandlersByIds .get(new SearchHandlerIdKey(resourceName, searchIds[0])); if (searchHandler == null) { throw new InvalidSearchException("The search with id '" + searchIds[0] + "' for '" + resourceName + "' resource is not recognized"); } else { return searchHandler; } } Set<String> searchParameters = new HashSet<String>(parameters.keySet()); searchParameters.removeAll(RestConstants.SPECIAL_REQUEST_PARAMETERS); Set<SearchHandler> candidateSearchHandlers = null; for (String searchParameter : searchParameters) { Set<SearchHandler> searchHandlers = searchHandlersByParameter .get(new SearchHandlerParameterKey(resourceName, searchParameter)); if (searchHandlers == null) { return null; //Missing parameter so there's no handler. } else if (candidateSearchHandlers == null) { candidateSearchHandlers = new HashSet<SearchHandler>(); candidateSearchHandlers.addAll(searchHandlers); } else { //Eliminate candidate search handlers that do not include all parameters candidateSearchHandlers.retainAll(searchHandlers); } } if (candidateSearchHandlers == null) { return null; } else { eliminateCandidateSearchHandlersWithMissingRequiredParameters(candidateSearchHandlers, searchParameters); if (candidateSearchHandlers.isEmpty()) { return null; } else if (candidateSearchHandlers.size() == 1) { return candidateSearchHandlers.iterator().next(); } else { List<String> candidateSearchHandlerIds = new ArrayList<String>(); for (SearchHandler candidateSearchHandler : candidateSearchHandlers) { candidateSearchHandlerIds.add(RestConstants.REQUEST_PROPERTY_FOR_SEARCH_ID + "=" + candidateSearchHandler.getSearchConfig().getId()); } throw new InvalidSearchException("The search is ambiguous. Please specify " + StringUtils.join(candidateSearchHandlerIds, " or ")); } } }
From source file:org.structr.core.property.EndNodes.java
@Override public SearchAttribute getSearchAttribute(SecurityContext securityContext, BooleanClause.Occur occur, List<T> searchValue, boolean exactMatch, final Query query) { final Predicate<GraphObject> predicate = query != null ? query.toPredicate() : null; final SourceSearchAttribute attr = new SourceSearchAttribute(occur); final Set<GraphObject> intersectionResult = new LinkedHashSet<>(); boolean alreadyAdded = false; if (searchValue != null && !StringUtils.isBlank(searchValue.toString())) { if (exactMatch) { for (NodeInterface node : searchValue) { switch (occur) { case MUST: if (!alreadyAdded) { // the first result is the basis of all subsequent intersections intersectionResult.addAll( getRelatedNodesReverse(securityContext, node, declaringClass, predicate)); // the next additions are intersected with this one alreadyAdded = true; } else { intersectionResult.retainAll( getRelatedNodesReverse(securityContext, node, declaringClass, predicate)); }//from ww w .j ava 2s . com break; case SHOULD: intersectionResult .addAll(getRelatedNodesReverse(securityContext, node, declaringClass, predicate)); break; case MUST_NOT: break; } } } else { // loose search behaves differently, all results must be combined for (NodeInterface node : searchValue) { intersectionResult .addAll(getRelatedNodesReverse(securityContext, node, declaringClass, predicate)); } } attr.setResult(intersectionResult); } else { // experimental filter attribute that // removes entities with a non-empty // value in the given field return new EmptySearchAttribute(this, null); } return attr; }
From source file:org.structr.core.property.StartNodes.java
@Override public SearchAttribute getSearchAttribute(SecurityContext securityContext, BooleanClause.Occur occur, List<S> searchValue, boolean exactMatch, final Query query) { final Predicate<GraphObject> predicate = query != null ? query.toPredicate() : null; final SourceSearchAttribute attr = new SourceSearchAttribute(occur); final Set<GraphObject> intersectionResult = new LinkedHashSet<>(); boolean alreadyAdded = false; if (searchValue != null && !StringUtils.isBlank(searchValue.toString())) { if (exactMatch) { for (NodeInterface node : searchValue) { switch (occur) { case MUST: if (!alreadyAdded) { // the first result is the basis of all subsequent intersections intersectionResult.addAll( getRelatedNodesReverse(securityContext, node, declaringClass, predicate)); // the next additions are intersected with this one alreadyAdded = true; } else { intersectionResult.retainAll( getRelatedNodesReverse(securityContext, node, declaringClass, predicate)); }// w w w. j av a 2s.c o m break; case SHOULD: intersectionResult .addAll(getRelatedNodesReverse(securityContext, node, declaringClass, predicate)); break; case MUST_NOT: break; } } } else { // loose search behaves differently, all results must be combined for (NodeInterface node : searchValue) { intersectionResult .addAll(getRelatedNodesReverse(securityContext, node, declaringClass, predicate)); } } attr.setResult(intersectionResult); } else { // experimental filter attribute that // removes entities with a non-empty // value in the given field return new EmptySearchAttribute(this, null); } return attr; }
From source file:com.mirth.connect.server.controllers.DonkeyMessageController.java
/** * Removes all message and metadata ids from messages that do not exist in newMessages */// w ww. j a va 2 s .co m private void joinMessages(Map<Long, MessageSearchResult> messages, Map<Long, MessageSearchResult> newMessages) { Iterator<Entry<Long, MessageSearchResult>> iterator = messages.entrySet().iterator(); while (iterator.hasNext()) { Entry<Long, MessageSearchResult> entry = iterator.next(); Long tempMessageId = entry.getKey(); if (!newMessages.containsKey(tempMessageId)) { iterator.remove(); } else { Set<Integer> firstMetaDataIds = entry.getValue().getMetaDataIdSet(); firstMetaDataIds.retainAll(newMessages.get(tempMessageId).getMetaDataIdSet()); } } }
From source file:org.cloudfoundry.identity.uaa.oauth.token.UaaTokenServices.java
private Set<String> getAutoApprovedScopes(Object grantType, Collection<String> tokenScopes, ClientDetails client) {// www. jav a 2 s . co m // ALL requested scopes are considered auto-approved for password grant if (grantType != null && "password".equals(grantType.toString())) { return new HashSet<String>(tokenScopes); } // start with scopes listed as autoapprove in client config Object autoApproved = client.getAdditionalInformation().get("autoapprove"); Set<String> autoApprovedScopes = new HashSet<String>(); if (autoApproved instanceof Collection<?>) { @SuppressWarnings("unchecked") Collection<? extends String> approvedScopes = (Collection<? extends String>) autoApproved; autoApprovedScopes.addAll(approvedScopes); } else if (autoApproved instanceof Boolean && (Boolean) autoApproved || "true".equals(autoApproved)) { autoApprovedScopes.addAll(client.getScope()); } // retain only the requested scopes autoApprovedScopes.retainAll(tokenScopes); return autoApprovedScopes; }
From source file:fr.univrouen.poste.web.candidat.MyPosteCandidatureController.java
@RequestMapping(produces = "text/html") public String list(@ModelAttribute("command") PosteCandidatureSearchCriteria searchCriteria, BindingResult bindResult, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "sortFieldName", required = false) String sortFieldName, @RequestParam(value = "sortOrder", required = false) String sortOrder, @RequestParam(value = "zip", required = false, defaultValue = "off") Boolean zip, HttpServletResponse response, HttpServletRequest request, Model uiModel) throws IOException, SQLException { // uiModel.addAttribute("users", User.findUserEntries(firstResult, // sizeNo));//w w w . j a v a 2 s . c om List<PosteCandidature> postecandidatures = null; Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String emailAddress = auth.getName(); User user = User.findUsersByEmailAddress(emailAddress, null, null).getSingleResult(); boolean isAdmin = auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_ADMIN")); boolean isManager = auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_MANAGER")); boolean isSuperManager = isManager || auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_SUPER_MANAGER")); boolean isMembre = auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_MEMBRE")); boolean isCandidat = auth.getAuthorities().contains(new GrantedAuthorityImpl("ROLE_CANDIDAT")); if (sortFieldName == null) sortFieldName = "o.poste.numEmploi,o.candidat.nom"; if ("nom".equals(sortFieldName)) sortFieldName = "candidat.nom"; if ("email".equals(sortFieldName)) sortFieldName = "candidat.emailAddress"; if ("numCandidat".equals(sortFieldName)) sortFieldName = "candidat.numCandidat"; if ("managerReviewState".equals(sortFieldName)) sortFieldName = "managerReview.reviewStatus"; // pagination only for admin / manager users ... if (isAdmin || isManager) { if (page != null || size != null) { int sizeNo = size == null ? 10 : size.intValue(); int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo; long nbResultsTotal = PosteCandidature.countPosteCandidatures(); uiModel.addAttribute("nbResultsTotal", nbResultsTotal); float nrOfPages = (float) nbResultsTotal / sizeNo; uiModel.addAttribute("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages)); postecandidatures = PosteCandidature.findPosteCandidatureEntries(firstResult, sizeNo, sortFieldName, sortOrder); } else { postecandidatures = PosteCandidature.findAllPosteCandidatures(sortFieldName, sortOrder); uiModel.addAttribute("nbResultsTotal", postecandidatures.size()); } uiModel.addAttribute("posteapourvoirs", PosteAPourvoir.findAllPosteAPourvoirNumEplois()); uiModel.addAttribute("candidats", User.findAllCandidatsIds()); uiModel.addAttribute("reviewStatusList", Arrays.asList(ReviewStatusTypes.values())); String mailAuditionnableEntete = AppliConfig.getCacheTexteEnteteMailCandidatAuditionnable(); String mailAuditionnablePiedPage = AppliConfig.getCacheTextePiedpageMailCandidatAuditionnable(); uiModel.addAttribute("mailAuditionnableEntete", mailAuditionnableEntete); uiModel.addAttribute("mailAuditionnablePiedPage", mailAuditionnablePiedPage); } else if (isCandidat) { if (!AppliConfig.getCacheCandidatCanSignup()) { postecandidatures = new ArrayList<PosteCandidature>( PosteCandidature.findPosteCandidaturesByCandidat(user, null, null).getResultList()); // restrictions si phase auditionnable Date currentTime = new Date(); if (currentTime.compareTo(AppliConfig.getCacheDateEndCandidat()) > 0 && currentTime.compareTo(AppliConfig.getCacheDateEndCandidatActif()) > 0) { for (PosteCandidature postecandidature : PosteCandidature .findPosteCandidaturesByCandidat(user, null, null).getResultList()) { if (!postecandidature.getAuditionnable() || postecandidature.getPoste() .getDateEndCandidatAuditionnable() != null && currentTime.compareTo( postecandidature.getPoste().getDateEndCandidatAuditionnable()) > 0) { postecandidatures.remove(postecandidature); } } } } else { postecandidatures = new ArrayList<PosteCandidature>(PosteCandidature .findPosteCandidaturesByCandidatAndByDateEndCandidatGreaterThanAndNoAuditionnableOrByDateEndCandidatAuditionnableGreaterThanAndAuditionnable( user, new Date()) .getResultList()); } } else if (isMembre) { Set<PosteAPourvoir> membresPostes = new HashSet<PosteAPourvoir>(user.getPostes()); List<PosteAPourvoir> postes = searchCriteria.getPostes(); if (postes != null && !postes.isEmpty()) { membresPostes.retainAll(postes); uiModel.addAttribute("finderview", true); uiModel.addAttribute("command", searchCriteria); } if (membresPostes.isEmpty()) { membresPostes = new HashSet<PosteAPourvoir>(user.getPostes()); } postecandidatures = PosteCandidature.findPosteCandidaturesRecevableByPostes(membresPostes, searchCriteria.getAuditionnable(), sortFieldName, sortOrder).getResultList(); if (zip) { String contentType = "application/zip"; Calendar cal = Calendar.getInstance(); Date currentTime = cal.getTime(); SimpleDateFormat dateFmt = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); String currentTimeFmt = dateFmt.format(currentTime); String baseName = "demat-" + currentTimeFmt + ".zip"; response.setContentType(contentType); response.setHeader("Content-Disposition", "attachment; filename=\"" + baseName + "\""); zipService.writeZip(postecandidatures, response.getOutputStream()); logService.logActionFile(LogService.DOWNLOAD_ACTION, postecandidatures, request, currentTime); return null; } for (PosteCandidature pc : postecandidatures) { if (pc.getReporters() != null && pc.getReporters().contains(user)) { pc.setReporterTag(true); } } uiModel.addAttribute("nbResultsTotal", postecandidatures.size()); List<PosteAPourvoir> membresPostes2Display = new ArrayList<PosteAPourvoir>(user.getPostes()); Collections.sort(membresPostes2Display, new Comparator<PosteAPourvoir>() { @Override public int compare(PosteAPourvoir p1, PosteAPourvoir p2) { return p1.getNumEmploi().compareTo(p2.getNumEmploi()); } }); uiModel.addAttribute("membresPostes", membresPostes2Display); } uiModel.addAttribute("postecandidatures", postecandidatures); uiModel.addAttribute("zip", new Boolean(false)); uiModel.addAttribute("texteMembreAideCandidatures", AppliConfig.getCacheTexteMembreAideCandidatures()); uiModel.addAttribute("texteCandidatAideCandidatures", AppliConfig.getCacheTexteCandidatAideCandidatures()); uiModel.addAttribute("legendColors", ManagerReviewLegendColor.getLegendColors()); addDateTimeFormatPatterns(uiModel); return "postecandidatures/list"; }
From source file:com.smartmarmot.dbforbix.config.Config.java
/** * compares config file hashes: previous and actual * @return true or false/*from w ww .j a v a2 s .co m*/ */ public boolean checkConfigChanges() { Config newconfig = new Config(); Config oldconfig = this; newconfig.setBasedir(oldconfig.getBasedir()); newconfig.setConfigFile(oldconfig.getConfigFile()); try { newconfig.readFileConfig(); } catch (IOException e) { LOG.error("Error in config: " + e.getLocalizedMessage()); return false; } catch (NullPointerException e) { LOG.error("Failed to calculate hash for config file: " + e.getLocalizedMessage()); return false; } boolean configFileChanged = (0 == newconfig.getFileConfigHash().compareTo(oldconfig.getFileConfigHash())) ? false : true; LOG.debug("Is config changed: " + configFileChanged); if (configFileChanged) return true; /** * Update configuration from Zabbix Servers */ newconfig.getZabbixConfigurationItems(); Set<String> configurationUIDs = oldconfig.getSetOfConfigurationUIDs(); Set<String> newConfigurationUIDs = newconfig.getSetOfConfigurationUIDs(); /** * candidates for update: * i.e. zbxServerHost:zbxServerPort, proxy, host, db, item key * are the same */ Set<String> toUpdate = new HashSet<>(configurationUIDs); toUpdate.retainAll(newConfigurationUIDs); Set<String> toRemoveFromUpdate = new HashSet<>(); for (String configurationUID : toUpdate) { ZabbixServer zabbixServer = oldconfig.getZabbixServerByConfigurationUID(configurationUID); ZabbixServer newZabbixServer = newconfig.getZabbixServerByConfigurationUID(configurationUID); IConfigurationItem configurationItem = zabbixServer .getConfigurationItemByConfigurationUID(configurationUID); IConfigurationItem newConfigurationItem = newZabbixServer .getConfigurationItemByConfigurationUID(configurationUID); String hashParam = configurationItem.getHashParam(); String newHashParam = newConfigurationItem.getHashParam(); if (hashParam.equals(newHashParam)) toRemoveFromUpdate.add(configurationUID); } toUpdate.removeAll(toRemoveFromUpdate); Set<String> toDelete = new HashSet<String>(configurationUIDs); toDelete.removeAll(newConfigurationUIDs); Set<String> toAdd = new HashSet<String>(newConfigurationUIDs); toAdd.removeAll(configurationUIDs); if (!toUpdate.isEmpty() || !toAdd.isEmpty() || !toDelete.isEmpty()) { /** * stop schedulers that are to be deleted and updated */ stopSchedulers(toDelete); stopSchedulers(toUpdate); /** * Build new Items */ newconfig.buildConfigurationElementsAndSchedulers(); /** * delete items configs */ deleteItemConfigs(toDelete); /** * add item configs */ addConfigurationItems(newconfig, toAdd); /** * update item configs */ updateItemConfigs(newconfig, toUpdate); /** * Open new connections to new DBs and Launch schedulers */ startChecks(); } return false; }
From source file:org.forgerock.openicf.maven.ConnectorDocBuilder.java
/** * Execute the generation of the report. * * @throws org.apache.maven.reporting.MavenReportException * if any/* ww w . j av a 2 s . c om*/ */ protected void executeReport() throws MojoExecutionException { List<ConnectorInfo> infoList = null; try { infoList = listAllConnectorInfo(); } catch (Exception e) { handler.getLog().error("Failed to get the ConnectorInfoManager", e); return; } for (ConnectorInfo info : infoList) { handler.getLog().debug("Processing ConnectorInfo: " + info.toString()); try { Context context = new VelocityContext(); context.put("connectorInfo", info); context.put("connectorDisplayName", info.getConnectorDisplayName()); context.put("connectorCategory", info.getConnectorCategory()); context.put("bookName", handler.getMavenProject().getArtifactId() + "-" + handler.getMavenProject().getVersion()); String connectorName = info.getConnectorKey().getConnectorName() .substring(info.getConnectorKey().getConnectorName().lastIndexOf('.') + 1).toLowerCase(); if (connectorName.endsWith("connector")) { connectorName = connectorName.substring(0, connectorName.length() - 9) + "-connector"; } context.put("connectorName", connectorName); context.put("uniqueConnectorName", info.getConnectorKey().getConnectorName().replaceAll("\\.", "-") + "-" + info.getConnectorKey().getBundleVersion()); APIConfiguration config = info.createDefaultAPIConfiguration(); context.put("APIConfiguration", config); try { if (config.getSupportedOperations().contains(SchemaApiOp.class)) { Schema schema = null; try { APIConfiguration facadeConfig = info.createDefaultAPIConfiguration(); if (null != handler.getConfigurationProperties()) { handler.getConfigurationProperties() .mergeConfigurationProperties(facadeConfig.getConfigurationProperties()); } schema = ConnectorFacadeFactory.getInstance().newInstance(facadeConfig).schema(); } catch (Throwable t) { handler.getLog().debug("Getting Schema with ConnectorFacade", t); } if (null == schema && info instanceof LocalConnectorInfoImpl) { Class<? extends Connector> connectorClass = ((LocalConnectorInfoImpl) info) .getConnectorClass(); try { SchemaOp connector = (SchemaOp) connectorClass.newInstance(); schema = connector.schema(); } catch (Throwable t) { handler.getLog().debug("Getting Schema with Connector Instance", t); } } if (null != schema) { SortedMap<Pair<String, String>, List<Map<String, Object>>> operationOptionsMap = new TreeMap<Pair<String, String>, List<Map<String, Object>>>( PAIR_COMPARATOR); for (Class<? extends APIOperation> op : OPERATIONS) { if (SchemaApiOp.class.equals(op) || TestApiOp.class.equals(op)) { continue; } List<Map<String, Object>> optionList = null; for (OperationOptionInfo optionInfo : schema.getSupportedOptionsByOperation(op)) { Map<String, Object> optionInfoMap = new HashMap<String, Object>(); optionInfoMap.put("name", optionInfo.getName()); optionInfoMap.put("type", optionInfo.getType().getSimpleName()); optionInfoMap.put("description", info.getMessages().format(optionInfo.getName() + ".help", "Additional description is not available")); if (null == optionList) { optionList = new ArrayList<Map<String, Object>>(); } optionList.add(optionInfoMap); } if (null != optionList) { operationOptionsMap.put(OP_DICTIONARY.get(op), optionList); } } List<Map<String, Object>> objectClasses = new ArrayList<Map<String, Object>>(); Set<Class<? extends APIOperation>> operationSet = new TreeSet<Class<? extends APIOperation>>( new Comparator<Class<? extends APIOperation>>() { public int compare(Class<? extends APIOperation> o1, Class<? extends APIOperation> o2) { return String.CASE_INSENSITIVE_ORDER.compare(o1.getCanonicalName(), o2.getCanonicalName()); } }); operationSet.addAll(config.getSupportedOperations()); operationSet.retainAll(OBJECTCLASS_OPERATIONS); for (ObjectClassInfo objectClassInfo : schema.getObjectClassInfo()) { Map<String, Object> objectClassInfoMap = new HashMap<String, Object>(); ObjectClass oc = new ObjectClass(objectClassInfo.getType()); objectClassInfoMap.put("name", objectClassInfo.getType()); objectClassInfoMap.put("displayName", info.getMessages() .format(oc.getDisplayNameKey(), oc.getObjectClassValue())); objectClassInfoMap.put("attributes", objectClassInfo.getAttributeInfo()); boolean limited = false; List<Pair<String, String>> operations = new ArrayList<Pair<String, String>>(); for (Class<? extends APIOperation> op : operationSet) { if (schema.getSupportedObjectClassesByOperation(op).contains(objectClassInfo)) { operations.add(OP_DICTIONARY.get(op)); } else { limited = true; } } objectClassInfoMap.put("operations", limited ? operations : null); objectClasses.add(objectClassInfoMap); } context.put("schema", schema); context.put("operationOptions", operationOptionsMap); context.put("objectClasses", objectClasses); } } } catch (Throwable e) { if (handler.getLog().isDebugEnabled()) { handler.getLog().debug("Getting the default Schema.", e); } } try { Set<Pair<String, String>> interfaces = new TreeSet<Pair<String, String>>(PAIR_COMPARATOR); for (Class<? extends APIOperation> clazz : config.getSupportedOperations()) { if (OP_DICTIONARY.containsKey(clazz)) { interfaces.add(OP_DICTIONARY.get(clazz)); } } context.put("connectorInterfaces", interfaces); } catch (Throwable e) { handler.getLog().error("Getting the connector interfaces.", e); } Map<String, List<Map<String, Object>>> configurationTable = new LinkedHashMap<String, List<Map<String, Object>>>(); for (String propertyName : config.getConfigurationProperties().getPropertyNames()) { ConfigurationProperty property = config.getConfigurationProperties().getProperty(propertyName); String groupKey = property.getGroup("Configuration"); List<Map<String, Object>> configurationGroup = configurationTable.get(groupKey); if (configurationGroup == null) { configurationGroup = new ArrayList<Map<String, Object>>(); configurationTable.put(groupKey, configurationGroup); } Map<String, Object> propertyMap = new HashMap<String, Object>(); propertyMap.put("name", propertyName); propertyMap.put("type", property.getType().getSimpleName()); propertyMap.put("property", property); propertyMap.put("required", property.isRequired()); propertyMap.put("operations", convertOperations(property.getOperations())); propertyMap.put("confidential", property.isConfidential()); propertyMap.put("description", convertHTMLtoDocBook(property.getHelpMessage("Description is not available"))); configurationGroup.add(propertyMap); } context.put("configurationProperties", configurationTable); context.put("connectorPoolingSupported", config.isConnectorPoolingSupported()); context.put("PathTool", new PathTool()); context.put("FileUtils", new FileUtils()); context.put("StringUtils", new org.codehaus.plexus.util.StringUtils()); context.put("ConnectorUtils", new ConnectorUtils()); context.put("i18n", handler.getI18N()); context.put("project", handler.getMavenProject()); handler.generate(this, context, connectorName); } catch (ResourceNotFoundException e) { throw new MojoExecutionException("Resource not found.", e); } catch (VelocityException e) { throw new MojoExecutionException(e.toString(), e); } } }
From source file:org.mksmart.ecapi.couchdb.CouchDbAssemblyProvider.java
private Set<String> filterDatasets(JSONObject view, Set<String> datasetNames) { boolean opendata = (datasetNames == null); log.debug("Requested datasets : {}", datasetNames); Set<String> filtered = new HashSet<>(), checkUs = new HashSet<>(); JSONArray rows = view.getJSONArray("rows"); for (int i = 0; i < rows.length(); i++) { JSONObject row = rows.getJSONObject(i); checkUs.add(row.getString("id")); }// w ww . j a v a2 s . c om if (opendata) try { log.info("Request is for all open datasets."); filtered = VisibilityChecker.getInstance().filter(checkUs); } catch (UnavailablePolicyTableException e) { log.error("Denying all data access due to unavailable policy table."); throw new RuntimeException(e); } else { filtered.addAll(datasetNames); filtered.retainAll(checkUs); } log.debug("{} datasets filtered in out of {} requested.", datasetNames == null ? "[undefined, all open data]" : filtered.size(), datasetNames == null ? "[none specifically]" : datasetNames.size()); return filtered; }