List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:com.cottsoft.thrift.framework.server.ThriftMultiBinaryServerFactory.java
/** * ?Service implSpring bean???@Service???? * /*from www .j a v a2 s. com*/ * @param thriftServiceImplClass * @return */ private String getServiceImplBeanName(Class<?> thriftServiceImplClass) { if (thriftServiceImplClass.isAnnotationPresent(Service.class)) { Service serviceAnnotation = (Service) thriftServiceImplClass.getAnnotation(Service.class); String value = serviceAnnotation.value(); if (StringUtils.isEmpty(value)) { return StringUtils.uncapitalize(thriftServiceImplClass.getSimpleName()); } else { return value; } } else { return StringUtils.uncapitalize(thriftServiceImplClass.getSimpleName()); } }
From source file:ca.roussil.ec2instancestarter.SimpleEc2Service.java
/** * Wait for a instance to complete transitioning (i.e. status not being in * INSTANCE_STATE_IN_PROGRESS_SET or the instance no longer existing). * // w ww .ja v a 2 s . c om * @param stateChangeList * @param instancebuilder * @param instanceId * @param BuildLogger * @throws InterruptedException * @throws Exception */ private final String waitForTransitionCompletion(List<InstanceStateChange> stateChangeList, final String desiredState, String instanceId) throws InterruptedException { Boolean transitionCompleted = false; InstanceStateChange stateChange = stateChangeList.get(0); String previousState = stateChange.getPreviousState().getName(); String currentState = stateChange.getCurrentState().getName(); String transitionReason = ""; while (!transitionCompleted) { try { Instance instance = getSingleEc2InstanceById(instanceId); currentState = instance.getState().getName(); if (previousState.equals(currentState)) { log.info("... '" + instanceId + "' is still in state " + currentState + " ..."); } else { log.info("... '" + instanceId + "' entered state " + currentState + " ..."); transitionReason = instance.getStateTransitionReason(); } previousState = currentState; if (currentState.equals(desiredState)) { transitionCompleted = true; } } catch (AmazonServiceException ase) { log.error("Failed to describe instance '" + instanceId + "'!", ase); throw ase; } // Sleep for WAIT_FOR_TRANSITION_INTERVAL seconds until transition // has completed. if (!transitionCompleted) { Thread.sleep(WAIT_FOR_TRANSITION_INTERVAL); } } log.info("Transition of instance '" + instanceId + "' completed with state " + currentState + " (" + (StringUtils.isEmpty(transitionReason) ? "Unknown transition reason" : transitionReason) + ")."); return currentState; }
From source file:com.ocs.dynamo.importer.impl.BaseXlsImporter.java
/** * Retrieves the value of a cell as a string, or falls back to the default if the value is empty * and a suitable default is defined//w ww .j av a 2 s . co m * * @param cell * @param field * @return */ @Override protected String getStringValueWithDefault(Cell cell, XlsField field) { String value = getStringValue(cell); if (StringUtils.isEmpty(value) && !StringUtils.isEmpty(field.defaultValue())) { value = field.defaultValue(); } return value; }
From source file:org.psikeds.knowledgebase.xml.impl.XSDValidator.java
/** * Validate XML against specified XSD schmema file.<br> * /* ww w . j ava2 s . co m*/ * @throws SAXException * if XML is not valid against XSD * @throws IOException */ @Override public void validate() throws SAXException, IOException { if (this.xsdStream != null && this.xmlStream != null) { validate(this.xsdStream, this.xmlStream); // Note: We do not close the streams here. // It's the responsibility of the caller return; } if (this.xsdResource != null && this.xmlResource != null) { validate(this.xsdResource, this.xmlResource); return; } if (!StringUtils.isEmpty(this.xsdFilename) && !StringUtils.isEmpty(this.xmlFilename) && !StringUtils.isEmpty(this.encoding)) { Reader xml = null; try { xml = new InputStreamReader(new FileInputStream(this.xmlFilename), this.encoding); validate(this.xsdFilename, xml); return; } finally { // We opened the file, therefore we also // must close the Reader/Stream again! if (xml != null) { try { xml.close(); } catch (final IOException ex) { // ignore } finally { xml = null; } } } } throw new IllegalArgumentException("Unsupported configuration settings!"); }
From source file:architecture.ee.web.community.spring.controller.SocialConnectController.java
@RequestMapping(value = "/lookup.json", method = RequestMethod.POST) @ResponseBody/* w w w . j a v a 2s . c o m*/ public SocialUserProfile lookup( @RequestParam(value = "onetime", defaultValue = "", required = false) String onetime, HttpServletRequest request) { User user = SecurityHelper.getUser(); SocialUserProfile sup = new SocialUserProfile(user, UserProfile.EMPTY); if (StringUtils.isEmpty(onetime)) { onetime = (String) request.getSession().getAttribute("onetime"); } if (!StringUtils.isEmpty(onetime) && getOnetimeObject(onetime) != null) { SocialConnect sc = (SocialConnect) getOnetimeObject(onetime); try { log.debug("search account user by:" + sc.getProviderId() + ", " + sc.getProviderUserId()); User founduser = findUser(2, sc.getProviderId(), sc.getProviderUserId()); sup.setUser(founduser); } catch (UserNotFoundException e) { } try { UserProfile up = sc.getConnection().fetchUserProfile(); sup.setImageUrl(sc.getConnection().getImageUrl()); sup.setProfile(up); } catch (Exception e) { } } return sup; }
From source file:com.biz.report.service.impl.ReportServiceImpl.java
@Override public List<Report5DataSet> readLineChart(String types, String months, String year) { if (!StringUtils.isEmpty(types) && types.contains("[")) { types = types.substring(1, types.length() - 1); }/*from w w w . j a v a 2 s . c o m*/ String[] typeAr; if (!StringUtils.isEmpty(types) && types.contains(",")) { typeAr = types.split("[,]"); } else { typeAr = new String[] { types }; } if (!StringUtils.isEmpty(months) && months.contains("[")) { months = months.substring(1, months.length() - 1); } String[] monthAr; if (!StringUtils.isEmpty(months) && months.contains(",")) { monthAr = months.split("[,]"); } else { monthAr = new String[] { months }; } int typeCount = typeAr.length; List list = reportDao.read(types, year, months); List<Report1> reportList = new MappingEngine().getList(list); logger.info(reportList.size()); List<Report5DataSet> dataSets = new ArrayList<Report5DataSet>(); for (int i = 0; i < typeCount; i++) { List<DataPoint> dataPoints = constructDataPoints(reportList, typeAr[i].trim(), monthAr, i); dataSets.add(new Report5DataSet(dataPoints, typeAr[i])); } return dataSets; }
From source file:com.sastix.cms.server.services.cache.hazelcast.HazelcastCacheService.java
@Override public void clearCache(RemoveCacheDTO removeCacheDTO) throws DataNotFound, CacheValidationException { LOG.info("HazelcastCacheService->CLEAR_CACHE_REGION"); nullValidationChecker(removeCacheDTO, RemoveCacheDTO.class); String cacheRegion = removeCacheDTO != null ? removeCacheDTO.getCacheRegion() : null; if (!StringUtils.isEmpty(cacheRegion)) {//clear specific region ConcurrentMap<String, IMap> regionCacheMap = (ConcurrentMap<String, IMap>) cm.getCaches() .get(cacheRegion);/*ww w .j ava 2 s .co m*/ if (regionCacheMap == null) { throw new DataNotFound("The supplied region was not available did not exist"); } else { ConcurrentMap<String, CacheDTO> cMap = cm.getCache(cacheRegion); cMap.clear(); } } else { throw new CacheValidationException( "A cacheRegion was not provided. If you want to clear all caches use the clearCache() without passing any object."); } }
From source file:com.baidu.rigel.biplatform.tesseract.isservice.search.service.impl.CallbackSearchServiceImpl.java
/** * @param context ?/* w ww . ja v a 2 s . co m*/ * @param query ? * @return * @throws IndexAndSearchException exception occurred when */ public SearchIndexResultSet query(QueryContext context, QueryRequest query) throws IndexAndSearchException { LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "callbackquery", "[callbackquery:" + query + "]")); if (query == null || context == null || StringUtils.isEmpty(query.getCubeId())) { LOGGER.error(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "callbackquery", "[callbackquery:" + query + "]")); throw new IndexAndSearchException( TesseractExceptionUtils.getExceptionMessage(IndexAndSearchException.QUERYEXCEPTION_MESSAGE, IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION), IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION); } // TODO ??? if (query.getGroupBy() == null || query.getSelect() == null) { return null; } Map<String, String> requestParams = ((QueryContextAdapter) context).getQuestionModel().getRequestParams(); // Build query target map Map<String, List<MiniCubeMeasure>> callbackMeasures = context.getQueryMeasures().stream() .filter(m -> m.getType().equals(MeasureType.CALLBACK)).map(m -> { CallbackMeasure tmp = (CallbackMeasure) m; for (Map.Entry<String, String> entry : tmp.getCallbackParams().entrySet()) { if (requestParams.containsKey(entry.getKey())) { tmp.getCallbackParams().put(entry.getKey(), requestParams.get(entry.getKey())); } } return m; }).collect(Collectors.groupingBy(c -> ((CallbackMeasure) c).getCallbackUrl(), Collectors.toList())); if (callbackMeasures == null || callbackMeasures.isEmpty()) { LOGGER.error(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "Empty callback measure", "[callbackquery:" + query + "]")); throw new IndexAndSearchException( TesseractExceptionUtils.getExceptionMessage(IndexAndSearchException.QUERYEXCEPTION_MESSAGE, IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION), IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION); } LOGGER.info("Find callback targets " + callbackMeasures); // Keep group-by sequence. List<String> groupby = new ArrayList<String>(query.getGroupBy().getGroups()); LinkedHashMap<String, List<String>> groupbyParams = new LinkedHashMap<String, List<String>>(groupby.size()); for (String g : groupby) { groupbyParams.put(g, new ArrayList<String>()); } LinkedHashMap<String, List<String>> whereParams = new LinkedHashMap<String, List<String>>(); for (Expression e : query.getWhere().getAndList()) { List<String> l = e.getQueryValues().stream().filter(v -> !StringUtils.isEmpty(v.getValue())) .map(v -> v.getValue()).collect(Collectors.toList()); if (groupbyParams.containsKey(e.getProperties())) { // if not contains SUMMARY_KEY, add it into group by list if (!l.contains(TesseractConstant.SUMMARY_KEY)) { l.add(TesseractConstant.SUMMARY_KEY); } // Put it into group by field groupbyParams.get(e.getProperties()).addAll(l); } else { // Put it into filter field if (CollectionUtils.isEmpty(l)) { List<Set<String>> tmp = e.getQueryValues().stream().map(v -> v.getLeafValues()) .collect(Collectors.toList()); List<String> values = Lists.newArrayList(); tmp.forEach(t -> values.addAll(t)); whereParams.put(e.getProperties(), values); } else { whereParams.put(e.getProperties(), new ArrayList<String>(l)); } } } // Prepare query tools // CountDownLatch latch = new CountDownLatch(response.size()); // List<Future<CallbackResponse>> results = Lists.newArrayList(); Map<CallbackExecutor, Future<CallbackResponse>> results = Maps.newHashMap(); ExecutorCompletionService<CallbackResponse> service = new ExecutorCompletionService<CallbackResponse>( taskExecutor); StringBuilder callbackMeasureNames = new StringBuilder(); for (Entry<String, List<MiniCubeMeasure>> e : callbackMeasures.entrySet()) { CallbackExecutor ce = new CallbackExecutor(e, groupbyParams, whereParams); results.put(ce, service.submit(ce)); e.getValue().forEach(m -> { callbackMeasureNames.append(" " + m.getCaption() + " "); }); } // } Map<CallbackExecutor, CallbackResponse> response = new ConcurrentHashMap<CallbackExecutor, CallbackResponse>( callbackMeasures.size()); StringBuffer sb = new StringBuffer(); results.forEach((k, v) -> { try { response.put(k, v.get()); } catch (Exception e1) { LOGGER.error(e1.getMessage(), e1); sb.append(": " + callbackMeasureNames.toString() + " ??, ?"); } }); if (!StringUtils.isEmpty(sb.toString())) { if (ThreadLocalPlaceholder.getProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY) != null) { ThreadLocalPlaceholder.unbindProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY); } ThreadLocalPlaceholder.bindProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY, sb.toString()); } // Package result SqlQuery sqlQuery = QueryRequestUtil.transQueryRequest2SqlQuery(query); SearchIndexResultSet result = null; if (!response.isEmpty()) { result = packageResultRecords(query, sqlQuery, response); } else { result = new SearchIndexResultSet(new Meta(query.getGroupBy().getGroups().toArray(new String[0])), 0); } LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "query", "[query:" + query + "]")); return result; }
From source file:com.krypc.hl.pr.controller.PatientRecordController.java
@RequestMapping(value = "/createRecord", method = { RequestMethod.POST, RequestMethod.GET }) public ResponseWrapper createRecord(HttpServletRequest request, HttpServletResponse response) { logger.info("PatientRecordController---invokeChaincode()--STARTS"); ResponseWrapper wrapper = new ResponseWrapper(); String data = request.getParameter("data"); try {// w w w . java 2s.c om if (utils.verifychaincode()) { if (data != null && !data.isEmpty()) { JSONObject recordData = (JSONObject) new JSONParser().parse(data); String user = ((String) recordData.get("user")).trim(); String hash = ((String) recordData.get("hash")).trim(); String labId = "LAB0000001"; String reportId = ((String) recordData.get("reportId")).trim(); if (!StringUtils.isEmpty(hash) && !StringUtils.isEmpty(labId) && !StringUtils.isEmpty(reportId) && !StringUtils.isEmpty(user)) { String[] arugs = new String[] { hash, labId, reportId }; InvokeRequest invokerequest = new InvokeRequest(); ArrayList<String> argss = new ArrayList<>( Arrays.asList(Constants.MethodName.addrecord.toString())); argss.addAll(Arrays.asList(arugs)); invokerequest.setArgs(argss); invokerequest.setChaincodeID(utils.getChaincodeName().getChainCodeID()); invokerequest.setChaincodeName(utils.getChaincodeName().getTransactionID()); invokerequest.setChaincodeLanguage(ChaincodeLanguage.JAVA); Member member = peerMembershipServicesAPI.getChain().getMember(user); wrapper.resultObject = member.invoke(invokerequest); } else { wrapper.setError(ERROR_CODES.MANDATORY_FIELDS_MISSING); } } else { wrapper.setError(ERROR_CODES.MANDATORY_FIELDS_MISSING); } } else { wrapper.setError(ERROR_CODES.CHAINCODE_NOT_DEPLOYED); } } catch (Exception e) { wrapper.setError(ERROR_CODES.DUPLICATE_HASH); logger.error("PatientRecordController---invokeChaincode()--ERROR " + e); } logger.info("PatientRecordController---invokeChaincode()--ENDS"); return wrapper; }
From source file:com.hemou.android.util.StrUtils.java
public static boolean isEmpties(String... itms) { if (itms == null || itms.length <= 0) throw new IllegalArgumentException(); for (String itm : itms) if (StringUtils.isEmpty(itm)) return true; return false; }