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

The following examples show how to use org.sonatype.nexus.blobstore.api.BlobStoreConfiguration#setName() . 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: GoogleCloudBlobStoreITSupport.java    From nexus-blobstore-google-cloud with Eclipse Public License 1.0 6 votes vote down vote up
public BlobStoreConfiguration newConfiguration(final String name, final String bucketName,
                                               @Nullable final File credentialFile) {
  BlobStoreConfiguration configuration = blobStoreManager.newConfiguration();
  configuration.setName(name);
  configuration.setType("Google Cloud Storage");
  NestedAttributesMap configMap = configuration.attributes("google cloud storage");
  configMap.set("bucket", bucketName);
  configMap.set("location", "us-central1");
  if (credentialFile != null) {
    configMap.set("credential_file", credentialFile.getAbsolutePath());
  }
  NestedAttributesMap quotaMap = configuration.attributes(BlobStoreQuotaSupport.ROOT_KEY);
  quotaMap.set(BlobStoreQuotaSupport.TYPE_KEY, SpaceUsedQuota.ID);
  quotaMap.set(BlobStoreQuotaSupport.LIMIT_KEY, 512000L);

  return configuration;
}
 
Example 2
Source File: FileBlobStoreResource.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@RequiresAuthentication
@RequiresPermissions("nexus:blobstores:update")
@PUT
@Path("/{name}")
@Validate
public void updateFileBlobStore(@PathParam("name") final String name,
                                @Valid final FileBlobStoreApiUpdateRequest request)
    throws Exception
{
  // Confirm that the blobstore name and type are the expected name and type
  getBlobStoreConfiguration(name);

  BlobStoreConfiguration configuration = request.toBlobStoreConfiguration(blobStoreManager.newConfiguration());
  configuration.setName(name);

  blobStoreManager.update(configuration);
}
 
Example 3
Source File: GoogleCloudBlobstoreApiResource.java    From nexus-blobstore-google-cloud with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param config the configuration to be updated
 * @param blobstoreApiModel the source of new values
 */
void merge(BlobStoreConfiguration config, GoogleCloudBlobstoreApiModel blobstoreApiModel) {
  config.setName(blobstoreApiModel.getName());
  NestedAttributesMap bucket = config.attributes(CONFIG_KEY);
  bucket.set(BUCKET_KEY, blobstoreApiModel.getBucketName());
  bucket.set(LOCATION_KEY, blobstoreApiModel.getRegion());

  if (blobstoreApiModel.getSoftQuota() != null ) {
    NestedAttributesMap softQuota = config.attributes(ROOT_KEY);
    softQuota.set(TYPE_KEY, checkNotNull(blobstoreApiModel.getSoftQuota().getType()));
    final Long softQuotaLimit = checkNotNull(blobstoreApiModel.getSoftQuota().getLimit());
    softQuota.set(LIMIT_KEY, softQuotaLimit * ONE_MILLION);
  }
}
 
Example 4
Source File: BlobStoreRule.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
public BlobStore createFile(String name) throws Exception {
  BlobStoreConfiguration config = blobStoreManagerProvider.get().newConfiguration();
  config.setName(name);
  config.setType(FileBlobStore.TYPE);
  config.attributes(FileBlobStore.CONFIG_KEY).set(PATH_KEY, name);
  BlobStore blobStore = blobStoreManagerProvider.get().create(config);
  blobStoreNames.add(name);
  return blobStore;
}
 
Example 5
Source File: BlobStoreRule.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
public BlobStore createGroup(String name, String... members) throws Exception {
  BlobStoreConfiguration config = blobStoreManagerProvider.get().newConfiguration();
  config.setName(name);
  config.setType(BlobStoreGroup.TYPE);
  config.attributes(BlobStoreGroup.CONFIG_KEY).set(BlobStoreGroup.MEMBERS_KEY, asList(members));
  config.attributes(BlobStoreGroup.CONFIG_KEY).set(BlobStoreGroup.FILL_POLICY_KEY, WriteToFirstMemberFillPolicy.TYPE);
  BlobStore blobStore = blobStoreManagerProvider.get().create(config);
  blobStoreGroupNames.add(name);
  return blobStore;
}
 
Example 6
Source File: FileBlobStoreConfigurationBuilder.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the configuration for the desired file blob store.
 */
public BlobStoreConfiguration build() {
  final BlobStoreConfiguration configuration = configurationSupplier.get();
  configuration.setName(name);
  configuration.setType(FileBlobStore.TYPE);
  configuration.attributes(FileBlobStore.CONFIG_KEY).set(FileBlobStore.PATH_KEY, path);
  return configuration;
}
 
Example 7
Source File: FileBlobStoreApiCreateRequest.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public BlobStoreConfiguration toBlobStoreConfiguration(final BlobStoreConfiguration oldConfig) {
  BlobStoreConfiguration newConfig = super.toBlobStoreConfiguration(oldConfig);
  newConfig.setName(name);
  return newConfig;
}