List of usage examples for org.springframework.util Assert state
public static void state(boolean expression, Supplier<String> messageSupplier)
From source file:com.autentia.wuija.widget.query.QueriedDataTable.java
/** * Este mtodo hace toda la inicializacin. Slo se debe llamar una vez desde el constructor. No se pone todo este codigo * en el constructor por el orden en el que se crean las cosas en el hijo. Teniendo este mtodo los hijos pueden crear su * infraestructura y luego llamar a este mtodo con parte de las cosas que han creado (query, pagedListDataProvider, ...) * para que se termine de hacer toda la inicializacin). * //w w w .j av a2s .c om * @param properties * @param pagedListDataProvider * @param dataTableQuery * @param csvReportsService */ void init(Property[] properties, PagedListDataProvider<T> pagedListDataProvider, Query dataTableQuery, CsvReportsService csvReportsService) { Assert.state(query == null, "You have to call init method just once"); elements = new JsfPagedList<T>(pagedListDataProvider, PagedDataTable.DEFAULT_PAGE_SIZE * 2); this.pagedDataTable = new PagedDataTable<T>(properties, elements, csvReportsService); this.pagedDataTable.addListener(new SortColumnChangedListener() { @Override public void sortColumnChanged(SortColumnChangedEvent event) { elements.clear(); // Forzamos a que se vuelva a hacer la consulta en la bbdd } }); this.query = dataTableQuery; // Este es el listener que se llamar al pulsar el botn de buscar. // Basta con borrar los elementos de la lista y forzar al paginador a ir a la primera pgina. // De esta forma al ir a pintar los elemntos se recargarn usando la ltima EntityCriteria introducida por el // usuario. this.query.addListener(new ActionListener() { @Override public void processAction(ActionEvent event) { forceReload(); pagedDataTable.gotoFirstPage(); } }); }
From source file:org.pivotal.gemfire.cache.GemFireBasedSerialAsyncEventQueueTest.java
protected Region<String, AsyncEvent> getEventsRegion() { Assert.state(eventsRegion != null, "The 'EventsRegion' was not properly configured and initialized!"); return eventsRegion; }
From source file:com._4dconcept.springframework.data.marklogic.datasource.TransactionAwareContentSourceProxy.java
/** * Delegates to ContentSourceUtils for automatically participating in Spring-managed * transactions. Throws the original XccException, if any. * <p>The returned Session handle implements the SessionProxy interface, * allowing to retrieve the underlying target Session. * * @see ContentSourceUtils#doGetSession/*from w w w .ja v a 2s .c o m*/ * @see SessionProxy#getTargetSession * * @return a transactional Session if any, a new one else */ @Override public Session newSession() { ContentSource ds = getTargetContentSource(); Assert.state(ds != null, "'targetContentSource' is required"); return getTransactionAwareSessionProxy(ds); }
From source file:com.ge.predix.uaa.token.lib.FastTokenServices.java
@Override public OAuth2Authentication loadAuthentication(final String accessToken) throws AuthenticationException { Map<String, Object> claims; try {//from w ww . ja v a 2 s .c o m claims = getTokenClaims(accessToken); } catch (IllegalArgumentException e) { LOG.error("Malformed Access Token: " + accessToken); LOG.error(e); throw new InvalidTokenException("Malformed Access Token", e); } String iss = getIssuerFromClaims(claims); verifyIssuer(iss); // check if the singerProvider for that issuer has already in the cache SignatureVerifier verifier = this.tokenKeys.get(iss); if (null == verifier) { String tokenKey = getTokenKey(iss); verifier = getVerifier(tokenKey); this.tokenKeys.put(iss, verifier); } JwtHelper.decodeAndVerify(accessToken, verifier); verifyTimeWindow(claims); Assert.state(claims.containsKey("client_id"), "Client id must be present in response from auth server"); String remoteClientId = (String) claims.get("client_id"); Set<String> scope = new HashSet<>(); if (claims.containsKey("scope")) { @SuppressWarnings("unchecked") Collection<String> values = (Collection<String>) claims.get("scope"); scope.addAll(values); } AuthorizationRequest clientAuthentication = new AuthorizationRequest(remoteClientId, scope); if (claims.containsKey("resource_ids") || claims.containsKey("client_authorities")) { Set<String> resourceIds = new HashSet<>(); if (claims.containsKey("resource_ids")) { @SuppressWarnings("unchecked") Collection<String> values = (Collection<String>) claims.get("resource_ids"); resourceIds.addAll(values); } Set<GrantedAuthority> clientAuthorities = new HashSet<>(); if (claims.containsKey("client_authorities")) { @SuppressWarnings("unchecked") Collection<String> values = (Collection<String>) claims.get("client_authorities"); clientAuthorities.addAll(getAuthorities(values)); } BaseClientDetails clientDetails = new BaseClientDetails(); clientDetails.setClientId(remoteClientId); clientDetails.setResourceIds(resourceIds); clientDetails.setAuthorities(clientAuthorities); clientAuthentication.setResourceIdsAndAuthoritiesFromClientDetails(clientDetails); } Map<String, String> requestParameters = new HashMap<>(); if (isStoreClaims()) { for (Map.Entry<String, Object> entry : claims.entrySet()) { if (entry.getValue() != null && entry.getValue() instanceof String) { requestParameters.put(entry.getKey(), (String) entry.getValue()); } } } if (claims.containsKey(Claims.ADDITIONAL_AZ_ATTR)) { try { requestParameters.put(Claims.ADDITIONAL_AZ_ATTR, JsonUtils.writeValueAsString(claims.get(Claims.ADDITIONAL_AZ_ATTR))); } catch (JsonUtils.JsonUtilException e) { throw new IllegalStateException("Cannot convert access token to JSON", e); } } clientAuthentication.setRequestParameters(Collections.unmodifiableMap(requestParameters)); Authentication userAuthentication = getUserAuthentication(claims, scope); clientAuthentication.setApproved(true); return new OAuth2Authentication(clientAuthentication.createOAuth2Request(), userAuthentication); }
From source file:es.fcs.batch.integration.chunk.MyRemoteChunkHandlerFactoryBean.java
/** * Builds a {@link ChunkHandler} from the {@link ChunkProcessor} extracted from the {@link #setStep(TaskletStep) * step} provided. Also modifies the step to send chunks to the chunk handler via the * {@link #setChunkWriter(ItemWriter) chunk writer}. * //from ww w.j a v a 2 s. com * @see FactoryBean#getObject() */ public ChunkProcessor<T> getObject() throws Exception { if (stepContributionSource == null) { Assert.state(chunkWriter instanceof StepContributionSource, "The chunk writer must be a StepContributionSource or else the source must be provided explicitly"); stepContributionSource = (StepContributionSource) chunkWriter; } Assert.state(step instanceof TaskletStep, "Step [" + step.getName() + "] must be a TaskletStep"); logger.debug("Converting TaskletStep with name=" + step.getName()); Tasklet tasklet = getTasklet((TaskletStep) step); Assert.state(tasklet instanceof ChunkOrientedTasklet<?>, "Tasklet must be ChunkOrientedTasklet in step=" + step.getName()); ChunkProcessor<T> chunkProcessor = getChunkProcessor((ChunkOrientedTasklet<?>) tasklet); Assert.state(chunkProcessor != null, "ChunkProcessor must be accessible in Tasklet in step=" + step.getName()); // System.out.println("====="+chunkWriter.getClass()); // setField(chunkWriter, "chunkProcessor", chunkProcessor); // if (Proxy.isProxyClass(chunkWriter.getClass())){ // InvocationHandler ih = Proxy.getInvocationHandler(chunkWriter); // Class[] cls = new Class[]{ChunkProcessor.class}; // Method m = MyChunkMessageChannelItemWriter.class.getMethod("setChunkProcessor", cls); // try { // ih.invoke(chunkWriter, m, new Object[]{chunkProcessor}); // } catch (Throwable e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // } else { // ((MyChunkMessageChannelItemWriter<T>)chunkWriter).setChunkProcessor(chunkProcessor); // } ItemWriter<T> itemWriter = getItemWriter(chunkProcessor); Assert.state(!(itemWriter instanceof ChunkMessageChannelItemWriter<?>), "Cannot adapt step [" + step.getName() + "] because it already has a remote chunk writer. Use a local writer in the step."); replaceChunkProcessor((ChunkOrientedTasklet<?>) tasklet, chunkWriter, stepContributionSource); if (chunkWriter instanceof StepExecutionListener) { step.registerStepExecutionListener((StepExecutionListener) chunkWriter); } ChunkProcessorChunkHandler<T> handler = new ChunkProcessorChunkHandler<T>(); setNonBuffering(chunkProcessor); handler.setChunkProcessor(chunkProcessor); // TODO: create step context for the processor in case it has // scope="step" dependencies handler.afterPropertiesSet(); return chunkProcessor; }
From source file:org.carewebframework.ui.util.RequestUtil.java
private static HttpServletRequest assertRequest() { final HttpServletRequest request = getRequest(); Assert.state(request != null, "Method must be invoked within the scope of an Execution/ServletRequest"); return request; }
From source file:io.dyn.net.tcp.TcpServer.java
@SuppressWarnings({ "unchecked" }) public T backlog(int backlog) { Assert.state(backlog > 0, "backlog must be > 0"); this.backlog = backlog; return (T) this; }
From source file:com.wavemaker.commons.io.store.StoredFolder.java
@Override public Folder moveTo(Folder folder) { Assert.notNull(folder, "Folder must not be empty"); ensureExists();/*from w ww. j a va 2 s .co m*/ Assert.state(getPath().getParent() != null, "Unable to move a root folder"); Folder destination = createDestinationFolder(folder); for (Resource child : list()) { child.moveTo(destination); } return destination; }
From source file:be.vlaanderen.sesam.monitor.internal.util.ThreadPoolTaskScheduler.java
/** * Return the underlying ScheduledExecutorService for native access. * @return the underlying ScheduledExecutorService (never <code>null</code>) * @throws IllegalStateException if the ThreadPoolTaskScheduler hasn't been initialized yet *///from w w w. jav a2 s .c o m public ScheduledExecutorService getScheduledExecutor() throws IllegalStateException { Assert.state(this.scheduledExecutor != null, "ThreadPoolTaskScheduler not initialized"); return this.scheduledExecutor; }
From source file:biz.c24.io.spring.integration.transformer.C24Transformer.java
@Override protected void onInit() throws Exception { super.onInit(); Assert.state(transformClass != null, "The transformClass property must not be null"); try {/*from w w w .ja va 2 s . c om*/ createTransform(); } catch (Exception e) { throw new IllegalArgumentException( "The provided transform class threw an exception from its default constructor.", e); } }