List of usage examples for org.springframework.util StringUtils hasLength
public static boolean hasLength(@Nullable String str)
From source file:org.codehaus.groovy.grails.plugins.springsecurity.AnnotationFilterInvocationDefinition.java
protected String findGrailsUrl(final UrlMappingInfo mapping, final GrailsApplication application) { String actionName = mapping.getActionName(); if (!StringUtils.hasLength(actionName)) { actionName = ""; }// w ww . j a v a 2s. co m String controllerName = mapping.getControllerName(); if (isController(controllerName, actionName, application)) { if (!StringUtils.hasLength(actionName) || "null".equals(actionName)) { actionName = "index"; } return ("/" + controllerName + "/" + actionName).trim(); } return null; }
From source file:org.codehaus.groovy.grails.scaffolding.view.ScaffoldingViewResolver.java
@Override protected View loadView(String viewName, Locale locale) throws Exception { final View resolvedView = super.loadView(viewName, locale); if (templateGenerator == null || resolvedView instanceof GroovyPageView) { return resolvedView; }// w w w . jav a 2 s. c om GrailsWebRequest webRequest = WebUtils.retrieveGrailsWebRequest(); List<String> controllerActions = scaffoldedActionMap.get(webRequest.getControllerName()); if (controllerActions != null && controllerActions.contains(webRequest.getActionName())) { GrailsDomainClass domainClass = scaffoldedDomains.get(webRequest.getControllerName()); if (domainClass != null) { String viewFileName; final int i = viewName.lastIndexOf('/'); if (i > -1) { viewFileName = viewName.substring(i, viewName.length()); } else { viewFileName = viewName; } final ViewKey viewKey = new ViewKey(webRequest.getControllerName(), viewFileName); View v = scaffoldedViews.get(viewKey); if (v == null) { String viewCode = null; try { viewCode = generateViewSource(viewFileName, domainClass); } catch (Exception e) { LOG.error("Error generating scaffolded view [" + viewName + "]: " + e.getMessage(), e); return resolvedView; } if (StringUtils.hasLength(viewCode)) { v = createScaffoldedView(viewName, viewCode); scaffoldedViews.put(viewKey, v); } } if (v != null) { return v; } } } return resolvedView; }
From source file:org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public ModelAndView handleActionResponse(GroovyObject controller, Object returnValue, GrailsWebRequest webRequest, Map chainModel, String closurePropertyName, String viewName) { boolean viewNameBlank = !StringUtils.hasLength(viewName); ModelAndView explicitModelAndView = (ModelAndView) controller .getProperty(ControllerDynamicMethods.MODEL_AND_VIEW_PROPERTY); if (!webRequest.isRenderView()) { return null; }/*w w w .j a va 2 s . co m*/ if (explicitModelAndView != null) { return explicitModelAndView; } if (returnValue == null) { if (viewNameBlank) { return null; } return new ModelAndView(viewName, chainModel); } if (returnValue instanceof Map) { // remove any Proxy wrappers and set the adaptee as the value Map finalModel = new LinkedHashMap(); if (!chainModel.isEmpty()) { finalModel.putAll(chainModel); } Map returnModel = (Map) returnValue; finalModel.putAll(returnModel); removeProxiesFromModelObjects(finalModel); return new ModelAndView(viewName, finalModel); } if (returnValue instanceof ModelAndView) { ModelAndView modelAndView = (ModelAndView) returnValue; // remove any Proxy wrappers and set the adaptee as the value Map modelMap = modelAndView.getModel(); removeProxiesFromModelObjects(modelMap); if (!chainModel.isEmpty()) { modelAndView.addAllObjects(chainModel); } if (modelAndView.getView() == null && modelAndView.getViewName() == null) { if (viewNameBlank) { throw new NoViewNameDefinedException( "ModelAndView instance returned by and no view name defined by nor for closure on property [" + closurePropertyName + "] in controller [" + controller.getClass() + "]!"); } modelAndView.setViewName(viewName); } return modelAndView; } return new ModelAndView(viewName, chainModel); }
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
/** * Parses the supplied <code><bean></code> element. May return <code>null</code> if there were errors during * parse. Errors are reported to the {@link org.springframework.beans.factory.parsing.ProblemReporter}. *///from ww w .j a v a 2 s. c o m private BeanDefinitionHolder parseComponentDefinitionElement(Element ele, BeanDefinition containingBean) { // extract bean name String id = ele.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE); String nameAttr = ele.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE); List<String> aliases = new ArrayList<String>(4); if (StringUtils.hasLength(nameAttr)) { String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS); aliases.addAll(Arrays.asList(nameArr)); } String beanName = id; if (!StringUtils.hasText(beanName) && !aliases.isEmpty()) { beanName = (String) aliases.remove(0); if (log.isDebugEnabled()) { log.debug("No XML 'id' specified - using '" + beanName + "' as bean name and " + aliases + " as aliases"); } } if (containingBean == null) { if (checkNameUniqueness(beanName, aliases, usedNames)) { error("Bean name '" + beanName + "' is already used in this file", ele); } if (ParsingUtils.isReservedName(beanName, ele, parserContext)) { error("Blueprint reserved name '" + beanName + "' cannot be used", ele); } } AbstractBeanDefinition beanDefinition = parseBeanDefinitionElement(ele, beanName, containingBean); if (beanDefinition != null) { if (!StringUtils.hasText(beanName)) { try { if (containingBean != null) { beanName = ParsingUtils.generateBlueprintBeanName(beanDefinition, parserContext.getRegistry(), true); } else { beanName = ParsingUtils.generateBlueprintBeanName(beanDefinition, parserContext.getRegistry(), false); // TODO: should we support 2.0 behaviour (see below): // // Register an alias for the plain bean class name, if still possible, // if the generator returned the class name plus a suffix. // This is expected for Spring 1.2/2.0 backwards compatibility. } if (log.isDebugEnabled()) { log.debug("Neither XML 'id' nor 'name' specified - " + "using generated bean name [" + beanName + "]"); } } catch (Exception ex) { error(ex.getMessage(), ele, ex); return null; } } return new BeanDefinitionHolder(beanDefinition, beanName); } return null; }
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
private void parseConstructorArgElement(Element ele, AbstractBeanDefinition beanDefinition) { String indexAttr = ele.getAttribute(BeanDefinitionParserDelegate.INDEX_ATTRIBUTE); String typeAttr = ele.getAttribute(BeanDefinitionParserDelegate.TYPE_ATTRIBUTE); boolean hasIndex = false; int index = -1; if (StringUtils.hasLength(indexAttr)) { hasIndex = true;//from ww w .j a v a2 s . co m try { index = Integer.parseInt(indexAttr); } catch (NumberFormatException ex) { error("Attribute 'index' of tag 'constructor-arg' must be an integer", ele); } if (index < 0) { error("'index' cannot be lower than 0", ele); } } try { this.parseState.push(hasIndex ? new ConstructorArgumentEntry(index) : new ConstructorArgumentEntry()); ConstructorArgumentValues values = beanDefinition.getConstructorArgumentValues(); // Blueprint failure (index duplication) Integer indexInt = Integer.valueOf(index); if (values.getIndexedArgumentValues().containsKey(indexInt)) { error("duplicate 'index' with value=[" + index + "] specified", ele); } Object value = parsePropertyValue(ele, beanDefinition, null); ConstructorArgumentValues.ValueHolder valueHolder = new ConstructorArgumentValues.ValueHolder(value); if (StringUtils.hasLength(typeAttr)) { valueHolder.setType(typeAttr); } valueHolder.setSource(extractSource(ele)); if (hasIndex) { values.addIndexedArgumentValue(index, valueHolder); } else { values.addGenericArgumentValue(valueHolder); } // Blueprint failure (mixed index/non-indexed arguments) if (!values.getGenericArgumentValues().isEmpty() && !values.getIndexedArgumentValues().isEmpty()) { error("indexed and non-indexed constructor arguments are not supported by Blueprint; " + "consider using the Spring namespace instead", ele); } } finally { this.parseState.pop(); } }
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
private void parsePropertyElement(Element ele, BeanDefinition bd) { String propertyName = ele.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE); if (!StringUtils.hasLength(propertyName)) { error("Tag 'property' must have a 'name' attribute", ele); return;/*from w ww . j av a 2s . c o m*/ } this.parseState.push(new PropertyEntry(propertyName)); try { if (bd.getPropertyValues().contains(propertyName)) { error("Multiple 'property' definitions for property '" + propertyName + "'", ele); return; } Object val = parsePropertyValue(ele, bd, propertyName); PropertyValue pv = new PropertyValue(propertyName, val); pv.setSource(parserContext.extractSource(ele)); bd.getPropertyValues().addPropertyValue(pv); } finally { this.parseState.pop(); } }
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
private Object parseRefElement(Element ele) { // A generic reference to any name of any component. String refName = ele.getAttribute(COMPONENT_ID_ATTR); if (!StringUtils.hasLength(refName)) { error("'" + COMPONENT_ID_ATTR + "' is required for <ref> element", ele); return null; }/*from www .jav a 2s .c o m*/ if (!StringUtils.hasText(refName)) { error("<ref> element contains empty target attribute", ele); return null; } RuntimeBeanReference ref = new InstanceEqualityRuntimeBeanReference(refName); ref.setSource(parserContext.extractSource(ele)); return ref; }
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
private Object parseIdRefElement(Element ele) { // A generic reference to any name of any bean/component. String refName = ele.getAttribute(COMPONENT_ID_ATTR); if (!StringUtils.hasLength(refName)) { error("'" + COMPONENT_ID_ATTR + "' is required for <idref> element", ele); return null; }/*from w w w.ja v a 2s. co m*/ if (!StringUtils.hasText(refName)) { error("<idref> element contains empty target attribute", ele); return null; } RuntimeBeanNameReference ref = new RuntimeBeanNameReference(refName); ref.setSource(parserContext.extractSource(ele)); return ref; }
From source file:org.ednovo.gooru.domain.service.ScollectionServiceImpl.java
private Boolean isNotEmptyString(final String field) { return StringUtils.hasLength(field); }
From source file:org.ednovo.gooru.domain.service.user.impl.UserServiceImpl.java
private Boolean isNotEmptyString(String field) { return StringUtils.hasLength(field); }