List of usage examples for java.util List contains
boolean contains(Object o);
From source file:eu.europa.ejusticeportal.dss.applet.model.token.CertificateDisplayUtils.java
/** * Decide whether to recommend this certificate based on the {@link KeyUsage} flags only * /* w w w .jav a 2s. c o m*/ * @param keyUsage the {@link KeyUsage} flags to analyse * @return true if the certificate could be recommended */ private static boolean isNonRepudiation(boolean[] keyUsage) { boolean recommended = false; if (keyUsage != null) { List<KeyUsage> keyUsages = KeyUsage.decode(keyUsage); if (keyUsages.contains(KeyUsage.nonRepudiation)) { recommended = true; } } return recommended; }
From source file:com.green.common.service.BaseService.java
/** * ?/*from ww w .ja v a2 s . c o m*/ * @param user ?UserUtils.getUser()?? * @param officeAlias ??dc.createAlias("office", "office"); * @param userAlias ??? * @return ? */ protected static Junction dataScopeFilter(User user, String officeAlias, String userAlias) { // ???? List<String> dataScope = Lists.newArrayList(); Junction junction = Restrictions.disjunction(); // ??? if (!user.isAdmin()) { for (Role r : user.getRoleList()) { if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(officeAlias)) { boolean isDataScopeAll = false; if (Role.DATA_SCOPE_ALL.equals(r.getDataScope())) { isDataScopeAll = true; } else if (Role.DATA_SCOPE_COMPANY_AND_CHILD.equals(r.getDataScope())) { junction.add(Restrictions.eq(officeAlias + ".id", user.getCompany().getId())); junction.add(Restrictions.like(officeAlias + ".parentIds", user.getCompany().getParentIds() + user.getCompany().getId() + ",%")); } else if (Role.DATA_SCOPE_COMPANY.equals(r.getDataScope())) { junction.add(Restrictions.eq(officeAlias + ".id", user.getCompany().getId())); junction.add(Restrictions.and( Restrictions.eq(officeAlias + ".parent.id", user.getCompany().getId()), Restrictions.eq(officeAlias + ".type", "2"))); // ? } else if (Role.DATA_SCOPE_OFFICE_AND_CHILD.equals(r.getDataScope())) { junction.add(Restrictions.eq(officeAlias + ".id", user.getOffice().getId())); junction.add(Restrictions.like(officeAlias + ".parentIds", user.getOffice().getParentIds() + user.getOffice().getId() + ",%")); } else if (Role.DATA_SCOPE_OFFICE.equals(r.getDataScope())) { junction.add(Restrictions.eq(officeAlias + ".id", user.getOffice().getId())); } else if (Role.DATA_SCOPE_CUSTOM.equals(r.getDataScope())) { junction.add(Restrictions.in(officeAlias + ".id", r.getOfficeIdList())); } //else if (Role.DATA_SCOPE_SELF.equals(r.getDataScope())){ if (!isDataScopeAll) { if (StringUtils.isNotBlank(userAlias)) { junction.add(Restrictions.eq(userAlias + ".id", user.getId())); } else { junction.add(Restrictions.isNull(officeAlias + ".id")); } } else { // ????? junction = Restrictions.disjunction(); break; } dataScope.add(r.getDataScope()); } } } return junction; }
From source file:org.wso2.carbon.appmgt.gateway.handlers.Utils.java
public static String getAllowedOrigin(String currentRequestOrigin) { String allowedOrigins = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration() .getFirstProperty(AppMConstants.CORS_CONFIGURATION_ACCESS_CTL_ALLOW_ORIGIN); if (allowedOrigins != null) { String[] origins = allowedOrigins.split(","); List<String> originsList = new LinkedList<String>(); for (String origin : origins) { originsList.add(origin.trim()); }/* w w w . j a va 2s . co m*/ if (currentRequestOrigin != null && originsList.contains(currentRequestOrigin)) { allowedOrigins = currentRequestOrigin; } else { allowedOrigins = null; } } return allowedOrigins; }
From source file:com.music.util.music.ChordUtils.java
private static boolean isDisallowedInProgression(Chord chord, Chord previousChord) { if (previousChord == null) { return false; }//from w w w .ja va 2 s .c om List<Chord> disallowed = disallowedProgressions.get(previousChord); if (disallowed == null) { return false; } return disallowed.contains(chord); }
From source file:com.eryansky.common.utils.collections.Collections3.java
/** * ab??List.// w w w . j a v a 2 s. c o m */ public static <T> List<T> aggregate(Collection<T> a, Collection<T> b) { List<T> list = new ArrayList<T>(); if (a != null) { Iterator it = a.iterator(); while (it.hasNext()) { T o = (T) it.next(); if (!list.contains(o)) { list.add(o); } } } if (b != null) { Iterator it = b.iterator(); while (it.hasNext()) { T o = (T) it.next(); if (!list.contains(o)) list.add(o); } } return list; }
From source file:com.msopentech.thali.utilities.universal.test.ThaliTestUtilities.java
/** * Checks if the docs exist in the database. Note that the DocType implements an overload for equals that * will properly compare instances of that class. * @param couchDbConnector//from w w w . j a v a 2 s .co m * @param docsToCheck */ public static void validateDatabaseState(CouchDbConnector couchDbConnector, Collection<CouchDbDocument> docsToCheck) { List<String> docIds = couchDbConnector.getAllDocIds(); assertFail(docIds.size() == docsToCheck.size()); for (CouchDbDocument doc : docsToCheck) { assertFail(docIds.contains(doc.getId())); CouchDbDocument remoteDocument = couchDbConnector.get(doc.getClass(), doc.getId()); assertFail(doc.equals(remoteDocument)); } }
From source file:com.limegroup.gnutella.util.Launcher.java
/** * Launches the file whose abstract path is specified in the <tt>File</tt> * parameter. This method will not launch any file with .exe, .vbs, .lnk, * .bat, .sys, or .com extensions, diplaying an error if one of the file is * of one of these types./*from w ww. j av a2s .c o m*/ * * @param path * The path of the file to launch * @return an object for accessing the launch process; null, if the process * can be represented (e.g. the file was launched through a native * call) * @throws IOException * if the file cannot be launched * @throws SecurityException * if the file has an extension that is not allowed */ public static LimeProcess launchFile(File file) throws IOException, SecurityException { List<String> forbiddenExtensions = Arrays.asList("exe", "vbs", "lnk", "bat", "sys", "com", "js", "scpt"); if (file.isFile() && forbiddenExtensions.contains(FilenameUtils.getExtension(file.getName()))) { throw new SecurityException(); } String path = file.getCanonicalPath(); if (OSUtils.isWindows()) { launchFileWindows(path); return null; } else if (OSUtils.isMacOSX()) { return launchFileMacOSX(path); } else { // Other OS, use helper apps return launchFileOther(path); } }
From source file:models.StockCategory.java
private static void arrangeItems(Map<Integer, List<StockCategory>> map, StockCategory item, Integer parId) { List<StockCategory> list = map.get(parId); if (list == null) list = new ArrayList<StockCategory>(); if (!list.contains(item)) { list.add(item);/*w w w.java 2 s . co m*/ } map.put(parId, list); }
From source file:com.doculibre.constellio.utils.persistence.ConstellioPersistenceContext.java
private static void generatePersistenceFile() { //Usefull for unit testing String basePersistenceFileName = System.getProperty("base-persistence-file"); if (basePersistenceFileName == null) { basePersistenceFileName = "persistence_derby.xml"; }/*from ww w. j a v a2 s . co m*/ File classesDir = ClasspathUtils.getClassesDir(); File metaInfDir = new File(classesDir, "META-INF"); File persistenceFile = new File(metaInfDir, "persistence.xml"); File persistenceBaseFile = new File(metaInfDir, basePersistenceFileName); if (persistenceFile.exists()) { persistenceFile.delete(); } // FIXME Using text files rather than Dom4J because of empty xmlns attribute generated... try { String persistenceBaseText = FileUtils.readFileToString(persistenceBaseFile); StringBuffer sbJarFile = new StringBuffer("\n"); File pluginsDir = PluginFactory.getPluginsDir(); for (String availablePluginName : ConstellioSpringUtils.getAvailablePluginNames()) { if (PluginFactory.isValidPlugin(availablePluginName)) { File pluginDir = new File(pluginsDir, availablePluginName); File pluginJarFile = new File(pluginDir, availablePluginName + ".jar"); String pluginJarURI = pluginJarFile.toURI().toString(); sbJarFile.append("\n"); sbJarFile.append("<jar-file>" + pluginJarURI + "</jar-file>"); } } File webInfDir = ClasspathUtils.getWebinfDir(); File libDir = new File(webInfDir, "lib"); File[] contellioJarFiles = libDir.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { boolean accept; if (pathname.isDirectory()) { accept = false; } else { List<String> availablePluginNames = ConstellioSpringUtils.getAvailablePluginNames(); String jarNameWoutExtension = FilenameUtils.removeExtension(pathname.getName()); accept = availablePluginNames.contains(jarNameWoutExtension); } return accept; } }); for (File constellioJarFile : contellioJarFiles) { URI constellioJarFileURI = constellioJarFile.toURI(); sbJarFile.append("\n"); sbJarFile.append("<jar-file>" + constellioJarFileURI + "</jar-file>"); } String persistenceText = persistenceBaseText.replaceAll("</provider>", "</provider>" + sbJarFile); FileUtils.writeStringToFile(persistenceFile, persistenceText); // persistenceFile.deleteOnExit(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.twosigma.beakerx.mimetype.MIMEContainer.java
private static String parseParams(HashMap paramsMap) { List iframeParamKeys = Arrays.asList("width", "height", "id"); StringBuilder sb = new StringBuilder(); for (Object key : paramsMap.keySet()) { if (iframeParamKeys.contains(key)) { continue; }/*from w w w .ja v a 2 s .c o m*/ sb.append("&").append(key.toString()).append("=").append(paramsMap.get(key).toString()); } String result = sb.toString().replaceFirst("&", "?"); return result.length() > 0 ? result : ""; }