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


Java StringUtils.isNullOrEmpty方法代码示例

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


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

示例1: getS3Client

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
public static AmazonS3 getS3Client(final String region, final String roleArn) {
    final Regions awsRegion = StringUtils.isNullOrEmpty(region) ? Regions.US_EAST_1 : Regions.fromName(region);

    if (StringUtils.isNullOrEmpty(roleArn)) {
        return AmazonS3ClientBuilder.standard().withRegion(awsRegion).build();
    } else {
        final AssumeRoleRequest assumeRole = new AssumeRoleRequest().withRoleArn(roleArn).withRoleSessionName("io-klerch-mp3-converter");

        final AWSSecurityTokenService sts = AWSSecurityTokenServiceClientBuilder.standard().withRegion(awsRegion).build();
        final Credentials credentials = sts.assumeRole(assumeRole).getCredentials();

        final BasicSessionCredentials sessionCredentials = new BasicSessionCredentials(
                credentials.getAccessKeyId(),
                credentials.getSecretAccessKey(),
                credentials.getSessionToken());

        return AmazonS3ClientBuilder.standard().withRegion(awsRegion).withCredentials(new AWSStaticCredentialsProvider(sessionCredentials)).build();
    }
}
 
开发者ID:KayLerch,项目名称:alexa-meets-polly,代码行数:20,代码来源:ConvertService.java

示例2: isUploadFile

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
private boolean isUploadFile(Iterator<S3ObjectSummary> iter, String path, String hash) {
    while (iter.hasNext()) {
        S3ObjectSummary fileS3 = iter.next();
        // Filename should look like this:
        // a/b
        if (!fileS3.getKey().equals(path)) {
            // If this is another file, then continue!
            continue;
        }
        // Remove the file from the S3 list as it does not need to be processed further
        iter.remove();
        // Upload if the hashes differ
        return StringUtils.isNullOrEmpty(hash) || !fileS3.getETag().equals(hash);
    }
    return true;
}
 
开发者ID:berlam,项目名称:github-bucket,代码行数:17,代码来源:RepositoryS3.java

示例3: handle

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
@Override
public AmazonWebServiceResponse<HeadBucketResult> handle(HttpResponse response)
        throws Exception {
    final AmazonWebServiceResponse<HeadBucketResult> awsResponse = new AmazonWebServiceResponse<HeadBucketResult>();
    final HeadBucketResult result = new HeadBucketResult();
    result.setBucketRegion(response.getHeaders().get(Headers.S3_BUCKET_REGION));

    if (!StringUtils.isNullOrEmpty(response.getHeaders().get(Headers.IBM_SSE_KP_ENABLED))){
    	result.setIBMSSEKPEnabled(Boolean.parseBoolean(response.getHeaders().get(Headers.IBM_SSE_KP_ENABLED)));
    }
    if (!StringUtils.isNullOrEmpty(response.getHeaders().get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))){
    	result.setIBMSSEKPCrk(response.getHeaders().get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN));
    }
    awsResponse.setResult(result);

    return awsResponse;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:18,代码来源:HeadBucketResultHandler.java

示例4: handle

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
/**
 * @see com.amazonaws.http.HttpResponseHandler#handle(com.amazonaws.http.HttpResponse)
 */
public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception {
    AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response);
    responseHeaders = response.getHeaders();

    if (responseUnmarshaller != null) {
        log.trace("Beginning to parse service response XML");
        T result = responseUnmarshaller.unmarshall(response.getContent());
        log.trace("Done parsing service response XML");
        awsResponse.setResult(result);
        
        if (result instanceof ObjectListing) {
        	if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED))){
        		((ObjectListing) result).setIBMSSEKPEnabled(Boolean.parseBoolean(responseHeaders.get(Headers.IBM_SSE_KP_ENABLED)));
        	}
        	if (!StringUtils.isNullOrEmpty(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN))) {
        		((ObjectListing) result).setIBMSSEKPCrk(responseHeaders.get(Headers.IBM_SSE_KP_CUSTOMER_ROOT_KEY_CRN));
        	} 
        }
    }

    return awsResponse;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:S3XmlResponseHandler.java

示例5: getCredentials

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
@Override
public AWSCredentials getCredentials() {
	// if profile is specified, use that
	final String profile = configuration.get(AWSConstants.PROFILE);
	if(!StringUtils.isNullOrEmpty(profile)) {
		return new ProfileCredentialsProvider(profile).getCredentials();
	}

	// then try access key and secret
	final String accessKeyId = configuration.get(AWSConstants.ACCESS_KEY_ID);
	final String secretAccessKey = configuration.get(AWSConstants.SECRET_ACCESS_KEY);
	if(!StringUtils.isNullOrEmpty(accessKeyId) && !StringUtils.isNullOrEmpty(secretAccessKey)) {
		return new BasicAWSCredentials(accessKeyId, secretAccessKey);
	}

	// fall back to default
	return new DefaultAWSCredentialsProviderChain().getCredentials();
}
 
开发者ID:KabbageInc,项目名称:bamboo-opsworks,代码行数:19,代码来源:ConfigurationMapCredentialsProvider.java

示例6: getCredentials

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
@Override
public AWSCredentials getCredentials() {
  String accessKey = null;
  if (config.hasPath(GobblinAWSConfigurationKeys.SERVICE_ACCESS_KEY)) {
    accessKey = config.getString(GobblinAWSConfigurationKeys.SERVICE_ACCESS_KEY);
  }

  String secretKey = null;
  if (config.hasPath(GobblinAWSConfigurationKeys.SERVICE_SECRET_KEY)) {
    secretKey = PasswordManager.getInstance(ConfigUtils.configToState(config))
            .readPassword(config.getString(GobblinAWSConfigurationKeys.SERVICE_SECRET_KEY));
  }

  accessKey = StringUtils.trim(accessKey);
  secretKey = StringUtils.trim(secretKey);
  if (StringUtils.isNullOrEmpty(accessKey) || StringUtils.isNullOrEmpty(secretKey)) {
    throw new AmazonClientException(String.format("Unable to load AWS credentials from config (%s and %s)",
            GobblinAWSConfigurationKeys.SERVICE_ACCESS_KEY, GobblinAWSConfigurationKeys.SERVICE_SECRET_KEY));
  }

  return new BasicAWSCredentials(accessKey, secretKey);
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:23,代码来源:AWSClusterSecurityManager.java

示例7: start

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
@Override
public void start() {
    if (RegionUtils.getRegion(region) == null) {
        addError(format("Region not set or invalid for appender '%s'", getName()));
        return;
    }
    if (StringUtils.isNullOrEmpty(logGroup)) {
        addError(format("Log group name not set for appender '%s'", getName()));
        return;
    }
    if (StringUtils.isNullOrEmpty(logStream)) {
        addError(format("Log stream name not set for appender '%s'", getName()));
        return;
    }
    setConverter(new StringPayloadConverter(getCharset(), isBinary()));
    super.start();
}
 
开发者ID:trautonen,项目名称:logback-ext,代码行数:18,代码来源:AbstractCloudWatchAppender.java

示例8: getRegion

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
@Override
public String getRegion() throws SdkClientException {
    File configFile = locationProvider.getLocation();
    if (configFile != null && configFile.exists()) {
        BasicProfile profile = loadProfile(configFile);
        if (profile != null && !StringUtils.isNullOrEmpty(profile.getRegion())) {
            return profile.getRegion();
        }
    }
    return null;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:12,代码来源:AwsProfileRegionProvider.java

示例9: parseNonProxyHosts

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
private void parseNonProxyHosts(String nonProxyHosts) {
    if (!StringUtils.isNullOrEmpty(nonProxyHosts)) {
        String[] hosts = nonProxyHosts.split("\\|");
        hostPatterns = new String[hosts.length];
        for (int i = 0; i < hosts.length; ++i) {
            hostPatterns[i] = hosts[i].toLowerCase().replace("*", ".*?");
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:10,代码来源:SdkProxyRoutePlanner.java

示例10: handle

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
@Override
public AmazonServiceException handle(HttpResponse errorResponse) throws Exception {
    AmazonServiceException ase = createAse(errorResponse);
    if (ase == null) {
        throw new SdkClientException("Unable to unmarshall error response from service");
    }
    ase.setHttpHeaders(errorResponse.getHeaders());
    if (StringUtils.isNullOrEmpty(ase.getErrorCode())) {
        ase.setErrorCode(errorResponse.getStatusCode() + " " + errorResponse.getStatusText());
    }
    return ase;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:13,代码来源:DefaultErrorResponseHandler.java

示例11: fromAssumeRole

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
private AWSCredentialsProvider fromAssumeRole() {
    if (StringUtils.isNullOrEmpty(profile.getRoleSourceProfile())) {
        throw new SdkClientException(String.format(
                "Unable to load credentials from profile [%s]: Source profile name is not specified",
                profile.getProfileName()));
    }

    final BasicProfile sourceProfile = allProfiles
            .getProfile(this.profile.getRoleSourceProfile());
    if (sourceProfile == null) {
        throw new SdkClientException(String.format(
                "Unable to load source profile [%s]: Source profile was not found [%s]",
                profile.getProfileName(), profile.getRoleSourceProfile()));
    }
    AWSCredentials sourceCredentials = new ProfileStaticCredentialsProvider(sourceProfile)
            .getCredentials();


    final String roleSessionName = (this.profile.getRoleSessionName() == null) ?
            "aws-sdk-java-" + System.currentTimeMillis() : this.profile.getRoleSessionName();

    RoleInfo roleInfo = new RoleInfo().withRoleArn(this.profile.getRoleArn())
            .withRoleSessionName(roleSessionName)
            .withExternalId(this.profile.getRoleExternalId())
            .withLongLivedCredentials(sourceCredentials);
    return profileCredentialsService.getAssumeRoleCredentialsProvider(roleInfo);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:28,代码来源:ProfileAssumeRoleCredentialsProvider.java

示例12: loadProfileName

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
/**
 * TODO The order would make more sense as System Property, Environment Variable, Default
 * Profile name but we have to keep the current order for backwards compatiblity. Consider
 * changing this in a future major version.
 */
public final String loadProfileName() {
    final String profileEnvVarOverride = getEnvProfileName();
    if (!StringUtils.isNullOrEmpty(profileEnvVarOverride)) {
        return profileEnvVarOverride;
    } else {
        final String profileSysPropOverride = getSysPropertyProfileName();
        if (!StringUtils.isNullOrEmpty(profileSysPropOverride)) {
            return profileSysPropOverride;
        } else {
            return DEFAULT_PROFILE_NAME;
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:19,代码来源:AwsProfileNameLoader.java

示例13: fromStaticCredentials

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
private AWSCredentials fromStaticCredentials() {
	
	//IBM bx Credentials loaded
	if (!StringUtils.isNullOrEmpty(profile.getIBMApiKey())){
		return new BasicIBMOAuthCredentials(profile.getIBMApiKey(),
                profile.getIBMServiceInstanceId());
	}
	
    if (StringUtils.isNullOrEmpty(profile.getAwsAccessIdKey())) {
        throw new SdkClientException(String.format(
                "Unable to load credentials into profile [%s]: AWS Access Key ID is not specified.",
                profile.getProfileName()));
    }
    if (StringUtils.isNullOrEmpty(profile.getAwsSecretAccessKey())) {
        throw new SdkClientException(String.format(
                "Unable to load credentials into profile [%s]: AWS Secret Access Key is not specified.",
                profile.getAwsSecretAccessKey()));
    }

    if (profile.getAwsSessionToken() == null) {
        return new BasicAWSCredentials(profile.getAwsAccessIdKey(),
                                       profile.getAwsSecretAccessKey());
    } else {
        if (profile.getAwsSessionToken().isEmpty()) {
            throw new SdkClientException(String.format(
                    "Unable to load credentials into profile [%s]: AWS Session Token is empty.",
                    profile.getProfileName()));
        }

        return new BasicSessionCredentials(profile.getAwsAccessIdKey(),
                                           profile.getAwsSecretAccessKey(),
                                           profile.getAwsSessionToken());
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:35,代码来源:ProfileStaticCredentialsProvider.java

示例14: getCredentials

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
@Override
public AWSCredentials getCredentials() {
    
	//Load IBM properties
	
	String accessKey =
        StringUtils.trim(System.getProperty(ACCESS_KEY_SYSTEM_PROPERTY));

    String secretKey =
        StringUtils.trim(System.getProperty(SECRET_KEY_SYSTEM_PROPERTY));
    
	String apiKey =
        StringUtils.trim(System.getProperty(SDKGlobalConfiguration.IBM_API_KEY_SYSTEM_PROPERTY));

    String serviceInstance =
        StringUtils.trim(System.getProperty(SDKGlobalConfiguration.IBM_SERVICE_INSTANCE_ID_SYSTEM_PROPERTY));
    
    if (!StringUtils.isNullOrEmpty(apiKey) && tokenManager == null) {

    	BasicIBMOAuthCredentials oAuthCreds = new BasicIBMOAuthCredentials(apiKey, serviceInstance);
    	tokenManager = oAuthCreds.getTokenManager();
    	return oAuthCreds;
    	
    } else if ((!StringUtils.isNullOrEmpty(apiKey) && tokenManager != null)) {

    	return new BasicIBMOAuthCredentials(tokenManager, serviceInstance);
    }

    if (StringUtils.isNullOrEmpty(accessKey)
            || StringUtils.isNullOrEmpty(secretKey)) {

        throw new SdkClientException(
                "Unable to load AWS credentials from Java system "
                + "properties (" + ACCESS_KEY_SYSTEM_PROPERTY + " and "
                + SECRET_KEY_SYSTEM_PROPERTY + ")");
    }

    return new BasicAWSCredentials(accessKey, secretKey);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:40,代码来源:SystemPropertiesCredentialsProvider.java

示例15: AlexaClient

import com.amazonaws.util.StringUtils; //导入方法依赖的package包/类
AlexaClient(final AlexaClientBuilder builder) {
    this.millisFromCurrentDate = builder.timestamp.getTime() - new Date().getTime();
    this.locale = builder.locale;
    apiEndpoint = apiEndpoints.getOrDefault(builder.apiEndpoint, apiEndpoints.get(NA));
    this.application = new Application(builder.applicationId);
    this.user = User.builder().withUserId(builder.uid).withAccessToken(builder.accessToken).build();
    this.device = builder.device;
    this.debugFlagSessionAttributeName = StringUtils.isNullOrEmpty(builder.debugFlagSessionAttributeName) ? Optional.empty() : Optional.of(builder.debugFlagSessionAttributeName);
    this.endpoint = builder.endpoint;
    this.yLaunch = builder.yLaunch;
}
 
开发者ID:KayLerch,项目名称:alexa-skills-kit-tester-java,代码行数:12,代码来源:AlexaClient.java


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