List of usage examples for org.apache.commons.lang StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(String str, String searchStr)
Checks if String contains a search String irrespective of case, handling null
.
From source file:com.iyonger.apm.web.controller.FileEntryController.java
/** * Search files on the query./*from www . ja v a 2 s .c o m*/ * * @param user current user * @param query query string * @param model model * @return script/list */ @RequestMapping(value = "/search/**") public String search(User user, @RequestParam(required = true, value = "query") final String query, ModelMap model) { final String trimmedQuery = StringUtils.trimToEmpty(query); List<FileEntry> searchResult = newArrayList( filter(fileEntryService.getAll(user), new Predicate<FileEntry>() { @Override public boolean apply(@Nullable FileEntry input) { return input.getFileType() != FileType.DIR && StringUtils .containsIgnoreCase(new File(input.getPath()).getName(), trimmedQuery); } })); model.addAttribute("query", query); model.addAttribute("files", searchResult); model.addAttribute("currentPath", ""); return "script/list"; }
From source file:com.tesora.dve.common.PEFileUtils.java
private static String getCanonicalPathFromURL(final URL url) throws PEException { File resourceFile;/*w ww . j a v a 2s. c o m*/ try { final String os = System.getProperty("os.name"); if (StringUtils.containsIgnoreCase(os, "win")) { return url.getFile(); } resourceFile = new File(url.toURI()); } catch (final URISyntaxException e) { resourceFile = new File(url.getPath()); } try { return resourceFile.getCanonicalPath(); } catch (final IOException e) { throw new PEException("Could not canonicalize the path '" + resourceFile.getAbsolutePath() + "'", e); } }
From source file:adalid.commons.properties.PropertiesHandler.java
public static void printExtendedProperties(ExtendedProperties extendedProperties) { ArrayList<String> list = new ArrayList<>(); for (Iterator i = extendedProperties.getKeys(); i.hasNext();) { list.add((String) i.next()); }/*w ww .jav a 2s . c om*/ String[] names = new String[list.size()]; list.toArray(names); Arrays.sort(names); String[] values; for (String name : names) { values = extendedProperties.getStringArray(name); logger.trace(name + " = " + (StringUtils.containsIgnoreCase(name, "password") ? "***" : getArrayString(values))); } }
From source file:com.gst.infrastructure.reportmailingjob.service.ReportMailingJobWritePlatformServiceImpl.java
@Override @CronTarget(jobName = JobName.EXECUTE_REPORT_MAILING_JOBS) public void executeReportMailingJobs() throws JobExecutionException { final Collection<ReportMailingJob> reportMailingJobCollection = this.reportMailingJobRepository .findByIsActiveTrueAndIsDeletedFalse(); for (ReportMailingJob reportMailingJob : reportMailingJobCollection) { // get the tenant's date as a DateTime object final DateTime localDateTimeOftenant = DateUtils.getLocalDateTimeOfTenant().toDateTime(); final DateTime nextRunDateTime = reportMailingJob.getNextRunDateTime(); if (nextRunDateTime != null && nextRunDateTime.isBefore(localDateTimeOftenant)) { // get the emailAttachmentFileFormat enum object final ReportMailingJobEmailAttachmentFileFormat emailAttachmentFileFormat = ReportMailingJobEmailAttachmentFileFormat .newInstance(reportMailingJob.getEmailAttachmentFileFormat()); if (emailAttachmentFileFormat != null && emailAttachmentFileFormat.isValid()) { final Report stretchyReport = reportMailingJob.getStretchyReport(); final String reportName = (stretchyReport != null) ? stretchyReport.getReportName() : null; final StringBuilder errorLog = new StringBuilder(); final Map<String, String> validateStretchyReportParamMap = this.reportMailingJobValidator .validateStretchyReportParamMap(reportMailingJob.getStretchyReportParamMap()); MultivaluedMap<String, String> reportParams = new MultivaluedMapImpl(); if (validateStretchyReportParamMap != null) { Iterator<Map.Entry<String, String>> validateStretchyReportParamMapEntries = validateStretchyReportParamMap .entrySet().iterator(); while (validateStretchyReportParamMapEntries.hasNext()) { Map.Entry<String, String> validateStretchyReportParamMapEntry = validateStretchyReportParamMapEntries .next(); String key = validateStretchyReportParamMapEntry.getKey(); String value = validateStretchyReportParamMapEntry.getValue(); if (StringUtils.containsIgnoreCase(key, "date")) { ReportMailingJobStretchyReportParamDateOption reportMailingJobStretchyReportParamDateOption = ReportMailingJobStretchyReportParamDateOption .newInstance(value); if (reportMailingJobStretchyReportParamDateOption.isValid()) { value = ReportMailingJobDateUtil .getDateAsString(reportMailingJobStretchyReportParamDateOption); }/*from ww w. j ava 2 s . c o m*/ } reportParams.add(key, value); } } // generate the report output stream, method in turn call another that sends the file to the email recipients this.generateReportOutputStream(reportMailingJob, emailAttachmentFileFormat, reportParams, reportName, errorLog); // update the previous run time, next run time, status, error log properties this.updateReportMailingJobAfterJobExecution(reportMailingJob, errorLog, localDateTimeOftenant); } } } }
From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java
private void jchkCompletedActionPerformed(ActionEvent evt) { String todoName = (String) jcbTodos.getSelectedItem(); boolean isCompletedTodo = StringUtils.containsIgnoreCase(todoName, CoreObject.getConfig().getString(Constants.CONFIG_COMPLETED_ITEM_TAG)); if (jchkCompleted.isSelected() && !isCompletedTodo) { String message = "This to-do item will be marked as completed. Are you sure to continue?"; String title = "Complete To-Do Item"; int optionType = JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; int selectedOption = JOptionPane.showOptionDialog(this, message, title, optionType, messageType, null, null, null);//from ww w . j a va2 s. c o m if (selectedOption == JOptionPane.YES_OPTION) { String todoDescription = (String) jcbTodos.getSelectedItem(); BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription); Integer todoItemId = todoItem.getId(); String statusCode = BasecampBusiness.completeTodoItem(todoItemId.toString()); if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) { jtfHours.setText("0"); jDateChooser_IL.setDate(new Date()); jchkCompleted.setSelected(false); jtfDescription.setText(""); CoreObject.reloadTodoMap(); lblMessages.setText("ToDo has been completed!"); } else { lblMessages.setText("Failed! Status: " + statusCode); } } else { jchkCompleted.setSelected(false); } } else { if (isCompletedTodo) { String message = "This to-do item will be marked as uncompleted. Are you sure to activate the item?"; String title = "Activate To-Do Item"; int optionType = JOptionPane.YES_NO_OPTION; int messageType = JOptionPane.QUESTION_MESSAGE; int selectedOption = JOptionPane.showOptionDialog(this, message, title, optionType, messageType, null, null, null); if (selectedOption == JOptionPane.YES_OPTION) { String todoDescription = (String) jcbTodos.getSelectedItem(); BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription); Integer todoItemId = todoItem.getId(); String statusCode = BasecampBusiness.uncompleteTodoItem(todoItemId.toString()); if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) { jtfHours.setText("0"); jDateChooser_IL.setDate(new Date()); jchkCompleted.setSelected(false); jtfDescription.setText(""); CoreObject.reloadTodoMap(); lblMessages.setText("ToDo is now active!"); } else { lblMessages.setText("Failed! Status: " + statusCode); } } else { jchkCompleted.setSelected(true); } } } }
From source file:edu.monash.merc.system.parser.nextprot.NXHandler.java
private NXPeTeOthEntryBean createPeTeOthEvidencesBean(String evidence, String nxAccession) { if (StringUtils.isNotBlank(evidence)) { //create NXPeTeOthEntryBean to store peOthCur Evidence and teOthCur Evidence NXPeTeOthEntryBean nxPeTeOthEntryBean = new NXPeTeOthEntryBean(); //nextprot pe oth cur evidence PEEvidenceBean nxPeOthEvidenceBean = new PEEvidenceBean(); //If it's protein level, we set the evidence level as green level, else we set it as black for pe if (StringUtils.containsIgnoreCase(evidence, NXFields.EV_PROTEIN_LEVEL)) { nxPeOthEvidenceBean.setColorLevel(ColorType.GREEN.color()); } else {//www . ja v a2 s . co m nxPeOthEvidenceBean.setColorLevel(ColorType.BLACK.color()); } //create a TPBDataTypeBean for PE Oth Cur TPBDataTypeBean peOthCurTDT = new TPBDataTypeBean(); //set the data type peOthCurTDT.setDataType(DataType.PE_OTH_CUR.type()); //set the traffic lights level to 3 peOthCurTDT.setLevel(TLLevel.TL3.level()); nxPeOthEvidenceBean.setTpbDataTypeBean(peOthCurTDT); nxPeOthEvidenceBean.setEvidenceValue(evidence); nxPeOthEvidenceBean.setHyperlink(NXFields.NX_BASE_URL + nxAccession); //Nextprot te oth cur evidence TEEvidenceBean nxTeOthEvidenceBean = new TEEvidenceBean(); if (StringUtils.containsIgnoreCase(evidence, NXFields.EV_PROTEIN_LEVEL) || StringUtils.containsIgnoreCase(evidence, NXFields.EV_TRANSCRIPT_LEVEL)) { nxTeOthEvidenceBean.setColorLevel(ColorType.GREEN.color()); } else { nxTeOthEvidenceBean.setColorLevel(ColorType.BLACK.color()); } //create a TPBDataTypeBean for TE Oth Cur TPBDataTypeBean teOthCurTDT = new TPBDataTypeBean(); //set the data type teOthCurTDT.setDataType(DataType.TE_OTH_CUR.type()); //set the traffic lights level to 3 teOthCurTDT.setLevel(TLLevel.TL3.level()); nxTeOthEvidenceBean.setTpbDataTypeBean(teOthCurTDT); nxTeOthEvidenceBean.setEvidenceValue(evidence); nxTeOthEvidenceBean.setHyperlink(NXFields.NX_BASE_URL + nxAccession); //add these two evidence beans nxPeTeOthEntryBean.setNxPeOthEvidenceBean(nxPeOthEvidenceBean); nxPeTeOthEntryBean.setNxTeOthEvidenceBean(nxTeOthEvidenceBean); return nxPeTeOthEntryBean; } return null; }
From source file:io.swagger.api.impl.ToolsApiServiceImpl.java
@Override public Response toolsIdVersionsVersionIdTypeDescriptorGet(String type, String id, String versionId, SecurityContext securityContext) throws NotFoundException { SourceFile.FileType fileType = getFileType(type); if (fileType == null) { return Response.status(Response.Status.NOT_FOUND).build(); }/*from w w w . j a v a2 s. c om*/ return getFileByToolVersionID(id, versionId, fileType, null, StringUtils.containsIgnoreCase(type, "plain")); }
From source file:com.cubusmail.mail.util.MessageUtils.java
/** * @param mailFolder/* w w w. j a v a 2s.com*/ * @param msgs * @param extendedSearchFields * @param params * @return */ public static Message[] filterMessages(IMailFolder mailFolder, Message[] msgs, String extendedSearchFields, String[][] params) { if (!StringUtils.isEmpty(extendedSearchFields)) { String[] fields = StringUtils.split(extendedSearchFields, ','); List<Message> filteredMsgs = new ArrayList<Message>(); String fromValue = getParamValue(params, SearchFields.FROM.name()); String toValue = getParamValue(params, SearchFields.TO.name()); String ccValue = getParamValue(params, SearchFields.CC.name()); String subjectValue = getParamValue(params, SearchFields.SUBJECT.name()); String contentValue = getParamValue(params, SearchFields.CONTENT.name()); String dateFromValue = getParamValue(params, SearchFields.DATE_FROM.name()); String dateToValue = getParamValue(params, SearchFields.DATE_TO.name()); try { // Body search if (StringUtils.contains(extendedSearchFields, SearchFields.CONTENT.name())) { BodyTerm term = new BodyTerm(contentValue); msgs = mailFolder.search(term, msgs); if (msgs == null) { msgs = new Message[0]; } } for (Message message : msgs) { boolean contains = true; for (String searchField : fields) { if (SearchFields.FROM.name().equals(searchField)) { String from = MessageUtils.getMailAdressString(message.getFrom(), AddressStringType.COMPLETE); contains = StringUtils.containsIgnoreCase(from, fromValue); } if (contains && SearchFields.TO.name().equals(searchField)) { String to = MessageUtils.getMailAdressString( message.getRecipients(Message.RecipientType.TO), AddressStringType.COMPLETE); if (!StringUtils.isEmpty(to)) { contains = StringUtils.containsIgnoreCase(to, toValue); } else { contains = false; } } if (contains && SearchFields.CC.name().equals(searchField)) { String cc = MessageUtils.getMailAdressString( message.getRecipients(Message.RecipientType.CC), AddressStringType.COMPLETE); if (!StringUtils.isEmpty(cc)) { contains = StringUtils.containsIgnoreCase(cc, ccValue); } else { contains = false; } } if (contains && SearchFields.SUBJECT.name().equals(searchField)) { if (!StringUtils.isEmpty(message.getSubject())) { contains = StringUtils.containsIgnoreCase(message.getSubject(), subjectValue); } else { contains = false; } } if (contains && SearchFields.DATE_FROM.name().equals(searchField)) { Date dateFrom = new Date(Long.parseLong(dateFromValue)); if (message.getSentDate() != null) { contains = !message.getSentDate().before(dateFrom); } else { contains = false; } } if (contains && SearchFields.DATE_TO.name().equals(searchField)) { Date dateTo = new Date(Long.parseLong(dateToValue)); if (message.getSentDate() != null) { contains = !message.getSentDate().after(dateTo); } else { contains = false; } } } if (contains) { filteredMsgs.add(message); } } } catch (MessagingException ex) { log.warn(ex.getMessage()); } return filteredMsgs.toArray(new Message[0]); } return msgs; }
From source file:id.ac.idu.webui.administrasi.pegawai.MpegawaiDetailCtrl.java
public void onClick$btnFoto(Event event) throws InterruptedException { try {/*from ww w . j a v a2 s . co m*/ image.setContent(new org.zkoss.image.AImage(new URL(txtb_foto.getValue()))); } catch (MalformedURLException e) { ZksampleMessageUtils.showErrorMessage("Harap masukkan protokol, contoh: Http://"); } catch (IOException e) { ZksampleMessageUtils.showErrorMessage("Gambar tidak bisa dibaca atau ditemukan"); } catch (IllegalArgumentException e) { if (StringUtils.containsIgnoreCase(e.toString(), "host = null")) { ZksampleMessageUtils.showErrorMessage("Harap masukkan host, contoh: Http://host.com"); } } catch (NullPointerException e) { ZksampleMessageUtils.showErrorMessage("URL yang anda masukkan salah"); } }
From source file:ddf.security.assertion.impl.SecurityAssertionImpl.java
@Override public Set<Principal> getPrincipals() { Set<Principal> principals = new HashSet<>(); Principal primary = getPrincipal(); principals.add(primary);//from www . ja v a2 s. c o m principals.add(new RolePrincipal(primary.getName())); for (AttributeStatement attributeStatement : getAttributeStatements()) { for (Attribute attr : attributeStatement.getAttributes()) { if (StringUtils.containsIgnoreCase(attr.getName(), "role")) { for (final XMLObject obj : attr.getAttributeValues()) { principals.add(new RolePrincipal(((XSString) obj).getValue())); } } } } return principals; }