コード例 #1
0
  public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
    List<StorageObjectMetadata> listFiles;
    try {
      String dir = options.getDir();
      if (dir != null) {
        listFiles = service.listFiles(container, dir, options.isRecursive());
      } else {
        listFiles = service.listFiles(container, "", options.isRecursive());
      }

      List<MutableStorageMetadata> jCloudsMetadata = new ArrayList<MutableStorageMetadata>();
      if (!listFiles.isEmpty()) {
        for (StorageObjectMetadata metadata : listFiles) {
          jCloudsMetadata.add(generateJcloudsMetadata(metadata));
        }
      } else {
        StorageObjectMetadata metadata = new StorageObjectMetadata();
        if (dir != null) metadata.setPathAndName(dir);
        metadata.setType(StorageObjectConstants.DIRECTORY_TYPE);
        jCloudsMetadata.add(generateJcloudsMetadata(metadata));
      }

      return new PageSetImpl<StorageMetadata>(jCloudsMetadata, null);
    } catch (MethodNotSupportedException e) {
      e.printStackTrace();
      return null;
    }
  }
コード例 #2
0
 private MutableBlobMetadataImpl generateJcloudsMetadata(
     StorageObjectMetadata storageObjectMetadata) {
   MutableBlobMetadataImpl mutableBlobMetadataImpl = new MutableBlobMetadataImpl();
   mutableBlobMetadataImpl.setName(storageObjectMetadata.getPathAndName());
   if (storageObjectMetadata.isFile()) {
     mutableBlobMetadataImpl.setType(StorageType.BLOB);
   } else if (storageObjectMetadata.isDirectory()) {
     mutableBlobMetadataImpl.setType(StorageType.FOLDER);
   } else if (storageObjectMetadata.isContainer()) {
     mutableBlobMetadataImpl.setType(StorageType.CONTAINER);
   }
   mutableBlobMetadataImpl
       .getContentMetadata()
       .setContentLength(storageObjectMetadata.getLength());
   mutableBlobMetadataImpl.setLastModified(storageObjectMetadata.getLastModified());
   if (storageObjectMetadata.getMd5hash() != null) {
     mutableBlobMetadataImpl.setETag(storageObjectMetadata.getMd5hash());
   }
   return mutableBlobMetadataImpl;
 }