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:ch.cyberduck.core.s3.RequestEntityRestStorageService.java
public RequestEntityRestStorageService(final S3Session session, final Jets3tProperties properties, final HttpClientBuilder configuration) { super(session.getHost().getCredentials().isAnonymousLogin() ? null : new AWSCredentials(null, null) { @Override/*from www.j ava2 s .c o m*/ public String getAccessKey() { return session.getHost().getCredentials().getUsername(); } @Override public String getSecretKey() { return session.getHost().getCredentials().getPassword(); } }, new PreferencesUseragentProvider().get(), null, properties); this.session = session; configuration.disableContentCompression(); configuration.setRetryHandler( new S3HttpRequestRetryHandler(this, preferences.getInteger("http.connections.retry"))); configuration.setRedirectStrategy(new DefaultRedirectStrategy() { @Override public HttpUriRequest getRedirect(final HttpRequest request, final HttpResponse response, final HttpContext context) throws ProtocolException { if (response.containsHeader("x-amz-bucket-region")) { final String host = ((HttpUriRequest) request).getURI().getHost(); if (!StringUtils.equals(session.getHost().getHostname(), host)) { regionEndpointCache.putRegionForBucketName( StringUtils .split(StringUtils.removeEnd(((HttpUriRequest) request).getURI().getHost(), session.getHost().getHostname()), ".")[0], response.getFirstHeader("x-amz-bucket-region").getValue()); } } return super.getRedirect(request, response, context); } }); this.setHttpClient(configuration.build()); }
From source file:net.dv8tion.jda.managers.ChannelManager.java
/** * Sets the topic of this Channel./*from w ww . j a v a 2 s . c om*/ * This is not available for {@link net.dv8tion.jda.entities.VoiceChannel VoiceChannels} * and will result in a {@link java.lang.UnsupportedOperationException UnsupportedOperationException}. * <p> * This change will only be applied, if {@link #update()} is called. * So multiple changes can be made at once. * * @param topic The new topic of the Channel, or null to keep current one * @return this * @throws java.lang.UnsupportedOperationException thrown when attempting to set the topic for a {@link net.dv8tion.jda.entities.VoiceChannel} */ public ChannelManager setTopic(String topic) { checkPermission(Permission.MANAGE_CHANNEL); if (channel instanceof VoiceChannel) { throw new UnsupportedOperationException("Setting a Topic on VoiceChannels is not allowed!"); } if (StringUtils.equals(topic, channel.getTopic())) { this.topic = null; } else { this.topic = topic; } return this; }
From source file:com.eryansky.common.orm.core.PageRequest.java
/** * ???./*from w w w .j av a 2s. c o m*/ * * @param orderDir ?descasc,?','. */ public void setOrderDir(final String orderDir) { String lowcaseOrderDir = StringUtils.lowerCase(orderDir); //order? String[] orderDirs = StringUtils.split(lowcaseOrderDir, ','); if (ArrayUtils.isEmpty(orderDirs)) { return; } for (String orderDirStr : orderDirs) { if (!StringUtils.equals(Sort.DESC, orderDirStr) && !StringUtils.equals(Sort.ASC, orderDirStr)) { throw new IllegalArgumentException("??" + orderDirStr + "??"); } } this.orderDir = lowcaseOrderDir; }
From source file:de.micromata.genome.gwiki.controls.GWikiCompareActionBean.java
public Object onInit() { if (StringUtils.isEmpty(leftPageId) == true || StringUtils.isEmpty(rightPageId) == true) { wikiContext.addValidationError("gwiki.page.edit.Compare.message.leftorrightpageidnotset"); return null; }/*from w w w .j a v a 2 s. co m*/ leftEl = wikiContext.getWikiWeb().findElement(leftPageId); rightEl = wikiContext.getWikiWeb().findElement(rightPageId); if (leftEl == null) { wikiContext.addValidationError("gwiki.page.edit.Compare.message.leftpageidnotfound", leftPageId); } if (rightEl == null) { wikiContext.addValidationError("gwiki.page.edit.Compare.message.rightpageidnotfound", rightPageId); } if (wikiContext.hasValidationErrors() == true) { return null; } if (wikiContext.getWikiWeb().getAuthorization().isAllowToView(wikiContext, leftEl.getElementInfo()) == false || wikiContext.getWikiWeb().getAuthorization().isAllowToView(wikiContext, leftEl.getElementInfo()) == false) { wikiContext.addValidationError("gwiki.page.edit.Compare.message.leftpageidnotfound", leftPageId); return null; } if (StringUtils.equals(rightEl.getElementInfo().getProps().getStringValue(GWikiPropKeys.WIKIMETATEMPLATE), leftEl.getElementInfo().getProps().getStringValue(GWikiPropKeys.WIKIMETATEMPLATE)) == false) { wikiContext.addValidationError("gwiki.page.edit.Compare.message.canonlycompareequalmetas", leftEl.getElementInfo().getMetaTemplate().getPageId(), leftEl.getElementInfo().getMetaTemplate().getPageId()); return null; } diffSets = buildElDiffset(); return null; }
From source file:io.wcm.handler.url.ui.SiteRoot.java
/** * @param page Page/*from ww w . j a v a2 s . co m*/ * @return true if given page is the site root page */ public boolean isRootPage(Page page) { return StringUtils.equals(page.getPath(), getRootPath()); }
From source file:ke.co.tawi.babblesms.server.servlet.admin.Login.java
/** * @param request//from w ww.j a v a2 s . c o m * @param response * @throws ServletException * @throws IOException */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); String username = StringUtils.trimToEmpty(request.getParameter("username")); String password = StringUtils.trimToEmpty(request.getParameter("password")); hiddenCaptchaStr = request.getParameter("captchaHidden"); String captchaAnswer = request.getParameter("captchaAnswer").trim(); if (!validateCaptcha(hiddenCaptchaStr, captchaAnswer)) { session.setAttribute(SessionConstants.ADMIN_SIGN_IN_ERROR_KEY, ACCOUNT_SIGN_IN_BAD_CAPTCHA); response.sendRedirect("index.jsp"); // The username supplied does not match what is in the config file } else if (!StringUtils.equals(username, PropertiesConfig.getConfigValue("ADMIN_USERNAME"))) { session.setAttribute(SessionConstants.ADMIN_SIGN_IN_ERROR_KEY, SessionConstants.ADMIN_SIGN_IN_ERROR_KEY); response.sendRedirect("index.jsp"); // The password supplied does not match what is in the config file } else if (!StringUtils.equals(password, PropertiesConfig.getConfigValue("ADMIN_PASSWORD"))) { session.setAttribute(SessionConstants.ADMIN_SIGN_IN_ERROR_KEY, SessionConstants.ADMIN_SIGN_IN_ERROR_VALUE); response.sendRedirect("index.jsp"); // The login is correct } else { session.setAttribute(SessionConstants.ADMIN_SESSION_KEY, "admin"); session.setAttribute(SessionConstants.ADMIN_LOGIN_TIME_KEY, new Date()); //initCache(); response.sendRedirect("accounts.jsp"); } }
From source file:de.blizzy.documentr.web.account.AccountController.java
@RequestMapping(value = "/save", method = RequestMethod.POST) @PreAuthorize("isAuthenticated()") public String saveMyAccount(@ModelAttribute @Valid AccountForm form, BindingResult bindingResult, Model model, Authentication authentication) throws IOException { if (StringUtils.isNotBlank(form.getNewPassword1()) || StringUtils.isNotBlank(form.getNewPassword2())) { User user = userStore.getUser(authentication.getName()); if (StringUtils.isBlank(form.getPassword())) { bindingResult.rejectValue("password", "user.password.blank"); //$NON-NLS-1$ //$NON-NLS-2$ } else if (!passwordEncoder.matches(form.getPassword(), user.getPassword())) { bindingResult.rejectValue("password", "user.password.wrong"); //$NON-NLS-1$ //$NON-NLS-2$ }/*from ww w . j a v a 2 s.c om*/ if (!StringUtils.equals(form.getNewPassword1(), form.getNewPassword2())) { bindingResult.rejectValue("newPassword1", "user.password.passwordsNotEqual"); //$NON-NLS-1$ //$NON-NLS-2$ } if (!bindingResult.hasErrors()) { String encodedPassword = passwordEncoder.encode(form.getNewPassword1()); User newUser = new User(user.getLoginName(), encodedPassword, user.getEmail(), user.isDisabled()); for (OpenId openId : user.getOpenIds()) { newUser.addOpenId(openId); } userStore.saveUser(newUser, user); } } if (!bindingResult.hasErrors()) { model.addAttribute("messageKey", "dataSaved"); //$NON-NLS-1$ //$NON-NLS-2$ } return "/account/index"; //$NON-NLS-1$ }
From source file:io.wcm.handler.url.impl.modes.DefaultUrlMode.java
/** * Checks if the target resource is located outsite the current site, and if for this other * resource context a valid url configuration with a specific hostname exists. * @param adaptable Adaptable//from w w w . j a v a 2s . c o m * @param currentPage Current page (may be null) * @param targetResource Target resource (may be null) * @return true if the target resources is located in another site/context with separate url configuration */ private boolean linksToOtherDomain(Adaptable adaptable, Page currentPage, Resource targetResource) { if (currentPage == null || targetResource == null) { return false; } UrlHandlerConfig urlHandlerConfig = AdaptTo.notNull(adaptable, UrlHandlerConfig.class); String currentPath = currentPage.getPath(); String targetPath = targetResource.getPath(); String currentSiteRoot = getRootPath(currentPath, urlHandlerConfig.getSiteRootLevel(currentPath)); String pathSiteRoot = getRootPath(targetPath, urlHandlerConfig.getSiteRootLevel(targetPath)); boolean notInCurrentSite = !StringUtils.equals(currentSiteRoot, pathSiteRoot); if (notInCurrentSite) { UrlConfig targetUrlConfig = new UrlConfig(targetResource); return targetUrlConfig.isValid(); } else { return false; } }
From source file:com.inkubator.hrm.web.recruitment.VacancyAdvertisementApprovalFormController.java
@PostConstruct @Override// w w w . ja v a2 s. c o m public void initialization() { try { super.initialization(); /** initial data for approval activity tracking */ String id = FacesUtil.getRequestParameter("execution"); currentActivity = approvalActivityService.getEntiyByPK(Long.parseLong(id.substring(1))); askingRevisedActivity = approvalActivityService.getEntityByActivityNumberAndSequence( currentActivity.getActivityNumber(), currentActivity.getSequence() - 1); isWaitingApproval = currentActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL; isWaitingRevised = currentActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_REVISED; isApprover = StringUtils.equals(UserInfoUtil.getUserName(), currentActivity.getApprovedBy()); isRequester = StringUtils.equals(UserInfoUtil.getUserName(), currentActivity.getRequestBy()); /** start binding data that needed (from json) to object */ vacancyAdvertisement = this.convertJsonToEntity(currentActivity.getPendingData()); //relational object RecruitAdvertisementMedia advertisementMedia = recruitAdvertisementMediaService .getEntiyByPK(vacancyAdvertisement.getAdvertisementMedia().getId()); vacancyAdvertisement.setAdvertisementMedia(advertisementMedia); } catch (Exception ex) { LOGGER.error("Error", ex); } }
From source file:com.webbfontaine.valuewebb.action.pricedb.mp.MPCriteriaContainer.java
@Override protected UserCriterion getDefinedCriterion(String criteriaKey) { UserCriterion uc = new UserCriterion(); uc.setFullKey(criteriaKey);//from w w w. j av a 2s . c om RefSelect refSelect = (RefSelect) Component.getInstance(RefSelect.class, true); if (StringUtils.equals(criteriaKey, "id")) { uc.setName("ID"); uc.setType(UserCriterionType.LONG); } if (StringUtils.equals(criteriaKey, "sourceOfPrice.cod")) { uc.setName("Source of Price"); uc.setType(UserCriterionType.REF); uc.setPossibleValues(refSelect.selectSourceOfPrice()); uc.setCondition(StringConditions.EQ); } if (StringUtils.equals(criteriaKey, "ctyOrigin")) { uc.setName("Country of Origin"); uc.setType(UserCriterionType.REF); uc.setPossibleValues(refSelect.selectCountry()); uc.setCondition(StringConditions.EQ); } if (StringUtils.equals(criteriaKey, "ctySupply")) { uc.setName("Country of supply"); uc.setType(UserCriterionType.REF); uc.setPossibleValues(refSelect.selectCountry()); } if (StringUtils.equals(criteriaKey, "priceDate")) { uc.setName("Price Date"); uc.setType(UserCriterionType.DATE); } if (StringUtils.equals(criteriaKey, "hsCode")) { uc.setName("HS Code"); uc.setType(UserCriterionType.STRING); uc.setCondition(StringConditions.STARTS_WITH); } if (StringUtils.equals(criteriaKey, "dpd")) { uc.setName("Declared Product Description"); uc.setType(UserCriterionType.STRING); uc.setCondition(StringConditions.CONTAINS); } if (StringUtils.equals(criteriaKey, "unit")) { uc.setType(UserCriterionType.REF); uc.setPossibleValues(refSelect.selectRimmUnit()); } if (StringUtils.equals(criteriaKey, "retailerPrice")) { uc.setType(UserCriterionType.BIG_DECIMAL); } if (StringUtils.equals(criteriaKey, "retailerRate")) { uc.setType(UserCriterionType.BIG_DECIMAL); } if (StringUtils.equals(criteriaKey, "vmRuleCode")) { uc.setType(UserCriterionType.REF); uc.setName("VM"); uc.setPossibleValues(refSelect.getValuationMethodForMP()); } if (StringUtils.equals(criteriaKey, "tradeLevel")) { uc.setType(UserCriterionType.REF); uc.setPossibleValues(refSelect.selectTradeLevel()); uc.setCondition(StringConditions.EQ); } if (StringUtils.equals(criteriaKey, "sourceRating")) { uc.setType(UserCriterionType.REF); uc.setPossibleValues(refSelect.selectSourceRating()); } if (StringUtils.equals(criteriaKey, "priceRating")) { uc.setType(UserCriterionType.REF); uc.setPossibleValues(refSelect.selectPriceRating()); } if (StringUtils.equals(criteriaKey, "retailerPriceCur")) { uc.setType(UserCriterionType.REF); uc.setName("Retailer Price Currency"); uc.setPossibleValues(refSelect.selectCurrency()); } if (StringUtils.equals(criteriaKey, "retailerPriceUsd")) { uc.setName("Retailer Price USD"); uc.setType(UserCriterionType.BIG_DECIMAL); } if (StringUtils.equals(criteriaKey, "fob")) { uc.setName("FOB"); uc.setType(UserCriterionType.BIG_DECIMAL); } if (StringUtils.equals(criteriaKey, "fobUsd")) { uc.setType(UserCriterionType.BIG_DECIMAL); uc.setName("FOB USD"); } if (StringUtils.equals(criteriaKey, "ageOfPrice")) { uc.setType(UserCriterionType.LONG); uc.setName("Age of Price"); } if (StringUtils.equals(criteriaKey, "used")) { uc.setType(UserCriterionType.BOOLEAN); } if (uc.getName() == null) { uc.setName(Utils.toWords(criteriaKey)); } return uc; }