List of usage examples for org.springframework.util Assert hasText
public static void hasText(@Nullable String text, Supplier<String> messageSupplier)
From source file:org.cleverbus.admin.web.msg.DirectCallController.java
@RequestMapping(value = "/directCall", method = RequestMethod.POST) public String processCallForm(@ModelAttribute("model") ModelMap modelMap, @RequestParam("body") String body, @RequestParam("uri") String uri, @RequestParam("senderRef") String senderRef, @RequestParam("soapAction") @Nullable String soapAction, @RequestParam("header") String header) { Assert.hasText(body, "the body must not be empty"); Assert.hasText(uri, "the uri must not be empty"); Assert.hasText(senderRef, "the senderRef must not be empty"); // generate unique ID String callId = UUID.randomUUID().toString(); // save params into registry DirectCallParams params = new DirectCallParams(body, uri, senderRef, soapAction, StringUtils.trimToNull(header)); callRegistry.addParams(callId, params); // call external system via internal servlet route try {/*from w w w. jav a 2s .co m*/ Log.debug("Calling external system with callId=" + callId + ", params: " + params); String res = directCall.makeCall(callId); modelMap.put(CALL_RESULT_ATTR, MessageController.prettyPrintXML(res)); } catch (Exception ex) { // error occurred StringWriter strOut = new StringWriter(); PrintWriter resStr = new PrintWriter(strOut); ExceptionUtils.printRootCauseStackTrace(ex, resStr); modelMap.put(CALL_RESULT_ERR_ATTR, strOut.toString()); } modelMap.put("header", header); modelMap.put("body", body); modelMap.put("uri", uri); modelMap.put("senderRef", senderRef); modelMap.put("soapAction", soapAction); return VIEW_NAME; }
From source file:org.openwms.core.uaa.SecurityObject.java
/** * Create a new {@code SecurityObject} with a name. * * @param name The name of the {@code SecurityObject} * @throws IllegalArgumentException if name is {@literal null} or an empty String *///from www . j av a2 s . co m public SecurityObject(String name) { Assert.hasText(name, "A name of a SecurityObject must not be null"); this.name = name; }
From source file:org.sharetask.utility.log.PerformanceInterceptor.java
/** * Set the template used for method exit log messages. * This template can contain any of the following placeholders: * <ul>//from ww w .ja v a 2 s .c o m * <li>{@code $[targetClassName]}</li> * <li>{@code $[targetClassShortName]}</li> * <li>{@code $[argumentTypes]}</li> * <li>{@code $[arguments]}</li> * <li>{@code $[returnValue]}</li> * <li>{@code $[invocationTime]}</li> * </ul> */ @Override public void setExitMessage(final String exitMessage) { Assert.hasText(exitMessage, "'exitMessage' must not be empty"); checkForInvalidPlaceholders(exitMessage); Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION, "exitMessage cannot contain placeholder [" + PLACEHOLDER_EXCEPTION + "]"); this.exitMessage = exitMessage; }
From source file:fr.mby.opa.picsimpl.service.BasicPictureFactory.java
@Override public Picture build(final String filename, final byte[] contents) throws IOException, PictureAlreadyExistsException, UnsupportedPictureTypeException { Assert.hasText(filename, "No filename supplied !"); Assert.notNull(contents, "No contents supplied !"); Picture picture = null;/* w ww .ja va2 s . c o m*/ if (contents.length > 0) { picture = new Picture(); picture.setFilename(filename); picture.setName(filename); final BufferedInputStream bufferedStream = new BufferedInputStream(new ByteArrayInputStream(contents), contents.length); bufferedStream.mark(contents.length + 1); this.loadPicture(picture, contents, bufferedStream); this.loadMetadata(picture, bufferedStream); bufferedStream.close(); } return picture; }
From source file:com.tealium.publisher.ftp.FtpSession.java
@Override public FTPFile[] list(String path) throws IOException { Assert.hasText(path, "path must not be null"); try {/*from w w w . ja va 2 s. c om*/ return this.client.list(); } catch (IllegalStateException | FTPIllegalReplyException | FTPException | FTPDataTransferException | FTPAbortedException | FTPListParseException e) { logger.error("list : " + path + "-" + getError(e), e); throw new IOException(getError(e).toString()); } }
From source file:com.minyisoft.webapp.core.utils.spring.cache.redis.RedisCache.java
/** * // w w w .j a va 2s .co m * Constructs a new <code>RedisCache</code> instance. * * @param name * cache name * @param template * @param expiration */ RedisCache(String name, JedisTemplate template, int expiration) { Assert.hasText(name, "non-empty cache name is required"); this.name = name; this.template = template; this.expiration = expiration; this.prefix = (name + ":").getBytes(defaultCharset); // name of the set holding the keys this.setName = (name + "~keys").getBytes(defaultCharset); this.cacheLockName = (name + "~lock").getBytes(defaultCharset); }
From source file:fr.mby.portal.coreimpl.action.BasicUserAction.java
@Override public String getProperty(final String name) throws IllegalArgumentException { Assert.hasText(name, "No property name provided !"); return this.getProperties(name).iterator().next(); }
From source file:com.baidu.jprotobuf.rpc.server.AnnotationServiceExporter.java
@Override public void afterPropertiesSet() throws Exception { Assert.notNull(getInvoker(), "property 'invoker' is null."); Assert.hasText(getServiceName(), "property 'serviceName' is blank."); if (inputClass != null) { Codec inputCodec = ProtobufProxy.create(inputClass); Object input = inputClass.newInstance(); inputIDLProxyObject = new IDLProxyObject(inputCodec, input, inputClass); inputIDLStr = ProtobufIDLGenerator.getIDL(inputClass); }/* w w w .j a v a2 s .c o m*/ if (outputClass != null) { Codec outputCodec = ProtobufProxy.create(outputClass); Object output = outputClass.newInstance(); outputIDLProxyObject = new IDLProxyObject(outputCodec, output, outputClass); outputIDLStr = ProtobufIDLGenerator.getIDL(outputClass); } }
From source file:cat.albirar.framework.sets.registry.impl.SetRegistryDefaultImpl.java
/** * {@inheritDoc}/* w w w. j av a 2 s. co m*/ */ @Override public INamedSet<?> getSet(String setName) { INamedSet<?> s; Assert.hasText(setName, "The setName are required and cannot be empty or only whitespace!"); s = registry.get(setName); if (s == null) { throw new SetNotFoundException("The named set '" + setName + "' doesn't exists in this registry"); } return s; }
From source file:fr.acxio.tools.agia.io.FilesOperationProcessor.java
public void afterPropertiesSet() { Assert.notNull(sourceFactory, "SourceFactory must be set"); if (operation != Operation.REMOVE) { Assert.notNull(destinationFactory, "DestinationFactory must be set"); }/*from w w w . j a va2s .c om*/ Assert.hasText(key, "Key must be set"); }