List of usage examples for org.springframework.util Assert isTrue
public static void isTrue(boolean expression, Supplier<String> messageSupplier)
From source file:org.opencredo.cloud.storage.si.adapter.WritingMessageHandler.java
public void afterPropertiesSet() throws Exception { Assert.isTrue(template.checkContainerStatus(containerName) == ContainerStatus.MINE, "Container '" + containerName + "' is not accessible."); }
From source file:com.azaptree.services.domain.entity.dao.JDBCEntityDAOSupport.java
protected void checkEntityField(final SortField... field) { if (ArrayUtils.isEmpty(field)) { return;/*from ww w . jav a2 s . c o m*/ } for (final SortField f : field) { Assert.isTrue(fieldColumnMappings.containsKey(f.getFieldName()), "Invalid field: " + field); } }
From source file:org.geowebcache.layer.wms.WMSHttpHelper.java
/** * Loops over the different backends, tries the request * /*w w w. j av a 2 s . co m*/ * @param tileRespRecv * @param profile * @param wmsparams * @return * @throws GeoWebCacheException */ @Override protected void makeRequest(TileResponseReceiver tileRespRecv, WMSLayer layer, Map<String, String> wmsParams, String expectedMimeType, Resource target) throws GeoWebCacheException { Assert.notNull(target, "Target resource can't be null"); Assert.isTrue(target.getSize() == 0, "Target resource is not empty"); URL wmsBackendUrl = null; final Integer backendTimeout = layer.getBackendTimeout(); int backendTries = 0; // keep track of how many backends we have tried GeoWebCacheException fetchException = null; while (target.getSize() == 0 && backendTries < layer.getWMSurl().length) { String requestUrl = layer.nextWmsURL(); try { wmsBackendUrl = new URL(requestUrl); } catch (MalformedURLException maue) { throw new GeoWebCacheException("Malformed URL: " + requestUrl + " " + maue.getMessage()); } try { connectAndCheckHeaders(tileRespRecv, wmsBackendUrl, wmsParams, expectedMimeType, backendTimeout, target); } catch (GeoWebCacheException e) { fetchException = e; } backendTries++; } if (target.getSize() == 0) { String msg = "All backends (" + backendTries + ") failed."; if (fetchException != null) { msg += " Reason: " + fetchException.getMessage() + ". "; } msg += " Last request: '" + wmsBackendUrl.toString() + "'. " + (tileRespRecv.getErrorMessage() == null ? "" : tileRespRecv.getErrorMessage()); tileRespRecv.setError(); tileRespRecv.setErrorMessage(msg); throw new GeoWebCacheException(msg); } }
From source file:com.yize.broadcast.core.hibernate.HibernateDao.java
/** * ?Query,./*from w w w .ja v a2 s .co m*/ */ protected Query setPageParameterToQuery(final Query q, final Page<T> page) { Assert.isTrue(page.getPageSize() > 0, "Page Size must larger than zero"); //hibernatefirstResult??0 q.setFirstResult(page.getFirst() - 1); q.setMaxResults(page.getPageSize()); return q; }
From source file:com.cloud.utils.rest.HttpUriRequestBuilder.java
private void validate() { Assert.notNull(method, "HTTP Method cannot be null"); Assert.hasText(path, "target path must be defined"); Assert.isTrue(path.startsWith("/"), "targte path must start with a '/' character"); }
From source file:com.becool.base.spring.tx.ChainedTransactionManager.java
/** * Creates a new {@link ChainedTransactionManager} using the given {@link SynchronizationManager} and * {@link PlatformTransactionManager}s.//from w ww. ja va2 s .c o m * * @param synchronizationManager must not be {@literal null}. * @param transactionManagers must not be {@literal null} or empty. */ ChainedTransactionManager(SynchronizationManager synchronizationManager, PlatformTransactionManager... transactionManagers) { Assert.notNull(synchronizationManager, "SynchronizationManager must not be null!"); Assert.notNull(transactionManagers, "Transaction managers must not be null!"); Assert.isTrue(transactionManagers.length > 0, "At least one PlatformTransactionManager must be given!"); this.synchronizationManager = synchronizationManager; this.transactionManagers = asList(transactionManagers); }
From source file:org.geoserver.wms.ncwms.GetTimeSeriesResponse.java
@Override public void write(Object value, OutputStream output, Operation operation) throws IOException, ServiceException { Assert.notNull(value, "value is null"); Assert.notNull(operation, "operation is null"); Assert.isTrue(value instanceof FeatureCollectionType, "unrecognized result type:"); Assert.isTrue(operation.getParameters() != null && operation.getParameters().length == 1 && operation.getParameters()[0] instanceof GetFeatureInfoRequest); GetFeatureInfoRequest request = (GetFeatureInfoRequest) operation.getParameters()[0]; FeatureCollectionType results = (FeatureCollectionType) value; String mime = getMimeType(value, operation); if (mime.startsWith("image/")) { writeChart(request, results, output, mime); } else {//from ww w . j av a 2 s . c om writeCsv(request, results, output); } }
From source file:org.synyx.hades.dao.query.QueryMethod.java
/** * Creates a new {@link QueryMethod} from the given parameters. Looks up the * correct query to use for following invocations of the method given. * //from w w w . j a v a2 s .c o m * @param method * @param domainClass * @param extractor */ public QueryMethod(Method method, Class<?> domainClass, QueryExtractor extractor) { Assert.notNull(method, "Method must not be null!"); Assert.notNull(domainClass, "Domain class must not be null!"); Assert.notNull(extractor, "Query extractor must not be null!"); for (Class<?> type : Parameters.TYPES) { if (ClassUtils.getNumberOfOccurences(method, type) > 1) { throw new IllegalStateException( String.format("Method must only one argument of type %s!", type.getSimpleName())); } } if (ClassUtils.hasParameterOfType(method, Pageable.class)) { ClassUtils.assertReturnType(method, Page.class, List.class); if (ClassUtils.hasParameterOfType(method, Sort.class)) { throw new IllegalStateException("Method must not have Pageable *and* Sort parameter. " + "Use sorting capabilities on Pageble instead!"); } } this.method = method; this.parameters = new Parameters(method); this.domainClass = domainClass; this.extractor = extractor; Assert.isTrue(!(isModifyingQuery() && parameters.hasSpecialParameter()), String.format("Modifying method must not contain %s!", Parameters.TYPES)); if (parameters.hasPageableParameter() && !extractor.canExtractQuery()) { throw new IllegalArgumentException("You cannot use Pageable as method parameter if your " + "persistence provider cannot extract queries!"); } }
From source file:org.apache.cxf.sts.ldap.LDAPClaimsTest.java
@org.junit.Test @org.junit.Ignore/* ww w . j ava 2 s . co m*/ public void testRetrieveClaims() throws Exception { LdapClaimsHandler claimsHandler = (LdapClaimsHandler) appContext.getBean("testClaimsHandler"); String user = props.getProperty("claimUser"); Assert.notNull(user, "Property 'claimUser' not configured"); ClaimCollection requestedClaims = createRequestClaimCollection(); List<URI> expectedClaims = new ArrayList<URI>(); expectedClaims.add(ClaimTypes.FIRSTNAME); expectedClaims.add(ClaimTypes.LASTNAME); expectedClaims.add(ClaimTypes.EMAILADDRESS); ClaimsParameters params = new ClaimsParameters(); params.setPrincipal(new CustomTokenPrincipal(user)); ProcessedClaimCollection retrievedClaims = claimsHandler.retrieveClaimValues(requestedClaims, params); Assert.isTrue(retrievedClaims.size() == expectedClaims.size(), "Retrieved number of claims [" + retrievedClaims.size() + "] doesn't match with expected [" + expectedClaims.size() + "]"); for (ProcessedClaim c : retrievedClaims) { if (expectedClaims.contains(c.getClaimType())) { expectedClaims.remove(c.getClaimType()); } else { Assert.isTrue(false, "Claim '" + c.getClaimType() + "' not requested"); } } }
From source file:cn.imethan.common.security.session.ConcurrentSessionFilter.java
public ConcurrentSessionFilter(SessionRegistry sessionRegistry, String expiredUrl) { Assert.notNull(sessionRegistry, "SessionRegistry required"); Assert.isTrue(expiredUrl == null || UrlUtils.isValidRedirectUrl(expiredUrl), expiredUrl + " isn't a valid redirect URL"); this.sessionRegistry = sessionRegistry; this.expiredUrl = expiredUrl; }