List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:com.formkiq.core.service.UserServiceImpl.java
@Override public UserDetails findActiveUser(final String email, final String password) throws AuthenticationFailureException { boolean matched = false; User user = null;//from ww w . ja va 2 s . c o m if (!StringUtils.isEmpty(email) && !StringUtils.isEmpty(password)) { try { user = findActiveUserByEmail(email); matched = isMatch(password, user.getPassword()); if (!matched && password.startsWith("Basic")) { user = findActiveUserByLoginToken(email, password); } } catch (AuthenticationFailureException e) { if (password.startsWith("Basic")) { user = findActiveUserByLoginToken(email, password); matched = true; } else { throw e; } } if (!matched) { user = null; } } if (user == null) { throw new AuthenticationFailureException("Authentication failed. " + "Please verify your email address " + "and password and try again."); } return user; }
From source file:uk.ac.ebi.ep.base.search.EnzymeFinder.java
private void getResultsFromEpIndex() { // EbeyeSearchResult searchResult = getEbeyeSearchResult(); String query = searchParams.getText(); if (!StringUtils.isEmpty(query)) { query = query.trim();/*from w ww .j a v a 2s. c o m*/ } List<String> accessions = ebeyeRestService.queryEbeyeForAccessions(query, true, LIMIT); // List<String> accessions = ebeyeRestService.queryEbeyeForAccessions(query, true); //List<String> accessions = ebeyeRestService.queryEbeyeForAccessions(query); LOGGER.warn("Number of Processed Accession for " + query + " :=:" + accessions.size()); //FIXEME if (accessions.size() > 1000) { accessions = accessions.subList(0, 1000); } uniprotAccessions = accessions; // if (searchResult != null) { // List<Entry> results = searchResult.getEntries().stream().distinct().collect(Collectors.toList()); // results.stream().distinct().forEach((result) -> { // // uniprotNameprefixes.add(result.getUniprot_name()); // // uniprotAccessions.add(result.getUniprot_accession()); // // }); // } }
From source file:com.sastix.cms.server.services.cache.hazelcast.HazelcastCacheService.java
@Override public void removeCachedResource(RemoveCacheDTO removeCacheDTO) throws DataNotFound, CacheValidationException { LOG.info("HazelcastCacheService->removeCachedResource"); nullValidationChecker(removeCacheDTO, RemoveCacheDTO.class); String cacheKey = removeCacheDTO.getCacheKey(); String cacheRegion = removeCacheDTO.getCacheRegion(); if (cacheKey == null) { throw new CacheValidationException("You cannot remove a cached a resource with a null cache key"); }/*from w w w . java 2s. com*/ if (!StringUtils.isEmpty(cacheRegion)) { ConcurrentMap<String, String> cMap = cm.getCache(cacheRegion); if (cMap.containsKey(cacheKey)) { cMap.remove(cacheKey); } else { throw new DataNotFound( "Nothing to remove. There is no cached resource with the given key: " + cacheKey); } } else { if (this.cache.containsKey(cacheKey)) { this.cache.remove(cacheKey); } else { throw new DataNotFound( "Nothing to remove. There is no cached resource with the given key: " + cacheKey); } } }
From source file:org.ihtsdo.otf.snomed.service.ConceptLookUpServiceImpl.java
@Override @Cacheable(value = { "conceptIds" }) public Set<String> getConceptIds(int offset, int limit) throws ConceptServiceException { LOGGER.debug("getting concept ids with offset {} and limit {} ", offset, limit); TreeSet<String> conceptIds = new TreeSet<String>(); TitanGraph g = null;/*w w w . j a v a 2 s. c om*/ try { g = factory.getReadOnlyGraph(); Iterable<Result<Vertex>> vs = g.indexQuery("concept", "v.sctid:*").offset(offset).limit(limit) .vertices(); for (Result<Vertex> v : vs) { String sctid = v.getElement().getProperty(Properties.sctid.toString()); if (!StringUtils.isEmpty(sctid)) { LOGGER.trace("Adding sctid {} to concept id list ", sctid); conceptIds.add(sctid); } } RefsetGraphFactory.commit(g); } catch (Exception e) { LOGGER.error("Error duing concept ids fetch ", e); RefsetGraphFactory.rollback(g); throw new ConceptServiceException(e); } finally { RefsetGraphFactory.shutdown(g); } LOGGER.debug("returning total {} concept ids ", conceptIds.size()); return Collections.unmodifiableSortedSet(conceptIds); }
From source file:com.baidu.rigel.biplatform.tesseract.dataquery.service.impl.SqlDataQueryServiceImpl.java
@Override public long queryForLongWithSql(String sql, DataSource dataSource) { LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "queryForListWithSql", "[sql:" + sql + "][dataSource:" + dataSource + "]")); long result = -1; if (StringUtils.isEmpty(sql) || dataSource == null) { throw new IllegalArgumentException(); }/*from w w w . j av a 2 s . c o m*/ this.initJdbcTemplate(dataSource); result = this.jdbcTemplate.queryForObject(sql, Long.class); LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "queryForListWithSql", "[sql:" + sql + "][dataSource:" + dataSource + "]")); return result; }
From source file:com.comcast.video.dawg.show.plugins.RemotePluginManager.java
/** * Gets the KeyInput for a particular stb to use. * TODO Should probably implement some sort of caching so we aren't reconstructing * a KeyInput every time we send a key./*from w w w . j a va 2 s .co m*/ * @param stb The stb metadata * @param remoteType The overriding parameter for the remote to use * @return */ public KeyInput getKeyInput(MetaStb stb, String remoteType) { String rt = StringUtils.isEmpty(remoteType) ? stb.getRemoteType() : remoteType; PluginAndConfig<KeyInput, ? extends PluginConfiguration> pac = this.plugins.get(rt); if (pac != null) { KeyInput ki = pac.getInstance(stb); if (ki != null) { return ki; } } return new IrClient(new DefaultMetaStb(stb.getData(), config), rt); }
From source file:com.baidu.rigel.biplatform.tesseract.isservice.index.service.impl.IndexMetaServiceImpl.java
@Override public List<IndexMeta> initMiniCubeIndexMeta(List<Cube> cubeList, DataSourceInfo dataSourceInfo) { /**/*from w w w. j a v a 2s .c o m*/ * ??cube????????UN_INIT;?? */ List<IndexMeta> result = new ArrayList<IndexMeta>(); if (cubeList == null || cubeList.size() == 0 || dataSourceInfo == null) { LOGGER.info("cubeList or dataSourceInfo in param list is null: [cubeList]:[" + cubeList + "][dataSourceInfo]:[" + dataSourceInfo + "]"); return result; } // ?CubeIndexMeta for (Cube cube : cubeList) { MiniCube currCube = (MiniCube) cube; // List<String> factTableList = new ArrayList<String>(); if (currCube.isMutilple()) { // currCubesource"," for (String factTable : currCube.getSource() .split(TesseractConstant.MINI_CUBE_MULTI_FACTTABLE_SPLITTER)) { factTableList.add(factTable); } } else { factTableList.add(currCube.getSource()); } // cube????? DataDescInfo dataDescInfo = new DataDescInfo(); dataDescInfo.setProductLine(currCube.getProductLine()); // ??key dataDescInfo.setSourceName(dataSourceInfo.getDataSourceKey()); dataDescInfo.setSplitTable(currCube.isMutilple()); dataDescInfo.setTableName(currCube.getSource()); dataDescInfo.setTableNameList(factTableList); //dataDescInfo.setIdStr(idStr); if (StringUtils.isEmpty(dataDescInfo.getIdStr())) { dataDescInfo.setIdStr(IndexFileSystemConstants.FACTTABLE_KEY); } IndexMeta idxMeta = new IndexMeta(); // ?? idxMeta.setIndexMetaId(String.valueOf(UUID.randomUUID())); idxMeta.setProductLine(currCube.getProductLine()); idxMeta.setDataDescInfo(dataDescInfo); idxMeta.getCubeIdSet().add(currCube.getId()); // ? Set<String> dimSet = new HashSet<String>(); if (currCube.getDimensions() != null) { for (String dimKey : currCube.getDimensions().keySet()) { Dimension dim = currCube.getDimensions().get(dimKey); // ??? if (dim.getLevels() != null) { for (String levelKey : dim.getLevels().keySet()) { Level dimLevel = dim.getLevels().get(levelKey); dimSet.add(dimLevel.getFactTableColumn()); } } } } idxMeta.setDimSet(dimSet); // ? Set<String> measureSet = new HashSet<String>(); if (currCube.getMeasures() != null) { for (String measureKey : currCube.getMeasures().keySet()) { Measure measure = currCube.getMeasures().get(measureKey); if (measure.getType().equals(MeasureType.COMMON)) { // select measureSet.add(measure.getDefine()); } else if (measure.getType().equals(MeasureType.DEFINE)) { // ??? } else if (measure.getType().equals(MeasureType.CAL)) { // ??? } } } idxMeta.setMeasureSet(measureSet); idxMeta.setReplicaNum(IndexShard.getDefaultShardReplicaNum()); idxMeta.setDataSourceInfo(dataSourceInfo); idxMeta.setDataDescInfo(dataDescInfo); // ? idxMeta.setIdxState(IndexState.INDEX_UNINIT); result.add(idxMeta); } LOGGER.info("Finished init MiniCube IndexMeta"); return result; }
From source file:com.biz.report.service.impl.RepReportServiceImpl.java
@Override public List<ItemDTO> readByRepName(String reps, String year, String month) { if (!StringUtils.isEmpty(month) && month.contains("[")) { month = month.substring(1, month.length() - 1); }/*w w w.j a v a2s. c o m*/ if (!StringUtils.isEmpty(reps) && !reps.contains("'")) { reps = "'" + reps + "'"; } List list = repReportDao.readByRepName(reps, year, month); List<ItemDTO> itemDTOs = new ArrayList<ItemDTO>(); for (Object object : list) { ItemDTO itemDTO = constructItemDTO(object); itemDTOs.add(itemDTO); } return itemDTOs; }