Java Code Examples for org.sonatype.nexus.blobstore.api.BlobStore#init()

The following examples show how to use org.sonatype.nexus.blobstore.api.BlobStore#init() . 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: BlobStoreManagerImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@Guarded(by = STARTED)
public BlobStore create(final BlobStoreConfiguration configuration) throws Exception {
  checkNotNull(configuration);
  log.debug("Creating BlobStore: {} with attributes: {}", configuration.getName(),
      configuration.getAttributes());
  BlobStoreDescriptor blobStoreDescriptor = blobStoreDescriptors.get(configuration.getType());
  blobStoreDescriptor.sanitizeConfig(configuration);
  blobStoreDescriptor.validateConfig(configuration);

  BlobStore blobStore = blobStorePrototypes.get(configuration.getType()).get();
  blobStore.init(configuration);

  if (!EventHelper.isReplicating()) {
    try {
      store.create(configuration);
    }
    catch (Exception e) {
      try {
        blobStore.remove();
      }
      catch (Exception removeException) {
        // if an error occurs on remove log and rethrow original to avoid losing the root cause
        log.error("Error removing BlobStore {} after create failed", configuration.getName(), removeException);
      }
      throw e;
    }
  }

  track(configuration.getName(), blobStore);

  blobStore.start();

  eventManager.post(new BlobStoreCreatedEvent(blobStore));

  return blobStore;
}
 
Example 2
Source File: BlobStoreManagerImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private void startWithConfig(final BlobStore blobStore, final BlobStoreConfiguration config) throws Exception {
  if (blobStore.isStarted()) {
    blobStore.stop();
  }
  blobStore.init(config);
  blobStore.start();
}