List of usage examples for org.apache.commons.lang StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(String str1, String str2)
Compares two Strings, returning true
if they are equal ignoring the case.
From source file:com.adobe.acs.commons.wcm.impl.AemEnvironmentIndicatorFilter.java
@Override @SuppressWarnings("squid:S3776") public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { if (!(servletRequest instanceof HttpServletRequest) || !(servletResponse instanceof HttpServletResponse)) { filterChain.doFilter(servletRequest, servletResponse); return;/* w w w . j a v a 2 s . c o m*/ } final HttpServletRequest request = (HttpServletRequest) servletRequest; final HttpServletResponse response = (HttpServletResponse) servletResponse; if (!this.accepts(request)) { filterChain.doFilter(request, response); return; } final BufferingResponse capturedResponse = new BufferingResponse(response); filterChain.doFilter(request, capturedResponse); boolean doInclude = true; if (ArrayUtils.isNotEmpty(excludedWCMModes)) { // Test for configured WCM modes, where the indicators are not displayed WCMMode wcmmode = extractFromRequest(request); if (wcmmode != null) { for (String m : excludedWCMModes) { if (StringUtils.equalsIgnoreCase(wcmmode.name(), m)) { doInclude = false; break; } } } else { // No wcmmode could be extracted from the request } } // Get contents final String contents = capturedResponse.getContents(); if (doInclude && contents != null && StringUtils.contains(response.getContentType(), "html")) { final int bodyIndex = contents.indexOf("</body>"); if (bodyIndex != -1) { final PrintWriter printWriter = response.getWriter(); printWriter.write(contents.substring(0, bodyIndex)); if (StringUtils.isNotBlank(css)) { printWriter.write("<style>" + css + " </style>"); printWriter.write("<div id=\"" + DIV_ID + "\">" + innerHTML + "</div>"); } if (StringUtils.isNotBlank(titlePrefix)) { printWriter.printf(TITLE_UPDATE_SCRIPT, titlePrefix); } printWriter.write(contents.substring(bodyIndex)); return; } } if (contents != null) { response.getWriter().write(contents); } }
From source file:com.sfs.whichdoctor.dao.BulkEmailDAOImpl.java
/** * Delete an email message (flag as non-active). * * @param bulkEmail the bulk email/*from w w w . ja v a 2 s . c o m*/ * @param checkUser the check user * @param privileges the privileges * @return true, if successful * @throws WhichDoctorDaoException the which doctor dao exception */ public final boolean delete(final BulkEmailBean bulkEmail, final UserBean checkUser, final PrivilegesBean privileges) throws WhichDoctorDaoException { boolean success = false; if (!StringUtils.equalsIgnoreCase(checkUser.getDN(), bulkEmail.getCreatedBy())) { if (!privileges.getPrivilege(checkUser, "systemAdmin", "modify")) { // The user trying to delete the BulkEmailBean does not own // the object or is not a system administrator. throw new WhichDoctorDaoException("Insufficient user " + "credentials to delete bulk email"); } } bulkEmail.setActive(false); int deleteId = save(bulkEmail, checkUser, "delete"); if (deleteId > 0) { success = true; } return success; }
From source file:hydrograph.ui.engine.ui.converter.impl.OutputFileExcelUiConverter.java
private ExcelFormattingDataStructure getExcelFormat() { ExcelFile excelFile = (ExcelFile) typeBaseComponent; CellFormat cellFormat = excelFile.getCellFormat(); FieldFormat data = cellFormat.getData(); FieldFormat header = cellFormat.getHeader(); String dataCopyOfField;/* w w w . ja va 2 s .co m*/ ExcelFormattingDataStructure excelFormattingDataStructure = new ExcelFormattingDataStructure(); List<String> dataCopyFieldList = data.getField().stream().filter( x -> (null != x.getCopyOfFiled() && StringUtils.isNotEmpty(x.getCopyOfFiled().getFieldName()))) .map(m -> m.getName()).collect(Collectors.toList()); if (dataCopyFieldList != null && dataCopyFieldList.size() > 0) { dataCopyOfField = data.getField().stream().filter( x -> (null != x.getCopyOfFiled() && StringUtils.isNotEmpty(x.getCopyOfFiled().getFieldName()))) .collect(Collectors.toList()).get(0).getCopyOfFiled().getFieldName(); } else { dataCopyOfField = "Select"; } List<ExcelConfigurationDataStructure> listEcds = data.getField().stream() .filter(x -> (null != x.getProperty() && x.getProperty().size() > 0)).map(m -> { ExcelConfigurationDataStructure ecds = new ExcelConfigurationDataStructure(); ecds.setFieldName(m.getName()); Map<String, String> fieldDatapropMap = m.getProperty().stream().collect(Collectors .toMap(FieldFormat.Field.Property::getName, FieldFormat.Field.Property::getValue)); ecds.setDataMap(fieldDatapropMap); Map<String, String> fieldHeaderPropMap = header.getField().stream() .filter(hf -> (StringUtils.equalsIgnoreCase(hf.getName(), m.getName()))).findFirst() .get().getProperty().stream().collect(Collectors.toMap( FieldFormat.Field.Property::getName, FieldFormat.Field.Property::getValue)); ecds.setHeaderMap(fieldHeaderPropMap); return ecds; }).collect(Collectors.toList()); excelFormattingDataStructure.setCopyFieldList(dataCopyFieldList); excelFormattingDataStructure.setCopyOfField(dataCopyOfField); excelFormattingDataStructure.setListOfExcelConfiguration(listEcds); return excelFormattingDataStructure; }
From source file:ddf.catalog.solr.external.SolrHttpCatalogProvider.java
/** * Updates the configuration of the Solr Server if necessary * * @param urlValue - url to the Solr Server *//*www . j ava2 s . co m*/ public void updateClient(String urlValue) { LOGGER.info("New url {}", urlValue); if (urlValue != null) { if (!StringUtils.equalsIgnoreCase(urlValue.trim(), url) || getClient() == null) { url = urlValue.trim(); if (getClient() != null) { LOGGER.info( "Shutting down the connection manager to the Solr Server and releasing allocated resources."); try { getClient().close(); } catch (IOException e) { LOGGER.warn("Unable to close Solr client", e); } LOGGER.info("Shutdown complete."); } updateClient(); } } else { // sets to null url = null; } }
From source file:com.adobe.acs.commons.quickly.operations.impl.LastModifiedOperationImpl.java
private String getUserIdParam(final Command cmd, String currentUserId) { final String[] params = cmd.getParams(); if (params.length > 0) { String param = params[0]; if (StringUtils.isNotBlank(param) && !StringUtils.equalsIgnoreCase(param, "me") && !param.matches("\\d+[s|m|h|d|w|M|y]{1}")) { return param; }/* w ww . j a v a2 s . c om*/ } return currentUserId; }
From source file:com.adobe.acs.commons.forms.helpers.impl.PostFormHelperImpl.java
/** * Determines of this FormHelper should handle the POST request * * @param formName//from w ww .j a v a 2 s. c om * @param request * @return */ protected boolean doHandlePost(final String formName, final SlingHttpServletRequest request) { if (StringUtils.equalsIgnoreCase("POST", request.getMethod())) { // Form should have a hidden input with the name this.getLookupKey(..) and value formName return StringUtils.equals(formName, request.getParameter(this.getPostLookupKey(formName))); } else { return false; } }
From source file:info.magnolia.cms.filters.InterceptFilter.java
/** * Request and Response here is same as received by the original page so it includes all post/get data. Sub action * could be called from here once this action finishes, it will continue loading the requested page. * @throws RepositoryException//ww w . j a v a 2 s. c o m * @throws LoginException */ public void intercept(HttpServletRequest request, HttpServletResponse response) throws LoginException, RepositoryException { final AggregationState aggregationState = MgnlContext.getAggregationState(); String action = request.getParameter(INTERCEPT); String repository = request.getParameter(PARAM_REPOSITORY); String nodePath = request.getParameter(PARAM_PATH); String handle = aggregationState.getHandle(); String channel = aggregationState.getChannel().getName(); if (repository == null) { repository = aggregationState.getRepository(); } if (repository == null) { repository = RepositoryConstants.WEBSITE; } final Session session = MgnlContext.getJCRSession(repository); if (ACTION_PREVIEW.equals(action)) { // preview mode (button in main bar) String preview = request.getParameter(MGNL_PREVIEW_ATTRIBUTE); log.debug("preview request parameter value is {} ", preview); if (preview != null) { if (Boolean.parseBoolean(preview)) { MgnlContext.setAttribute(MGNL_PREVIEW_ATTRIBUTE, Boolean.TRUE, Context.SESSION_SCOPE); MgnlContext.setAttribute(MultiChannelFilter.ENFORCE_CHANNEL_PARAMETER, channel, Context.SESSION_SCOPE); } else { MgnlContext.removeAttribute(MGNL_PREVIEW_ATTRIBUTE, Context.SESSION_SCOPE); MgnlContext.removeAttribute(MultiChannelFilter.ENFORCE_CHANNEL_PARAMETER, Context.SESSION_SCOPE); } } else { MgnlContext.removeAttribute(MGNL_PREVIEW_ATTRIBUTE, Context.SESSION_SCOPE); MgnlContext.removeAttribute(MultiChannelFilter.ENFORCE_CHANNEL_PARAMETER, Context.SESSION_SCOPE); } } else if (ACTION_NODE_DELETE.equals(action)) { // delete paragraph try { Node page = session.getNode(handle); session.removeItem(nodePath); MetaDataUtil.updateMetaData(page); session.save(); } catch (RepositoryException e) { log.error("Exception caught: {}", e.getMessage(), e); } } else if (ACTION_NODE_SORT.equals(action)) { // sort paragraphs try { String pathSelected = request.getParameter(PARAM_PATH_SELECTED); String pathTarget = request.getParameter(PARAM_PATH_TARGET); String pathParent = StringUtils.substringBeforeLast(pathSelected, "/"); String srcName = StringUtils.substringAfterLast(pathSelected, "/"); String destName = StringUtils.substringAfterLast(pathTarget, "/"); String order = StringUtils.defaultIfEmpty(request.getParameter("order"), "before"); if (StringUtils.equalsIgnoreCase(destName, "mgnlNew")) { destName = null; } Node parent = session.getNode(pathParent + srcName); if ("before".equals(order)) { NodeUtil.orderBefore(parent, destName); } else { NodeUtil.orderAfter(parent, destName); } Node page = session.getNode(handle); MetaDataUtil.updateMetaData(page); session.save(); } catch (RepositoryException e) { log.error("Exception caught: {}", e.getMessage(), e); } } else { log.warn("Unknown action {}", action); } }
From source file:com.edgenius.core.model.User.java
public boolean equals(Object obj) { if (!(obj instanceof User)) { return false; }// www . j a va2 s . c om return StringUtils.equalsIgnoreCase(((User) obj).username, username); }
From source file:com.edgenius.wiki.service.impl.FriendServiceImpl.java
public void makeFriendsWithSpaceGroups(String spaceUname, List<String> roleNameList) { if (roleNameList == null || roleNameList.size() == 0) { log.info("No new role updated in given input."); return;//w w w . j ava 2s.c o m } //skip all non-space role, such as system role for (Iterator<String> iter = roleNameList.iterator(); iter.hasNext();) { String roleName = iter.next(); if (!roleName.startsWith(Role.SPACE_ROLE_PREFIX)) iter.remove(); } if (roleNameList.size() == 0) { log.info("All roles is system role, no need continue to check friendship."); return; } //get all available roles(type must be ROLE.TYPE_SPACE) for this space currently. List<String> availRoleList = new ArrayList<String>(); Resource res = resourceDAO.getByName(spaceUname); Set<Permission> perms = res.getPermissions(); if (perms != null) { for (Permission perm : perms) { Set<Role> roles = perm.getRoles(); if (roles != null) { for (Role role : roles) { if (role.getType() != Role.TYPE_SPACE) continue; availRoleList.add(role.getName()); } } } } //filter out which role is new added List<String> newRoleList = new ArrayList<String>(); for (String name : roleNameList) { boolean found = false; for (String exist : availRoleList) { if (StringUtils.equalsIgnoreCase(exist, name)) { found = true; break; } } if (!found) { newRoleList.add(name); } } if (newRoleList.size() == 0) { log.info("Given new role list does not contain any new added role for space " + spaceUname); } else { //OK, find new added role for this space. check if it is in friends list already int prefixLen = Role.SPACE_ROLE_PREFIX.length(); for (String newSpace : newRoleList) { //get space name from newSpace = newSpace.substring(prefixLen); Friend frd = friendDAO.getFriendship(Friend.PREFIX_SPACE + spaceUname, Friend.PREFIX_SPACE + newSpace); if (frd != null && frd.isConfirmed()) { continue; } if (frd == null) { //CREATE Pending friendship frd = new Friend(); frd.setSender(Friend.PREFIX_SPACE + spaceUname); frd.setReceiver(Friend.PREFIX_SPACE + newSpace); WikiUtil.setTouchedInfo(userReadingService, frd); frd.setStatus(Friend.STATUS_PENDING); friendDAO.saveOrUpdate(frd); //send message String text = "Space " + spaceUname + " adds your space " + newSpace + " on its friend list."; // "{action:id="+rejectFriendship+ "|title=reject|confirmMessage=Do you want to reject this request?|" + // "sender="+spaceUname+"|receiver="+newSpace // +"} or {action:id="+acceptFriendship+"|title=accept|confirmMessage=Do you want to accept this request?|" + // "sender="+spaceUname+"|receiver="+newSpace+"}"; notificationService.sendMessage(text, SharedConstants.MSG_TARGET_SPACE_ADMIN_ONLY, newSpace, NotificationService.SEND_MAIL_ONLY_HAS_RECEIVERS); //send request email Set<String> userMails = userReadingService.getSpaceAdminMailList(newSpace); for (String mail : userMails) { try { SimpleMailMessage msg = new SimpleMailMessage(); msg.setFrom(Global.DefaultNotifyMail); Map<String, Object> map = new HashMap<String, Object>(); map.put("sender", spaceUname); map.put("receiver", newSpace); map.put(WikiConstants.ATTR_PAGE_LINK, WebUtil.getHostAppURL() + "invite!friendship.do?sender=" + URLEncoder.encode(spaceUname, Constants.UTF8) + "&receiver=" + URLEncoder.encode(newSpace, Constants.UTF8)); msg.setTo(mail); mailService.sendPlainMail(msg, WikiConstants.MAIL_TEMPL_FRIENDSHIP, map); } catch (Exception e) { log.error("Failed send friendship email:" + mail, e); } } } //reject,pending do nothing } } }