List of usage examples for org.apache.commons.lang StringUtils startsWithIgnoreCase
public static boolean startsWithIgnoreCase(String str, String prefix)
Case insensitive check if a String starts with a specified prefix.
From source file:org.onehippo.forge.exdocpicker.impl.field.tree.ExternalTreeItemFieldBrowserDialog.java
/** * Constructs external document(s) picker dialog. * @param titleModel title model//from w ww . java 2 s . c o m * @param extDocServiceContext {@link ExternalDocumentServiceContext} instance * @param exdocService {@link ExternalDocumentServiceFacade} instance * @param model the model containing the currently selected external documents in the document node data */ public ExternalTreeItemFieldBrowserDialog(IModel<String> titleModel, final ExternalDocumentServiceContext extDocServiceContext, final ExternalDocumentServiceFacade<Serializable> exdocService, IModel<ExternalDocumentCollection<Serializable>> model) { super(titleModel, extDocServiceContext, exdocService, model); final String themeName = extDocServiceContext.getPluginConfig().getString( PluginConstants.PARAM_EXTERNAL_TREE_VIEW_THEME, PluginConstants.DEFAULT_EXTERNAL_TREE_VIEW_THEME); if (StringUtils.startsWithIgnoreCase(themeName, "window")) { theme = new WindowsTheme(); } else { theme = new HumanTheme(); } expandSelectedButton = new AjaxButton("expand-selected-button") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { expandPickedExternalTreeItemNodes(getExternalDocumentServiceFacade()); target.add(ExternalTreeItemFieldBrowserDialog.this); } }; add(expandSelectedButton); expandAllButton = new AjaxButton("expand-all-button") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { treeExpansionSet.expandAll(); target.add(ExternalTreeItemFieldBrowserDialog.this); } }; add(expandAllButton); collapseAllButton = new AjaxButton("collapse-all-button") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { treeExpansionSet.collapseAll(); target.add(ExternalTreeItemFieldBrowserDialog.this); } }; add(collapseAllButton); }
From source file:org.openbravo.erpCommon.security.Login.java
/** * Shows 3.0 login page/*w w w . ja v a2 s .c o m*/ */ private void printPageLogin30(VariablesSecureApp vars, HttpServletResponse response, String strTheme, String cacheMsg, String validBrowserMsg, String orHigherMsg, String recBrowserMsgTitle, String recBrowserMsgText, String identificationFailureTitle, String emptyUsernameOrPasswordText) throws IOException, ServletException { boolean showForgeLogo = true; boolean showITLogo = false; boolean showCompanyLogo = false; boolean showGSignInButtonDemo = true; String itLink = ""; String companyLink = ""; SystemInformation sysInfo = OBDal.getInstance().get(SystemInformation.class, "0"); ActivationKey ak = ActivationKey.getInstance(true); if (ak.isActive()) { String hql = "from ADPreference pref where searchKey like :value and property = :prop and (visibleAtClient is null or visibleAtClient.id = '0')"; Query q = OBDal.getInstance().getSession().createQuery(hql); q.setParameter("value", "N"); q.setParameter("prop", GOOGLE_PREFERENCE_PROPERTY); // show by default - not show when there is a preference to disable it showGSignInButtonDemo = q.list().size() == 0; } if (sysInfo == null) { log4j.error("System information not found"); } else { showITLogo = sysInfo.getYourItServiceLoginImage() != null; showCompanyLogo = sysInfo.getYourCompanyLoginImage() != null; showForgeLogo = !ActivationKey.getInstance().isActive() || (ActivationKey.getInstance().isActive() && sysInfo.isShowForgeLogoInLogin()); itLink = sysInfo.getSupportContact() == null ? "" : sysInfo.getSupportContact(); if (!itLink.isEmpty() && !(StringUtils.startsWithIgnoreCase(itLink, "http://") || StringUtils.startsWithIgnoreCase(itLink, "https://") || StringUtils.startsWithIgnoreCase(itLink, "ftp://"))) { itLink = "http://" + itLink; } companyLink = sysInfo.getYourCompanyURL() == null ? "" : sysInfo.getYourCompanyURL(); if (!companyLink.isEmpty() && !(StringUtils.startsWithIgnoreCase(companyLink, "http://") || StringUtils.startsWithIgnoreCase(companyLink, "https://") || StringUtils.startsWithIgnoreCase(companyLink, "ftp://"))) { companyLink = "http://" + companyLink; } } Client systemClient = OBDal.getInstance().get(Client.class, "0"); xmlEngine.sessionLanguage = systemClient.getLanguage().getLanguage(); XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/security/Login") .createXmlDocument(); xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n"); xmlDocument.setParameter("theme", strTheme); String visualPrefs = "var showCompanyLogo = " + showCompanyLogo + ", showSupportLogo = " + showITLogo + ", showForgeLogo = " + showForgeLogo + ", urlCompany = '" + companyLink + "', urlSupport = '" + itLink + "', urlOBForge = 'http://forge.openbravo.com/';"; xmlDocument.setParameter("visualPrefs", visualPrefs); String expirationMessage = "var expirationMessage=" + ak.getExpirationMessage(vars.getLanguage()).toString() + ";"; xmlDocument.setParameter("expirationMessage", expirationMessage); xmlDocument.setParameter("itServiceUrl", "var itServiceUrl = '" + SessionLoginData.selectSupportContact(this) + "'"); String cacheMsgFinal = "var cacheMsg = \"" + cacheMsg + "\""; xmlDocument.setParameter("cacheMsg", cacheMsgFinal.replaceAll("\\n", "\n")); String identificationFailureFinal = "var identificationFailureTitle = \"" + identificationFailureTitle + "\""; xmlDocument.setParameter("identificationFailureTitle", identificationFailureFinal.replaceAll("\\n", "\n")); String emptyUserNameOrPasswordFinal = "var errorEmptyContent = \"" + emptyUsernameOrPasswordText + "\""; xmlDocument.setParameter("errorEmptyContent", emptyUserNameOrPasswordFinal.replaceAll("\\n", "\n")); String validBrowserMsgFinal = "var validBrowserMsg = \"" + validBrowserMsg + "\""; String orHigherMsgFinal = "var validBrowserMsgOrHigher = \"" + orHigherMsg + "\""; xmlDocument.setParameter("validBrowserMsg", validBrowserMsgFinal.replaceAll("\\n", "\n")); xmlDocument.setParameter("validBrowserMsgOrHigher", orHigherMsgFinal.replaceAll("\\n", "\n")); String recBrowserMsgTitleFinal = "var recBrowserMsgTitle = \"" + recBrowserMsgTitle + "\""; String recBrowserMsgTextFinal = "var recBrowserMsgText = \"" + recBrowserMsgText + "\""; xmlDocument.setParameter("recBrowserMsgTitle", recBrowserMsgTitleFinal.replaceAll("\\n", "\n")); xmlDocument.setParameter("recBrowserMsgText", recBrowserMsgTextFinal.replaceAll("\\n", "\n")); if (showGSignInButtonDemo || !signInProvider.isUnsatisfied()) { String link = "<span class=\"LabelText Login_LabelText\">" + Utility.messageBD(this, "OBUIAPP_SignIn", vars.getLanguage()) + "</span>"; if (signInProvider.isUnsatisfied()) { // if there is no external sign in provider, show Google Sign In icon with demo purposes String lang = OBDal.getInstance().get(Client.class, "0").getLanguage().getLanguage(); String message = ""; if (ak.isActive()) { message = Utility.messageBD(this, "OBUIAPP_gSignInButtonDemoProfessional", lang); } else { message = Utility.messageBD(this, "OBUIAPP_ActivateMessage", lang); message = message.replace("%0", Utility.messageBD(this, "OBUIAPP_gSignInButtonDemoCommunity", lang)); } message = message.replaceAll(""", "\"").replaceAll("\"", "\\\\\"").replaceAll("'", ""); link += "<style type=\"text/css\">" // + " .gSignInButtonDemo {" // + " display: inline-block;" // + " background-color: #dd4b39;" // + " color: white;" // + " width: 24px;" // + " border-radius: 2px;" // + " white-space: nowrap;" // + " border: 1px solid #d9d9d9;" // + " }" // + " .gSignInButtonDemo:hover," // + " .gSignInButtonDemo:active {" // + " border-color: #c0c0c0;" // + " box-shadow: 0 1px 0 rgba(0, 0, 0, 0.10);" // + " cursor: hand;" // + " }" // + " .gSignInButtonDemo:hover {" // + " background-color: #e74b37;" // + " }" // + " .gSignInButtonDemo:active {" // + " background-color: #be3e2e;" // + " }" // + " .gSignInButtonDemo > span {" // + " background: url('../web/images/gSignInButtonDemo.png') 2px 2px;" // + " height: 24px;" // + " width: 24px;" // + " margin-top: -1px;" // + " display: inline-block;" // + " vertical-align: middle;" // + " }" // + "</style>" // + " <div id=\"gSignInButtonDemo\" class=\"gSignInButtonDemo\" onclick='setLoginMessage(\"Error\", null, \"" + message + "\")'>" // + " <span title=\"" + Utility.messageBD(this, "OBUIAPP_gSignInButtonDemoAltMsg", vars.getLanguage()) // + "\"></span>" // + "</div>"; } else { // a module is providing a different sign in: including its HTML code in Log In page for (SignInProvider cSignInProvider : signInProvider) { link += " "; link += cSignInProvider.getLoginPageSignInHTMLCode(); } } xmlDocument.setParameter("sign-in", link); } OBError error = (OBError) vars.getSessionObject("LoginErrorMsg"); if (error != null) { vars.removeSessionValue("LoginErrorMsg"); xmlDocument.setParameter("errorMsgStyle", ""); // clear style xmlDocument.setParameter("errorMsgTitle", error.getTitle()); xmlDocument.setParameter("errorMsgContent", error.getMessage()); } response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); out.println(xmlDocument.print()); out.close(); }
From source file:org.openhab.action.openwebif.internal.OpenWebIfActionService.java
/** * {@inheritDoc}//from w w w . jav a 2 s .com */ @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { if (properties != null) { Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = StringUtils.trimToNull((String) properties.get(key)); if (StringUtils.startsWithIgnoreCase(key, "receiver")) { parseConfig(key, value); } } for (OpenWebIfConfig config : OpenWebIf.getConfigs().values()) { if (!config.isValid()) { throw new ConfigurationException("openwebif", "Invalid OpenWebIf receiver configuration: " + config.toString()); } logger.info("{}", config.toString()); } } }
From source file:org.openhab.binding.amazonechocontrol.internal.handler.EchoHandler.java
public void handlePushActivity(Activity pushActivity) { Description description = pushActivity.ParseDescription(); if (StringUtils.isEmpty(description.firstUtteranceId) || StringUtils.startsWithIgnoreCase(description.firstUtteranceId, "TextClient:")) { return;/*from w ww . j a v a 2s . c o m*/ } if (StringUtils.isEmpty(description.firstStreamId)) { return; } String spokenText = description.summary; if (spokenText != null && StringUtils.isNotEmpty(spokenText)) { // remove wake word String wakeWordPrefix = this.wakeWord; if (wakeWordPrefix != null) { wakeWordPrefix += " "; if (StringUtils.startsWithIgnoreCase(spokenText, wakeWordPrefix)) { spokenText = spokenText.substring(wakeWordPrefix.length()); } } if (lastSpokenText.equals(spokenText)) { updateState(CHANNEL_LAST_VOICE_COMMAND, new StringType("")); } lastSpokenText = spokenText; updateState(CHANNEL_LAST_VOICE_COMMAND, new StringType(spokenText)); } }
From source file:org.openhab.binding.homematic.internal.communicator.client.RpcClient.java
/** * Tries to identify the gateway and returns the GatewayInfo. *///from w ww . jav a2 s . co m public HmGatewayInfo getGatewayInfo(String id) throws IOException { RpcRequest<T> request = createRpcRequest("getDeviceDescription"); request.addArg("BidCoS-RF"); GetDeviceDescriptionParser ddParser = new GetDeviceDescriptionParser(); ddParser.parse(sendMessage(config.getRpcPort(HmInterface.RF), request)); boolean isHomegear = StringUtils.equalsIgnoreCase(ddParser.getType(), "Homegear"); request = createRpcRequest("listBidcosInterfaces"); ListBidcosInterfacesParser biParser = new ListBidcosInterfacesParser(); biParser.parse(sendMessage(config.getRpcPort(HmInterface.RF), request)); HmGatewayInfo gatewayInfo = new HmGatewayInfo(); gatewayInfo.setAddress(biParser.getGatewayAddress()); if (isHomegear) { gatewayInfo.setId(HmGatewayInfo.ID_HOMEGEAR); gatewayInfo.setType(ddParser.getType()); gatewayInfo.setFirmware(ddParser.getFirmware()); } else if ((StringUtils.startsWithIgnoreCase(biParser.getType(), "CCU") || StringUtils.startsWithIgnoreCase(ddParser.getType(), "HM-RCV-50") || config.isCCUType()) && !config.isNoCCUType()) { gatewayInfo.setId(HmGatewayInfo.ID_CCU); String type = StringUtils.isBlank(biParser.getType()) ? "CCU" : biParser.getType(); gatewayInfo.setType(type); gatewayInfo.setFirmware(ddParser.getFirmware()); } else { gatewayInfo.setId(HmGatewayInfo.ID_DEFAULT); gatewayInfo.setType(biParser.getType()); gatewayInfo.setFirmware(biParser.getFirmware()); } if (gatewayInfo.isCCU() || config.hasWiredPort()) { gatewayInfo.setWiredInterface(hasInterface(HmInterface.WIRED, id)); } if (gatewayInfo.isCCU() || config.hasHmIpPort()) { gatewayInfo.setHmipInterface(hasInterface(HmInterface.HMIP, id)); } if (gatewayInfo.isCCU() || config.hasCuxdPort()) { gatewayInfo.setCuxdInterface(hasInterface(HmInterface.CUXD, id)); } if (gatewayInfo.isCCU() || config.hasGroupPort()) { gatewayInfo.setGroupInterface(hasInterface(HmInterface.GROUP, id)); } return gatewayInfo; }
From source file:org.openhab.binding.homematic.internal.communicator.parser.DeleteDevicesParser.java
/** * {@inheritDoc}//ww w. j a va2 s . c om */ @Override public List<String> parse(Object[] message) throws IOException { List<String> adresses = new ArrayList<String>(); if (message != null && message.length > 1) { Object[] data = (Object[]) message[1]; for (int i = 0; i < message.length; i++) { String address = toString(data[i]); boolean isDevice = !StringUtils.contains(address, ":") && !StringUtils.startsWithIgnoreCase(address, "BidCos"); if (isDevice) { adresses.add(address); } } } return adresses; }
From source file:org.openhab.binding.homematic.internal.communicator.parser.NewDevicesParser.java
/** * {@inheritDoc}//from w w w .j ava 2 s .c om */ @Override @SuppressWarnings("unchecked") public List<String> parse(Object[] message) throws IOException { List<String> adresses = new ArrayList<String>(); if (message != null && message.length > 1) { message = (Object[]) message[1]; for (int i = 0; i < message.length; i++) { Map<String, ?> data = (Map<String, ?>) message[i]; String address = toString(data.get("ADDRESS")); boolean isDevice = !StringUtils.contains(address, ":") && !StringUtils.startsWithIgnoreCase(address, "BidCos"); if (isDevice) { adresses.add(address); } } } return adresses; }
From source file:org.openhab.binding.http.internal.HttpBinding.java
/** * Check a URL is a valid HTTP request/*from w w w. j a va2s. co m*/ * * @param url * @return true if a valid HTTP request, false otherwise */ private boolean isValidUrl(String url) { if (StringUtils.startsWithIgnoreCase(url, "http://")) return true; if (StringUtils.startsWithIgnoreCase(url, "https://")) return true; return false; }
From source file:org.openhab.binding.onkyo.internal.discovery.OnkyoDiscoveryParticipant.java
/** * Return true only if the given device model is supported. * * @param deviceModel//from w w w . ja va 2s. co m * @return */ private boolean isSupportedDeviceModel(final String deviceModel) { return StringUtils.isNotBlank(deviceModel) && !Collections2.filter(SUPPORTED_DEVICE_MODELS, new com.google.common.base.Predicate<String>() { @Override public boolean apply(String input) { return StringUtils.startsWithIgnoreCase(deviceModel, input); } }).isEmpty(); }
From source file:org.openhab.binding.onkyo.internal.discovery.OnkyoUpnpDiscoveryParticipant.java
/** * Return true only if the given device model is supported. * * @param deviceModel/* www.j av a 2s. co m*/ * @return */ private boolean isSupportedDeviceModel(final String deviceModel) { return StringUtils.isNotBlank(deviceModel) && SUPPORTED_DEVICE_MODELS.stream() .filter(device -> StringUtils.startsWithIgnoreCase(deviceModel, device)).count() > 0; }