当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.defaultIfBlank方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils.defaultIfBlank方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.defaultIfBlank方法的具体用法?Java StringUtils.defaultIfBlank怎么用?Java StringUtils.defaultIfBlank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.defaultIfBlank方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildClientForSecurityTokenRequests

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Build client for security token requests.
 *
 * @param service the rp
 * @return the security token service client
 */
public SecurityTokenServiceClient buildClientForSecurityTokenRequests(final WSFederationRegisteredService service) {
    final Bus cxfBus = BusFactory.getDefaultBus();
    final SecurityTokenServiceClient sts = new SecurityTokenServiceClient(cxfBus);
    sts.setAddressingNamespace(StringUtils.defaultIfBlank(service.getAddressingNamespace(), WSFederationConstants.HTTP_WWW_W3_ORG_2005_08_ADDRESSING));
    sts.setTokenType(StringUtils.defaultIfBlank(service.getTokenType(), WSConstants.WSS_SAML2_TOKEN_TYPE));
    sts.setKeyType(WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
    sts.setWsdlLocation(prepareWsdlLocation(service));
    if (StringUtils.isNotBlank(service.getPolicyNamespace())) {
        sts.setWspNamespace(service.getPolicyNamespace());
    }
    final String namespace = StringUtils.defaultIfBlank(service.getNamespace(), WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512);
    sts.setServiceQName(new QName(namespace, StringUtils.defaultIfBlank(service.getWsdlService(), WSFederationConstants.SECURITY_TOKEN_SERVICE)));
    sts.setEndpointQName(new QName(namespace, service.getWsdlEndpoint()));
    sts.getProperties().putAll(new HashMap<>());
    return sts;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:SecurityTokenServiceClientBuilder.java

示例2: buildClientForRelyingPartyTokenResponses

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Build client for relying party token responses.
 *
 * @param securityToken the security token
 * @param service       the service
 * @return the security token service client
 */
public SecurityTokenServiceClient buildClientForRelyingPartyTokenResponses(final SecurityToken securityToken,
                                                                           final WSFederationRegisteredService service) {
    final Bus cxfBus = BusFactory.getDefaultBus();
    final SecurityTokenServiceClient sts = new SecurityTokenServiceClient(cxfBus);
    sts.setAddressingNamespace(StringUtils.defaultIfBlank(service.getAddressingNamespace(), WSFederationConstants.HTTP_WWW_W3_ORG_2005_08_ADDRESSING));
    sts.setWsdlLocation(prepareWsdlLocation(service));
    final String namespace = StringUtils.defaultIfBlank(service.getNamespace(), WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512);
    sts.setServiceQName(new QName(namespace, service.getWsdlService()));
    sts.setEndpointQName(new QName(namespace, service.getWsdlEndpoint()));
    sts.setEnableAppliesTo(StringUtils.isNotBlank(service.getAppliesTo()));
    sts.setOnBehalfOf(securityToken.getToken());
    sts.setKeyType(WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
    sts.setTokenType(StringUtils.defaultIfBlank(service.getTokenType(), WSConstants.WSS_SAML2_TOKEN_TYPE));

    if (StringUtils.isNotBlank(service.getPolicyNamespace())) {
        sts.setWspNamespace(service.getPolicyNamespace());
    }

    return sts;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:28,代码来源:SecurityTokenServiceClientBuilder.java

示例3: createAppender

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Create appender cloud watch appender.
 *
 * @param name                             the name
 * @param awsLogStreamName                 the aws log stream name
 * @param awsLogGroupName                  the aws log group name
 * @param awsLogStreamFlushPeriodInSeconds the aws log stream flush period in seconds
 * @param credentialAccessKey              the credential access key
 * @param credentialSecretKey              the credential secret key
 * @param awsLogRegionName                 the aws log region name
 * @param layout                           the layout
 * @return the cloud watch appender
 */
@PluginFactory
public static CloudWatchAppender createAppender(@PluginAttribute("name") final String name,
                                                @PluginAttribute("awsLogStreamName") final String awsLogStreamName,
                                                @PluginAttribute("awsLogGroupName") final String awsLogGroupName,
                                                @PluginAttribute("awsLogStreamFlushPeriodInSeconds") final String awsLogStreamFlushPeriodInSeconds,
                                                @PluginAttribute("credentialAccessKey") final String credentialAccessKey,
                                                @PluginAttribute("credentialSecretKey") final String credentialSecretKey,
                                                @PluginAttribute("awsLogRegionName") final String awsLogRegionName,
                                                @PluginElement("Layout") final Layout<Serializable> layout) {
    return new CloudWatchAppender(
            name,
            awsLogGroupName,
            awsLogStreamName,
            awsLogStreamFlushPeriodInSeconds,
            StringUtils.defaultIfBlank(credentialAccessKey, System.getProperty("AWS_ACCESS_KEY")),
            StringUtils.defaultIfBlank(credentialSecretKey, System.getProperty("AWS_SECRET_KEY")),
            StringUtils.defaultIfBlank(awsLogRegionName, System.getProperty("AWS_REGION_NAME")),
            layout);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:33,代码来源:CloudWatchAppender.java

示例4: exceptionHandler

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/** 异常处理 */
@ExceptionHandler(Exception.class)
public void exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception ex)
        throws Exception {
    logger.error(Constants.Exception_Head, ex);
    OperationResult result=new OperationResult();
    if (ex instanceof AbstractException) {
        ((AbstractException) ex).handler(result);
    } /*else if (ex instanceof IllegalArgumentException) {
        new IllegalParameterException(ex.getMessage()).handler(modelMap);
    } else if (ex instanceof UnauthorizedException) {
        modelMap.put("httpCode", HttpCode.FORBIDDEN.value());
        modelMap.put("msg", StringUtils.defaultIfBlank(ex.getMessage(), HttpCode.FORBIDDEN.msg()));
    } */else {
        result.setCode(HttpCode.INTERNAL_SERVER_ERROR.value());
        String msg = StringUtils.defaultIfBlank(ex.getMessage(), HttpCode.INTERNAL_SERVER_ERROR.msg());
        result.setMessage(msg.length() > 100 ? "系统走神了,请稍候再试." : msg);
    }
    response.setContentType("application/json;charset=UTF-8");
    logger.info(JSON.toJSONString(result));
    byte[] bytes = JSON.toJSONBytes(result, SerializerFeature.DisableCircularReferenceDetect);
    response.getOutputStream().write(bytes);
}
 
开发者ID:liuxx001,项目名称:bird-java,代码行数:24,代码来源:AbstractController.java

示例5: buildNormalizedHomePath

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private Path buildNormalizedHomePath(final String rawHomePath) {
    final String defaultPath = StringUtils.defaultIfBlank(rawHomePath, Path.HOME);
    final String accountRootRegex = String.format("^/?(%s|~~?)/?", accountRoot.getAbsolute());
    final String subdirectoryRawPath = defaultPath.replaceFirst(accountRootRegex, "");

    if(StringUtils.isEmpty(subdirectoryRawPath)) {
        return accountRoot;
    }

    final String[] subdirectoryPathSegments = StringUtils.split(subdirectoryRawPath, Path.DELIMITER);
    Path homePath = accountRoot;

    for(final String pathSegment : subdirectoryPathSegments) {
        EnumSet<Path.Type> types = EnumSet.of(Path.Type.directory);
        if(homePath.getParent().equals(accountRoot)
            && StringUtils.equalsAny(pathSegment, HOME_PATH_PRIVATE, HOME_PATH_PUBLIC)) {
            types.add(Path.Type.volume);
        }

        homePath = new Path(homePath, pathSegment, types);
    }

    return homePath;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:25,代码来源:MantaAccountHomeInfo.java

示例6: getDataSource

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Return the data source of JIRA database server.
 * 
 * @param parameters
 *            the subscription parameters containing at least the data source
 *            configuration.
 * @return the data source of JIRA database server.
 */
protected DataSource getDataSource(final Map<String, String> parameters) {
	try {
		return new SimpleDriverDataSource(
				(Driver) Class.forName(StringUtils.defaultIfBlank(parameters.get(PARAMETER_JDBC_DRIVER), "com.mysql.cj.jdbc.Driver"))
						.newInstance(),
				StringUtils.defaultIfBlank(parameters.get(PARAMETER_JDBC_URL),
						"jdbc:mysql://localhost:3306/jira6?useColumnNamesInFindColumn=true&useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true&maxReconnects=3"),
				parameters.get(PARAMETER_JDBC_USER), parameters.get(PARAMETER_JDBC_PASSSWORD));
	} catch (final Exception e) {
		log.error("Database connection issue for JIRA", e);
		throw new TechnicalException("Database connection issue for JIRA", e);
	}
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:22,代码来源:JiraBaseResource.java

示例7: build

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Create an authentication from a user profile.
 *
 * @param profile           the given user profile
 * @param registeredService the registered service
 * @param context           the context
 * @param service           the service
 * @return the built authentication
 */
public Authentication build(final UserProfile profile,
                            final OAuthRegisteredService registeredService,
                            final J2EContext context,
                            final Service service) {

    final Map<String, Object> profileAttributes = getPrincipalAttributesFromProfile(profile);
    final Principal newPrincipal = this.principalFactory.createPrincipal(profile.getId(), profileAttributes);
    LOGGER.debug("Created final principal [{}] after filtering attributes based on [{}]", newPrincipal, registeredService);

    final String authenticator = profile.getClass().getCanonicalName();
    final CredentialMetaData metadata = new BasicCredentialMetaData(new BasicIdentifiableCredential(profile.getId()));
    final HandlerResult handlerResult = new DefaultHandlerResult(authenticator, metadata, newPrincipal, new ArrayList<>());

    final String state = StringUtils.defaultIfBlank(context.getRequestParameter(OAuth20Constants.STATE), StringUtils.EMPTY);
    final String nonce = StringUtils.defaultIfBlank(context.getRequestParameter(OAuth20Constants.NONCE), StringUtils.EMPTY);
    LOGGER.debug("OAuth [{}] is [{}], and [{}] is [{}]", OAuth20Constants.STATE, state, OAuth20Constants.NONCE, nonce);

    /**
     * pac4j UserProfile.getPermissions() and getRoles() returns UnmodifiableSet which Jackson Serializer
     * happily serializes to json but is unable to deserialize.
     * We have to wrap it to HashSet to avoid such problem
     */
    final AuthenticationBuilder bldr = DefaultAuthenticationBuilder.newInstance()
            .addAttribute("permissions", new HashSet<>(profile.getPermissions()))
            .addAttribute("roles", new HashSet<>(profile.getRoles()))
            .addAttribute(OAuth20Constants.STATE, state)
            .addAttribute(OAuth20Constants.NONCE, nonce)
            .addCredential(metadata)
            .setPrincipal(newPrincipal)
            .setAuthenticationDate(ZonedDateTime.now())
            .addSuccess(profile.getClass().getCanonicalName(), handlerResult);

    collectionAuthenticationAttributesIfNecessary(profile, bldr);
    return bldr.build();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:45,代码来源:OAuth20CasAuthenticationBuilder.java

示例8: setParams

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/** 设置参数 */
private void setParams(String sender, SendMsg sendMsg) {
	String cacheKey1, cacheKey2;
	switch (sendMsg.getMsgType()) {
	case "1":// 用户注册验证码
		cacheKey2 = "REGIN_" + sendMsg.getPhone();
		sendRandomCode(sender, sendMsg, cacheKey2);
		break;
	case "2":// 登录确认验证码
		cacheKey1 = "LOGIN_" + DateUtil.getDate() + "_" + sendMsg.getPhone();
		cacheKey2 = "LOGIN_" + sendMsg.getPhone();
		String times = StringUtils.defaultIfBlank(paramService.getValue("LOGIN_DAILY_TIMES"), "3");
		String msg = StringUtils.defaultIfBlank(paramService.getValue("LOGIN_LIMIT_MSG"), "您今天登录的次数已达到最大限制。");
		refreshSendTimes(cacheKey1, 60 * 60 * 24, Integer.parseInt(times), msg);
		sendRandomCode(sender, sendMsg, cacheKey2);
		break;
	case "3":// 修改密码验证码
		cacheKey2 = "CHGPWD_" + sendMsg.getPhone();
		sendRandomCode(sender, sendMsg, cacheKey2);
		break;
	case "4":// 身份验证验证码
		cacheKey2 = "VLDID_" + sendMsg.getPhone();
		sendRandomCode(sender, sendMsg, cacheKey2);
		break;
	case "5":// 信息变更验证码
		cacheKey2 = "CHGINFO_" + sendMsg.getPhone();
		sendRandomCode(sender, sendMsg, cacheKey2);
		break;
	case "6":// 活动确认验证码
		cacheKey2 = "AVTCMF_" + sendMsg.getPhone();
		sendRandomCode(sender, sendMsg, cacheKey2);
		break;
	default:
		break;
	}
}
 
开发者ID:youngMen1,项目名称:JAVA-,代码行数:37,代码来源:SendMsgService.java

示例9: composeMergedAndCachedAttributeRepositories

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private IPersonAttributeDao composeMergedAndCachedAttributeRepositories(final List<IPersonAttributeDao> list) {
    final MergingPersonAttributeDaoImpl mergingDao = new MergingPersonAttributeDaoImpl();

    final String merger = StringUtils.defaultIfBlank(casProperties.getAuthn().getAttributeRepository().getMerger(), "replace".trim());
    LOGGER.debug("Configured merging strategy for attribute sources is [{}]", merger);
    switch (merger.toLowerCase()) {
        case "merge":
            mergingDao.setMerger(new MultivaluedAttributeMerger());
            break;
        case "add":
            mergingDao.setMerger(new NoncollidingAttributeAdder());
            break;
        case "replace":
        default:
            mergingDao.setMerger(new ReplacingAttributeAdder());
            break;
    }

    final CachingPersonAttributeDaoImpl impl = new CachingPersonAttributeDaoImpl();
    impl.setCacheNullResults(false);

    final Cache graphs = CacheBuilder.newBuilder()
            .concurrencyLevel(2)
            .weakKeys()
            .maximumSize(casProperties.getAuthn().getAttributeRepository().getMaximumCacheSize())
            .expireAfterWrite(casProperties.getAuthn().getAttributeRepository().getExpireInMinutes(), TimeUnit.MINUTES)
            .build();
    impl.setUserInfoCache(graphs.asMap());
    mergingDao.setPersonAttributeDaos(list);
    impl.setCachedPersonAttributesDao(mergingDao);

    if (list.isEmpty()) {
        LOGGER.debug("No attribute repository sources are available/defined to merge together.");
    } else {
        LOGGER.debug("Configured attribute repository sources to merge together: [{}]", list);
        LOGGER.debug("Configured cache expiration policy for merging attribute sources to be [{}] minute(s)",
                casProperties.getAuthn().getAttributeRepository().getExpireInMinutes());
    }
    return impl;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:41,代码来源:CasPersonDirectoryConfiguration.java

示例10: getResourceName

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String getResourceName(String path) {
    String name = StringUtils.removeStart(path, "/api/");
    if (StringUtils.startsWith(name, "_search")) {
        name = StringUtils.substringAfter(name, "/");
    }
    return StringUtils.defaultIfBlank(StringUtils.substringBefore(name, "/"), "unknown");
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:8,代码来源:TimelineEventProducer.java

示例11: processRequest

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
String processRequest(final RestfulMock mock, final Request req, final Response res) {

        RestfulResponseDTO outcome;

        switch (mock.getMockType()) {
            case RULE:
                outcome = ruleEngine.process(req, mock.getRules());
                break;
            case PROXY_HTTP:
                outcome = proxyService.waitForResponse(req.pathInfo(), mock);
                break;
            case SEQ:
            default:
                outcome = mockOrderingCounterService.process(mock);
                break;
        }

        if (outcome == null) {
            // Load in default values
            outcome = getDefault(mock);
        }

        res.status(outcome.getHttpStatusCode());
        res.type(outcome.getResponseContentType());

        // Apply any response headers
        for (Map.Entry<String, String> e : outcome.getHeaders().entrySet()) {
            res.header(e.getKey(), e.getValue());
        }

        final String response = inboundParamMatchService.enrichWithInboundParamMatches(req, outcome.getResponseBody());

        return StringUtils.defaultIfBlank(response,"");
    }
 
开发者ID:mgtechsoftware,项目名称:smockin,代码行数:35,代码来源:MockedRestServerEngine.java

示例12: getAppliesTo

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public String getAppliesTo() {
    return StringUtils.defaultIfBlank(appliesTo, this.realm);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:4,代码来源:WSFederationRegisteredService.java

示例13: getSql

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public String getSql() {
    return StringUtils.defaultIfBlank(getSetting(environment, "sql"), SQL);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:4,代码来源:JdbcCloudConfigBootstrapConfiguration.java

示例14: getUrl

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String getUrl() {
    return StringUtils.defaultIfBlank(getSetting(environment, "url"), super.getUrl());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:5,代码来源:JdbcCloudConfigBootstrapConfiguration.java

示例15: getPassword

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String getPassword() {
    return StringUtils.defaultIfBlank(getSetting(environment, "password"), super.getPassword());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:5,代码来源:JdbcCloudConfigBootstrapConfiguration.java


注:本文中的org.apache.commons.lang3.StringUtils.defaultIfBlank方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。