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.adobe.acs.commons.wcm.vanity.impl.VanityURLServiceImpl.java
public boolean dispatch(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException, RepositoryException { if (request.getAttribute(VANITY_DISPATCH_CHECK_ATTR) != null) { log.trace("Processing a previously vanity dispatched request. Skipping..."); return false; }//from www . j a v a 2 s . co m request.setAttribute(VANITY_DISPATCH_CHECK_ATTR, true); final String requestURI = request.getRequestURI(); final RequestPathInfo mappedPathInfo = new PathInfo(request.getResourceResolver(), requestURI); final String candidateVanity = mappedPathInfo.getResourcePath(); final String pathScope = StringUtils.removeEnd(requestURI, candidateVanity); log.debug("Candidate vanity URL to check and dispatch: [ {} ]", candidateVanity); // Check if... // 1) the candidateVanity and the requestURI are the same; If they are it means the request has already // gone through resource resolution and failed so there is no sense in sending it through again. // 2) the candidate is in at least 1 sling:vanityPath under /content if (!StringUtils.equals(candidateVanity, requestURI) && isVanityPath(pathScope, candidateVanity, request)) { log.debug("Forwarding request to vanity resource [ {} ]", candidateVanity); final RequestDispatcher requestDispatcher = request.getRequestDispatcher(candidateVanity); requestDispatcher.forward(new ExtensionlessRequestWrapper(request), response); return true; } return false; }
From source file:io.ehdev.json.validation.pojo.validation.JsonValidationEnum.java
private boolean checkCaseSensitive(String inputValue) { for (String value : enumValues) { if (StringUtils.equals(value, inputValue)) return true; }/* w w w.jav a 2 s . c om*/ return false; }
From source file:com.glaf.mail.web.rest.MailAccountResource.java
@POST @Path("/delete") public void deleteById(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String accountId = request.getParameter("accountId"); if (StringUtils.isEmpty(accountId)) { accountId = request.getParameter("id"); }/* ww w. j ava2 s .c o m*/ if (accountId != null) { String actorId = RequestUtils.getActorId(request); MailAccount mailAccount = mailAccountService.getMailAccount(accountId); if (mailAccount != null && StringUtils.equals(mailAccount.getCreateBy(), actorId)) { mailAccountService.deleteById(accountId); } } else { throw new WebApplicationException(Response.Status.NOT_FOUND); } }
From source file:com.glaf.mail.web.springmvc.MailStorageController.java
@RequestMapping public ModelAndView list(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); String x_query = request.getParameter("x_query"); if (StringUtils.equals(x_query, "true")) { Map<String, Object> paramMap = RequestUtils.getParameterMap(request); String x_complex_query = JsonUtils.encode(paramMap); x_complex_query = RequestUtils.encodeString(x_complex_query); request.setAttribute("x_complex_query", x_complex_query); } else {/*w w w.j a v a 2 s .co m*/ request.setAttribute("x_complex_query", ""); } String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = CustomProperties.getString("mailStorage.list"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/modules/mail/mailStorage/list", modelMap); }
From source file:ch.cyberduck.core.preferences.BundleApplicationResourcesFinder.java
protected NSBundle bundle(final NSBundle main, Local executable) { if (!executable.isSymbolicLink()) { return main; }//w w w . j a v a2s. c o m while (executable.isSymbolicLink()) { try { executable = executable.getSymlinkTarget(); } catch (NotfoundException | LocalAccessDeniedException e) { return main; } } Local folder = executable.getParent(); NSBundle b; do { b = NSBundle.bundleWithPath(folder.getAbsolute()); if (null == b) { log.error(String.format("Loading bundle %s failed", folder)); break; } if (StringUtils.equals(String.valueOf(Path.DELIMITER), b.bundlePath())) { break; } folder = folder.getParent(); } while (b.executablePath() == null); return b; }
From source file:de.knightsoftnet.validators.shared.data.ValueWithPosAndCountry.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }/*from w w w. java2 s .co m*/ if (!super.equals(obj)) { return false; } if (this.getClass() != obj.getClass()) { return false; } @SuppressWarnings("unchecked") final ValueWithPosAndCountry<E> other = (ValueWithPosAndCountry<E>) obj; return super.equals(other) && StringUtils.equals(this.country, other.country) && StringUtils.equals(this.language, other.language); }
From source file:com.glaf.core.web.springmvc.MxSchedulerLogController.java
@ResponseBody @RequestMapping("/delete") public byte[] delete(HttpServletRequest request, ModelMap modelMap) { LoginContext loginContext = RequestUtils.getLoginContext(request); logger.debug(RequestUtils.getParameterMap(request)); String id = RequestUtils.getString(request, "id"); String ids = request.getParameter("ids"); if (StringUtils.isNotEmpty(ids)) { StringTokenizer token = new StringTokenizer(ids, ","); while (token.hasMoreTokens()) { String x = token.nextToken(); if (StringUtils.isNotEmpty(x)) { SchedulerLog schedulerLog = schedulerLogService.getSchedulerLog(String.valueOf(x)); if (schedulerLog != null && (StringUtils.equals(schedulerLog.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { schedulerLogService.deleteById(schedulerLog.getId()); }/* www . ja va2 s .co m*/ } } return ResponseUtils.responseResult(true); } else if (id != null) { SchedulerLog schedulerLog = schedulerLogService.getSchedulerLog(String.valueOf(id)); if (schedulerLog != null && (StringUtils.equals(schedulerLog.getCreateBy(), loginContext.getActorId()) || loginContext.isSystemAdministrator())) { schedulerLogService.deleteById(schedulerLog.getId()); return ResponseUtils.responseResult(true); } } return ResponseUtils.responseResult(false); }
From source file:com.mirth.connect.plugins.datatypes.ncpdp.NCPDPReference.java
public String getDescription(String key, String version) { if (StringUtils.equals(version, VERSION_D0)) { return MapUtils.getString(NCPDPD0map, key, StringUtils.EMPTY); } else {/*w w w.j a va 2s . c o m*/ return MapUtils.getString(NCPDP51map, key, StringUtils.EMPTY); } }
From source file:net.dv8tion.jda.handle.PresenceUpdateHandler.java
@Override protected String handleInternally(JSONObject content) { if (!content.has("guild_id")) { return null; }// w w w . j a v a 2 s . c om if (GuildLock.get(api).isLocked(content.getString("guild_id"))) { return content.getString("guild_id"); } JSONObject jsonUser = content.getJSONObject("user"); String id = jsonUser.getString("id"); UserImpl user = (UserImpl) api.getUserMap().get(id); if (user == null) { //This is basically only received when a user has left a guild. Discord doesn't always send events // in order, so sometimes we get the presence updated after the GuildMemberLeave event has been received // thus there is no user which to apply a presence update to. //We don't cache this event because it is completely unneeded, furthermore it can (and probably will) // cause problems if the user rejoins the guild. return null; } if (jsonUser.has("username")) { String username = jsonUser.getString("username"); String discriminator = jsonUser.get("discriminator").toString(); String avatarId = jsonUser.isNull("avatar") ? null : jsonUser.getString("avatar"); if (!user.getUsername().equals(username)) { String oldUsername = user.getUsername(); user.setUserName(username); user.setDiscriminator(discriminator); api.getEventManager().handle(new UserNameUpdateEvent(api, responseNumber, user, oldUsername)); } String oldAvatar = user.getAvatarId(); if (!(avatarId == null && oldAvatar == null) && !StringUtils.equals(avatarId, oldAvatar)) { String oldAvatarId = user.getAvatarId(); user.setAvatarId(avatarId); api.getEventManager().handle(new UserAvatarUpdateEvent(api, responseNumber, user, oldAvatarId)); } } String gameName = null; String gameUrl = null; Game.GameType type = null; if (!content.isNull("game") && !content.getJSONObject("game").isNull("name")) { gameName = content.getJSONObject("game").get("name").toString(); gameUrl = (content.getJSONObject("game").isNull("url") ? null : content.getJSONObject("game").get("url").toString()); try { type = content.getJSONObject("game").isNull("type") ? Game.GameType.DEFAULT : Game.GameType .fromKey(Integer.parseInt(content.getJSONObject("game").get("type").toString())); } catch (NumberFormatException ex) { type = Game.GameType.DEFAULT; } } Game nextGame = (gameName == null ? null : new GameImpl(gameName, gameUrl, type)); OnlineStatus status = OnlineStatus.fromKey(content.getString("status")); if (!user.getOnlineStatus().equals(status)) { OnlineStatus oldStatus = user.getOnlineStatus(); user.setOnlineStatus(status); api.getEventManager().handle(new UserOnlineStatusUpdateEvent(api, responseNumber, user, oldStatus)); } if (user.getCurrentGame() == null ? nextGame != null : !user.getCurrentGame().equals(nextGame)) { Game oldGame = user.getCurrentGame(); user.setCurrentGame(nextGame); api.getEventManager().handle(new UserGameUpdateEvent(api, responseNumber, user, oldGame)); } api.getEventManager().handle(new GenericUserEvent(api, responseNumber, user)); return null; }
From source file:io.wcm.handler.media.spi.helpers.AbstractMediaHandlerConfig.java
@Override public double getDefaultImageQuality(String mimeType) { if (StringUtils.isNotEmpty(mimeType)) { String format = StringUtils.substringAfter(mimeType.toLowerCase(), "image/"); if (StringUtils.equals(format, "jpg") || StringUtils.equals(format, "jpeg")) { return DEFAULT_JPEG_QUALITY; } else if (StringUtils.equals(format, "gif")) { return 256d; // 256 colors }/*from w w w . ja v a 2 s . c om*/ } // return quality "1" for all other mime types return 1d; }