List of usage examples for org.apache.commons.lang3 StringUtils endsWithIgnoreCase
public static boolean endsWithIgnoreCase(final CharSequence str, final CharSequence suffix)
Case insensitive check if a CharSequence ends with a specified suffix.
null s are handled without exceptions.
From source file:org.kuali.coeus.common.questionnaire.impl.core.QuestionnaireMaintenanceDocumentRule.java
/** * //from w ww .j a va 2 s . c om * This method to check whether if the required fields are ok and whether name exists. * @param maintenanceDocument * @return */ private boolean validateQuestionnaire(MaintenanceDocument maintenanceDocument) { boolean valid = true; Questionnaire newQuestionnaire = (Questionnaire) maintenanceDocument.getNewMaintainableObject() .getDataObject(); MessageMap errorMap = GlobalVariables.getMessageMap(); if (StringUtils.isBlank(newQuestionnaire.getName())) { errorMap.putError("document.newMaintainableObject.businessObject.name", RiceKeyConstants.ERROR_REQUIRED, "Questionnaire Name"); valid = false; } if (StringUtils.isBlank(newQuestionnaire.getDescription())) { errorMap.putError("document.newMaintainableObject.businessObject.description", RiceKeyConstants.ERROR_REQUIRED, "Questionnaire Description"); valid = false; } if (getQuestionnaireService().isQuestionnaireNameExist(newQuestionnaire.getQuestionnaireSeqId(), newQuestionnaire.getName())) { errorMap.putError("document.newMaintainableObject.businessObject.name", KeyConstants.ERROR_QUESTIONNAIRE_NAME_EXIST); valid = false; } if (StringUtils.isNotBlank(newQuestionnaire.getFileName()) && !StringUtils.endsWithIgnoreCase(newQuestionnaire.getFileName(), ".xsl")) { errorMap.putError("document.newMaintainableObject.businessObject.fileName", KeyConstants.ERROR_QUESTIONNAIRE_FILENAME_INVALID); valid = false; } for (QuestionnaireQuestion questionnaireQuestion : newQuestionnaire.getQuestionnaireQuestions()) { if ((questionnaireQuestion.getQuestion() != null) && ("I".equals(questionnaireQuestion.getQuestion().getStatus()))) { errorMap.putError( "document.newMaintainableObject.businessObject.question" + newQuestionnaire.getQuestionnaireQuestions().indexOf(questionnaireQuestion), KeyConstants.ERROR_QUESTIONNAIRE_QUESTION_INACTIVE, questionnaireQuestion.getQuestion().getQuestion()); valid = false; } } if (newQuestionnaire.getObjectId() != null && checkForLatestQuuestionnaireSequenceNumber( newQuestionnaire.getId(), newQuestionnaire.getSequenceNumber())) { errorMap.putError("document.newMaintainableObject.businessObject.name", ALREADY_EDITED_ERROR, ""); valid = false; } for (QuestionnaireUsage usage : newQuestionnaire.getQuestionnaireUsages()) { if (usage.getCoeusSubModule() != null && usage.getCoeusSubModule().isRequireUniqueQuestionnareUsage() && !getQuestionnaireService().isUniqueUsage(newQuestionnaire, usage)) { errorMap.putError( "document.newMaintainableObject.businessObject.questionnaireUsages[" + newQuestionnaire.getQuestionnaireUsages().indexOf(usage) + "].moduleSubItemCode", KeyConstants.ERROR_QUESTIONNAIRE_DUPLICATE_USAGE); } } return valid; }
From source file:org.kuali.coeus.sys.framework.model.KcTransactionalDocumentFormBase.java
/** * This is a duplication of KualiTransactionalDocumentFormBase.populateFalseCheckboxes with the cavet that this function * puts a NULL in for fields that contain "answer", which are the field names of radio Y/N buttons for the questionnaire framework. * @see org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase#populateFalseCheckboxes(javax.servlet.http.HttpServletRequest) *///from w w w .ja va 2s. c o m @Override protected void populateFalseCheckboxes(HttpServletRequest request) { Map<String, String[]> parameterMap = request.getParameterMap(); final String checkBoxToResetFieldParam = "checkboxToReset"; if (parameterMap.get(checkBoxToResetFieldParam) != null) { final String[] checkboxesToResetFields = request.getParameterValues("checkboxToReset"); if (checkboxesToResetFields != null && checkboxesToResetFields.length > 0) { for (int i = 0; i < checkboxesToResetFields.length; i++) { String propertyName = (String) checkboxesToResetFields[i]; if (!StringUtils.isBlank(propertyName) && parameterMap.get(propertyName) == null) { if (this instanceof QuestionableFormInterface && (StringUtils.startsWithIgnoreCase(propertyName, ((QuestionableFormInterface) this).getQuestionnaireFieldStarter()) && StringUtils.containsIgnoreCase(propertyName, ((QuestionableFormInterface) this).getQuestionnaireFieldMiddle()) && StringUtils.endsWithIgnoreCase(propertyName, ((QuestionableFormInterface) this).getQuestionnaireFieldEnd()) || propertyName.matches( ((QuestionableFormInterface) this).getQuestionnaireExpression()))) { populateForProperty(propertyName, null, parameterMap); } else if (this instanceof MultiQuestionableFormInterface) { processMultiQuestionCheckBox(propertyName, parameterMap, (MultiQuestionableFormInterface) this); } else { populateForProperty(propertyName, KimConstants.KIM_ATTRIBUTE_BOOLEAN_FALSE_STR_VALUE_DISPLAY, parameterMap); } } else if (!StringUtils.isBlank(propertyName) && parameterMap.get(propertyName) != null && parameterMap.get(propertyName).length >= 1 && parameterMap.get(propertyName)[0].equalsIgnoreCase("on")) { populateForProperty(propertyName, KimConstants.KIM_ATTRIBUTE_BOOLEAN_TRUE_STR_VALUE_DISPLAY, parameterMap); } } } } }
From source file:org.kuali.coeus.sys.framework.model.KcTransactionalDocumentFormBase.java
protected void processMultiQuestionCheckBox(String propertyName, Map<String, String[]> parameterMap, MultiQuestionableFormInterface form) { boolean checkBoxFound = false; int j = 0;/*from w w w . j a v a 2 s. c om*/ for (String starter : form.getQuestionnaireFieldStarters()) { if (!checkBoxFound && StringUtils.startsWithIgnoreCase(propertyName, starter) && StringUtils.containsIgnoreCase(propertyName, form.getQuestionnaireFieldEnds()[j]) && StringUtils.endsWithIgnoreCase(propertyName, form.getQuestionnaireFieldEnds()[j])) { populateForProperty(propertyName, null, parameterMap); ; checkBoxFound = true; break; } j++; } if (!checkBoxFound) { populateForProperty(propertyName, KimConstants.KIM_ATTRIBUTE_BOOLEAN_FALSE_STR_VALUE_DISPLAY, parameterMap); } }
From source file:org.kuali.test.utils.Utils.java
/** * * @param configuration//from w ww.j a v a 2 s.c o m * @param testSuite * @return */ public static boolean removeTestSuite(KualiTestConfigurationDocument.KualiTestConfiguration configuration, TestSuite testSuite) { boolean retval = false; if (testSuite != null) { Platform platform = findPlatform(configuration, testSuite.getPlatformName()); if (platform != null) { TestSuite[] testSuites = platform.getTestSuites().getTestSuiteArray(); int indx = -1; for (int i = 0; i < testSuites.length; ++i) { if (StringUtils.endsWithIgnoreCase(testSuites[i].getName(), testSuite.getName())) { indx = i; break; } } if (indx > -1) { platform.getTestSuites().removeTestSuite(indx); retval = true; } } } return retval; }
From source file:org.lockss.config.ConfigManager.java
public static boolean shouldParamBeLogged(String key) { return !(key.startsWith(PREFIX_TITLE_DB) || key.startsWith(PREFIX_TITLE_SETS_DOT) || key.startsWith(PluginManager.PARAM_AU_TREE + ".") || StringUtils.endsWithIgnoreCase(key, "password")); }
From source file:org.mariotaku.twidere.loader.MediaTimelineLoader.java
@NonNull @Override/*ww w . j a va2s . c o m*/ protected ResponseList<Status> getStatuses(@NonNull final MicroBlog microBlog, @NonNull final ParcelableCredentials credentials, @NonNull final Paging paging) throws MicroBlogException { final Context context = getContext(); switch (ParcelableAccountUtils.getAccountType(credentials)) { case ParcelableAccount.Type.TWITTER: { if (Utils.isOfficialCredentials(context, credentials)) { if (mUserKey != null) { return microBlog.getMediaTimeline(mUserKey.getId(), paging); } if (mUserScreenName != null) { return microBlog.getMediaTimelineByScreenName(mUserScreenName, paging); } } else { final String screenName; if (mUserScreenName != null) { screenName = mUserScreenName; } else if (mUserKey != null) { if (mUser == null) { mUser = TwitterWrapper.tryShowUser(microBlog, mUserKey.getId(), null, credentials.account_type); } screenName = mUser.getScreenName(); } else { throw new MicroBlogException("Invalid parameters"); } final SearchQuery query; if (MicroBlogAPIFactory.isTwitterCredentials(credentials)) { query = new SearchQuery("from:" + screenName + " filter:media exclude:retweets"); } else { query = new SearchQuery("@" + screenName + " pic.twitter.com -RT"); } query.paging(paging); final ResponseList<Status> result = new ResponseList<>(); for (Status status : microBlog.search(query)) { final User user = status.getUser(); if ((mUserKey != null && TextUtils.equals(user.getId(), mUserKey.getId())) || StringUtils.endsWithIgnoreCase(user.getScreenName(), mUserScreenName)) { result.add(status); } } return result; } throw new MicroBlogException("Wrong user"); } case ParcelableAccount.Type.FANFOU: { if (mUserKey != null) { return microBlog.getPhotosUserTimeline(mUserKey.getId(), paging); } if (mUserScreenName != null) { return microBlog.getPhotosUserTimeline(mUserScreenName, paging); } throw new MicroBlogException("Wrong user"); } } throw new MicroBlogException("Not implemented"); }
From source file:org.mariotaku.twidere.util.net.TwidereDns.java
private static boolean hostMatches(final String host, final String rule) { if (rule == null || host == null) return false; if (rule.startsWith(".")) return StringUtils.endsWithIgnoreCase(host, rule); return host.equalsIgnoreCase(rule); }
From source file:org.mitre.mpf.mvc.controller.MarkupController.java
@RequestMapping(value = "/markup/content", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE) @ResponseBody/*from w ww . jav a 2s . c o m*/ public void serve(HttpServletResponse response, @RequestParam(value = "id", required = true) long id) throws IOException, URISyntaxException { MarkupResult mediaMarkupResult = mpfService.getMarkupResult(id); if (mediaMarkupResult != null) { //only on image! if (!StringUtils.endsWithIgnoreCase(mediaMarkupResult.getMarkupUri(), "avi")) { String nonUrlPath = mediaMarkupResult.getMarkupUri().replace("file:", ""); File f = new File(nonUrlPath); if (f.canRead()) { FileUtils.copyFile(f, response.getOutputStream()); response.flushBuffer(); } } } //TODO need a no image available if final nested if is not met }
From source file:org.mskcc.cbio.oncokb.util.AlterationUtils.java
private static boolean itemFromSetAtEndString(String inputString, Set<String> items) { for (String item : items) { if (StringUtils.endsWithIgnoreCase(inputString, item)) { return true; }//from ww w. j a va 2 s . co m } return false; }
From source file:org.openlca.io.EcoSpoldUnitFetch.java
/** * Get the units from the given files. Allowed input are zip and xml files. *//* ww w .j av a2s. c o m*/ public String[] getUnits(File[] files) throws Exception { units.clear(); for (File file : files) { if (StringUtils.endsWithIgnoreCase(file.getName(), ".xml")) parser.parse(file, handler); else if (StringUtils.endsWithIgnoreCase(file.getName(), ".zip")) { try (ZipFile zip = new ZipFile(file)) { parseZip(zip); } } } return units.toArray(new String[units.size()]); }