List of usage examples for org.apache.commons.lang StringUtils contains
public static boolean contains(String str, String searchStr)
Checks if String contains a search String, handling null
.
From source file:com.floreantpos.license.FiveStarPOSLicenseManager.java
/** * Check if we need to generate the public/private keys. * /*from w w w. j a v a2s. c o m*/ * @param args * @return boolean */ private static boolean genKeys(String[] args) { if (args != null) { for (String string : args) { boolean genKeys = StringUtils.contains(string, "-k=true"); if (genKeys) { return true; } } } return false; }
From source file:com.safi.workshop.sqlexplorer.connections.actions.NewQueryAction.java
@Override public void run() { try {//from www. j av a 2 s . co m if (!SafiServerPlugin.getDefault().isConnected()) { MessageDialog.openError(Display.getCurrent().getActiveShell(), "Not Connected", "You must be connected to a SafiServer instance to access this feature"); return; } final SafiNavigator nav = getView(); nav.switchToDBPerspective(); final Query qry = DbFactory.eINSTANCE.createQuery(); if (StringUtils.isNotBlank(sql)) qry.setQuerySql(sql); Alias alias = null; DBConnection connection = null; if (user == null) { alias = getView().getSelectedAlias(true); user = alias.getDefaultUser(); } else { alias = user.getAlias(); } connection = alias.getConnection(); final DBConnection fconn = connection; InputDialog dlg = new InputDialog(SafiWorkshopEditorUtil.getActiveShell(), "New Query", "Enter a new query name", connection.getUniqueQueryName(queryName), new IInputValidator() { @Override public String isValid(String newText) { if (StringUtils.isBlank(newText)) { return "Query name must not be blank"; } else if (StringUtils.contains(newText, ".")) { return "Query name must not contain '.'"; } Query q = fconn.getQuery(newText); if (q != null) { return "Query with name " + newText + " already exists. Please select another name"; } return null; } }); if (Window.OK == dlg.open()) { qry.setName(dlg.getValue()); qry.setConnection(connection); } else return; qry.setLastModified(new Date()); // OpenPasswordConnectDialogAction openDlgAction = new // OpenPasswordConnectDialogAction(user == null ? null : user // .getAlias(), user, false); // openDlgAction.run(); boolean notAuthenticated = false; if (user != null) { notAuthenticated = !user.hasAuthenticated(); } SessionEstablishedListener listener = null; if (notAuthenticated) { listener = new SessionEstablishedAdapter() { @Override public void sessionEstablished(Session session) { // synchronized (lock) { // lock.notifyAll(); // } Display.getDefault().asyncExec(new Runnable() { public void run() { DatabaseStructureView dsView = SQLExplorerPlugin.getDefault() .showDatabaseStructureView(); // DatabaseStructureView dsView = // SQLExplorerPlugin.getDefault().getDatabaseStructureView(); if (dsView != null) try { dsView.addUser(user); SQLEditorInput input = new SQLEditorInput(qry); input.setUser(user); IWorkbenchPage page = SQLExplorerPlugin.getDefault().getWorkbench() .getActiveWorkbenchWindow().getActivePage(); if (page == null) return; SQLEditor editorPart = (SQLEditor) page.openEditor(input, SQLEditor.class.getName()); editorPart.setText(qry.getQuerySql()); getView().modelChanged(SafiServerPlugin.getDefault().isConnected()); } catch (SQLCannotConnectException e) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Cannot connect", e.getMessage()); } catch (PartInitException e) { // TODO Auto-generated catch block e.printStackTrace(); MessageDialog.openError(Display.getDefault().getActiveShell(), "Editor Exception", "Could't create SQL Editor: " + e.getLocalizedMessage()); } } }); } }; } else { SQLEditorInput input = new SQLEditorInput(qry); input.setUser(user); IWorkbenchPage page = SQLExplorerPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow() .getActivePage(); if (page == null) return; SQLEditor editorPart = (SQLEditor) page.openEditor(input, SQLEditor.class.getName()); editorPart.setText(qry.getQuerySql()); if (StringUtils.isNotBlank(qry.getQuerySql())) { editorPart.setIsDirty(true); } getView().modelChanged(); } ConnectionJob.createSession(alias, user, listener, false); // SQLEditorInput input = new SQLEditorInput(qry); // input.setUser(user); // IWorkbenchPage page = SQLExplorerPlugin.getDefault().getWorkbench() // .getActiveWorkbenchWindow().getActivePage(); // if (page == null) return; // SQLEditor editorPart = (SQLEditor) page.openEditor(input, // SQLEditor.class.getName()); // editorPart.setText(qry.getQuerySql()); // getView().modelChanged(); } catch (Throwable e) { SQLExplorerPlugin.error("Error creating sql editor", e); } // NewQueryDialog dlg = new NewQueryDialog(Display.getCurrent().getActiveShell(), qry, // NewQueryDialog.Mode.ADD); // dlg.setParentConnection(alias.getConnection()); // int result = dlg.open(); // if (result == Dialog.OK){ // SQLExplorerPlugin.getDefault().saveDBResources(); // getView().modelChanged(); // } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaFileUpload.java
protected void setUploadingErrorHandler() { setErrorHandler(event -> {//from w w w .ja v a 2 s . co m //noinspection ThrowableResultOfMethodCallIgnored Throwable ex = event.getThrowable(); String rootCauseMessage = ExceptionUtils.getRootCauseMessage(ex); Logger log = LoggerFactory.getLogger(CubaFileUpload.class); if (StringUtils.contains(rootCauseMessage, "The multipart stream ended unexpectedly") || StringUtils.contains(rootCauseMessage, "Unexpected EOF read on the socket")) { log.warn("Unable to upload file, it seems upload canceled or network error occurred"); } else { log.error("Unexpected error in CubaFileUpload", ex); } if (isUploading) { endUpload(); } }); }
From source file:edu.ku.brc.dbsupport.DBConnection.java
/** * @param connectionStr//from w w w . j av a2 s. co m * @return */ public static boolean isEmbedded(final String connectionStr) { return StringUtils.isNotEmpty(connectionStr) && StringUtils.contains(connectionStr, "mxj"); }
From source file:com.adobe.acs.commons.rewriter.impl.ResourceResolverMapTransformerFactory.java
@Activate protected void activate(final Map<String, Object> config) { final String[] test = PropertiesUtil.toStringArray(config.get(PROP_ATTRIBUTES), new String[] {}); String[] normalizedValue = PropertiesUtil.toStringArray(config.get(PROP_ATTRIBUTES), DEFAULT_ATTRIBUTES); if (test.length == 1 && StringUtils.contains(test[0], ",")) { normalizedValue = StringUtils.split(test[0], ","); }// ww w .jav a2 s . c om this.attributes = ParameterUtil.toMap(normalizedValue, ":", ","); }
From source file:info.magnolia.init.DefaultMagnoliaInitPaths.java
/** * Figures out the local host name, makes sure it's lowercase, and use its unqualified name if the {@value #MAGNOLIA_UNQUALIFIED_SERVER_NAME} init parameter is set to true. *///www . ja v a 2 s. c om protected String determineServerName(ServletContext context) { final boolean unqualifiedServerName = BooleanUtils .toBoolean(context.getInitParameter(MAGNOLIA_UNQUALIFIED_SERVER_NAME)); final String retroCompatMethodCall = magnoliaServletContextListener.initServername(unqualifiedServerName); if (retroCompatMethodCall != null) { DeprecationUtil.isDeprecated( "You should update your code and override determineServerName(ServletContext) instead of initServername(String)"); return retroCompatMethodCall; } try { String serverName = StringUtils.lowerCase(InetAddress.getLocalHost().getHostName()); if (unqualifiedServerName && StringUtils.contains(serverName, ".")) { serverName = StringUtils.substringBefore(serverName, "."); } return serverName; } catch (UnknownHostException e) { log.error(e.getMessage()); return null; } }
From source file:com.greenline.guahao.web.module.home.controllers.json.area.JsonAreaController.java
@MethodRemark(value = "remark=??json?,method=ajax") @RequestMapping(value = "/json/white/area/position", method = RequestMethod.GET) public @ResponseBody OperationJsonObject areaPosition() { OperationJsonObject json = new OperationJsonObject(); Map<String, String> dataMap = new HashMap<String, String>(); String position = StringUtils.EMPTY; try {//ww w . j av a 2s.c o m // ip??? position = areaManager.getAreaInfo(IpUtil.getIpAddr(request)); } catch (Exception e) { logger.error("ip?", e); } String provinceName = StringUtils.EMPTY; String cityName = StringUtils.EMPTY; if (StringUtils.isNotBlank(position)) { if (StringUtils.contains(position, LOCATION_PROVINCE_SUFFIX)) { String[] positionArr = StringUtils.split(position, LOCATION_PROVINCE_SUFFIX); provinceName = positionArr[0]; if (positionArr.length > 1) { cityName = positionArr[1]; if (StringUtils.contains(cityName, LOCATION_CITY_SUFFIX)) { cityName = StringUtils.substring(cityName, 0, cityName.length() - 1); } } } else { if (StringUtils.contains(position, LOCATION_CITY_SUFFIX)) { String[] positionArr = StringUtils.split(position, LOCATION_CITY_SUFFIX); provinceName = positionArr[0]; if (positionArr.length > 1) { cityName = positionArr[1]; } } } } if (StringUtils.isNotBlank(provinceName)) { dataMap.put("provice", provinceName); } if (StringUtils.isNotBlank(cityName)) { dataMap.put("city", cityName); } json.setData(dataMap); return json; }
From source file:info.magnolia.cms.core.AbstractNodeData.java
protected Content getReferencedContent(HierarchyManager hm) throws PathNotFoundException, RepositoryException { if (!isExist()) { return null; }//from w w w. j a v a 2 s.com // node containing this property Content node = getParent(); Content refNode = null; int type = getType(); if (type == PropertyType.REFERENCE) { refNode = getContentFromJCRReference(); } else if (type != PropertyType.PATH && type != PropertyType.STRING) { throw new ItemNotFoundException("can't find referenced node for value " + PropertyType.nameFromValue(type) + "[" + getString() + "]. This type is not supported."); } final String pathOrUUID = this.getString(); if (StringUtils.isNotBlank(pathOrUUID)) { // we support uuids as strings if (!StringUtils.contains(pathOrUUID, "/")) { try { refNode = hm.getContentByUUID(pathOrUUID); } catch (ItemNotFoundException e) { // this is not an uuid } } // not found by uuid, check the path then if (refNode == null) { // is this relative path? if (!pathOrUUID.startsWith("/") && node.hasContent(pathOrUUID)) { refNode = node.getContent(pathOrUUID); } else if (pathOrUUID.startsWith("/") && hm.isExist(pathOrUUID)) { refNode = hm.getContent(pathOrUUID); } } } if (refNode == null) { throw new ItemNotFoundException("can't find referenced node for value [" + getString() + "]"); } return refNode; }
From source file:de.hybris.platform.chineseprofile.controllers.pages.ChineseLoginPageController.java
@Override protected void storeReferer(final String referer, final HttpServletRequest request, final HttpServletResponse response) { if (StringUtils.isNotBlank(referer) && !StringUtils.endsWith(referer, "/login") && !StringUtils.endsWith(referer, MOBILE_REBIND_URL) && !StringUtils.endsWith(referer, MOBILE_BIND_URL) && StringUtils.contains(referer, request.getServerName())) { httpSessionRequestCache.saveRequest(request, response); }// ww w . jav a 2 s.c o m }
From source file:com.jgeppert.struts2.jquery.showcase.Autocompleter.java
public Map<Integer, String> getCustomersMap() { Map<Integer, String> map = new HashMap<Integer, String>(); if (term != null && term.length() > 0) { for (Customer customer : staticCustomers) { if (StringUtils.contains(customer.getName().toLowerCase(), term.toLowerCase())) { map.put(new Integer(customer.getId()), customer.getName()); }/*ww w .j ava2 s . c om*/ } } return map; }