Java Code Examples for org.sonatype.nexus.blobstore.api.BlobStoreConfiguration#getName()

The following examples show how to use org.sonatype.nexus.blobstore.api.BlobStoreConfiguration#getName() . 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: S3BlobStoreDescriptor.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private void validateOverlappingBucketWithConfiguration(final BlobStoreConfiguration newConfig, // NOSONAR
                                                        final BlobStoreConfiguration existingConfig) {
  String newName = newConfig.getName();
  String newBucket = newConfig.attributes(CONFIG_KEY).get(BUCKET_KEY, String.class, "");
  String newPrefix = newConfig.attributes(CONFIG_KEY).get(BUCKET_PREFIX_KEY, String.class, "");
  String newEndpoint = newConfig.attributes(CONFIG_KEY).get(ENDPOINT_KEY, String.class, "");

  if (!existingConfig.getName().equals(newName) && existingConfig.getType().equals(S3BlobStore.TYPE)) {
    String existingBucket = existingConfig.attributes(CONFIG_KEY).get(BUCKET_KEY, String.class, "");
    String existingPrefix = existingConfig.attributes(CONFIG_KEY).get(BUCKET_PREFIX_KEY, String.class, "");
    String existingEndpoint = existingConfig.attributes(CONFIG_KEY).get(ENDPOINT_KEY, String.class, "");
    if (newBucket.equals(existingBucket) &&
        newEndpoint.equals(existingEndpoint) &&
        prefixesOverlap(existingPrefix, newPrefix)) {
      String message = format("Blob Store '%s' is already using bucket '%s'", existingConfig.getName(),
          existingBucket);
      if (!newPrefix.isEmpty() || !existingPrefix.isEmpty()) {
        message = message + format(" with prefix '%s'", existingPrefix);
      }
      if (!newEndpoint.isEmpty() || !existingEndpoint.isEmpty()) {
        message = message + format(" on endpoint '%s'", existingEndpoint);
      }
      throw new ValidationException(message);
    }
  }
}
 
Example 2
Source File: BlobStoreGroupDescriptor.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void validateConfig(final BlobStoreConfiguration config) {
  super.validateConfig(config);
  validateEnabled();
  String name = config.getName();

  String fillPolicy = config.attributes(CONFIG_KEY).get(FILL_POLICY_KEY, String.class);
  if (StringUtils.isBlank(fillPolicy)) {
    throw new ValidationErrorsException("Blob store group requires a fill policy configuration");
  }

  List<String> memberNames = config.attributes(CONFIG_KEY).get(MEMBERS_KEY, List.class);
  validateNotEmptyOrSelfReferencing(name, memberNames);
  validateEligibleMembers(name, memberNames);
  validateOnlyEmptyOrNotWritableExistingMembersRemoved(name, memberNames);
}
 
Example 3
Source File: GoogleCloudBlobstoreApiModel.java    From nexus-blobstore-google-cloud with Eclipse Public License 1.0 5 votes vote down vote up
GoogleCloudBlobstoreApiModel(BlobStoreConfiguration configuration) {
  this.name = configuration.getName();
  this.bucketName = configuration.attributes(CONFIG_KEY).get(BUCKET_KEY, String.class);
  this.region = configuration.attributes(CONFIG_KEY).get(LOCATION_KEY, String.class);

  NestedAttributesMap softQuotaAttributes = configuration.attributes(ROOT_KEY);
  if (softQuotaAttributes != null) {
    BlobStoreApiSoftQuota softQuota = new BlobStoreApiSoftQuota();
    softQuota.setLimit(configuration.attributes(ROOT_KEY).get(LIMIT_KEY, Long.class));
    softQuota.setType(configuration.attributes(ROOT_KEY).get(TYPE_KEY, String.class));
    this.softQuota = softQuota;
  }
}