@Override protected boolean processValidateWithVetoing(Object target, Object propertyValue, Errors errors) { if (propertyValue instanceof String && GrailsStringUtils.isBlank((String)propertyValue)) { if (!blank) { Object[] args = new Object[] { constraintPropertyName, constraintOwningClass }; rejectValue(target, errors, ConstrainedProperty.DEFAULT_BLANK_MESSAGE_CODE, ConstrainedProperty.BLANK_CONSTRAINT, args); // empty string is caught by 'blank' constraint, no addition validation needed return true; } } return false; } }
if (GrailsStringUtils.isNotBlank(var)) { b.put(var, attrs.get("bean")); while (iterator.hasNext()) { Object it = iterator.next(); if (key == null && GrailsStringUtils.isBlank(var) && it != null) { key = GrailsNameUtils.getPropertyName(it.getClass()); if (GrailsStringUtils.isNotBlank(var)) { itmap.put(var, it);
/** * @return prefix for cache key that contains current controller's context (currently plugin and namespace) */ protected String resolveCurrentControllerKeyPrefixes(boolean absolute) { String pluginContextPath; String namespace; String controller; GrailsWebRequest webRequest = GrailsWebRequest.lookup(); if(webRequest != null) { StringBuilder stringBuilder = new StringBuilder(); namespace = webRequest.getControllerNamespace(); controller = webRequest.getControllerName(); pluginContextPath = (webRequest.getAttributes() != null && webRequest.getCurrentRequest() != null) ? webRequest.getAttributes().getPluginContextPath(webRequest.getCurrentRequest()) : null; stringBuilder.append(GrailsStringUtils.isNotEmpty(pluginContextPath) ? pluginContextPath : "-"); stringBuilder.append(','); stringBuilder.append(GrailsStringUtils.isNotEmpty(namespace) ? namespace : "-"); if (!absolute && GrailsStringUtils.isNotEmpty(controller)) { stringBuilder.append(','); stringBuilder.append(controller); } return stringBuilder.toString(); } else { return null; } }
@Override protected void processValidate(Object target, Object propertyValue, Errors errors) { if (!email) { return; } EmailValidator emailValidator = EmailValidator.getInstance(); Object[] args = new Object[] { constraintPropertyName, constraintOwningClass, propertyValue }; String value = propertyValue.toString(); if (GrailsStringUtils.isBlank(value)) { return; } if (!emailValidator.isValid(value)) { rejectValue(target, errors, ConstrainedProperty.DEFAULT_INVALID_EMAIL_MESSAGE_CODE, ConstrainedProperty.EMAIL_CONSTRAINT + ConstrainedProperty.INVALID_SUFFIX, args); } } }
private Template findAndCacheTemplate(Object controller, TemplateVariableBinding pageScope, String templateName, String contextPath, String pluginName, final String uri) throws IOException { String templatePath = GrailsStringUtils.isNotEmpty(contextPath) ? GrailsResourceUtils.appendPiecesForUri(contextPath, templateName) : templateName; final GroovyPageScriptSource scriptSource; if (pluginName == null) {
public void validate(Object target, Object propertyValue, Errors errors) { checkState(); // Skip null values if desired. if (propertyValue == null && skipNullValues()) { return; } // Skip blank values if desired. if (skipBlankValues() && propertyValue instanceof String && GrailsStringUtils.isBlank((String) propertyValue)) { return; } // Do the validation for this constraint. processValidate(target, propertyValue, errors); }
@Override protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute(GrailsApplicationAttributes.REQUEST_SCOPE_ID, grailsAttributes); request.setAttribute(GroovyPagesServlet.SERVLET_INSTANCE, this); String pageName = (String)request.getAttribute(GrailsApplicationAttributes.GSP_TO_RENDER); if (GrailsStringUtils.isBlank(pageName)) { pageName = getCurrentRequestUri(request); } boolean isNotInclude = !WebUtils.isIncludeRequest(request) ; if (isNotInclude && isSecurePath(pageName)) { sendNotFound(response, pageName); } else { GroovyPageScriptSource scriptSource = groovyPagesTemplateEngine.findScriptSource(pageName); if (scriptSource == null) { scriptSource = findPageInBinaryPlugins(pageName); } if (scriptSource == null || (isNotInclude && !scriptSource.isPublic())) { sendNotFound(response, pageName); return; } renderPageWithEngine(groovyPagesTemplateEngine, request, response, scriptSource); } }
public void render(GrailsWebRequest webRequest, TemplateVariableBinding pageScope, Map<String, Object> attrs, Object body, Writer out) throws IOException { Assert.state(groovyPagesTemplateEngine != null, "Property [groovyPagesTemplateEngine] must be set!"); String templateName = getStringValue(attrs, "template"); if (GrailsStringUtils.isBlank(templateName)) { throw new GrailsTagException("Tag [render] is missing required attribute [template]"); } String uri = webRequest.getAttributes().getTemplateUri(templateName, webRequest.getRequest()); String contextPath = getStringValue(attrs, "contextPath"); String pluginName = getStringValue(attrs, "plugin"); final Object controller = webRequest.getAttribute(GrailsApplicationAttributes.CONTROLLER, GrailsWebRequest.SCOPE_REQUEST); Template t = findAndCacheTemplate(controller, pageScope, templateName, contextPath, pluginName, uri); if (t == null) { throw new GrailsTagException("Template not found for name [" + templateName + "] and path [" + uri + "]"); } makeTemplate(webRequest, t, attrs, body, out); }