List of usage examples for org.apache.commons.lang StringUtils isNotEmpty
public static boolean isNotEmpty(String str)
Checks if a String is not empty ("") and not null.
From source file:cn.cuizuoli.appranking.typehandler.DeviceTypeTypeHandler.java
@Override public DeviceType getNullableResult(ResultSet rs, String columnName) throws SQLException { DeviceType deviceType = null;// w ww . j a v a2 s .c om String s = rs.getString(columnName); if (StringUtils.isNotEmpty(s)) { deviceType = DeviceType.getObject(s); } return deviceType; }
From source file:com.pscnlab.member.daos.impls.MemberDaoImpl.java
@Override public Page<Member> findPage(MemberPageQueryDTO query, Integer offset, Integer size) { FilterMap filterMap = new FilterMap(); if (query != null) { if (query.getUuidRole() != null) { filterMap.eq("uuidRole", query.getUuidRole()); }//from w ww . j a v a 2s . com if (StringUtils.isNotBlank(query.getGender())) { filterMap.eq("gender", query.getGender()); } if (StringUtils.isNotEmpty(query.getName())) { filterMap.like("name", "%" + query.getName() + "%"); } if (StringUtils.isNotEmpty(query.getTelephone())) { filterMap.like("telephone", "%" + query.getTelephone() + "%"); } } return super.page(filterMap, offset, size); }
From source file:com.github.gekoh.yagen.api.DefaultNamingStrategy.java
@Override public String classToTableName(String className) { try {//from w w w . j a v a 2 s. c om Class<?> aClass = Class.forName(className); if (aClass.isAnnotationPresent(javax.persistence.Table.class)) { String tableName = aClass.getAnnotation(javax.persistence.Table.class).name(); if (StringUtils.isNotEmpty(tableName)) { return tableName(tableName); } } } catch (ClassNotFoundException ignore) { } return super.classToTableName(className); }
From source file:com.haulmont.cuba.web.gui.components.WebStreamResource.java
@Override protected void createResource() { String name = StringUtils.isNotEmpty(fileName) ? fileName : RandomStringUtils.random(16, true, true); resource = new com.vaadin.server.StreamResource(() -> streamSupplier.get(), name); com.vaadin.server.StreamResource vStreamResource = (com.vaadin.server.StreamResource) this.resource; vStreamResource.setCacheTime(cacheTime); vStreamResource.setBufferSize(bufferSize); vStreamResource.setMIMEType(mimeType); }
From source file:com.dp2345.service.impl.ShippingServiceImpl.java
@SuppressWarnings("unchecked") @Transactional(readOnly = true)/*from w w w . ja va 2s. c om*/ @Cacheable("shipping") public Map<String, Object> query(Shipping shipping) { Setting setting = SettingUtils.get(); Map<String, Object> data = new HashMap<String, Object>(); if (shipping != null && StringUtils.isNotEmpty(setting.getKuaidi100Key()) && StringUtils.isNotEmpty(shipping.getDeliveryCorpCode()) && StringUtils.isNotEmpty(shipping.getTrackingNo())) { try { ObjectMapper mapper = new ObjectMapper(); URL url = new URL("http://api.kuaidi100.com/api?id=" + setting.getKuaidi100Key() + "&com=" + shipping.getDeliveryCorpCode() + "&nu=" + shipping.getTrackingNo() + "&show=0&muti=1&order=asc"); data = mapper.readValue(url, Map.class); } catch (Exception e) { e.printStackTrace(); } } return data; }
From source file:com.jaspersoft.jasperserver.war.cascade.handlers.converters.DateDataConverter.java
@Override public Date stringToValue(String rawData) throws ParseException { return StringUtils.isNotEmpty(rawData) ? calendarFormatProvider.getDateFormat().parse(rawData) : null; }
From source file:com.orchestra.portale.externalauth.FbAuthenticationManager.java
public static User fbLoginJs(HttpServletRequest request, HttpServletResponse response, UserRepository userRepository) { //Get access_token from request String access_token = request.getParameter("access_token"); User user = null;//from w w w .j av a2 s. co m if (StringUtils.isNotEmpty(access_token)) { try { Boolean validity = FacebookUtils.ifTokenValid(access_token); //if token is valid, retrieve userid and email from Facebook if (validity) { Map<String, String> userId_mail = FacebookUtils.getUserIDMail(access_token); String id = userId_mail.get("id"); String email = userId_mail.get("email"); try { user = fbUserCheck(id, email, userRepository); } catch (UserNotFoundException ioex) { /*Retrieve User Data to Registration*/ Map<String, String> userData = FacebookUtils.getUserData(access_token); /*Create User*/ com.orchestra.portale.persistence.sql.entities.User new_user = new com.orchestra.portale.persistence.sql.entities.User(); new_user.setFbEmail(userData.get("email")); new_user.setFbUser(userData.get("id")); new_user.setUsername(userData.get("email")); new_user.setFirstName(userData.get("firstName")); new_user.setLastName(userData.get("lastName")); new_user.setPassword(new BigInteger(130, new SecureRandom()).toString(32)); /*Create Role*/ com.orchestra.portale.persistence.sql.entities.Role new_user_role = new com.orchestra.portale.persistence.sql.entities.Role(); new_user_role.setRole("ROLE_USER"); new_user_role.setUser(new_user); ArrayList<com.orchestra.portale.persistence.sql.entities.Role> new_user_roles = new ArrayList<com.orchestra.portale.persistence.sql.entities.Role>(); new_user_roles.add(new_user_role); new_user.setRoles(new_user_roles); /*Save User*/ userRepository.save(new_user); //Save user image try { String img_url = userData.get("img"); String user_id_img = userRepository.findByUsername(new_user.getUsername()).getId() .toString(); HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); String destination = sc.getRealPath("/") + "dist" + File.separator + "user" + File.separator + "img" + File.separator + user_id_img + File.separator; NetworkUtils.saveImageFromURL(img_url, destination, "avatar.jpg"); } catch (MalformedURLException ex) { throw new FacebookException(); } catch (IOException ioexc) { ioexc.getMessage(); } /*Create Spring User*/ boolean enabled = true; boolean accountNonExpired = true; boolean credentialsNonExpired = true; boolean accountNonLocked = true; user = new User(new_user.getUsername(), new_user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(new_user.getRoles())); } } } catch (FacebookException ioex) { ioex.printStackTrace(); } } return user; }
From source file:com.cognifide.cq.cache.plugins.statistics.action.ClearAction.java
@Override public void exectue() { String cacheName = request.getParameter(Statistics.CACHE_NAME_PARAMETER); if (StringUtils.isNotEmpty(cacheName)) { logger.info("Cache {} will be cleared", cacheName); cacheHolder.clear(cacheName);//from w w w .ja v a 2 s. c o m } else { logger.error("Error while reciving request. No key prameter."); response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } }
From source file:com.microsoft.alm.common.utils.UrlHelper.java
public static String trimTrailingSeparators(final String uri) { if (StringUtils.isNotEmpty(uri)) { int lastIndex = uri.length(); while (lastIndex > 0 && uri.charAt(lastIndex - 1) == URL_SEPARATOR.charAt(0)) { lastIndex--;//from ww w . j av a 2 s . co m } if (lastIndex >= 0) { return uri.substring(0, lastIndex); } } return uri; }
From source file:com.prowidesoftware.swift.model.mt.ServiceIdType.java
/** * Returns true if the parameter number is a valid service id. * This method is null-safe./*from w w w.java 2 s .com*/ * * @param number the service id number to test, may be <code>null</code> * @return <code>true</code> if the parameter number is a valid service id * @since 7.8.8 */ public static final boolean valid(String number) { if (StringUtils.isNotEmpty(number)) { try { valueOf("_" + number); return true; } catch (Exception unused) { return false; } } return false; }