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.apache.geode.distributed.internal.DefaultPropertiesGenerator.java
public static void main(final String args[]) throws IOException { String targetFileName = null; if (ArrayUtils.isNotEmpty(args)) { targetFileName = args[0];/* ww w. ja v a 2 s .c o m*/ } DefaultPropertiesGenerator generator = new DefaultPropertiesGenerator(); generator.generateDefaultPropertiesFile(targetFileName); }
From source file:org.apache.geode.management.internal.security.TestCommand.java
public static List<TestCommand> getOnlineCommands() { return testCommands.stream().filter((x) -> ArrayUtils.isNotEmpty(x.getPermissions())) .collect(Collectors.toList()); }
From source file:org.apache.hadoop.hive.metastore.tools.SchemaToolTaskValidate.java
/** * Check if the location is valid for the given entity. * @param entity the entity to represent a database, partition or table * @param entityLocation the location/*from ww w . ja v a 2 s . c om*/ * @param defaultServers a list of the servers that the location needs to match. * The location host needs to match one of the given servers. * If empty, then no check against such list. * @return true if the location is valid */ private boolean checkLocation(String entity, String entityLocation, URI[] defaultServers) { boolean isValid = true; if (entityLocation == null) { System.err.println(entity + ", Error: empty location"); isValid = false; } else { try { URI currentUri = new Path(entityLocation).toUri(); String scheme = currentUri.getScheme(); String path = currentUri.getPath(); if (StringUtils.isEmpty(scheme)) { System.err.println( entity + ", Location: " + entityLocation + ", Error: missing location scheme."); isValid = false; } else if (StringUtils.isEmpty(path)) { System.err .println(entity + ", Location: " + entityLocation + ", Error: missing location path."); isValid = false; } else if (ArrayUtils.isNotEmpty(defaultServers) && currentUri.getAuthority() != null) { String authority = currentUri.getAuthority(); boolean matchServer = false; for (URI server : defaultServers) { if (StringUtils.equalsIgnoreCase(server.getScheme(), scheme) && StringUtils.equalsIgnoreCase(server.getAuthority(), authority)) { matchServer = true; break; } } if (!matchServer) { System.err .println(entity + ", Location: " + entityLocation + ", Error: mismatched server."); isValid = false; } } // if there is no path element other than "/", report it but not fail if (isValid && StringUtils.containsOnly(path, "/")) { System.err.println(entity + ", Location: " + entityLocation + ", Warn: location set to root, " + "not a recommended config."); } } catch (Exception pe) { System.err.println(entity + ", Error: invalid location - " + pe.getMessage()); isValid = false; } } return isValid; }
From source file:org.apache.hive.beeline.HiveSchemaTool.java
/** * Check if the location is valid for the given entity * @param entity the entity to represent a database, partition or table * @param entityLocation the location//from w w w . j a va 2 s . c om * @param defaultServers a list of the servers that the location needs to match. * The location host needs to match one of the given servers. * If empty, then no check against such list. * @return true if the location is valid */ private boolean checkLocation(String entity, String entityLocation, URI[] defaultServers) { boolean isValid = true; if (entityLocation == null) { System.err.println(entity + ", Error: empty location"); isValid = false; } else { try { URI currentUri = new Path(entityLocation).toUri(); String scheme = currentUri.getScheme(); String path = currentUri.getPath(); if (StringUtils.isEmpty(scheme)) { System.err.println( entity + ", Location: " + entityLocation + ", Error: missing location scheme."); isValid = false; } else if (StringUtils.isEmpty(path)) { System.err .println(entity + ", Location: " + entityLocation + ", Error: missing location path."); isValid = false; } else if (ArrayUtils.isNotEmpty(defaultServers) && currentUri.getAuthority() != null) { String authority = currentUri.getAuthority(); boolean matchServer = false; for (URI server : defaultServers) { if (StringUtils.equalsIgnoreCase(server.getScheme(), scheme) && StringUtils.equalsIgnoreCase(server.getAuthority(), authority)) { matchServer = true; break; } } if (!matchServer) { System.err .println(entity + ", Location: " + entityLocation + ", Error: mismatched server."); isValid = false; } } // if there is no path element other than "/", report it but not fail if (isValid && StringUtils.containsOnly(path, "/")) { System.err.println(entity + ", Location: " + entityLocation + ", Warn: location set to root, not a recommended config."); } } catch (Exception pe) { System.err.println(entity + ", Error: invalid location - " + pe.getMessage()); isValid = false; } } return isValid; }
From source file:org.apache.phoenix.hive.query.PhoenixQueryBuilderTest.java
private IndexSearchCondition mockedIndexSearchCondition(String comparisionOp, Object constantValue, Object[] constantValues, String columnName, String typeString, boolean isNot) { IndexSearchCondition condition = mock(IndexSearchCondition.class); when(condition.getComparisonOp()).thenReturn(comparisionOp); if (constantValue != null) { ExprNodeConstantDesc constantDesc = mock(ExprNodeConstantDesc.class); when(constantDesc.getValue()).thenReturn(constantValue); when(condition.getConstantDesc()).thenReturn(constantDesc); }//w ww .j av a 2s . c o m ExprNodeColumnDesc columnDesc = mock(ExprNodeColumnDesc.class); when(columnDesc.getColumn()).thenReturn(columnName); when(columnDesc.getTypeString()).thenReturn(typeString); when(condition.getColumnDesc()).thenReturn(columnDesc); if (ArrayUtils.isNotEmpty(constantValues)) { ExprNodeConstantDesc[] constantDescs = new ExprNodeConstantDesc[constantValues.length]; for (int i = 0; i < constantDescs.length; i++) { constantDescs[i] = mock(ExprNodeConstantDesc.class); when(condition.getConstantDesc(i)).thenReturn(constantDescs[i]); when(constantDescs[i].getValue()).thenReturn(constantValues[i]); } when(condition.getConstantDescs()).thenReturn(constantDescs); } when(condition.isNot()).thenReturn(isNot); return condition; }
From source file:org.apache.stratos.rest.endpoint.util.converter.ObjectConverter.java
/** * Convert Persistence To PersistenceBean * * @param baseDir base directory/*from www. ja v a 2 s . c om*/ * @param directories directories * @return DeploymentBean */ private static DeploymentBean convertDeploymentToDeploymentBean(String[] directories, String baseDir) { if (baseDir == null && (directories == null || directories[0] == null)) { return null; } DeploymentBean deploymentBean = new DeploymentBean(); deploymentBean.setBaseDir(baseDir); if (ArrayUtils.isNotEmpty(directories) && (directories[0] != null)) { deploymentBean.setDir(Arrays.asList(directories)); } return deploymentBean; }
From source file:org.bigmouth.nvwa.network.ftp.client.SimpleFTPClient.java
@Override public boolean exists(String path, String fileName) throws IOException { try {//from w w w .ja va2s. c o m this.connect(); if (dirExists(path)) { FTPFile[] listFiles = client.listFiles(path); if (ArrayUtils.isNotEmpty(listFiles)) { for (FTPFile ftpFile : listFiles) { if (ftpFile.getName().equals(fileName)) return true; } } } if (LOGGER.isWarnEnabled()) LOGGER.warn("File " + path + fileName + " does not exist."); return false; } catch (IOException e) { LOGGER.error("exists: ", e); throw e; } finally { if (autoDisconnect) this.disconnect(); } }
From source file:org.bigmouth.nvwa.network.http.HttpClientHelper.java
private static void setRequestHeader(HttpRequestBase httpRequest, Header[] headers) { List<Header> cookies = Lists.newArrayList(); if (ArrayUtils.isNotEmpty(headers)) { for (Header header : headers) { if (header.getName().equals("Set-Cookie")) { cookies.add(header);//from w w w . j a v a 2s . co m } else { httpRequest.addHeader(header); } } } setRequestCookie(httpRequest, cookies.toArray(new Header[0])); }
From source file:org.bigmouth.nvwa.network.http.HttpClientHelper.java
protected static void setRequestCookie(HttpRequestBase httpRequest, Header[] headers) { StringBuilder sb = new StringBuilder(128); if (ArrayUtils.isNotEmpty(headers)) { for (Header header : headers) { if (StringUtils.equals(header.getName(), "Set-Cookie")) { String value = header.getValue(); if (StringUtils.isNotBlank(value)) { // Because of the need to remove the effective range: path=/ String[] values = StringUtils.split(value, ";"); for (String string : values) { String[] v = string.split("="); if (v.length >= 2) sb.append(v[0]).append("=").append(v[1]).append(";"); }/*from w ww . ja v a2s. co m*/ } } } } httpRequest.addHeader("Cookie", sb.toString()); }
From source file:org.bigmouth.nvwa.network.http.HttpServletRequestHelper.java
public static String getContentString(HttpServletRequest request) throws IOException { byte[] bytes = getContentByteArray(request); if (ArrayUtils.isNotEmpty(bytes)) { try {//from w ww . j av a 2 s . com return new String(bytes, UTF_8); } catch (UnsupportedEncodingException e) { return new String(bytes); } } return null; }