List of usage examples for org.springframework.util Assert hasText
public static void hasText(@Nullable String text, Supplier<String> messageSupplier)
From source file:fr.mby.opa.picsimpl.service.BasicProposalService.java
@Override public ProposalBranch createBranch(final String name, final String description, final Album album, final Long branchToForkId) { Assert.hasText(name, "No name supplied !"); Assert.notNull(album, "No Album supplied !"); final ProposalBranch branch = new ProposalBranch(); branch.setCreationTime(new Timestamp(System.currentTimeMillis())); branch.setName(name);/* w w w . ja va 2 s.c o m*/ branch.setDescription(description); final ProposalBranch createdBranch; if (branchToForkId != null) { // We fork the branch => we duplicate it createdBranch = this.proposalDao.forkBranch(branch, branchToForkId); } else { createdBranch = this.proposalDao.createBranch(branch); } return createdBranch; }
From source file:fr.mby.opa.picsimpl.dao.DbAlbumDao.java
@Override public Album createAlbum(final Album album) { Assert.notNull(album, "No Album supplied !"); Assert.isNull(album.getId(), "Id should not be set for creation !"); Assert.hasText(album.getName(), "No Album name supplied !"); new TxCallback(this.getEmf()) { @Override/*from w w w. jav a 2s . c om*/ protected void executeInTransaction(final EntityManager em) { final Timestamp creationTime = new Timestamp(System.currentTimeMillis()); // Persist album album.setCreationTime(creationTime); album.setLocked(false); em.persist(album); // Create initial bag final ProposalBag initialBag = new ProposalBag(); initialBag.setCommited(false); initialBag.setCreationTime(creationTime); initialBag.setName(IProposalDao.INITIAL_PROPOSAL_NAME); initialBag.setRevision("0"); em.persist(initialBag); // Create master branch final ProposalBranch masterBranch = new ProposalBranch(); masterBranch.setAlbum(album); masterBranch.setCreationTime(creationTime); masterBranch.setName(IProposalDao.MASTER_BRANCH_NAME); masterBranch.setHead(initialBag); final List<ProposalBag> bagList = new ArrayList<>(); bagList.add(initialBag); masterBranch.setBags(bagList); em.persist(masterBranch); } }; return album; }
From source file:org.cleverbus.spi.throttling.ThrottleScope.java
/** * Creates new throttle scope.// w w w .j a va 2 s .c o m * * @param sourceSystem the source system, can be used {@link #ANY_SOURCE_SYSTEM} or '*' * @param serviceName the service name, can be used {@link #ANY_SERVICE} or '*' */ public ThrottleScope(String sourceSystem, String serviceName) { Assert.hasText(sourceSystem, "the sourceSystem must not be empty"); Assert.hasText(serviceName, "the serviceName must not be empty"); this.sourceSystem = sourceSystem.equals(ANY) ? ANY_SOURCE_SYSTEM : sourceSystem; this.serviceName = serviceName.equals(ANY) ? ANY_SERVICE : serviceName; }
From source file:io.galeb.core.entity.Farm.java
public Farm(String name, String domain, String api, Environment environment, Provider provider) { Assert.hasText(domain, "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank"); Assert.hasText(api,/* www .ja v a2s . c o m*/ "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank"); Assert.notNull(environment, "[Assertion failed] - this argument is required; it must not be null"); Assert.notNull(provider, "[Assertion failed] - this argument is required; it must not be null"); setName(name); this.domain = domain; this.api = api; this.environment = environment; this.provider = provider; }
From source file:org.cleverbus.core.common.route.SpringWsUriBuilder.java
@Override public String getOutWsSoap12Uri(String connectionUri, String messageSenderRef, String soapAction) { Assert.hasText(connectionUri, "the connectionUri must not be empty"); Assert.hasText(messageSenderRef, "the messageSenderRef must not be empty"); String wsUri = "spring-ws:" + connectionUri + "?messageSender=#" + messageSenderRef + "&messageFactory=#" + MESSAGE_FACTORY_SOAP12;//www. j a v a 2 s . c o m if (StringUtils.isNotEmpty(soapAction)) { wsUri += "&soapAction=" + soapAction; } return wsUri; }
From source file:com.oreilly.springdata.gemfire.core.Product.java
/** * Creates a new {@link Product} from the given name and description. * @param id a unique Id/*w w w. j a va 2 s . co m*/ * @param name must not be {@literal null} or empty. * @param price must not be {@literal null} or less than or equal to zero. * @param description */ @PersistenceConstructor public Product(Long id, String name, BigDecimal price, String description) { super(id); Assert.hasText(name, "Name must not be null or empty!"); Assert.isTrue(BigDecimal.ZERO.compareTo(price) < 0, "Price must be greater than zero!"); this.name = name; this.price = price; this.description = description; }
From source file:org.spring.data.gemfire.app.beans.User.java
public User(final String username) { Assert.hasText(username, "Username is required!"); this.username = username; }
From source file:org.jasig.cas.DefaultMessageDescriptor.java
/** * Instantiates a new message.//from w ww . j a v a2 s.co m * * @param code the code * @param defaultMessage the default message * @param params the params */ public DefaultMessageDescriptor(final String code, final String defaultMessage, final Serializable... params) { Assert.hasText(code, "Code cannot be null or empty"); Assert.hasText(defaultMessage, "Default message cannot be null or empty"); this.code = code; this.defaultMessage = defaultMessage; this.params = params; }
From source file:org.cleverbus.spi.alerts.AlertInfo.java
/** * Creates new alert./*from w ww. ja va2 s .c om*/ * * @param id the alert unique identification * @param limit limit that must be exceeded to activate alert * @param sql SQL query that returns count of items for comparison with limit value * @param enabled if specified alert is enabled or disabled * @param notificationSubject the (mail, sms) subject * @param notificationBody the (mail, sms) body */ public AlertInfo(String id, long limit, String sql, boolean enabled, @Nullable String notificationSubject, @Nullable String notificationBody) { Assert.hasText(id, "the id must not be empty"); Assert.hasText(sql, "the sql must not be empty"); this.id = id; this.limit = limit; this.sql = sql; this.enabled = enabled; this.notificationSubject = notificationSubject; this.notificationBody = notificationBody; }
From source file:org.cleverbus.core.common.asynch.notification.EmailServiceCamelSmtpImpl.java
@Override public void sendFormattedEmail(String recipients, String subject, String body, Object... values) { Assert.hasText(subject, "the subject must not be empty"); Assert.hasText(body, "the body must not be empty"); if (StringUtils.isNotEmpty(recipients)) { Map<String, Object> map = new HashMap<String, Object>(); map.put("To", recipients); map.put("From", from); map.put("Subject", subject); producerTemplate.sendBodyAndHeaders("smtp://" + smtp, Strings.fm(body, values), map); }//from w w w . ja v a 2s.co m }