List of usage examples for org.apache.commons.lang3 StringUtils contains
public static boolean contains(final CharSequence seq, final CharSequence searchSeq)
Checks if CharSequence contains a search CharSequence, handling null .
From source file:com.glaf.jbpm.container.ProcessContainer.java
/** * //from w w w .jav a 2s .c om * * @param actorId * @param rows * @return */ public List<TaskItem> filter(String actorId, List<TaskItem> rows) { List<Agent> agents = this.getAgents(actorId); logger.debug(agents); List<TaskItem> taskItems = new java.util.ArrayList<TaskItem>(); if (rows != null && rows.size() > 0) { Iterator<TaskItem> iter = rows.iterator(); while (iter.hasNext()) { TaskItem item = iter.next(); // logger.debug(item.getProcessDescription() + "\t" // + item.getTaskDescription() + "\t" + item.getActorId()); /** * ? */ if (StringUtils.equals(actorId, item.getActorId())) { taskItems.add(item); } else if (StringUtils.contains(item.getActorId(), actorId)) { List<String> actorIds = StringTools.split(item.getActorId()); if (actorIds != null && actorIds.contains(actorId)) { taskItems.add(item); } } else { if (agents != null && agents.size() > 0) { Iterator<Agent> it = agents.iterator(); while (it.hasNext()) { Agent agent = it.next(); if (!agent.isValid()) { continue; } /** * ??? */ if (!StringUtils.equals(item.getActorId(), agent.getAssignFrom())) { continue; } switch (agent.getAgentType()) { case 0:// ? taskItems.add(item); break; case 1:// ?? if (StringUtils.equalsIgnoreCase(agent.getProcessName(), item.getProcessName())) { taskItems.add(item); } break; case 2:// ?? if (StringUtils.equalsIgnoreCase(agent.getProcessName(), item.getProcessName()) && StringUtils.equalsIgnoreCase(agent.getTaskName(), item.getTaskName())) { taskItems.add(item); } break; default: break; } } } } } } return taskItems; }
From source file:com.adguard.commons.web.UrlUtils.java
/** * Checks if specified parameter is valid domain name * * @param domainName Domain name/* w w w.j a v a 2s. co m*/ * @return true if it is really a domain name */ @SuppressWarnings("UnusedDeclaration") public static boolean isDomainName(String domainName) { if (StringUtils.isEmpty(domainName) || !StringUtils.contains(domainName, ".")) { return false; } String url = "http://" + domainName; String normalizedDomainName = getDomainName(url); //noinspection RedundantIfStatement if (normalizedDomainName != null && "".equals(normalizedDomainName.replaceAll("[a-zA-Z0-9-.]+", ""))) { return true; } return false; }
From source file:com.streamsets.pipeline.stage.origin.tcp.TCPObjectToRecordHandler.java
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) { Throwable exception = t;// w ww. ja v a 2 s .com if (exception instanceof DecoderException) { // unwrap the Netty decoder exception exception = exception.getCause(); } if (exception instanceof IOException && StringUtils.contains(exception.getMessage(), RST_PACKET_MESSAGE)) { // client disconnected forcibly if (LOG.isDebugEnabled()) { LOG.debug("Client at {} (established at {}) sent RST to server; disconnecting", ctx.channel().remoteAddress().toString(), new SimpleDateFormat(LOG_DATE_FORMAT_STR).format(new Date(lastChannelStart))); } ctx.close(); return; } else if (exception instanceof DataParserException) { exception = new OnRecordErrorException(Errors.TCP_08, exception.getMessage(), exception); } LOG.error("exceptionCaught in TCPObjectToRecordHandler", exception); if (exception instanceof OnRecordErrorException) { OnRecordErrorException errorEx = (OnRecordErrorException) exception; switch (context.getOnErrorRecord()) { case DISCARD: break; case STOP_PIPELINE: if (LOG.isErrorEnabled()) { LOG.error(String.format( "OnRecordErrorException caught when parsing TCP data; failing pipeline %s as per stage configuration: %s", context.getPipelineId(), exception.getMessage()), exception); } stopPipelineHandler.stopPipeline(context.getPipelineId(), errorEx); break; case TO_ERROR: batchContext.toError(context.createRecord(generateRecordId()), errorEx); break; } } else { context.reportError(Errors.TCP_07, exception.getClass().getName(), exception.getMessage(), exception); } // Close the connection when an exception is raised. ctx.close(); }
From source file:io.wcm.handler.url.suffix.SuffixParser.java
/** * Get the resources selected in the suffix of the URL * @param filter optional filter to select only specific resources * @param baseResource the suffix path is relative to this resource path (null for current page's jcr:content node) * @return a list containing the Resources *//* w w w .j ava 2s . co m*/ public List<Resource> getResources(Filter<Resource> filter, Resource baseResource) { // resolve base path or fallback to current page's content if not specified Resource baseResourceToUse = baseResource; if (baseResourceToUse == null) { PageManager pageManager = request.getResourceResolver().adaptTo(PageManager.class); Page currentPage = pageManager.getContainingPage(request.getResource()); if (currentPage != null) { baseResourceToUse = currentPage.getContentResource(); } else { baseResourceToUse = request.getResource(); } } // split the suffix to extract the paths of the selected components String[] suffixParts = splitSuffix(request.getRequestPathInfo().getSuffix()); // iterate over all parts and gather those resources List<Resource> selectedResources = new ArrayList<>(); for (String path : suffixParts) { // if path contains the key/value-delimiter then don't try to resolve it as a content path if (StringUtils.contains(path, KEY_VALUE_DELIMITER)) { continue; } String decodedPath = decodeResourcePathPart(path); // lookup the resource specified by the path (which is relative to the current page's content resource) Resource resource = request.getResourceResolver().getResource(baseResourceToUse, decodedPath); if (resource == null) { // no resource found with given path, continue with next path in suffix continue; } // if a filter is given - check if (filter == null || filter.includes(resource)) { selectedResources.add(resource); } } return selectedResources; }
From source file:ee.ria.xroad.asyncdb.AsyncDBIntegrationTest.java
private static void sendSecondRequestUnsuccessfully() throws Exception { LOG.info("TEST 7: sendSecondRequestUnsuccessfully - STARTED"); SendingCtx sendingCtx = queue.startSending(); String expectedSoap = AsyncDBTestUtil.getSecondSoapRequest().getXml(); String secondRequestContent = IOUtils.toString(sendingCtx.getInputStream()); if (!StringUtils.contains(secondRequestContent, expectedSoap)) { throw new IntegrationTestFailedException("Message input stream does not contain expected content."); }/*from ww w . ja v a 2 s. c om*/ sendingCtx.failure("ERROR", LAST_SEND_RESULT_FAILURE); QueueInfo expectedQueueInfo = new QueueInfo(AsyncDBTestUtil.getProvider(), new QueueState(1, 1, new Date(), 1, "1234567890", new Date(), LAST_SEND_RESULT_FAILURE)); validateQueueInfo(expectedQueueInfo); RequestInfo expectedRequestInfo = getSecondRequest(); validateRequestInfo(expectedRequestInfo); SUCCESSFUL_STEPS.add("sendSecondRequestUnsuccessfully"); LOG.info("TEST 7: sendSecondRequestUnsuccessfully - FINISHED"); }
From source file:com.github.binlee1990.spider.movie.spider.MovieCrawler.java
private void setFilmReviewDoubanGrade(Document doc, FilmReview filmReview) { Elements doubanElements = doc.select(".fm-title .fm-green"); if (CollectionUtils.isNotEmpty(doubanElements) && doubanElements.size() == 1) { Element doubanElement = doubanElements.get(0); if (null != doubanElement) { String doubanGradeStr = doubanElement.text(); if (StringUtils.isNotBlank(doubanGradeStr) && StringUtils.contains(doubanGradeStr, "")) { String gradeStr = StringUtils.trimToEmpty( doubanGradeStr.substring(doubanGradeStr.indexOf("") + "".length())); if (StringUtils.isNotBlank(gradeStr)) { float grade = getGrade(gradeStr); filmReview.setGradeDouban(grade); }/* w w w. j av a 2s . c om*/ } } } }
From source file:net.eledge.android.europeana.search.SearchController.java
public String getSearchTitle(Context context) { String title = GuiUtils.getString(context, R.string.app_name); if (!terms.isEmpty()) { title = terms.get(0);/*from w w w. j av a 2s . c o m*/ if (StringUtils.contains(title, ":")) { title = StringUtils.substringAfter(title, ":"); } title = WordUtils.capitalizeFully(title); } return title; }
From source file:de.micromata.genome.gwiki.page.search.expr.SearchUtils.java
public static SearchResult findResultFallback(GWikiContext ctx, SearchQuery query, SearchResult sr, String normExpress) {//from w ww . java 2 s. c om String pageId = sr.getPageId(); String nt = NormalizeUtils.normalize(pageId); if (StringUtils.contains(nt, normExpress) == true) { return new SearchResult(sr, 20); } GWikiElementInfo eli = ctx.getWikiWeb().findElementInfo(pageId); if (eli == null) { return null; } nt = NormalizeUtils.normalize(eli.getTitle()); if (StringUtils.contains(nt, normExpress) == true) { return new SearchResult(sr, 30); } return null; }
From source file:com.dominion.salud.pedicom.negocio.service.impl.UsuariosServiceImpl.java
@Override public Usuarios validarUsuarios(Usuarios usuarios) throws UsuarioIncorrectoException, UsuarioNoAsociadoACentroException, Exception { CabParInt cabParInt = cabParIntRepository.getCabParIntByCodigo(new CabParInt("LDAP")); if (StringUtils.equals(cabParInt.getActivado(), "S")) { logger.debug("Iniciando validacion LDAP"); LDAPFarmatools ldapFarmatools = new LDAPFarmatools(); try {/* ww w. j a va 2 s. co m*/ logger.debug(" Obteniendo parametros de la validacion LDAP"); boolean LDAP_AD = BooleanUtils.toBoolean(linParIntRepository .getLinParIntByCodInterfaceTipo(new LinParInt(new LinParIntPK("LDAP", "LDAP_AD"))) .getParametro()); String[] LDAP_HOSTS = { linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_HOST_1"))).getParametro(), linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_HOST_2"))).getParametro(), linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_HOST_3"))).getParametro(), linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_HOST_4"))).getParametro(), linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_HOST_5"))).getParametro(), linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_HOST_6"))).getParametro() }; String LDAP_DOMINIO = linParIntRepository .getLinParIntByCodInterfaceTipo(new LinParInt(new LinParIntPK("LDAP", "LDAP_DOMINIO"))) .getParametro(); String LDAP_USUARIO = linParIntRepository .getLinParIntByCodInterfaceTipo(new LinParInt(new LinParIntPK("LDAP", "LDAP_USUARIO"))) .getParametro(); String LDAP_PASSWORD = linParIntRepository .getLinParIntByCodInterfaceTipo(new LinParInt(new LinParIntPK("LDAP", "LDAP_PASSWORD"))) .getParametro(); String LDAP_RUTA_USUARIOS = linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_RUTA_USUARIOS"))).getParametro(); logger.debug(" LDAP_AD: " + LDAP_AD); logger.debug(" LDAP_HOSTS: " + StringUtils.join(LDAP_HOSTS, ",")); logger.debug(" LDAP_DOMINIO: " + LDAP_DOMINIO); logger.debug(" LDAP_USUARIO: " + LDAP_USUARIO); logger.debug(" LDAP_PASSWORD: " + LDAP_PASSWORD); logger.debug(" LDAP_RUTA_USUARIOS: " + LDAP_RUTA_USUARIOS); logger.debug(" Parametros de la validacion LDAP obtenidos correctamente"); logger.debug(" Validando Usuario LDAP"); if (ldapFarmatools.validarUsuario(LDAP_AD, LDAP_HOSTS, LDAP_DOMINIO, usuarios.getLoginUsu(), usuarios.getPasswUsu())) { logger.debug(" Usuario LDAP validado correctamente"); boolean LDAP_CREAR_USUARIOS = BooleanUtils .toBoolean(linParIntRepository .getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_CREAR_USUARIOS"))) .getParametro()); if (LDAP_CREAR_USUARIOS && !existeUsuario(usuarios)) { List<EquiEc> equiGrupo = equiEcRepository .findEquiEcByTipo(new EquiEc(new EquiEcPK("GR", "LDP"), "S")); List<EquiEc> equiTipo = equiEcRepository .findEquiEcByTipo(new EquiEc(new EquiEcPK("TG", "LDP"), "S")); boolean ENCRIPTADO = BooleanUtils .toBoolean(linParIntRepository .getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("PEDICOM", "ENCRIPTADO"))) .getParametro()); String LDAP_P_MEMBER_OF = linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_P_IsMemberOf"))).getParametro(); String LDAP_P_UID = linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_P_UID"))).getParametro(); String LDAP_P_NOMBRE = linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_P_NOMBRE"))).getParametro(); String LDAP_P_MAIL = linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_P_MAIL"))).getParametro(); String LDAP_CENTRO = linParIntRepository.getLinParIntByCodInterfaceTipo( new LinParInt(new LinParIntPK("LDAP", "LDAP_CENTRO"))).getParametro(); String[] attrs = { LDAP_P_MEMBER_OF, LDAP_P_UID, LDAP_P_NOMBRE, LDAP_P_MAIL }; logger.debug(" Creando el usuario: " + usuarios.getLoginUsu() + " en FARMATOOLS"); HashMap<String, String> params; logger.debug(" Buscando ATRIBUTOS del usuario: " + LDAP_P_UID + "=" + usuarios.getLoginUsu()); if (StringUtils.isNotBlank(LDAP_USUARIO) && StringUtils.isNotBlank(LDAP_PASSWORD)) { params = ldapFarmatools.findByQueryAttr(LDAP_AD, LDAP_HOSTS, LDAP_DOMINIO, LDAP_USUARIO, LDAP_PASSWORD, LDAP_RUTA_USUARIOS, LDAP_P_UID + "=" + usuarios.getLoginUsu(), attrs); } else { params = ldapFarmatools.findByQueryAttr(LDAP_AD, LDAP_HOSTS, LDAP_DOMINIO, usuarios.getLoginUsu(), usuarios.getPasswUsu(), LDAP_RUTA_USUARIOS, LDAP_P_UID + "=" + usuarios.getLoginUsu(), attrs); } logger.debug(" Atributos del usuario"); logger.debug( " " + LDAP_P_MEMBER_OF + ": " + params.get(LDAP_P_MEMBER_OF)); logger.debug(" " + LDAP_P_UID + ": " + params.get(LDAP_P_UID)); logger.debug(" " + LDAP_P_NOMBRE + ": " + params.get(LDAP_P_NOMBRE)); logger.debug(" " + LDAP_P_MAIL + ": " + params.get(LDAP_P_MAIL)); //Creamos el usuario nuevo Usuarios usu = new Usuarios(); usu.setLoginUsu(usuarios.getLoginUsu()); if (ENCRIPTADO) { usu.setPasswUsu(encriptar(usuarios.getPasswUsu())); } else { usu.setPasswUsu(usuarios.getPasswUsu()); } //Nombre del Usuario if (StringUtils.isNotBlank(params.get(LDAP_P_NOMBRE))) { usu.setNombreUsu(params.get(LDAP_P_NOMBRE)); } else { usu.setNombreUsu(usuarios.getLoginUsu()); } //Valida el centro if (StringUtils.isNotBlank(LDAP_CENTRO)) { logger.debug(" Validando el CENTRO: " + LDAP_CENTRO); if (!StringUtils.contains(params.get(LDAP_P_MEMBER_OF), LDAP_CENTRO)) { logger.error("El atributo: " + LDAP_P_MEMBER_OF + "[" + params.get(LDAP_P_MEMBER_OF) + "], no contiene el CENTRO: " + LDAP_CENTRO); throw new UsuarioIncorrectoException( "El usuario no pertenece al centro: " + LDAP_CENTRO + ". Validacion LDAP"); } } //Valida el grupo String grupo = ""; logger.debug(" Obteniendo el GRUPO del usuario"); if (equiGrupo != null && !equiGrupo.isEmpty()) { for (EquiEc equiEc : equiGrupo) { logger.debug(" Evaluando si el ATRIBUTO: " + params.get(LDAP_P_MEMBER_OF) + " contiene la EQUIVALENCIA: " + equiEc.getEquiEcPK().getCodEc() + " del GRUPO: " + equiEc.getEquiEcPK().getCodFar()); if (StringUtils.contains(params.get(LDAP_P_MEMBER_OF), equiEc.getEquiEcPK().getCodEc())) { grupo = equiEc.getEquiEcPK().getCodFar(); break; } } } if (StringUtils.isBlank(grupo)) { logger.error("El ATRIBUTO: " + params.get(LDAP_P_MEMBER_OF) + " no contiene ningun GRUPO de FARMATOOLS"); throw new UsuarioIncorrectoException( "El usuario pertenece a un GRUPO sin acceso a Farmatools. Validacion LDAP"); } //Valida el tipo String tipo = ""; logger.debug(" Obteniendo el TIPO del usuario"); if (equiTipo != null && !equiTipo.isEmpty()) { for (EquiEc equiEc : equiTipo) { logger.debug(" Evaluando si el ATRIBUTO: " + params.get(LDAP_P_MEMBER_OF) + " contiene la EQUIVALENCIA: " + equiEc.getEquiEcPK().getCodEc() + " del TIPO: " + equiEc.getEquiEcPK().getCodFar()); if (StringUtils.contains(params.get(LDAP_P_MEMBER_OF), equiEc.getEquiEcPK().getCodEc())) { tipo = equiEc.getEquiEcPK().getCodFar(); break; } } } if (StringUtils.isBlank(tipo)) { logger.error("El ATRIBUTO: " + params.get(LDAP_P_MEMBER_OF) + " no contiene ningun TIPO de FARMATOOLS"); throw new UsuarioIncorrectoException( "El usuario pertenece a un TIPO sin acceso a Farmatools. Validacion LDAP"); } usu.setGrpUsu(grupo); usu.setTipoUsu(tipo); //Graba el usuario try { logger.debug( " Creando el usuario: " + usu.getLoginUsu() + " en FARMATOOLS"); usuariosRepository.save(usu); logger.debug(" Usuario: " + usu.getLoginUsu() + " creado correctamente en FARMATOOLS"); } catch (Exception e) { logger.warn("No se ha podido almacenar el nuevo usuario: " + e.toString()); } } } else { logger.error("El usuario no se ha validado correctamente contra LDAP"); throw new UsuarioIncorrectoException("El usuario no se ha validado correctamente contra LDAP"); } } catch (Exception e) { throw new UsuarioIncorrectoException( "Se han producido errores al realizar la validacion LDAP: " + e.toString()); } try { logger.debug("Usuario validado LDAP, comprobando asociacion usuario con centro"); Usuarios usuariosVal = usuariosRepository.validarCentroUsuarios(usuarios); logger.debug("Usuario asociado"); session.setAttribute("pedicom.usuario", usuariosVal); return usuariosVal; } catch (NoResultException nre) { throw new UsuarioNoAsociadoACentroException( "El usuario no esta asociado al centro: " + nre.toString()); } } else { try { logger.debug("Comprobando que el usuario existe"); usuariosRepository.validarUsuarios(usuarios); logger.debug("Usuario correcto"); } catch (NoResultException nre) { throw new UsuarioIncorrectoException("Las credenciales no son correctas"); } catch (NonUniqueResultException nure) { throw new UsuarioIncorrectoException("Mas de un usuario con ese login"); } try { logger.debug("Comprobando que el usuario esta asociado al centro"); Usuarios usuariosVal = usuariosRepository.validarCentroUsuarios(usuarios); session.setAttribute("pedicom.usuario", usuariosVal); logger.debug("Usuario asociado"); return usuariosVal; } catch (NoResultException nre) { throw new UsuarioNoAsociadoACentroException("El usuario no esta asociado al centro"); } } }
From source file:com.github.binlee1990.spider.movie.spider.MovieCrawler.java
private void setFilmReviewImdbGrade(Document doc, FilmReview filmReview) { Elements imdbElements = doc.select(".fm-title .fm-orange"); if (CollectionUtils.isNotEmpty(imdbElements) && imdbElements.size() == 1) { Element imdbElement = imdbElements.get(0); if (null != imdbElement) { String imdbGradeStr = imdbElement.text(); if (StringUtils.isNotBlank(imdbGradeStr) && StringUtils.contains(imdbGradeStr, "IMDB")) { String gradeStr = StringUtils .trimToEmpty(imdbGradeStr.substring(imdbGradeStr.indexOf("IMDB") + "IMDB".length())); if (StringUtils.isNotBlank(gradeStr)) { float grade = getGrade(gradeStr); filmReview.setGradeDouban(grade); }//from w ww.j a v a2 s. com } } } }