Java Code Examples for org.apache.commons.lang3.StringUtils#endsWithAny()

The following examples show how to use org.apache.commons.lang3.StringUtils#endsWithAny() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LanguageProcessingHelper.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
private boolean skip(Item o) {
	if ((StringUtils.length(o.getValue()) > 1) && (!StringUtils.startsWithAny(o.getValue(), SKIP_START_WITH))
			&& (!StringUtils.endsWithAny(o.getValue(), SKIP_END_WITH))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "b"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "c"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "d"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "e"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "f"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "h"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "k"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "o"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "p"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "q"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "r"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "u"))
			&& (!StringUtils.startsWithIgnoreCase(o.getLabel(), "w")) && (!label_skip_m(o))) {
		return false;
	}
	return true;
}
 
Example 2
Source File: StaticResourceResolver.java    From Plan with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Response getResponse(Request request) {
    String resource = getPath(request).asString().substring(1);
    if (resource.endsWith(".css")) {
        return responseFactory.cssResponse(resource);
    }
    if (resource.endsWith(".js")) {
        return responseFactory.javaScriptResponse(resource);
    }
    if (resource.endsWith(".png")) {
        return responseFactory.imageResponse(resource);
    }
    if (StringUtils.endsWithAny(resource, ".woff", ".woff2", ".eot", ".ttf")) {
        return responseFactory.fontResponse(resource);
    }
    return null;
}
 
Example 3
Source File: TitleGenerator.java    From computoser with GNU Affero General Public License v3.0 6 votes vote down vote up
private String conjugate(String verb, boolean thirdPerson, boolean allowProgressiveTense) {
   if (Chance.test(20) && allowProgressiveTense) { //progressive tesnse
       if (verb.endsWith("e")) {
           verb = verb.substring(0, verb.length() - 1) + "ing";
       } else {
           verb = verb + "ing";
       }
   } else if (thirdPerson){
       if (verb.endsWith("o")) {
           verb += "es";
       } else if (verb.endsWith("y")) {
           if (StringUtils.endsWithAny(verb, "ay", "oy", "ey", "uy")) {
               verb += "s";
           } else {
               verb = verb.substring(0, verb.length() - 1) + "ies";
           }
       } else if (verb.endsWith("s") || verb.endsWith("ch") || verb.endsWith("sh")){
           verb += "es";
       } else {
           verb += "s";
       }
   }
   return verb;
}
 
Example 4
Source File: PermissionUtils.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 权限错误消息提醒
 * 
 * @param permissionsStr 错误信息
 * @return 提示信息
 */
public static String getMsg(String permissionsStr)
{
    String permission = StringUtils.substringBetween(permissionsStr, "[", "]");
    String msg = MessageUtils.message(PERMISSION, permission);
    if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION))
    {
        msg = MessageUtils.message(CREATE_PERMISSION, permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION))
    {
        msg = MessageUtils.message(UPDATE_PERMISSION, permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION))
    {
        msg = MessageUtils.message(DELETE_PERMISSION, permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION))
    {
        msg = MessageUtils.message(EXPORT_PERMISSION, permission);
    }
    else if (StringUtils.endsWithAny(permission,
            new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
    {
        msg = MessageUtils.message(VIEW_PERMISSION, permission);
    }
    return msg;
}
 
Example 5
Source File: PermissionUtils.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 权限错误消息提醒
 * 
 * @param permissionsStr 错误信息
 * @return
 */
public static String getMsg(String permissionsStr)
{
    String permission = StringUtils.substringBetween(permissionsStr, "[", "]");
    String msg = MessageUtils.message("no.view.permission", permission);
    if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION))
    {
        msg = MessageUtils.message("no.create.permission", permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION))
    {
        msg = MessageUtils.message("no.update.permission", permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION))
    {
        msg = MessageUtils.message("no.delete.permission", permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION))
    {
        msg = MessageUtils.message("no.export.permission", permission);
    }
    else if (StringUtils.endsWithAny(permission,
            new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
    {
        msg = MessageUtils.message("no.view.permission", permission);
    }
    return msg;
}
 
Example 6
Source File: CacheSessionDAO.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 判断访问URI是否是静态文件请求
 * @throws Exception
 */
public static boolean isStaticFile(String uri){
	if (staticFiles == null){
		try {
			throw new Exception("检测到“app.properties”中没有配置“web.staticFile”属性。配置示例:\n#静态文件后缀\n"
					+"web.staticFile=.css,.js,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	if (StringUtils.endsWithAny(uri, staticFiles) ){
		return true;
	}
	return false;
}
 
Example 7
Source File: StringEndsWith.java    From levelup-java-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void string_ends_with_any_apache_commons () {

	boolean endsWithAnchorOrQ = StringUtils
			.endsWithAny("http://www.leveluplunch.com", new String[] {"#", "?"});
	
	assertFalse(endsWithAnchorOrQ);
}
 
Example 8
Source File: ResourceManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private static Set<String> doGetResourceNames(List<String> paths, String resourceDirName,
		String extension) {

	// check the system resource paths first
	Set<String> set = new HashSet<>();

	// now search the path entries
	for (String path : paths) {

		if (!StringUtils.endsWithAny(path.toLowerCase(), ".jar", ".zip")) {

			// maybe a directory	
			String classpathDirectoryEntry = path + File.separator + resourceDirName;
			File f = new File(classpathDirectoryEntry);
			findResources(set, f, resourceDirName, extension);
			continue;
		}

		// jar/zip
		File file = new File(path);
		try {
			if (file.exists()) {
				searchJarFile(set, file, resourceDirName, extension);
			}
		}
		catch (IOException e) {
			Msg.error(ResourceManager.class, "Unable to search compressed file", e);
		}
	}
	return set;
}
 
Example 9
Source File: ResourceManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private static void filterImages(Set<String> set) {
	Iterator<String> it = set.iterator();
	while (it.hasNext()) {
		String filename = it.next().toLowerCase();
		if (!StringUtils.endsWithAny(filename, ".gif", ".jpg", ".png")) {
			it.remove();
		}
	}
}
 
Example 10
Source File: PermissionUtils.java    From LuckyFrameWeb with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 权限错误消息提醒
 * 
 * @param permissionsStr 错误信息
 */
public static String getMsg(String permissionsStr)
{
    String permission = StringUtils.substringBetween(permissionsStr, "[", "]");
    String msg = MessageUtils.message("no.view.permission", permission);
    if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION))
    {
        msg = MessageUtils.message("no.create.permission", permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION))
    {
        msg = MessageUtils.message("no.update.permission", permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION))
    {
        msg = MessageUtils.message("no.delete.permission", permission);
    }
    else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION))
    {
        msg = MessageUtils.message("no.export.permission", permission);
    }
    else if (StringUtils.endsWithAny(permission, new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
    {
        msg = MessageUtils.message("no.view.permission", permission);
    }
    return msg;
}
 
Example 11
Source File: EntityLogItemDetachListener.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void fillAttributesFromChangesField(EntityLogItem item) {
    log.trace("fillAttributesFromChangesField for {}", item);
    List<EntityLogAttr> attributes = new ArrayList<>();

    if (!entityStates.isLoaded(item, "changes")) {
        item.setAttributes(new LinkedHashSet<>(attributes));
        return;
    }

    StringReader reader = new StringReader(item.getChanges());
    Properties properties = new Properties();
    try {
        properties.load(reader);
        Enumeration<?> names = properties.propertyNames();
        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            if (StringUtils.endsWithAny(name, skipNames))
                continue;

            EntityLogAttr attr = new EntityLogAttr();
            attr.setLogItem(item);
            attr.setName(name);
            attr.setValue(properties.getProperty(name));
            attr.setValueId(properties.getProperty(name + VALUE_ID_SUFFIX));
            attr.setOldValue(properties.getProperty(name + OLD_VALUE_SUFFIX));
            attr.setOldValueId(properties.getProperty(name + OLD_VALUE_ID_SUFFIX));
            attr.setMessagesPack(properties.getProperty(name + MP_SUFFIX));

            attributes.add(attr);
        }
    } catch (Exception e) {
        log.error("Unable to fill EntityLog attributes for {}", item, e);
    }

    attributes.sort((o1, o2) -> Ordering.natural().compare(o1.getName(), o2.getName()));

    item.setAttributes(new LinkedHashSet<>(attributes));
}
 
Example 12
Source File: ScooldUtils.java    From scoold with Apache License 2.0 5 votes vote down vote up
public ParaObject checkAuth(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
	Profile authUser = null;
	boolean isApiRequest = isApiRequest(req);
	boolean isStaticRequest = StringUtils.endsWithAny(req.getRequestURI(), ".js", ".css", ".svg", ".png", ".jpg");
	boolean isGlobalsJS = StringUtils.endsWithAny(req.getRequestURI(), "globals.js");
	if (isApiRequest) {
		return checkApiAuth(req);
	} else if (HttpUtils.getStateParam(AUTH_COOKIE, req) != null && (!isStaticRequest || isGlobalsJS)) {
		User u = pc.me(HttpUtils.getStateParam(AUTH_COOKIE, req));
		if (u != null && isEmailDomainApproved(u.getEmail())) {
			authUser = getOrCreateProfile(u, req);
			authUser.setUser(u);
			boolean updatedRank = promoteOrDemoteUser(authUser, u);
			boolean updatedProfile = updateProfilePictureAndName(authUser, u);
			if (updatedRank || updatedProfile) {
				authUser.update();
			}
		} else {
			clearSession(req, res);
			if (u != null) {
				logger.warn("Attempted signin from an unknown domain: {}", u.getEmail());
			} else {
				logger.info("Invalid JWT found in cookie {}.", AUTH_COOKIE);
			}
			res.sendRedirect(SIGNINLINK + "?code=3&error=true");
			return null;
		}
	}
	return authUser;
}
 
Example 13
Source File: LinkCrawler.java    From vividus with Apache License 2.0 4 votes vote down vote up
private static boolean isNotFile(WebURL url)
{
    return !StringUtils.endsWithAny(url.getPath().toLowerCase(), EXCLUDED_EXTENSIONS);
}
 
Example 14
Source File: RequestLogFilter.java    From app-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) servletRequest;
    HttpServletResponse response = (HttpServletResponse) servletResponse;
    String path = request.getRequestURI();
    if (StringUtils.startsWithAny(path, "/webjars", "/static", "/js", "/css", "/libs", "/WEB-INF")
            || StringUtils.endsWithAny(path, GlobalConstants.staticResourceArray)) {
        filterChain.doFilter(request, response);
        return;
    }

    RequestContext context = ThreadLocalContext.getRequestContext();
    MDC.put("requestId", context.getRequestId());

    response = new ResponseWrapper(response);
    long startTime = System.currentTimeMillis();
    try {
        filterChain.doFilter(request, response);
    } catch (Exception e) {
        //此处拦截也必须抛出,否则不执行ErrorHandlerResource
        if (e instanceof EngineException) {
            logger.error("EngineException error", e.getMessage() + " " + ((EngineException) e).getErrorMsgCn());
        } else if (e.getCause() instanceof EngineException) {
            logger.error("EngineException error", e.getCause().getMessage() + " " + ((EngineException) e.getCause()).getErrorMsgCn());
        } else {
            logger.error("filterChain.doFilter error", e);
        }
        throw e;
    } finally {
        //如果是错误页面 或 没有错误的第一次执行
        if (StringUtils.equals("/error", path) || request.getAttribute("org.springframework.boot.autoconfigure.web.DefaultErrorAttributes.ERROR") == null) {
            long endTime = System.currentTimeMillis();
            RequestLogRecord record = new RequestLogRecord();
            record.setRequestId(context.getRequestId());
            record.setIp(request.getRemoteHost());
            record.setUid(context.getCurrentUid());
            record.setSource(context.getAppId() + "");
            record.setUseTime(endTime - startTime);
            Object requestUri = request.getAttribute("javax.servlet.error.request_uri");
            record.setApi(requestUri != null ? (String) requestUri : path);
            record.setMethod(request.getMethod());
            record.setParameters(request.getParameterMap());
            record.setResponseStatus(response.getStatus());
            record.setClientVersion(context.getClientVersion());
            record.setResponse(new String(((ResponseWrapper) response).toByteArray(), response.getCharacterEncoding()));
            //text/html不打印body
            if (!StringUtils.contains(response.getContentType(), "application/json")) {
                record.setWriteBody(false);
            }
            MDC.put("CUSTOM_LOG", "request");
            logger.info(record.toString());
            MDC.remove("CUSTOM_LOG");
            ThreadLocalContext.clear();
        }
    }
}
 
Example 15
Source File: ErrorHandlerResource.java    From app-engine with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value = ERROR_PATH)
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public String error(HttpServletRequest request) {
    String path = (String) request.getAttribute("javax.servlet.error.request_uri");
    String errorMsg = (String) request.getAttribute("javax.servlet.error.message");
    MediaType mediaType = (MediaType) request.getAttribute("org.springframework.web.servlet.View.selectedContentType");
    int status = (int) request.getAttribute("javax.servlet.error.status_code");

    Exception exception = (Exception) request.getAttribute(GlobalExceptionHandler.GlobalExceptionAttribute);
    if (exception == null) {
        exception = (Exception) request.getAttribute("javax.servlet.error.exception");
    }
    EngineException apiException;
    String pageError = "500 - System error.";
    if (exception != null && exception instanceof EngineException) {
        apiException = (EngineException) exception;
    } else if (status == 405) {
        apiException = EngineExceptionHelper.localException(ExcepFactor.E_METHOD_ERROR);
    } else if (status == 404) {
        pageError = "404 - Page not Found: " + errorMsg;
        apiException = EngineExceptionHelper.localException(ExcepFactor.E_API_NOT_EXIST);
    } else if (status == 415) {
        apiException = EngineExceptionHelper.localException(ExcepFactor.E_UNSUPPORT_MEDIATYPE_ERROR, new Object[]{"unknow"});
    } else if (status >= 400 && status < 500) {
        apiException = EngineExceptionHelper.localException(ExcepFactor.E_ILLEGAL_REQUEST, errorMsg);
    } else if (status == 503) {
        apiException = EngineExceptionHelper.localException(ExcepFactor.E_SERVICE_UNAVAILABLE);
    } else {
        apiException = EngineExceptionHelper.localException(ExcepFactor.E_DEFAULT);
        log.error(errorMsg, exception);
    }
    if (MediaType.TEXT_HTML.equals(mediaType) || StringUtils.endsWithAny(path, GlobalConstants.staticResourceArray)) {
        return "<!DOCTYPE html>\n" +
                "<html>\n" +
                "<head>\n" +
                "    <title>" + pageError + "</title>\n" +
                "</head>\n" +
                "<body>\n" +
                "<h2>" + pageError + "</h2>\n" +
                "</body>\n" +
                "</html>";
    } else {
        return apiException.formatException(path);
    }
}
 
Example 16
Source File: OpenFilter.java    From seed with Apache License 2.0 4 votes vote down vote up
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
    ReqData reqData;
    String reqDataStr;
    String respDataStr;
    String reqIp = RequestUtil.getClientIP(request);
    long startTime = System.currentTimeMillis();
    try{
        //将请求入参解析到ReqData
        String method = request.getParameter("method");
        if(StringUtils.isNotBlank(method) && StringUtils.endsWithAny(method, "h5", "file.upload")){
            reqDataStr = JadyerUtil.buildStringFromMap(request.getParameterMap());
            LogUtil.getLogger().debug("收到客户端IP=[{}]的请求报文为-->{}", reqIp, reqDataStr);
            reqData = BeanUtil.requestToBean(request, ReqData.class);
        }else{
            reqDataStr = IOUtils.toString(request.getInputStream(), SeedConstants.DEFAULT_CHARSET);
            LogUtil.getLogger().debug("收到客户端IP=[{}]的请求报文为-->[{}]", reqIp, reqDataStr);
            if(StringUtils.isBlank(reqDataStr)){
                throw new SeedException(CodeEnum.OPEN_FORM_ILLEGAL.getCode(), "请求无数据");
            }
            reqData = JSON.parseObject(reqDataStr, ReqData.class);
            method = reqData.getMethod();
        }
        //验证请求方法名非空
        if(StringUtils.isBlank(reqData.getMethod())){
            throw new SeedException(CodeEnum.OPEN_UNKNOWN_METHOD.getCode(), String.format("%s-->[%s]", CodeEnum.OPEN_UNKNOWN_METHOD.getMsg(), reqData.getMethod()));
        }
        //验证时间戳
        this.verifyTimestamp(reqData.getTimestamp());
        //识别合作方
        String appsecret = appsecretMap.get(reqData.getAppid());
        LogUtil.getLogger().debug("通过appid=[{}]读取到合作方密钥{}", reqData.getAppid(), appsecret);
        if(appsecretMap.isEmpty() || StringUtils.isBlank(appsecret)){
            throw new SeedException(CodeEnum.OPEN_UNKNOWN_APPID);
        }
        //获取协议版本
        if(!StringUtils.equalsAny(reqData.getVersion(), SeedConstants.OPEN_VERSION_21, SeedConstants.OPEN_VERSION_22)){
            throw new SeedException(CodeEnum.OPEN_UNKNOWN_VERSION);
        }
        //验证接口是否已授权
        this.verifyGrant(reqData.getAppid(), method);
        //验签
        //if(SeedConstants.VERSION_20.equals(reqData.getVersion())){
        //    this.verifySign(request.getParameterMap(), apiApplication.getAppSecret());
        //    filterChain.doFilter(request, response);
        //}
        //解密并处理(返回诸如html或txt内容时,就不用先得到字符串再转成字节数组输出,这会影响性能,尤其对账文件下载)
        RequestParameterWrapper requestWrapper = new RequestParameterWrapper(request);
        requestWrapper.addAllParameters(this.decrypt(reqData, appsecret));
        if(StringUtils.endsWithAny(method, "h5", "agree", "download")){
            filterChain.doFilter(requestWrapper, response);
            respDataStr = method + "...";
            LogUtil.getLogger().info("返回客户端IP=[{}]的应答明文为-->[{}],Duration[{}]ms", reqIp, respDataStr, (System.currentTimeMillis()-startTime));
        }else{
            ResponseContentWrapper responseWrapper = new ResponseContentWrapper(response);
            filterChain.doFilter(requestWrapper, responseWrapper);
            respDataStr = responseWrapper.getContent();
            LogUtil.getLogger().info("返回客户端IP=[{}]的应答明文为-->[{}]", reqIp, respDataStr);
            RespData respData = JSON.parseObject(respDataStr, RespData.class);
            if(CodeEnum.SUCCESS.getCode() == Integer.parseInt(respData.getCode())){
                if(SeedConstants.OPEN_VERSION_21.equals(reqData.getVersion())){
                    respData.setData(StringUtils.isBlank(respData.getData()) ? "" : CodecUtil.buildAESEncrypt(respData.getData(), appsecret));
                }else{
                    Map<String, String> dataMap = JSON.parseObject(appsecret, new TypeReference<Map<String, String>>(){});
                    respData.setSign(StringUtils.isBlank(respData.getData()) ? "" : CodecUtil.buildRSASignByPrivateKey(respData.getData(), dataMap.get("openPrivateKey")));
                    respData.setData(StringUtils.isBlank(respData.getData()) ? "" : CodecUtil.buildRSAEncryptByPublicKey(respData.getData(), dataMap.get("publicKey")));
                }
            }
            String respDataJson = JSON.toJSONString(respData);
            LogUtil.getLogger().debug("返回客户端IP=[{}]的应答密文为-->[{}],Duration[{}]ms", reqIp, respDataJson, (System.currentTimeMillis()-startTime));
            this.writeToResponse(respDataJson, response);
        }
    }catch(SeedException e){
        respDataStr = JSON.toJSONString(CommResult.fail(e.getCode(), e.getMessage()), true);
        LogUtil.getLogger().info("返回客户端IP=[{}]的应答明文为-->[{}],Duration[{}]ms", reqIp, respDataStr, (System.currentTimeMillis()-startTime));
        this.writeToResponse(respDataStr, response);
    }
}
 
Example 17
Source File: SiteAddParticipantHandler.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Checks if the given domain ends with any of the invalid domains listed in sakai.properties
 * @param domain the domain suffix to be checked
 * @return true if the domain is valid; false otherwise
 */
private boolean isValidDomain( String domain )
{
	return !StringUtils.endsWithAny( domain, invalidDomains.toArray( new String[invalidDomains.size()] ) );
}
 
Example 18
Source File: Resource.java    From Plan with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Check if a resource is a text based file.
 *
 * @param resourceName Name of the resource
 * @return true if the resource is text based.
 */
static boolean isTextResource(String resourceName) {
    return StringUtils.endsWithAny(resourceName, ".html", ".js", ".css", ".yml", ".txt");
}
 
Example 19
Source File: SiteAddParticipantHandler.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Checks if the given domain ends with any of the invalid domains listed in sakai.properties
 * @param domain the domain suffix to be checked
 * @return true if the domain is valid; false otherwise
 */
private boolean isValidDomain( String domain )
{
	return !StringUtils.endsWithAny( domain, invalidDomains.toArray( new String[invalidDomains.size()] ) );
}
 
Example 20
Source File: WebUtil.java    From hdw-dubbo with Apache License 2.0 2 votes vote down vote up
/**
 * 判断访问URI是否是静态文件请求
 *
 * @throws Exception
 */
public static boolean isStaticFile(String uri) {
    return StringUtils.endsWithAny(uri, staticFiles) && !StringUtils.endsWithAny(uri, new String[]{urlSuffix})
            && !StringUtils.endsWithAny(uri, new String[]{".jsp"}) && !StringUtils.endsWithAny(uri, new String[]{".java"});
}