Java Code Examples for com.google.api.client.repackaged.com.google.common.base.Strings

The following examples show how to use com.google.api.client.repackaged.com.google.common.base.Strings. These examples are extracted from open source projects. 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
/**
 * Performs all necessary setup steps for running requests against the API.
 *
 * @param applicationName the name of the application: com.example.app
 * @param serviceAccountEmail the Service Account Email (empty if using
 *            installed application)
 * @return the {@Link AndroidPublisher} service
 * @throws GeneralSecurityException
 * @throws IOException
 */
protected static AndroidPublisher init(String applicationName,
        String serviceAccountEmail, File serviceAccountKeyFile)
throws IOException, GeneralSecurityException {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(applicationName),
            "Application name cannot be null or empty!");

    // Authorization.
    newTrustedTransport();
    Credential credential = authorizeWithServiceAccount(serviceAccountEmail, serviceAccountKeyFile);

    // Set up and return API client.
    return new AndroidPublisher.Builder(
            HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName(applicationName)
            .build();
}
 
Example 2
private AndroidPublisherExtension getAndVerifyExtension() {
	AndroidPublisherExtension publisherExtension = getProject().getExtensions()
			.getByType(AndroidPublisherExtension.class);

	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getApplicationName()),
			"Application name cannot be null or empty!");
	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getTrack()),
			"Track cannot be null or empty!");
	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getVariantName()),
			"Variant name cannot be null or empty!");
	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getPackageName()),
			"Package name cannot be null or empty!");
	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getServiceAccountEmail()),
			"Service account email cannot be null or empty!");
	Preconditions.checkArgument(publisherExtension.getServiceAccountKeyFile() != null,
			"Service account key file cannot be null or empty!");

	return publisherExtension;
}
 
Example 3
public String createTimeline() throws IOException {
  TimelineCreateResponse timelineCreateResponse =
      makeRequest(
          ImmutableMap.of("method", RememberTheMilkMethods.TIMELINES_CREATE.getMethodName()),
          TimelineCreateResponse.class);
  checkState(!Strings.isNullOrEmpty(timelineCreateResponse.timeline));
  return timelineCreateResponse.timeline;
}
 
Example 4
private AndroidPublisherExtension getAndVerifyExtension() {
	AndroidPublisherExtension publisherExtension = getProject().getExtensions()
			.getByType(AndroidPublisherExtension.class);

	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getApplicationName()),
			"Application name cannot be null or empty!");
	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getTrack()),
			"Track cannot be null or empty!");
	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getPromotionTrack()),
			"Promotion track cannot be null or empty!");
	Preconditions.checkArgument(!publisherExtension.getTrack()
					.equals(publisherExtension.getPromotionTrack()),
			"The publishing track cannot be the same as the promotion track!");
	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getPackageName()),
			"Package name cannot be null or empty!");
	Preconditions.checkArgument(!Strings.isNullOrEmpty(
					publisherExtension.getServiceAccountEmail()),
			"Service account email cannot be null or empty!");
	Preconditions.checkArgument(publisherExtension.getServiceAccountKeyFile() != null,
			"Service account key file cannot be null or empty!");

	return publisherExtension;
}
 
Example 5
Source Project: cloudbreak   Source File: StackV4RequestToStackConverter.java    License: Apache License 2.0 5 votes vote down vote up
private void validateStackAuthentication(StackV4Request source) {
    if (Strings.isNullOrEmpty(source.getAuthentication().getPublicKey())
            && Strings.isNullOrEmpty(source.getAuthentication().getPublicKeyId())) {
        throw new BadRequestException("You should define the publickey or publickeyid!");
    } else if (source.getAuthentication().getLoginUserName() != null) {
        throw new BadRequestException("You can not modify the default user!");
    }
}
 
Example 6
private static JsonElement toJson(String string) {
    return new JsonPrimitive(Strings.nullToEmpty(string));
}