List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:com.github.braully.web.DescriptorExposedEntity.java
public Map<String, String> sanitizeFilterParams(Map<String, String> params) { Map<String, String> sanitized = new HashMap<>(); if (params != null) { for (Map.Entry<String, String> ent : params.entrySet()) { String key = ent.getKey(); String value = ent.getValue(); value = StringEscapeUtils.escapeJava(value); key = StringEscapeUtils.escapeJava(key); key = removeCharctersUnsafe(key); if (!StringUtils.isEmpty(key) && !StringUtils.isEmpty(value)) { sanitized.put(key, value); }/*from w ww. java2 s . co m*/ } } return sanitized; }
From source file:com.atlassian.connect.spring.internal.AtlassianConnectContextModelAttributeProvider.java
private Optional<String> getHostBaseUrlFromQueryParameters() { String hostUrl = request.getParameter("xdm_e"); String contextPath = request.getParameter("cp"); Optional<String> optionalBaseUrl = Optional.empty(); if (!StringUtils.isEmpty(hostUrl)) { if (!StringUtils.isEmpty(contextPath)) { optionalBaseUrl = Optional.of(hostUrl + contextPath); } else {// w w w.j av a 2 s . co m optionalBaseUrl = Optional.of(hostUrl); } } return optionalBaseUrl; }
From source file:com.netflix.spinnaker.halyard.config.validate.v1.providers.google.GoogleBaseImageValidator.java
@Override public void validate(ConfigProblemSetBuilder p, GoogleBaseImage n) { String sourceImage = n.getVirtualizationSettings().getSourceImage(); String sourceImageFamily = n.getVirtualizationSettings().getSourceImageFamily(); if (StringUtils.isEmpty(sourceImage) && StringUtils.isEmpty(sourceImageFamily)) { p.addProblem(Problem.Severity.ERROR, "Either source image or source image family must be specified for " + n.getBaseImage().getId() + "."); }//from w w w .j a v a 2 s . c o m if (!StringUtils.isEmpty(sourceImage)) { int i = 0; boolean[] foundSourceImageHolder = new boolean[1]; while (!foundSourceImageHolder[0] && i < credentialsList.size()) { GoogleNamedAccountCredentials credentials = credentialsList.get(i); List<String> imageProjects = Lists.newArrayList(credentials.getProject()); imageProjects.addAll(credentials.getImageProjects()); imageProjects.addAll(baseImageProjects); Compute compute = credentials.getCompute(); BatchRequest imageListBatch = buildBatchRequest(compute); JsonBatchCallback<ImageList> imageListCallback = new JsonBatchCallback<ImageList>() { @Override public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) throws IOException { p.addProblem(Problem.Severity.ERROR, "Error locating " + sourceImage + " in these projects: " + imageProjects + ": " + e.getMessage() + "."); } @Override public void onSuccess(ImageList imageList, HttpHeaders responseHeaders) throws IOException { // No need to look through these images if the requested image was already found. if (!foundSourceImageHolder[0]) { if (imageList.getItems() != null) { foundSourceImageHolder[0] = imageList.getItems().stream() .filter(image -> image.getName().equals(sourceImage)).findFirst() .isPresent(); } } } }; try { for (String imageProject : imageProjects) { compute.images().list(imageProject).queue(imageListBatch, imageListCallback); } imageListBatch.execute(); } catch (IOException e) { p.addProblem(Problem.Severity.ERROR, "Error locating " + sourceImage + " in these projects: " + imageProjects + ": " + e.getMessage() + "."); } i++; } if (!foundSourceImageHolder[0]) { p.addProblem(Problem.Severity.ERROR, "Image " + sourceImage + " not found via any configured google account."); } } if (!StringUtils.isEmpty(sourceImageFamily)) { int i = 0; boolean[] foundSourceImageFamilyHolder = new boolean[1]; while (!foundSourceImageFamilyHolder[0] && i < credentialsList.size()) { GoogleNamedAccountCredentials credentials = credentialsList.get(i); List<String> imageProjects = Lists.newArrayList(credentials.getProject()); imageProjects.addAll(credentials.getImageProjects()); imageProjects.addAll(baseImageProjects); Compute compute = credentials.getCompute(); BatchRequest imageListBatch = buildBatchRequest(compute); JsonBatchCallback<ImageList> imageListCallback = new JsonBatchCallback<ImageList>() { @Override public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) throws IOException { p.addProblem(Problem.Severity.ERROR, "Error locating " + sourceImageFamily + " in these projects: " + imageProjects + ": " + e.getMessage() + "."); } @Override public void onSuccess(ImageList imageList, HttpHeaders responseHeaders) throws IOException { // No need to look through these images if the requested image family was already found. if (!foundSourceImageFamilyHolder[0]) { if (imageList.getItems() != null) { foundSourceImageFamilyHolder[0] = imageList.getItems().stream() .filter(image -> sourceImageFamily.equals(image.getFamily())).findFirst() .isPresent(); } } } }; try { for (String imageProject : imageProjects) { compute.images().list(imageProject).queue(imageListBatch, imageListCallback); } imageListBatch.execute(); } catch (IOException e) { p.addProblem(Problem.Severity.ERROR, "Error locating " + sourceImageFamily + " in these projects: " + imageProjects + ": " + e.getMessage() + "."); } i++; } if (!foundSourceImageFamilyHolder[0]) { p.addProblem(Problem.Severity.ERROR, "Image family " + sourceImageFamily + " not found via any configured google account."); } } if (StringUtils.isEmpty(n.getBaseImage().getPackageType())) { p.addProblem(Problem.Severity.ERROR, "Package type must be specified for " + n.getBaseImage().getId() + "."); } }
From source file:org.psikeds.resolutionengine.rules.RelationStack.java
public Relation removeRelation(final String rid) { return (StringUtils.isEmpty(rid) ? null : this.remove(rid)); }
From source file:com.jiwhiz.rest.MessageSender.java
/** * Send message to admin when a new user registered by auto signup. * @param user//from w ww. j a va 2 s .co m */ public void sendNewUserRegistered(UserAccount user) { String userEmail = user.getEmail(); if (StringUtils.isEmpty(userEmail)) { userEmail = "[not set]"; } String subject = "New user registered"; String message = "A new user registered: name is " + user.getDisplayName() + ", email is " + userEmail; emailService.sendEmail(new EmailMessage(properties, subject, message, null)); }
From source file:com.stehno.sjdbcx.reflection.extractor.RowMapperExtractor.java
public RowMapper extract(final Method method) { final com.stehno.sjdbcx.annotation.RowMapper mapper = AnnotationUtils.getAnnotation(method, com.stehno.sjdbcx.annotation.RowMapper.class); if (mapper == null) { Class mappedType = method.getReturnType(); if (Collection.class.isAssignableFrom(mappedType)) { mappedType = (Class) ((ParameterizedType) method.getGenericReturnType()) .getActualTypeArguments()[0]; } else if (mappedType.isArray()) { throw new UnsupportedOperationException("Auto-mapping for array return types is not yet supported"); } else if (mappedType.isPrimitive()) { if (mappedType == int.class || mappedType == long.class) { return new SingleColumnRowMapper(); } else if (mappedType == boolean.class) { return new RowMapper<Boolean>() { @Override//from www . j av a2s.com public Boolean mapRow(final ResultSet resultSet, final int i) throws SQLException { return resultSet.getBoolean(1); } }; } } return new BeanPropertyRowMapper(mappedType); } else { final String extractKey = mapper.value(); if (StringUtils.isEmpty(extractKey)) { return resolve((Class<RowMapper>) mapper.type()); } else { return resolve(extractKey); } } }
From source file:com.codestd.spring.cxf.config.EndpointBeanProcessor.java
public void setAnnotationPackage(String annotationPackage) { this.annotationPackage = annotationPackage; if (!StringUtils.isEmpty(this.annotationPackage)) this.annotationPackages = this.annotationPackage.split(this.COMMA_SPLIT_PATTERN); }
From source file:org.bigtester.ate.browser.BrowserProfile.java
/** * Instantiates a new profile creator./*from w w w . j a v a 2 s .c om*/ * * @param profileName the profile name */ @SuppressWarnings("unchecked") public BrowserProfile(Class<T> profileType, String profileName) { if (StringUtils.isEmpty(profileName)) { throw new IllegalArgumentException(); } this.profileName = profileName; this.profileType = profileType; if (this.profileType == FirefoxProfile.class) { ProfilesIni profileIni = new ProfilesIni(); T tmpProfile = (T) profileIni.getProfile(profileName); if (null == tmpProfile) { throw new IllegalArgumentException("Could not find the browser profile."); } else { this.profile = tmpProfile; } } else { //TODO set default profile type to firefox profile type ProfilesIni profileIni = new ProfilesIni(); T tmpProfile = (T) profileIni.getProfile(profileName); if (null == tmpProfile) { throw new IllegalArgumentException(); } else { this.profile = tmpProfile; } } }
From source file:org.zalando.baigan.proxy.ConfigurationBeanDefinitionRegistrar.java
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { final AnnotationAttributes annotationAttributes = AnnotationAttributes .fromMap(importingClassMetadata.getAnnotationAttributes(ConfigurationServiceScan.class.getName())); if (annotationAttributes == null || annotationAttributes.isEmpty()) { throw new IllegalArgumentException("ConfigurationServiceScan requires at least 1 scan package."); }//from ww w . j av a2 s . c om final List<String> basePackages = Lists.newArrayList(); basePackages.addAll(Arrays.asList(annotationAttributes.getStringArray("value"))); basePackages.addAll(Arrays.asList(annotationAttributes.getStringArray("basePackages"))); final Set<String> saneSet = basePackages.stream().filter(str -> !StringUtils.isEmpty(str)) .collect(Collectors.toSet()); createAndRegisterBeanDefinitions(saneSet, registry); }
From source file:com.reactive.hzdfs.cluster.HazelcastClusterServiceFactoryBean.java
@PostConstruct private void setUp() { if (StringUtils.isEmpty(entityBasePkg)) throw new BeanCreationException("'entityBasePkg' not specified in factory bean"); }