List of usage examples for java.util LinkedHashSet LinkedHashSet
public LinkedHashSet(Collection<? extends E> c)
From source file:com.github.pires.example.shiro.OrientDbRealm.java
@Override protected AuthorizationInfo doGetAuthorizationInfo(final PrincipalCollection principals) { // retrieve role names and permission names final String email = (String) principals.getPrimaryPrincipal(); final User user = userRepository.findByEmailAndActive(email, true); if (user == null) { throw new UnknownAccountException("Account does not exist"); }/*from www . j a v a 2 s . c om*/ final int totalRoles = user.getRoles().size(); final Set<String> roleNames = new LinkedHashSet<>(totalRoles); final Set<String> permissionNames = new LinkedHashSet<>(); if (totalRoles > 0) { for (Role role : user.getRoles()) { roleNames.add(role.getName()); for (Permission permission : role.getPermissions()) { permissionNames.add(permission.getName()); } } } final SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(roleNames); info.setStringPermissions(permissionNames); return info; }
From source file:org.jct.spellchecker.wordsrepository.cli.commands.SpellCheckerCommandTests.java
@Test public void testAddWhenNotAuthorized() { when(spellCheckerCliService.parseFile(Mockito.anyString())) .thenReturn(new LinkedHashSet<String>(Arrays.asList("this", "is", "a", "test"))); JLineShellComponent shell = bootstrap.getJLineShellComponent(); CommandResult cr = shell.executeCommand("add"); assertEquals(false, cr.isSuccess()); }
From source file:org.jasig.portlet.blackboardvcportlet.dao.impl.PresentationDaoImpl.java
@Override public Set<Presentation> getAllPresentations() { final TypedQuery<PresentationImpl> query = this.createQuery(this.findAllPresentation); return new LinkedHashSet<Presentation>(query.getResultList()); }
From source file:com.gs.obevo.db.impl.platforms.db2.Db2SqlExecutor.java
/** * Package-private for unit testing only. */// w w w. j av a 2 s . co m static String getCurrentPathSql(Connection conn, JdbcHelper jdbc, ImmutableSet<PhysicalSchema> physicalSchemas) { String path = jdbc.query(conn, "select current path from sysibm.sysdummy1", new ScalarHandler<String>()); MutableList<String> currentSchemaPathList = Lists.mutable.of(path.split(",")) .collect(new Function<String, String>() { @Override public String valueOf(String object) { if (object.startsWith("\"") && object.endsWith("\"")) { return object.substring(1, object.length() - 1); } else { return object; } } }); // Rules on constructing this "set path" command: // 1) The existing default path must come first (respecting the existing connection), followed by the // schemas in our environment. The default path must take precedence. // 2) We cannot have duplicate schemas listed in the "set path" call; i.e. in case the schemas in our // environment config are already in the default schema. // // Given these two requirements, we use a LinkedHashSet LinkedHashSet<String> currentSchemaPaths = new LinkedHashSet(currentSchemaPathList); currentSchemaPaths.addAll(physicalSchemas.collect(PhysicalSchema.TO_PHYSICAL_NAME).castToSet()); // This is needed to work w/ stored procedures // Ideally, we'd use "set current path current path, " + physicalSchemaList // However, we can't set this multiple times in a connection, as we can't have dupes in "current path" // Ideally, we could use BasicDataSource.initConnectionSqls, but this does not interoperate w/ the LDAP // datasource for JNDI-JDBC return "set path " + CollectionAdapter.adapt(currentSchemaPaths).makeString(","); }
From source file:com.icfcc.cache.annotation.AnnotationCacheOperationSource.java
/** * Create a custom AnnotationCacheOperationSource. * @param annotationParsers the CacheAnnotationParser to use *//*from ww w .ja va 2s . c om*/ public AnnotationCacheOperationSource(CacheAnnotationParser... annotationParsers) { this.publicMethodsOnly = true; Assert.notEmpty(annotationParsers, "At least one CacheAnnotationParser needs to be specified"); Set<CacheAnnotationParser> parsers = new LinkedHashSet<CacheAnnotationParser>(annotationParsers.length); Collections.addAll(parsers, annotationParsers); this.annotationParsers = parsers; }