List of usage examples for org.apache.commons.lang3 StringUtils equals
public static boolean equals(final CharSequence cs1, final CharSequence cs2)
Compares two CharSequences, returning true if they represent equal sequences of characters.
null s are handled without exceptions.
From source file:com.anrisoftware.globalpom.checkfilehash.CheckFileHash.java
private HashName hashName(URI hashResource) { if (StringUtils.equals(hashResource.getScheme(), "md5")) { return HashName.forExtension("md5"); } else if (StringUtils.equals(hashResource.getScheme(), "sha1")) { return HashName.forExtension("sha1"); } else {/*from w w w . j a va 2s.c o m*/ String ex = getExtension(hashResource.getPath()); return HashName.forExtension(ex); } }
From source file:com.nike.cerberus.auth.connector.okta.OktaAuthConnector.java
@Override public AuthResponse authenticate(String username, String password) { final AuthResult authResult = oktaApiClientHelper.authenticateUser(username, password, null); final String userId = oktaClientResponseUtils.getUserIdFromAuthResult(authResult); final String userLogin = oktaClientResponseUtils.getUserLoginFromAuthResult(authResult); final AuthData authData = new AuthData().setUserId(userId).setUsername(userLogin); final AuthResponse authResponse = new AuthResponse().setData(authData); final List<Factor> factors; if (StringUtils.equals(authResult.getStatus(), OktaClientResponseUtils.AUTHENTICATION_MFA_REQUIRED_STATUS) || StringUtils.equals(authResult.getStatus(), OktaClientResponseUtils.AUTHENTICATION_MFA_ENROLL_STATUS)) { authData.setStateToken(authResult.getStateToken()); authResponse.setStatus(AuthStatus.MFA_REQUIRED); factors = oktaClientResponseUtils.getUserFactorsFromAuthResult(authResult); oktaClientResponseUtils.validateUserFactors(factors); factors.forEach(factor -> authData.getDevices().add(new AuthMfaDevice().setId(factor.getId()) .setName(oktaClientResponseUtils.getDeviceName(factor)))); } else {//from w w w .j av a2s. c o m authResponse.setStatus(AuthStatus.SUCCESS); } return authResponse; }
From source file:io.wcm.wcm.commons.util.Template.java
/** * Checks if the given page uses a specific template. * @param page AEM page/*ww w . j a v a 2 s .com*/ * @param templatePaths Template path(s) * @return true if the page uses the template */ public static boolean is(Page page, String... templatePaths) { if (page == null || templatePaths == null || templatePaths.length == 0) { return false; } String templatePath = page.getProperties().get(NameConstants.PN_TEMPLATE, String.class); for (String givenTemplatePath : templatePaths) { if (StringUtils.equals(templatePath, givenTemplatePath)) { return true; } } return false; }
From source file:de.micromata.genome.gwiki.controls.GWikiPageListActionBean.java
public String getjqGridSearchExpression() { if (StringUtils.equals(getReqParam("_search"), "true") == false) { return null; }//w w w . j a v a2 s . c om // // String skey = getReqParam("sidx"); // if (StringUtils.isBlank(skey) == true) { // return null; // } List<String> fl = Converter.parseStringTokens(fields, "|", false); StringBuilder sb = new StringBuilder(); for (String f : fl) { String sval = getReqParam(f); if (StringUtils.isBlank(sval) == true) { continue; } List<String> args = Converter.parseStringTokens(sval, " ", false); for (String a : args) { if (sb.length() != 0) { sb.append(" and "); } sb.append("prop:" + f + " ~ " + a); } } if (sb.length() == 0) { return null; } return sb.toString(); }
From source file:com.libedi.test.common.service.RestApiRequestServiceTest.java
@Test public void testRestApiRequest() throws Exception { // Parameter Object ApiTestRequest apiTestRequest = new ApiTestRequest("Peter", "01012345678", "IT_DEV"); // JSON request string String reqStr = this.objectMapper.writeValueAsString(apiTestRequest); // HTTP request ResponseEntity<String> response = restApiRequestService.restSendByPost("http://api.test.com", "8080", "/test/request", reqStr); // response OK if (HttpStatus.OK == response.getStatusCode()) { String resStr = response.getBody(); ApiTestResponse apiTestResponse = this.objectMapper.readValue(resStr, ApiTestResponse.class); if (StringUtils.equals("0000", apiTestResponse.getResCode())) { logger.debug("success!"); }/*from ww w . j a v a 2s . c o m*/ } }
From source file:de.micromata.genome.gwiki.web.dav.GFsResource.java
public Object authenticate(String user, String password) { if (StringUtils.equals(user, resourceFactory.getInternalUserName()) == true) { String encpass = GWikiUserAuthorization.encrypt(password); if (StringUtils.equals(encpass, resourceFactory.getInternalPass()) == true) { return true; }/*w ww . j a v a 2s .co m*/ return false; } GWikiContext ctx = GWikiContext.getCurrent(); GWikiAuthorization auth = getAuthorization(ctx); if (auth == null) { return null; } if (auth.login(ctx, user, password) == false) { return null; } return user; }
From source file:com.hybris.mobile.app.commerce.utils.UIUtils.java
public static void showError(Response<ErrorList> error, Activity activity) { Error firstError = error != null && error.getData().getErrors() != null && !error.getData().getErrors().isEmpty() ? error.getData().getErrors().get(0) : null; // We don't show the no connection error because it's already shown as a static block in the MainActivity if (firstError != null && !StringUtils.equals(firstError.getType(), Constants.ERROR_TYPE_NO_CONNECTION)) { Alert.showError(activity, firstError.getMessage()); }// www . j a va 2 s . co m }
From source file:com.ottogroup.bi.streaming.operator.json.JsonProcessingUtils.java
/** * Splits the given dot-separated value string into an array where each artifact * separated by a dot is one element inside an array. The string may contain more * than one path description where these elements are separated by a given character * @param str/*from w ww . ja va 2 s . c om*/ * The string to parse the content from * @param separator * The string (or character) used to separate multiple paths from each other. If it equals the dot the result is empty * @return List of paths */ public static List<String[]> toPathList(final String str, final String separator) { if (StringUtils.isBlank(str) || StringUtils.equals(separator, ".")) return Collections.<String[]>emptyList(); List<String[]> result = new ArrayList<>(); final String[] providedPaths = str.split(separator); if (providedPaths != null && providedPaths.length > 0) { for (final String path : providedPaths) { if (StringUtils.isNotBlank(path)) { result.add(path.trim().split("\\.")); } } } return result; }
From source file:io.wcm.wcm.ui.extjs.provider.impl.util.PageIterator.java
/** * Seeks the next available page// w w w . j a v a 2s . c o m * @return the previous element */ private Page seek() { Page prev = next; next = null; while (resources.hasNext() && next == null) { Resource nextResource = resources.next(); next = nextResource.adaptTo(Page.class); if (next == null) { // handle sling:Folder and sling:OrderedFolder as "virtual pages" to allow browsing pages below them String primaryType = nextResource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class); if (StringUtils.equals(primaryType, "sling:Folder") || StringUtils.equals(primaryType, "sling:OrderedFolder")) { next = new SlingFolderVirtualPage(nextResource); } } if (next != null && pageFilter != null && !pageFilter.includes(next)) { next = null; } } return prev; }
From source file:ch.cyberduck.core.irods.IRODSListService.java
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try {/*from w w w.j av a 2 s .c o m*/ final AttributedList<Path> children = new AttributedList<Path>(); final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(directory.getAbsolute()); if (!f.exists()) { throw new NotfoundException(directory.getAbsolute()); } for (File file : fs.getListInDirWithFileFilter(f, TrueFileFilter.TRUE)) { final String normalized = PathNormalizer.normalize(file.getAbsolutePath(), true); if (StringUtils.equals(normalized, directory.getAbsolute())) { continue; } final PathAttributes attributes = new PathAttributes(); final ObjStat stats = fs.getObjStat(file.getAbsolutePath()); attributes.setModificationDate(stats.getModifiedAt().getTime()); attributes.setCreationDate(stats.getCreatedAt().getTime()); attributes.setSize(stats.getObjSize()); attributes .setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum())))); attributes.setOwner(stats.getOwnerName()); attributes.setGroup(stats.getOwnerZone()); children.add(new Path(directory, PathNormalizer.name(normalized), file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file), attributes)); listener.chunk(directory, children); } return children; } catch (JargonException e) { throw new IRODSExceptionMappingService().map("Listing directory {0} failed", e, directory); } }