List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.LuceneIAViewConfiguration.java
/** * w// w ww .j a v a2 s .c o m * * @return */ public @Bean Query catalogueFilter() { if (!StringUtils.isEmpty(queryFilterSourceValues)) { String[] arrayOfSourceValues = queryFilterSourceValues.split(","); if (arrayOfSourceValues.length == 1) { return getSourceFilterForValue(arrayOfSourceValues[0]); } else { return getChainOfSourceFiltersForValues(arrayOfSourceValues); } } return null; }
From source file:com.baidu.rigel.biplatform.tesseract.isservice.index.service.impl.IndexMetaServiceImpl.java
public List<IndexMeta> getIndexMetasByDataSourceKey(String dataSourceKey) { LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "getIndexMetasByDataSourceKey", dataSourceKey));/*www.jav a 2 s . c o m*/ if (StringUtils.isEmpty(dataSourceKey)) { LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "getIndexMetasByDataSourceKey", dataSourceKey)); throw new IllegalArgumentException(); } List<IndexMeta> metaList = super.getStoreMetaListByStoreKey(IndexMeta.getDataStoreName(), dataSourceKey); LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "getIndexMetasByDataSourceKey", dataSourceKey)); return metaList; }
From source file:org.terasoluna.gfw.web.el.ObjectToMapConverter.java
/** * Add the pair of the given name and value to the given map. The value is flattened if required to be available in query * params. <br>// www.j a v a2s . c o m * Return whether the value is flattened. The value is flattened in the case of the following types: * <ul> * <li>Array (unless the name is empty)</li> * <li>Iterable (unless the name is empty)</li> * <li>Map</li> * <li>{@link BeanUtils#isSimpleProperty(java.lang.Class)}</li> * <li>if {@link #conversionService} can convert</li> * </ul> * <p> * The value is formatted using {@link FormattingConversionService} is possible. If the value of a property is {@code null}, * the value is converted to an empty string and the key is prefixed with {@code "_"}. Request parameter that start with * {@code "_"} is reset parameter provided by Spring Web MVC. If a reset parameter is specified, Spring Web MVC bind * {@code null} to a property value. * </p> * @param map map to add * @param prefix prefix of the key * @param name name of the value * @param value value to convert * @param sourceType {@link TypeDescriptor} to use * @return flatten map */ private boolean flatten(Map<String, String> map, String prefix, String name, Object value, TypeDescriptor sourceType) { String key = StringUtils.isEmpty(prefix) ? name : prefix + "." + name; if (value == null) { String resetKey = "_" + key; map.put(resetKey, ""); // the value has been flatten return true; } Class<?> clazz = value.getClass(); if (value instanceof Iterable) { if (StringUtils.isEmpty(name)) { // skip flatten return true; } Iterable iterable = (Iterable) value; map.putAll(this.convert(key, iterable)); } else if (clazz.isArray()) { if (StringUtils.isEmpty(name)) { // skip flatten return true; } map.putAll(this.convert(key, arrayObjectToList(value))); } else if (value instanceof Map) { Map m = (Map) value; map.putAll(this.convert(key, m)); } else { TypeDescriptor descriptor = (sourceType != null) ? sourceType : TypeDescriptor.forObject(value); if (BeanUtils.isSimpleProperty(clazz) || conversionService.canConvert(descriptor, STRING_DESC)) { map.put(key, conversionService.convert(value, descriptor, STRING_DESC).toString()); } else { // the value is Java Bean? return false; } } // the value has been flatten return true; }
From source file:org.bigtester.ate.model.page.atewebdriver.MultiWindowsHandler.java
/** * Refresh windows list./*from w ww .j a v a2 s .c om*/ * * @param webD * the web d */ private void refreshWindowsList(@Nullable WebDriver webD) { if (null == webD) throw GlobalUtils.createNotInitializedException("Web Driver"); Set<String> allWinHandles = webD.getWindowHandles(); for (String winH : allWinHandles) { if (null == winH) throw GlobalUtils.createInternalError("web driver get all windows handles error."); boolean winAlreadyStored = false; //NOPMD for (BrowserWindow bWin : windows) { if (bWin.getWindowHandle().equals(winH)) { winAlreadyStored = true; break; } } if (!winAlreadyStored) { BrowserWindow temp = new BrowserWindow(winH, driver); windows.add(temp); } } for (Iterator<BrowserWindow> iter = windows.iterator(); iter.hasNext();) { BrowserWindow winH2 = iter.next(); if (allWinHandles.contains(winH2.getWindowHandle())) { continue; } else { iter.remove(); } } for (Iterator<BrowserWindow> iter = windows.iterator(); iter.hasNext();) { BrowserWindow winH2 = iter.next(); winH2.refreshFrames(); } if (StringUtils.isEmpty(this.mainWindowHandler) || StringUtils.isEmpty(this.mainWindowTitle)) { this.mainWindowHandler = windows.get(0).getWindowHandle(); String currentWinHandle = webD.getWindowHandle(); webD.switchTo().window(this.mainWindowHandler); this.mainWindowTitle = windows.get(0).getMyWd().getTitle(); webD.switchTo().window(currentWinHandle); } }
From source file:io.cos.cas.authentication.handler.support.OpenScienceFrameworkPrincipalFromRequestRemoteUserNonInteractiveCredentialsAction.java
/** * Abstract method to implement to construct the credential from the * request object./* w ww . ja v a 2 s .com*/ * * @param context the context for this request. * @return the constructed credential or null if none could be constructed * from the request. * @throws AccountException a account exception */ protected Credential constructCredentialsFromRequest(final RequestContext context) throws AccountException { final HttpServletRequest request = WebUtils.getHttpServletRequest(context); final OpenScienceFrameworkCredential credential = (OpenScienceFrameworkCredential) context.getFlowScope() .get("credential"); // WARNING: Do not assume this works w/o acceptance testing in a Production environment. // The call is made to trust these headers only because we assume the Apache Shibboleth Service Provider module // rejects any conflicting / forged headers. final String shibbolethSession = request.getHeader(SHIBBOLETH_SESSION_HEADER); if (StringUtils.hasText(shibbolethSession)) { final String remoteUser = request.getHeader(REMOTE_USER); if (StringUtils.isEmpty(remoteUser)) { logger.error("Invalid Remote User specified as Empty"); throw new RemoteUserFailedLoginException("Invalid Remote User specified as Empty"); } logger.info("Remote User from HttpServletRequest '{}'", remoteUser); credential.setRemotePrincipal(Boolean.TRUE); for (final String headerName : Collections.list(request.getHeaderNames())) { if (headerName.startsWith(ATTRIBUTE_PREFIX)) { final String headerValue = request.getHeader(headerName); logger.debug("Remote User [{}] Auth Header '{}': '{}'", remoteUser, headerName, headerValue); credential.getAuthenticationHeaders().put(headerName.substring(ATTRIBUTE_PREFIX.length()), headerValue); } } // Notify the OSF of the remote principal authentication. final PrincipalAuthenticationResult remoteUserInfo = notifyRemotePrincipalAuthenticated(credential); credential.setUsername(remoteUserInfo.getUsername()); credential.setInstitutionId(remoteUserInfo.getInstitutionId()); return credential; } else if (request.getParameter("username") != null && request.getParameter("verification_key") != null) { // Construct credential if presented with (username, verification_key) // This is used when: // 1. User creates an account // 2. User resets the password through forgot_password // 3. User sets password when added as an unregistered contribution // Note: Two-factor sign in works and remain unchanged credential.setUsername(request.getParameter("username")); credential.setVerificationKey(request.getParameter("verification_key")); return credential; } return null; }
From source file:core.Reconciler.java
public void PostToSalesForce(List<LicenseInternal> aInLicenses, Map<String, LicenseInternal> aInOutFailedRequests, Map<String, LicenseInternal> aInAllRequests, boolean aInRetry, StringBuilder aInOutErrors) { String lMsg = ""; System.out.println(// w w w .j ava 2 s. c o m "Reconciler: Call to Post to sales force, size " + aInLicenses.size() + " retry " + aInRetry); try { List<LicenseResponse> lLicenseResponses = sfdcService.syncNIPRLicenses(aInLicenses); // Check sales force response and record failed requests. for (LicenseResponse lLicenseResponse : lLicenseResponses) { String lKey = lLicenseResponse.getKey(); if (lLicenseResponse.isSuccess()) { System.out.println("Reconciler: License Key " + lKey + " successfully updated in SDFC"); } else if (StringUtils.isEmpty(lLicenseResponse.getErrorCode()) || SalesforceService.NIPR_ERROR_CODE_TO_IGNORE.contains(lLicenseResponse.getErrorCode())) { System.out.println("Reconciler: License Key " + lKey + " ignore data error " + lLicenseResponse.getErrorCode()); } else { lMsg = "Reconciler: License Key " + lKey + " failed to send " + lLicenseResponse.getErrorDescription(); WebUtils.appendline(lMsg, aInOutErrors); // System.out.println(lMsg); if (aInAllRequests.containsKey(lKey)) { LicenseInternal lLicense = aInAllRequests.get(lKey); lLicense.lastErrorCode = (CalenderUtils.isNullOrWhiteSpace(lLicenseResponse.getErrorCode())) ? "UNKNOWN" : lLicenseResponse.getErrorCode(); lLicense.lastErrorMessage = (CalenderUtils .isNullOrWhiteSpace(lLicenseResponse.getErrorMessage())) ? "UNKNOWN" : lLicenseResponse.getErrorMessage(); ; aInOutFailedRequests.put(lKey, lLicense); } else { lMsg = "Reconciler: License Key " + lKey + " failed as per response but not found in request!! Ignoring .."; WebUtils.appendline(lMsg, aInOutErrors); System.out.println(lMsg); } } } } catch (Exception ex) { lMsg = "Post to sales force failed due to exception " + ex; WebUtils.appendline(lMsg, aInOutErrors); System.out.println(lMsg); // TODO: Check the failure if (aInRetry) { System.out.println("Retyring call to sales force "); PostToSalesForce(aInLicenses, aInOutFailedRequests, aInAllRequests, false, aInOutErrors); } else { // Add all the requests to Failed ones for (LicenseInternal lLicense : aInLicenses) { String lKey = lLicense.GetKey(); if (!aInOutFailedRequests.containsKey(lKey)) { System.out.println( "Adding License " + lKey + " to failed request dues to sales force api failure"); lLicense.lastErrorCode = "SDFC_API_CALL_FAILURE"; lLicense.lastErrorMessage = "Failed to call SDFC api, bulk failure"; aInOutFailedRequests.put(lKey, lLicense); } } } } }
From source file:com.web.mavenproject6.controller.UserController.java
@RequestMapping(value = "/guest/add/{propId}", method = RequestMethod.POST) @ResponseBody//w w w . j a v a2 s. co m public String addGuest(@PathVariable("propId") String userId, @RequestParam("sdata") String sdata) throws JSONException { if (StringUtils.isEmpty(sdata)) { return (new Date()).toString(); } JSONObject o = new JSONObject(sdata); Object pObject = personalService.findByAccessNumber((String) o.get("propId")); guest g = new guest(); g.setFname((String) o.get("fname")); g.setSname((String) o.get("sname")); g.setTname((String) o.get("tname")); g.setPassportNum("-"); g.setPassportSeria((String) o.get("pasport")); g.setPersonal_guest((personal) pObject); ((personal) pObject).addGuest(g); ((personal) pObject).setLastUpdate(new Date()); personalService.getRepository().save(((personal) pObject)); guestService.getRepository().save(g); g = (guest) guestService.findByFST(g.getFname(), g.getSname(), g.getTname()); g.setAccessNumber("g" + formatNum("" + g.getId())); guestService.getRepository().save(g); return g.getPersonal_guest().getLastUpdate().toString(); }
From source file:org.psikeds.knowledgebase.xml.impl.XMLParser.java
private Reader createXmlReader() throws UnsupportedEncodingException, IOException { if (!StringUtils.isEmpty(this.encoding)) { if (this.xmlResource != null) { return new InputStreamReader(this.xmlResource.getInputStream(), this.encoding); }/*from w ww . ja va 2 s . com*/ if (this.xmlStream != null) { return new InputStreamReader(this.xmlStream, this.encoding); } if (!StringUtils.isEmpty(this.xmlFilename)) { return new InputStreamReader(new FileInputStream(this.xmlFilename), this.encoding); } } throw new IllegalArgumentException("Unsupported configuration settings!"); }
From source file:cn.guoyukun.spring.jpa.plugin.serivce.BaseTreeableService.java
public Set<ID> findAncestorIds(ID currentId) { Set ids = Sets.newHashSet();/*ww w . j a v a 2 s . co m*/ M m = findOne(currentId); if (m == null) { return ids; } for (String idStr : StringUtils.tokenizeToStringArray(m.getParentIds(), "/")) { if (!StringUtils.isEmpty(idStr)) { ids.add(Long.valueOf(idStr)); } } return ids; }
From source file:com.krypc.hl.pr.controller.PatientRecordController.java
@RequestMapping(value = "/requestRecord", method = { RequestMethod.POST, RequestMethod.GET }) public ResponseWrapper requestRecord(HttpServletRequest request, HttpServletResponse response) { logger.info("PatientRecordController---requestRecord()--STARTS"); ResponseWrapper wrapper = new ResponseWrapper(); String data = request.getParameter("data"); try {/*from ww w .ja va 2 s . com*/ 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 docId = ((String) recordData.get("doctorId")).trim(); String patientSSN = ((String) recordData.get("patientSSN")).trim(); if (!StringUtils.isEmpty(hash) && !StringUtils.isEmpty(docId) && !StringUtils.isEmpty(patientSSN) && !StringUtils.isEmpty(user)) { String[] arugs = new String[] { hash, docId, patientSSN }; InvokeRequest invokerequest = new InvokeRequest(); ArrayList<String> argss = new ArrayList<>( Arrays.asList(Constants.MethodName.requestrecord.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.RECORD_HASH_NOT_AVAILABLE); logger.error("PatientRecordController---requestRecord()--ERROR " + e); } logger.info("PatientRecordController---requestRecord()--ENDS"); return wrapper; }