List of usage examples for org.apache.commons.lang ArrayUtils isNotEmpty
public static boolean isNotEmpty(boolean[] array)
Checks if an array of primitive booleans is not empty or not null
.
From source file:org.bigmouth.nvwa.network.http.HttpServletResponseHelper.java
public static boolean doRespond(HttpServletResponse response, byte[] data) { if (null == response) return false; if (ArrayUtils.isNotEmpty(data)) { PrintWriter out = null;//w ww . j a va2s .com try { response.setContentType(CONTENT_TYPE); out = response.getWriter(); out.println(data); out.flush(); return true; } catch (IOException e) { LOGGER.error("println:", e); } finally { IOUtils.closeQuietly(out); } } return false; }
From source file:org.bigmouth.nvwa.pay.service.prepay.AbstractPrepay.java
@Override public PrepayResponse prepay(PrepayRequest argument) { Preconditions.checkNotNull(argument, "argument"); argument.validate();//from w w w .j av a 2s . co m Map<String, PayConfig> configs = configService.getConfigs(); if (MapUtils.isEmpty(configs)) { throw new PayConfigException("pay configs is empty!"); } String appId = argument.getAppId(); PayConfig config = configs.get(appId); config.validate(); File pkcs12 = config.getPkcs12(); String appSecret = config.getAppSecret(); String url = config.getUrlPrepay(); String xml = getPayRequest(argument, config).toXML(); HttpClient https = HttpClientHelper.https(pkcs12, appSecret.toCharArray()); try { HttpPost post = HttpClientHelper.post(url); HttpClientHelper.addByteArrayEntity(post, StringHelper.convert(xml), PayDefaults.APPLICATION_XML); HttpResponse httpResponse = https.execute(post); int statusCode = httpResponse.getStatusLine().getStatusCode(); if (LOGGER.isInfoEnabled()) { LOGGER.info("Received response statusCode {} from {}", statusCode, url); } byte[] array = HttpClientHelper.getResponse(httpResponse); if (ArrayUtils.isNotEmpty(array)) { return convert(array); } else { LOGGER.warn("Empty response content! from {}", url); } } catch (Exception e) { LOGGER.error("Access " + url + " occur exception!", e); } finally { https.getConnectionManager().shutdown(); } return null; }
From source file:org.bigmouth.nvwa.session.spring.SessionAdvisor.java
private Trackable getTrackable(Object[] args, Annotation[][] parameterAnnotations) { Trackable trackable = null;/*ww w . j a v a2 s . c o m*/ if (ArrayUtils.isNotEmpty(parameterAnnotations)) { for (int i = 0, len = parameterAnnotations.length; i < len; i++) { Annotation[] annotations = parameterAnnotations[i]; if (ArrayUtils.isEmpty(annotations)) { continue; } else { for (Annotation annotation : annotations) { if (annotation instanceof SessionTrackable) { if (args[i] instanceof Trackable) { trackable = (Trackable) args[i]; break; } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn("args[{}]'s java type must be org.bigmouth.nvwa.session.Trackable!", i); } } } } } } } return trackable; }
From source file:org.bigmouth.nvwa.zookeeper.concurrent.spring.SynchronousAdvisor.java
private String getPrimaryKey(Object[] args, Annotation[][] parameterAnnotations) { String primary = null;/* ww w .j a v a 2s .c o m*/ if (ArrayUtils.isNotEmpty(parameterAnnotations)) { for (int i = 0, len = parameterAnnotations.length; i < len; i++) { Annotation[] annotations = parameterAnnotations[i]; if (ArrayUtils.isEmpty(annotations)) { continue; } else { for (Annotation annotation : annotations) { if (annotation instanceof PrimaryKey) { if (args[i] instanceof String || args[i] instanceof Integer || args[i] instanceof Long) { primary = String.valueOf(args[i]); break; } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn( "args[{}]'s java type must be java.lang.String|java.lang.Integer|java.lang.Long!", i); } } } } } } } return primary; }
From source file:org.bigmouth.nvwa.zookeeper.queue.SimpleQueueConsumerKeeper.java
@Override protected void doInit() { pool.submit(new Runnable() { @Override/*from w ww. j av a 2 s . c o m*/ public void run() { while (true) { try { byte[] take = simpleQueue.take(); if (ArrayUtils.isNotEmpty(take)) { if (null != simpleQueueConsumer) { simpleQueueConsumer.consumeMessage(take); } } } catch (Exception e) { LOGGER.error("take:", e); } } } }); }
From source file:org.broadleafcommerce.core.catalog.dao.FieldOnlyPropertiesCustomPersistenceHandler.java
@Override public Boolean canHandleInspect(PersistencePackage persistencePackage) { return ArrayUtils.isNotEmpty(persistencePackage.getCustomCriteria()) && Objects.equals(persistencePackage.getCustomCriteria()[0], "fieldImplOnly"); }
From source file:org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest.java
public PersistencePackageRequest withFilterAndSortCriteria(FilterAndSortCriteria[] filterAndSortCriteria) { if (ArrayUtils.isNotEmpty(filterAndSortCriteria)) { setFilterAndSortCriteria(filterAndSortCriteria); }/*from w ww . j a va2 s .com*/ return this; }
From source file:org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest.java
public PersistencePackageRequest withCustomCriteria(String[] customCriteria) { if (ArrayUtils.isNotEmpty(customCriteria)) { setCustomCriteria(customCriteria); }//from w w w .java 2s .c om return this; }
From source file:org.candlepin.resource.ConsumerResource.java
private void validateBindArguments(boolean hasPoolQuantities, String poolIdString, Integer quantity, String[] productIds, List<String> fromPools, Date entitleDate, boolean async) { short parameters = 0; if (hasPoolQuantities) { parameters++;/* w ww.jav a2s .c o m*/ } if (poolIdString != null) { parameters++; } if (ArrayUtils.isNotEmpty(productIds) || CollectionUtils.isNotEmpty(fromPools) || entitleDate != null) { parameters++; } if (parameters > 1) { throw new BadRequestException(i18n.tr("Cannot bind by multiple parameters.")); } if (hasPoolQuantities) { if (quantity != null) { throw new BadRequestException(i18n.tr("Cannot specify a single quantity when binding a batch of " + " exact pools. Please specify a quantity for each pool")); } else if (!async) { throw new BadRequestException(i18n.tr("Batch bind can only be performed asynchronously")); } } if (poolIdString == null && quantity != null) { throw new BadRequestException(i18n.tr("Cannot specify a quantity when auto-binding.")); } }
From source file:org.codehaus.grepo.query.commons.generator.GeneratorUtils.java
/** * @param clazz The clazz to check.// w w w. j a v a 2s .c om * @param to The desired type. * @return Returns {@code true} if the given {@code clazz} is valid and {@code false} otherwise. */ public static boolean validateQueryGenerator(Class<? extends QueryGenerator<?, ?>> clazz, Class<? extends QueryGenerator<?, ?>>... expectedTypes) { if (isUserDefinedQueryGenerator(clazz)) { if (ArrayUtils.isNotEmpty(expectedTypes)) { boolean isAssignable = false; for (Class<? extends QueryGenerator<?, ?>> expectedType : expectedTypes) { if (expectedType.isAssignableFrom(clazz)) { isAssignable = true; break; } } if (!isAssignable) { throw ConfigurationException.notAssignableException(clazz, expectedTypes); } } return true; } return false; }