List of usage examples for org.apache.commons.lang ArrayUtils isEmpty
public static boolean isEmpty(boolean[] array)
Checks if an array of primitive booleans is empty or null
.
From source file:io.fabric8.kubernetes.api.KubernetesFactory.java
private void configureCaCert(WebClient webClient) { try (InputStream pemInputStream = getInputStreamFromDataOrFile(caCertData, caCertFile)) { CertificateFactory certFactory = CertificateFactory.getInstance("X509"); X509Certificate cert = (X509Certificate) certFactory.generateCertificate(pemInputStream); KeyStore trustStore = KeyStore.getInstance("JKS"); trustStore.load(null);/*from w ww. j av a2 s . c om*/ String alias = cert.getSubjectX500Principal().getName(); trustStore.setCertificateEntry(alias, cert); TrustManagerFactory trustManagerFactory = TrustManagerFactory .getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit(); TLSClientParameters params = conduit.getTlsClientParameters(); if (params == null) { params = new TLSClientParameters(); conduit.setTlsClientParameters(params); } TrustManager[] existingTrustManagers = params.getTrustManagers(); TrustManager[] trustManagers; if (existingTrustManagers == null || ArrayUtils.isEmpty(existingTrustManagers)) { trustManagers = trustManagerFactory.getTrustManagers(); } else { trustManagers = (TrustManager[]) ArrayUtils.addAll(existingTrustManagers, trustManagerFactory.getTrustManagers()); } params.setTrustManagers(trustManagers); } catch (Exception e) { log.error("Could not create trust manager for " + caCertFile, e); } }
From source file:de.codesourcery.eve.skills.ui.components.impl.ImportMarketLogFileComponent.java
protected void markRowsManually(boolean selectForImport) { int[] selectedRows = table.getSelectedRows(); if (ArrayUtils.isEmpty(selectedRows)) { return;/*w w w. j a v a 2s. co m*/ } int minRow = -1; int maxRow = -1; for (int viewRow : selectedRows) { final int modelRow = table.convertRowIndexToModel(viewRow); model.getRow(modelRow).setEnteredByUser(true); model.getRow(modelRow).setValid(selectForImport); if (minRow == -1 || viewRow < minRow) { minRow = viewRow; } if (maxRow == -1 || viewRow > maxRow) { maxRow = viewRow; } } model.rowsChanged(minRow, maxRow); }
From source file:eu.europa.esig.dss.client.http.commons.CommonsDataLoader.java
/** * This method retrieves data using LDAP protocol. * - CRL from given LDAP url, e.g. ldap://ldap.infonotary.com/dc=identity-ca,dc=infonotary,dc=com * - ex URL from AIA ldap://xadessrv.plugtests.net/CN=LevelBCAOK,OU=Plugtests_2015-2016,O=ETSI,C=FR?cACertificate;binary * * @param urlString// w ww. j a v a 2s. co m * @return */ private byte[] ldapGet(final String urlString) { final Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, urlString); try { String attributeName = StringUtils.substringAfterLast(urlString, "?"); if (StringUtils.isEmpty(attributeName)) { // default was CRL attributeName = "certificateRevocationList;binary"; } final DirContext ctx = new InitialDirContext(env); final Attributes attributes = ctx.getAttributes(StringUtils.EMPTY); final Attribute attribute = attributes.get(attributeName); final byte[] ldapBytes = (byte[]) attribute.get(); if (ArrayUtils.isEmpty(ldapBytes)) { throw new DSSException("Cannot download CRL from: " + urlString); } return ldapBytes; } catch (Exception e) { LOG.warn(e.getMessage(), e); } return null; }
From source file:com.hs.mail.mailet.RemoteDelivery.java
/** * Build error message from the exception. */// w w w .j a v a 2s . c o m private String buildErrorMessage(Address[] addresses, MessagingException ex) { StringBuilder errorBuffer = new StringBuilder(); if (!ArrayUtils.isEmpty(addresses)) { for (int i = 0; i < addresses.length; i++) { errorBuffer.append(addresses[i].toString()).append("\r\n"); } } Exception ne = ex.getNextException(); if (ne == null) { errorBuffer.append(ex.getMessage().trim()); } else if (ne instanceof SendFailedException) { errorBuffer.append("Remote server told me: " + ne.getMessage().trim()); } else if (ne instanceof UnknownHostException) { errorBuffer.append("Unknown host: " + ne.getMessage().trim()); } else if (ne instanceof ConnectException) { // Already formatted as "Connection timed out: connect" errorBuffer.append(ne.getMessage().trim()); } else if (ne instanceof SocketException) { errorBuffer.append("Socket exception: " + ne.getMessage().trim()); } else { errorBuffer.append(ne.getMessage().trim()); } errorBuffer.append("\r\n"); return errorBuffer.toString(); }
From source file:com.etcc.csc.presentation.datatype.PaymentContext.java
public BigDecimal getSecondInvTotalUnPaidAmount() { BigDecimal amount = BigDecimal.ZERO; if (!ArrayUtils.isEmpty(secondInvs)) { for (int i = 0; i < secondInvs.length; i++) { if ("N".equals(secondInvs[i].getPaidIndicator())) { amount = amount.add(secondInvs[i].getAmount()); }//from w ww . j av a 2s . c o m } } return amount; }
From source file:com.etcc.csc.presentation.datatype.PaymentContext.java
public BigDecimal getSecondInvTotalTollDue() { BigDecimal amount = BigDecimal.ZERO; if (!ArrayUtils.isEmpty(secondInvs)) { for (int i = 0; i < secondInvs.length; i++) { if ("N".equals(secondInvs[i].getPaidIndicator())) { amount = amount.add(secondInvs[i].getAmount()).subtract(secondInvs[i].getInvoiceAdminFee()) .subtract(secondInvs[i].getAdjustedTxnFees()) .subtract(secondInvs[i].getInvSecondNoticeAdminFee()); }//ww w . j a va2s . com } } return amount; }
From source file:com.fiveamsolutions.nci.commons.search.SearchCallback.java
private void validateCollection(Collection<?> col, SearchOptions searchOptions) { if (ArrayUtils.isEmpty(searchOptions.getFields()) && !searchOptions.isNested()) { throw new IllegalArgumentException("Cannot use the searchable annotation on a collection without" + " specifying at least one field name or nested."); }/* ww w . j av a2 s . c o m*/ if (col.size() > GenericSearchService.MAX_IN_CLAUSE_SIZE) { throw new IllegalArgumentException(String.format("Cannot query on more than %s elements.", GenericSearchService.MAX_IN_CLAUSE_SIZE)); } }
From source file:cn.fastmc.core.utils.ReflectionUtils.java
/** * ?constructors?annotationClass// w ww.j a v a 2s . c om * * @param constructors * constructor * @param annotationClass * annotationClass * * @return List */ public static <T extends Annotation> List<T> getAnnotations(Constructor[] constructors, Class annotationClass) { if (ArrayUtils.isEmpty(constructors)) { return null; } List<T> result = new ArrayList<T>(); for (Constructor constructor : constructors) { Annotation annotation = getAnnotation(constructor, annotationClass); if (annotation != null) { result.add((T) annotation); } } return result; }
From source file:com.etcc.csc.presentation.datatype.PaymentContext.java
public BigDecimal getSecondInvTotalTXNAdminFee() { BigDecimal amount = BigDecimal.ZERO; if (!ArrayUtils.isEmpty(secondInvs)) { for (int i = 0; i < secondInvs.length; i++) { if ("N".equals(secondInvs[i].getPaidIndicator())) { amount = amount.add(BigDecimalUtil.nullSafe(secondInvs[i].getAdjustedTxnFees())); }/* ww w . j a v a 2 s. c o m*/ } } return amount; }
From source file:com.nec.harvest.service.impl.BudgetPerformanceServiceImpl.java
/** {@inheritDoc} */ @Override/*from w w w.ja v a2s. c om*/ public boolean checkAvailableByOrgCodeAndMonthlyAndKmkCodeJs(String orgCode, String monthly, String... kmkCodeJs) throws ServiceException { if (StringUtils.isEmpty(orgCode)) { throw new IllegalArgumentException( "Organization code or current month in acton must not be null or empty"); } if (StringUtils.isEmpty(monthly)) { throw new IllegalArgumentException("Month must not be null or empty"); } if (ArrayUtils.isEmpty(kmkCodeJs)) { throw new IllegalArgumentException("KmkCodeJs must not be null"); } final Session session = HibernateSessionManager.getSession(); Transaction tx = null; boolean isAvailable = Boolean.FALSE; try { tx = session.beginTransaction(); StringBuilder sql = new StringBuilder("SELECT count(strcode) "); sql.append(" FROM " + TblConstants.TBL_BUDGET_PERFORMANCE); sql.append(" WHERE strcode = (:orgCodes) "); sql.append(" AND GetSudo = (:month) "); sql.append(" AND KmkCodeJ IN (:kmkCodeJs) "); sql.append(" AND DelKbn = 2 "); Query query = repository.getSQLQuery(session, sql.toString()); query.setParameter("orgCodes", orgCode); query.setParameter("month", monthly); query.setParameterList("kmkCodeJs", kmkCodeJs); Object count = query.uniqueResult(); if (count != null) { isAvailable = Long.parseLong(count.toString()) > 0; } tx.commit(); } catch (SQLGrammarException | GenericJDBCException ex) { if (tx != null) { tx.rollback(); } throw new ServiceException("An exception occured while checking data for budgetperformance", ex); } finally { HibernateSessionManager.closeSession(session); } return isAvailable; }