List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:com.alibaba.otter.node.etl.conflict.impl.FileBatchConflictDetectServiceImpl.java
/** * ?//from w w w . ja va 2s.co m */ private FileBatch onFileConflictDetect(FileConflictDetectEvent event) { final FileBatch fileBatch = event.getFileBatch(); if (CollectionUtils.isEmpty(fileBatch.getFiles())) { return fileBatch; } ExecutorTemplate executorTemplate = executorTemplateGetter.get(); try { MDC.put(OtterConstants.splitPipelineLoadLogFileKey, String.valueOf(fileBatch.getIdentity().getPipelineId())); executorTemplate.start(); // ?poolSize Pipeline pipeline = configClientService.findPipeline(fileBatch.getIdentity().getPipelineId()); executorTemplate.adjustPoolSize(pipeline.getParameters().getFileLoadPoolSize()); // ? final List<FileData> result = Collections.synchronizedList(new ArrayList<FileData>()); final List<FileData> filter = Collections.synchronizedList(new ArrayList<FileData>()); for (final FileData source : fileBatch.getFiles()) { EventType type = source.getEventType(); if (type.isDelete()) { result.add(source); } else { executorTemplate.submit(new Runnable() { public void run() { MDC.put(OtterConstants.splitPipelineLoadLogFileKey, String.valueOf(fileBatch.getIdentity().getPipelineId())); // ? String namespace = source.getNameSpace(); String path = source.getPath(); FileData target = null; int count = 0; while (count++ < retry) {// ?? try { if (true == StringUtils.isBlank(namespace)) { // local file java.io.File targetFile = new java.io.File(path); if (true == targetFile.exists()) { // modified time cost long lastModified = targetFile.lastModified(); long size = targetFile.length(); // ? target = new FileData(); target.setLastModifiedTime(lastModified); target.setSize(size); } } else { // remote file throw new RuntimeException(source + " is not support!"); } break; // ? } catch (Exception ex) { target = null; } } boolean shouldSync = false; if (target != null) { if (true == accept(target, source)) { shouldSync = true; } } else { shouldSync = true; } if (true == shouldSync) { result.add(source); } else { filter.add(source); } } }); } } // ?? executorTemplate.waitForResult(); if (pipeline.getParameters().getDumpEvent() && logger.isInfoEnabled()) { logger.info(FileloadDumper.dumpFilterFileDatas(fileBatch.getIdentity(), fileBatch.getFiles().size(), result.size(), filter)); } // FileBatch target = new FileBatch(); target.setIdentity(fileBatch.getIdentity()); target.setFiles(result); return target; } finally { if (executorTemplate != null) { executorTemplateGetter.release(executorTemplate); } MDC.remove(OtterConstants.splitPipelineLoadLogFileKey); } }
From source file:org.wallride.support.PageUtils.java
public Map<Page, String> getPaths(Page page, boolean includeUnpublished) { List<Page> parents = pageService.getPathPages(page, includeUnpublished); Map<Page, String> paths = new LinkedHashMap<>(); if (CollectionUtils.isEmpty(parents)) { return paths; }/*from w w w. jav a 2 s.c o m*/ StringBuilder path = new StringBuilder(); for (Page p : parents) { if (path != null) { path.append("/"); } path.append(p.getCode()); paths.put(p, path.toString()); } return paths; }
From source file:com.sinet.gage.tasklets.DominFullImportTasklet.java
/** * Inserting all child domains for state * /* w ww . jav a 2 s . c o m*/ * @param childDomains * @param stateName */ private void insertDomainsForState(List<Domain> childDomains, String stateName) { try { if (!CollectionUtils.isEmpty(childDomains)) { domainsRepository.insertDomains(childDomains); } } catch (Exception e) { logger.error("Error inserting domains " + childDomains.size() + " for state " + stateName, e); } }
From source file:am.ik.categolj2.domain.model.User.java
@Transient public boolean hasRole(String roleName) { if (CollectionUtils.isEmpty(this.getRoles())) { return false; }/*from www. j ava 2 s . c o m*/ return this.getRoles().stream().filter(role -> Objects.equals(roleName, role.getRoleName())).count() > 0; }
From source file:com.kurento.kmf.jsonrpcconnector.internal.server.config.JsonRpcConfiguration.java
@Autowired(required = false) public void setConfigurers(List<JsonRpcConfigurer> configurers) { if (!CollectionUtils.isEmpty(configurers)) { this.configurers.addAll(configurers); }/*from ww w. j a va2 s .c om*/ }
From source file:org.duracloud.snapshot.service.impl.SyncWriter.java
@Override public void beforeStep(StepExecution stepExecution) { try {/*from w w w . j ava 2s . c o m*/ restoreManager.transitionRestoreStatus(restorationId, RestoreStatus.TRANSFERRING_TO_DURACLOUD, ""); Space space = this.contentStore.getSpace(destinationSpaceId, null, 1, null); if (!CollectionUtils.isEmpty(space.getContentIds())) { stepExecution.addFailureException(new RuntimeException( "destination space " + destinationSpaceId + " must be empty to receive restored content")); } } catch (NotFoundException ex) { try { this.contentStore.createSpace(destinationSpaceId); } catch (ContentStoreException e) { stepExecution.addFailureException(e); } } catch (Exception ex) { stepExecution.addFailureException(ex); } }
From source file:org.wallride.web.controller.admin.user.UserDescribeController.java
@RequestMapping public String describe(@PathVariable String language, @RequestParam long id, String query, Model model) { User user = userService.getUserById(id); if (user == null) { throw new HttpNotFoundException(); }/*from w w w. j a v a 2s. c om*/ MutablePropertyValues mpvs = new MutablePropertyValues( UriComponentsBuilder.newInstance().query(query).build().getQueryParams()); for (Iterator<PropertyValue> i = mpvs.getPropertyValueList().iterator(); i.hasNext();) { PropertyValue pv = i.next(); boolean hasValue = false; for (String value : (List<String>) pv.getValue()) { if (StringUtils.hasText(value)) { hasValue = true; break; } } if (!hasValue) { i.remove(); } } BeanWrapperImpl beanWrapper = new BeanWrapperImpl(new UserSearchForm()); beanWrapper.setConversionService(conversionService); beanWrapper.setPropertyValues(mpvs, true, true); UserSearchForm form = (UserSearchForm) beanWrapper.getWrappedInstance(); List<Long> ids = userService.getUserIds(form.toUserSearchRequest()); if (!CollectionUtils.isEmpty(ids)) { int index = ids.indexOf(user.getId()); if (index < ids.size() - 1) { Long next = ids.get(index + 1); model.addAttribute("next", next); } if (index > 0) { Long prev = ids.get(index - 1); model.addAttribute("prev", prev); } } model.addAttribute("user", user); model.addAttribute("query", query); return "user/describe"; }
From source file:com.asuraiv.coordination.menu.MainMenu.java
/** * ? .//from w w w . ja v a 2 s . c o m */ private void doTaskListUp() { try { ZooKeeper zk = new ZooKeeper("10.113.182.195:2181", 15000, this); System.out.println(); System.out.println("### ###"); List<String> tasks = zk.getChildren("/tasks", false, null); if (CollectionUtils.isEmpty(tasks)) { System.out.println("[WARNNING] ?? ? ."); } for (String task : tasks) { String status = new String(zk.getData("/tasks/" + task, false, null)); System.out.println(task + ": " + status); } zk.close(); } catch (IOException e) { e.printStackTrace(); } catch (KeeperException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:com.frank.search.solr.core.schema.SolrPersistentEntitySchemaCreator.java
public SolrPersistentEntitySchemaCreator enable(Collection<Feature> features) { if (!CollectionUtils.isEmpty(features)) { this.features.addAll(features); }/*from w ww.j a v a 2 s. co m*/ return this; }
From source file:com.hs.mail.imap.message.MessageHeader.java
public Mailbox getFrom() { MailboxList mailboxList = getMailboxList(FieldName.FROM); if (CollectionUtils.isEmpty(mailboxList)) { Field field = header.getField(FieldName.FROM); return (field != null) ? new Mailbox(field.getBody(), null) : null; } else {/*from ww w . j ava 2 s . c om*/ return mailboxList.get(0); } }