List of usage examples for java.util LinkedList addAll
public boolean addAll(Collection<? extends E> c)
From source file:com.google.gerrit.server.account.CreateAccount.java
@Override public Response<AccountInfo> apply(TopLevelResource rsrc, AccountInput input) throws BadRequestException, ResourceConflictException, UnprocessableEntityException, OrmException, IOException, ConfigInvalidException { if (input == null) { input = new AccountInput(); }// ww w.j av a2 s .c om if (input.username != null && !username.equals(input.username)) { throw new BadRequestException("username must match URL"); } if (!username.matches(Account.USER_NAME_PATTERN)) { throw new BadRequestException( "Username '" + username + "'" + " must contain only letters, numbers, _, - or ."); } Set<AccountGroup.Id> groups = parseGroups(input.groups); Account.Id id = new Account.Id(db.nextAccountId()); AccountExternalId extUser = new AccountExternalId(id, new AccountExternalId.Key(AccountExternalId.SCHEME_USERNAME, username)); if (input.httpPassword != null) { extUser.setPassword(input.httpPassword); } if (db.accountExternalIds().get(extUser.getKey()) != null) { throw new ResourceConflictException("username '" + username + "' already exists"); } if (input.email != null) { if (db.accountExternalIds().get(getEmailKey(input.email)) != null) { throw new UnprocessableEntityException("email '" + input.email + "' already exists"); } if (!EmailValidator.getInstance().isValid(input.email)) { throw new BadRequestException("invalid email address"); } } LinkedList<AccountExternalId> externalIds = new LinkedList<>(); externalIds.add(extUser); for (AccountExternalIdCreator c : externalIdCreators) { externalIds.addAll(c.create(id, username, input.email)); } try { db.accountExternalIds().insert(externalIds); } catch (OrmDuplicateKeyException duplicateKey) { throw new ResourceConflictException("username '" + username + "' already exists"); } if (input.email != null) { AccountExternalId extMailto = new AccountExternalId(id, getEmailKey(input.email)); extMailto.setEmailAddress(input.email); try { db.accountExternalIds().insert(Collections.singleton(extMailto)); } catch (OrmDuplicateKeyException duplicateKey) { try { db.accountExternalIds().delete(Collections.singleton(extUser)); } catch (OrmException cleanupError) { // Ignored } throw new UnprocessableEntityException("email '" + input.email + "' already exists"); } } Account a = new Account(id, TimeUtil.nowTs()); a.setFullName(input.name); a.setPreferredEmail(input.email); db.accounts().insert(Collections.singleton(a)); for (AccountGroup.Id groupId : groups) { AccountGroupMember m = new AccountGroupMember(new AccountGroupMember.Key(id, groupId)); auditService.dispatchAddAccountsToGroup(currentUser.get().getAccountId(), Collections.singleton(m)); db.accountGroupMembers().insert(Collections.singleton(m)); } if (input.sshKey != null) { try { authorizedKeys.addKey(id, input.sshKey); sshKeyCache.evict(username); } catch (InvalidSshKeyException e) { throw new BadRequestException(e.getMessage()); } } accountCache.evictByUsername(username); byEmailCache.evict(input.email); indexer.index(id); AccountLoader loader = infoLoader.create(true); AccountInfo info = loader.get(id); loader.fill(); return Response.created(info); }
From source file:io.fabric8.spring.cloud.kubernetes.reload.ConfigurationChangeDetector.java
/** * Finds all registered property sources of the given type. *//*from w w w . j ava 2 s . c om*/ protected <S extends PropertySource<?>> List<S> findPropertySources(Class<S> sourceClass) { List<S> managedSources = new LinkedList<>(); LinkedList<PropertySource<?>> sources = toLinkedList(environment.getPropertySources()); while (!sources.isEmpty()) { PropertySource<?> source = sources.pop(); if (source instanceof CompositePropertySource) { CompositePropertySource comp = (CompositePropertySource) source; sources.addAll(comp.getPropertySources()); } else if (sourceClass.isInstance(source)) { managedSources.add(sourceClass.cast(source)); } } return managedSources; }
From source file:org.rascalmpl.library.cobra.RandomValueTypeVisitor.java
@Override public IValue visitAbstractData(Type type) { LinkedList<Type> alternatives = new LinkedList<Type>(); alternatives.addAll(this.rootEnv.lookupAlternatives(type)); Collections.shuffle(alternatives); for (Type pick : alternatives) { IConstructor result = (IConstructor) this.generate(pick); if (result != null) { RandomValueTypeVisitor visitor = descend(); Map<String, Type> annotations = rootEnv.getStore().getAnnotations(type); for (Map.Entry<String, Type> entry : annotations.entrySet()) { IValue value = visitor.generate(entry.getValue()); if (value == null) { return null; }/*from www .j ava2s . c o m*/ result = result.asAnnotatable().setAnnotation(entry.getKey(), value); } return result; } } return null; }
From source file:com.gooddata.warehouse.WarehouseServiceAT.java
@Test(groups = "warehouse", dependsOnMethods = "createWarehouse") public void listWarehouses() throws Exception { final LinkedList<Warehouse> result = new LinkedList<>(); Page page = new PageRequest(1000); PageableList<Warehouse> warehouses; do {/* w ww .j a v a 2s.co m*/ warehouses = service.listWarehouses(page); result.addAll(warehouses); page = warehouses.getNextPage(); } while (warehouses.hasNextPage()); assertThat(result, hasItem(hasSameIdAs(warehouse))); }
From source file:poisondog.tree.BinaryTree.java
private Collection<BinaryTree<E>> noLeftChild(BinaryTree<E> tree) { LinkedList<BinaryTree<E>> result = new LinkedList<BinaryTree<E>>(); if (tree.getLeftTree().isEmpty()) { result.add(tree);//from w w w . j av a 2s. c om } else { result.addAll(noLeftChild(tree.getLeftTree())); } if (!tree.getRightTree().isEmpty()) { result.addAll(noLeftChild(tree.getRightTree())); } return result; }
From source file:poisondog.tree.BinaryTree.java
private Collection<BinaryTree<E>> noRightChild(BinaryTree<E> tree) { LinkedList<BinaryTree<E>> result = new LinkedList<BinaryTree<E>>(); if (tree.getRightTree().isEmpty()) { result.add(tree);//from w w w.ja va2 s. c o m } else { result.addAll(noRightChild(tree.getRightTree())); } if (!tree.getLeftTree().isEmpty()) { result.addAll(noRightChild(tree.getLeftTree())); } return result; }
From source file:de.tudarmstadt.ukp.lmf.transform.wordnet.SubcategorizationFrameExtractor.java
/** * Returns a list of all SemanticPredicates processed by this extractor * @return all {@link SemanticPredicate}-instances, processed by this extractor *//*from w ww. jav a2 s .co m*/ public List<SemanticPredicate> getSemanticPredicates() { LinkedList<SemanticPredicate> result = new LinkedList<SemanticPredicate>(); result.addAll(codePredMappings.values()); return result; }
From source file:com.erudika.scoold.controllers.QuestionController.java
@GetMapping({ "/{id}", "/{id}/{title}" }) public String get(@PathVariable String id, @PathVariable(required = false) String title, @RequestParam(required = false) String sortby, HttpServletRequest req, HttpServletResponse res, Model model) {// www. ja v a2 s . c o m Post showPost = pc.read(id); if (showPost == null || !ParaObjectUtils.typesMatch(showPost)) { return "redirect:" + QUESTIONSLINK; } Profile authUser = utils.getAuthUser(req); if (!utils.canAccessSpace(authUser, showPost.getSpace())) { return "redirect:" + (utils.isDefaultSpacePublic() ? QUESTIONSLINK : SIGNINLINK + "?returnto=" + showPost.getPostLink(false, false)); } Pager itemcount = utils.getPager("page", req); itemcount.setSortby("newest".equals(sortby) ? "timestamp" : "votes"); List<Reply> answerslist = showPost.getAnswers(itemcount); LinkedList<Post> allPosts = new LinkedList<Post>(); allPosts.add(showPost); allPosts.addAll(answerslist); utils.fetchProfiles(allPosts); utils.getComments(allPosts); utils.updateViewCount(showPost, req, res); model.addAttribute("path", "question.vm"); model.addAttribute("title", utils.getLang(req).get("questions.title") + " - " + showPost.getTitle()); model.addAttribute("description", Utils.abbreviate(Utils.stripAndTrim(showPost.getBody(), " "), 195)); model.addAttribute("itemcount", itemcount); model.addAttribute("showPost", allPosts.removeFirst()); model.addAttribute("answerslist", allPosts); model.addAttribute("similarquestions", utils.getSimilarPosts(showPost, new Pager(10))); model.addAttribute("maxCommentLength", Comment.MAX_COMMENT_LENGTH); model.addAttribute("maxCommentLengthError", Utils.formatMessage(utils.getLang(req).get("maxlength"), Comment.MAX_COMMENT_LENGTH)); return "base"; }
From source file:de.tudarmstadt.ukp.lmf.transform.wordnet.SubcategorizationFrameExtractor.java
/** * Returns a list of all SynSemCorrespondences processed by this extractor * @return all {@link SynSemCorrespondence}-instances, processed by this extractor *//*from ww w. jav a2s.c o m*/ public List<SynSemCorrespondence> getSynSemCorrespondences() { LinkedList<SynSemCorrespondence> result = new LinkedList<SynSemCorrespondence>(); result.addAll(synsemargsSynSemCorrMap.values()); return result; }
From source file:org.signserver.web.SignServerHealthCheck.java
@Override public String checkHealth(HttpServletRequest request) { final LinkedList<String> errors = new LinkedList<String>(); if (LOG.isDebugEnabled()) { LOG.debug("Starting HealthCheck health check requested by : " + request.getRemoteAddr()); }//w w w .j a va2s . c o m errors.addAll(checkMaintenance()); // Perform further checks unless Down for maintenance if (errors.size() == 0) { if (FileBasedDatabaseManager.getInstance().isUsed()) { LOG.debug("Checking file based database"); errors.addAll(FileBasedDatabaseManager.getInstance().getFatalErrors()); } else { LOG.debug("Checking real database"); errors.addAll(HealthCheckUtils.checkDB(em, checkDBString)); } if (errors.size() == 0) { errors.addAll(HealthCheckUtils.checkMemory(minfreememory)); errors.addAll(checkSigners()); } } // Render as text final StringBuilder buff = new StringBuilder(); final String result; if (errors.size() == 0) { result = null; } else { for (final String error : errors) { buff.append(error).append("\n"); } result = buff.toString(); } if (LOG.isDebugEnabled()) { LOG.debug("HealthCheck result : " + result); } return result; }