List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:com.flyingdonut.implementation.persistence.MongoDBConnection.java
public void initDatabase() throws UnknownHostException { if (StringUtils.hasText(getMongoURI())) { mongoURIInit();//w w w . j a v a2s.c om } else { simpleInit(); } if (getUserName() != null && getUserName().trim().length() > 0) { db.authenticate(getUserName(), getPassword().toCharArray()); } }
From source file:com.phoenixnap.oss.ramlapisync.naming.NamingHelper.java
/** * Utility method to clean New Line,Spaces and other highly useless characters found (mainly in javadoc) * /*from w w w. j a v a 2s .c o m*/ * @param input The string to be cleaned * @return Cleaned String */ public static String cleanLeadingAndTrailingNewLineAndChars(String input) { if (!StringUtils.hasText(input)) { return input; } String output = input; output = output.replaceAll("[\\s]+\\*[\\s]+", " "); while (output.startsWith("/") || output.startsWith("\n") || output.startsWith("*") || output.startsWith("-") || output.startsWith("\t") || output.startsWith(" ") || output.startsWith("\\")) { output = output.substring(1); } while (output.endsWith("/") || output.endsWith("\n") || output.endsWith(" ") || output.endsWith(",") || output.endsWith("\t") || output.endsWith("-") || output.endsWith("*")) { output = output.substring(0, output.length() - 1); } return output; }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.facebook.FacebookAuthenticationProcessingFilter.java
/** * {@inheritDoc}//ww w . j ava 2 s . c o m * @see org.springframework.security.ui.AbstractProcessingFilter#attemptAuthentication( * javax.servlet.http.HttpServletRequest) */ @Override public Authentication attemptAuthentication(final HttpServletRequest request) throws AuthenticationException { String authToken = request.getParameter("auth_token"); if (!StringUtils.hasText(authToken)) { // trigger a redirect to the Facebook login throw new FacebookAuthenticationRequiredException(); } FacebookAuthenticationToken token = createToken(authToken, request, SecurityRequestHolder.getResponse(), _apiKey, _secretKey); token.setDetails(authenticationDetailsSource.buildDetails(request)); Authentication authentication = getAuthenticationManager().authenticate(token); if (authentication.isAuthenticated()) { setLastUsername(token.getUserId(), request); } return authentication; }
From source file:com.artivisi.biller.simulator.service.impl.PlnSimulatorServiceImpl.java
@Override public void delete(Pelanggan pelanggan) { if (pelanggan == null || !StringUtils.hasText(pelanggan.getId())) { return;//from w w w .j a v a 2 s. c om } sessionFactory.getCurrentSession().createQuery( "delete from PembayaranPascabayar p where p.tagihanPascabayar.id in (select t.id from TagihanPascabayar t where t.pelanggan.id = :pelanggan)") .setString("pelanggan", pelanggan.getId()).executeUpdate(); sessionFactory.getCurrentSession() .createQuery("delete from TagihanPascabayar t where t.pelanggan.id = :pelanggan") .setString("pelanggan", pelanggan.getId()).executeUpdate(); sessionFactory.getCurrentSession().delete(pelanggan); }
From source file:com.joyveb.dbpimpl.cass.prepare.config.xml.CassandraSessionParser.java
@Override protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) throws BeanDefinitionStoreException { String id = super.resolveId(element, definition, parserContext); return StringUtils.hasText(id) ? id : ConfigConstants.CASSANDRA_SESSION; }
From source file:org.openmrs.web.OpenmrsCookieThemeResolver.java
/** * Return the name of the default theme. *///from www .j av a2s . c om @Override public String getDefaultThemeName() { // check the global properties for the current theme String themeName = null; boolean openedSession = false; try { if (!Context.isSessionOpen()) { // only try to open a session if one isn't open for us already openedSession = true; Context.openSession(); } // check the admin-set global property for the theme themeName = Context.getAdministrationService().getGlobalProperty(GP_THEME_NAME); } catch (Exception ex) { // We must not throw an exception here, since this code is called from every page including the // for uncaught exceptions. Therefore we pass, and fall back to default behavior. } finally { // only close the session if we opened it if (openedSession) { Context.closeSession(); } } if (StringUtils.hasText(themeName)) { return themeName; } else { return super.getDefaultThemeName(); } }
From source file:com.devnexus.ting.model.support.PresentationSearchQuery.java
public static PresentationSearchQuery create(Event event, Long trackId, String trackName, String presentationTypeName, String skillLevelName, String presentationTagsAsString) { if (trackId == null && trackName == null && presentationTypeName == null && skillLevelName == null && presentationTagsAsString == null) { return null; }//from w w w. j a va 2 s.co m final PresentationSearchQuery presentationSearchQuery = new PresentationSearchQuery(); presentationSearchQuery.setEvent(event); if (trackId != null) { final Track track = new Track(); track.setId(trackId); presentationSearchQuery.setTrack(track); } else if (StringUtils.hasText(trackName)) { final Track track = new Track(); track.setName(StringUtils.trimWhitespace(trackName).toLowerCase(Locale.ENGLISH)); presentationSearchQuery.setTrack(track); } if (StringUtils.hasText(presentationTypeName)) { final PresentationType presentationType = PresentationType .valueOf(StringUtils.trimWhitespace(presentationTypeName).toUpperCase(Locale.ENGLISH)); presentationSearchQuery.setPresentationType(presentationType); } if (StringUtils.hasText(skillLevelName)) { final SkillLevel skillLevel = SkillLevel .valueOf(StringUtils.trimWhitespace(skillLevelName).toUpperCase(Locale.ENGLISH)); presentationSearchQuery.setSkillLevel(skillLevel); } if (StringUtils.hasText(presentationTagsAsString)) { final Set<String> tagNames = StringUtils.commaDelimitedListToSet(presentationTagsAsString); for (String tagName : tagNames) { PresentationTag presentationTag = new PresentationTag(); presentationTag.setName(tagName); presentationSearchQuery.getPresentationTags().add(presentationTag); } } return presentationSearchQuery; }
From source file:com.brienwheeler.svc.users.validation.UsernameNotExistValidator.java
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (!StringUtils.hasText(value)) return !constraintAnnotation.failOnEmpty(); IUserService userService = applicationContext.getBean(constraintAnnotation.userService(), IUserService.class); return userService.findByUsername(value) == null; }
From source file:org.openmrs.module.htmlwidgets.web.handler.PropertiesHandler.java
/** * @see WidgetHandler#parse(String, Class<?>) *//* w w w. jav a 2 s.com*/ @Override public Object parse(String input, Class<?> type) { if (StringUtils.hasText(input)) { Properties p = new Properties(); try { OpenmrsUtil.loadProperties(p, new ByteArrayInputStream(input.getBytes("UTF-8"))); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unable to load properties from string", e); } return p; } return null; }
From source file:com.consol.citrus.admin.service.spring.filter.GetSpringImportsFilter.java
@Override public short startElement(Element element) { if (DomUtils.nodeNameEquals(element, "import")) { String resourceLocation = element.getAttribute("resource"); if (StringUtils.hasText(resourceLocation)) { if (resourceLocation.startsWith("classpath:")) { resourceLocation = resourceLocation.substring("classpath:".length()); } else if (resourceLocation.startsWith("file:")) { resourceLocation = resourceLocation.substring("file:".length()); }//from www.ja va 2 s . c om try { File importedFile = new FileSystemResource( parentConfigFile.getParentFile().getCanonicalPath() + File.separator + resourceLocation) .getFile(); if (importedFile.exists()) { importedFiles.add(importedFile); } } catch (IOException e) { log.warn("Unable to resolve imported file resource location", e); } } } return NodeFilter.FILTER_ACCEPT; }