List of usage examples for org.springframework.util Assert hasText
public static void hasText(@Nullable String text, Supplier<String> messageSupplier)
From source file:org.codehaus.groovy.grails.scaffolding.AbstractGrailsTemplateGenerator.java
public void generateController(GrailsControllerType controllerType, GrailsDomainClass domainClass, String destDir) throws IOException { Assert.hasText(destDir, "Argument [destdir] not specified"); if (domainClass == null) { return;// ww w. j av a 2s . c o m } String fullName = domainClass.getFullName(); String pkg = ""; int pos = fullName.lastIndexOf('.'); if (pos != -1) { // Package name with trailing '.' pkg = fullName.substring(0, pos + 1); } File destFile = new File(destDir, "grails-app/controllers/" + pkg.replace('.', '/') + domainClass.getShortName() + "Controller.groovy"); if (canWrite(destFile)) { destFile.getParentFile().mkdirs(); BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(destFile)); generateController(controllerType, domainClass, writer); try { writer.flush(); } catch (IOException ignored) { } } finally { IOGroovyMethods.closeQuietly(writer); } log.info("Controller generated at [" + destFile + "]"); } }
From source file:com.codeabovelab.dm.mail.template.ResourceMailTemplateProvider.java
public ResourceMailTemplateProvider(Config config, ObjectMapper objectMapper) { this.prefix = config.prefix; this.suffix = config.suffix; this.mimeType = config.mimeType; this.objectMapper = objectMapper; Assert.notNull(this.objectMapper, "'objectMapper' is null"); Assert.hasText(this.prefix, "'prefix' must contains text"); Assert.hasText(this.suffix, "'suffix' must contains text"); Assert.notNull(this.mimeType, "'mimeType' is null"); this.protocols = Collections.singleton(PROTOCOL); }
From source file:com.autentia.wuija.security.impl.hibernate.HibernateUserDetailsServiceHelper.java
/** * Devuelve el grupo que corresponde con <code>group</code>. * //from w w w .j a v a 2 s. com * @param group El nombre del grupo. * @return El grupo que corresponde con <code>group</code>. * @throws BadCredentialsException Si no se encuentra el grupo o si hay algun problema. */ public SecurityGroup loadGroupByGroupName(String group) throws BadCredentialsException, DataAccessException { Assert.hasText(group, "group must not be empty"); final String groupByNameHql = userDetailsHqlProvider.getGroupByNameHql(); if (log.isDebugEnabled()) { log.debug("Loading group: " + group + ", query: " + groupByNameHql); } final List<SecurityGroup> groups = dao.find(groupByNameHql, group); Assert.state(groups.size() == 1, "Cannot find group: " + group); return groups.get(0); }
From source file:org.cleverbus.core.common.directcall.DirectCallWsRoute.java
/** * Gets URI for calling external system. * * @param callId Call ID for getting call parameters from {@link DirectCallRegistry} * @return WS URI/*w w w. ja v a2 s.c o m*/ */ @Handler public String getWsUri(@Header(CALL_ID_HEADER) String callId) { Assert.hasText(callId, "the callId must not be empty"); DirectCallParams params = callRegistry.getParams(callId); return getOutWsUri(params.getUri(), params.getSenderRef(), params.getSoapAction()); }
From source file:com.leadtone.riders.utils.ReflectionUtils.java
/** * ?, ?DeclaredField.//ww w .j a v a 2s .c o m * * ?Object?, null. */ protected static Field getDeclaredField(final Object object, final String fieldName) { Assert.notNull(object, "object?"); Assert.hasText(fieldName, "fieldName"); for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass .getSuperclass()) { try { return superClass.getDeclaredField(fieldName); } catch (NoSuchFieldException e) {//NOSONAR // Field??,? } } return null; }
From source file:eu.openanalytics.rsb.security.X509AuthenticationFilter.java
/** * Sets the regular expression which will by used to extract the user name from the * certificate's Subject DN./*from w w w.j a v a 2s.co m*/ * <p> * It should contain a single group; for example the default expression "CN=(.*?)(?:/|$)" * matches the common name field. So "CN=Jimi Hendrix/OU=..." will give a user name of * "Jimi Hendrix". * <p> * The matches are case insensitive. So "emailAddress=(.?)/" will match * "EMAILADDRESS=jimi@hendrix.org/CN=..." giving a user name "jimi@hendrix.org" * * @param subjectDnRegex the regular expression to find in the subject */ public void setSubjectDnRegex(final String subjectDnRegex) { Assert.hasText(subjectDnRegex, "Regular expression may not be null or empty"); subjectDnPattern = Pattern.compile(subjectDnRegex, Pattern.CASE_INSENSITIVE); }
From source file:fr.mby.portal.coreimpl.action.BasicUserAction.java
@Override public Object getAttribute(final String name) throws IllegalArgumentException { Assert.hasText(name, "No property name provided !"); return this.attributes.get(name); }
From source file:com.frank.search.solr.core.query.FacetOptions.java
/** * Append additional field for faceting// www . j av a 2s . c om * * @param field * @return */ public final FacetOptions addFacetOnField(Field field) { Assert.notNull(field, "Cannot facet on null field."); Assert.hasText(field.getName(), "Cannot facet on field with null/empty fieldname."); this.facetOnFields.add(field); return this; }
From source file:com.rosy.bill.utils.jmx.JmxClientTemplate.java
/** * ??MBean(MBeanClass).// w w w .j ava2 s . c o m * * attributeName?. */ public void setAttribute(final String mbeanName, final String attributeName, final Object value) { Assert.hasText(mbeanName, "mbeanName?"); Assert.hasText(attributeName, "attributeName?"); assertConnected(); try { ObjectName objectName = buildObjectName(mbeanName); Attribute attribute = new Attribute(attributeName, value); connection.setAttribute(objectName, attribute); } catch (JMException e) { throw new IllegalArgumentException("??", e); } catch (IOException e) { throw new IllegalStateException("", e); } }
From source file:com.azaptree.services.json.JsonUtils.java
public static <T> T parse(final String json, final Class<T> clazz) { Assert.hasText(json, "json is required"); Assert.notNull(clazz, "clazz is required"); try {//ww w . j a va2 s.c o m return JsonUtils.parse(new ByteArrayInputStream(json.getBytes("UTF-8")), clazz); } catch (final IOException e) { throw new RuntimeException(e); } }