Package com.elasticinbox.config.blob

Examples of com.elasticinbox.config.blob.BlobStoreProfile


    }

    logger.debug("Deleting blob {}", uri);

    String profileName = uri.getHost();
    BlobStoreProfile profile = Configurator.getBlobStoreProfile(profileName);
    String path = BlobUtils.relativize(uri.getPath());
   
    if (profile.getProvider().equals(PROVIDER_FILESYSTEM))
    {
      // Following part is added as a replacement for jClouds delete due to
      // performance issues with jClouds

      String fileName = new StringBuilder(profile.getEndpoint())
          .append(File.separator).append(profile.getContainer())
          .append(File.separator).append(path).toString();
     
      File f = new File(fileName);

      // If file does not exist, skip
      if (!f.exists()) {
        return;
      }

      // Make sure the file is writable
      Assert.isTrue(f.canWrite(), "File is write protected: " + fileName);

      // Check if it is a directory
      Assert.isTrue(!f.isDirectory(), "Can't delete directory: " + fileName);

      // Attempt to delete it
      boolean success = f.delete();

      Assert.isTrue(success, "Deletion failed");
    } else {
      String container = profile.getContainer();
      BlobStoreContext context = getBlobStoreContext(profileName);
      context.getBlobStore().removeBlob(container, path);
    }
  }
View Full Code Here


      synchronized (CloudStoreProxy.class)
      {
        logger.debug("Creating new connection for '{}' blob store.", profileName);
       
        Properties properties = new Properties();
        BlobStoreProfile profile = Configurator.getBlobStoreProfile(profileName);
        ContextBuilder contextBuilder = ContextBuilder.newBuilder(profile.getProvider());

        if (profile.getProvider().equals(PROVIDER_FILESYSTEM)) {
          // use endpoint as fs basedir, see: http://code.google.com/p/jclouds/issues/detail?id=776
          properties.setProperty(FilesystemConstants.PROPERTY_BASEDIR, profile.getEndpoint());
          contextBuilder.endpoint(profile.getEndpoint());
          //properties.setProperty(PROPERTY_CREDENTIAL, "dummy");
        } else if (BLOBSTORE_PROVIDERS.contains(profile.getProvider())) {
          if (profile.getEndpoint() != null) {
            contextBuilder.endpoint(profile.getEndpoint());
          }
          if (profile.getApiversion() != null) {
            contextBuilder.apiVersion(profile.getApiversion());
          }
          if (profile.getIdentity() != null && profile.getCredential() != null) {
            contextBuilder.credentials(profile.getIdentity(), profile.getCredential());
          }
        } else {
          throw new UnsupportedOperationException(
              "Unsupported Blobstore provider: " + profile.getProvider());
        }

        // get a context with filesystem that offers the portable BlobStore api
        BlobStoreContext context = contextBuilder
            .overrides(properties)
            .modules(ImmutableSet.of(new JcloudsSlf4JLoggingModule()))
            .buildView(BlobStoreContext.class);

        // create container for transient store
        if(profile.getProvider().equals(PROVIDER_TRANSIENT)) {
          context.getBlobStore().createContainerInLocation(null, profile.getContainer());
        }

        blobStoreContexts.put(profileName, context);
      }
View Full Code Here

TOP

Related Classes of com.elasticinbox.config.blob.BlobStoreProfile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.