示例#1
0
 /**
  * Injects the StorageInfo into the FileAttributes.
  *
  * <p>Legacy fields that used to be stored in StorageInfo, but are now stored in FileAttributes,
  * are injected into the FileAttributes too.
  *
  * <p>Should only be used when backwards compatibility must be maintained.
  */
 public static FileAttributes injectInto(StorageInfo info, FileAttributes attributes) {
   attributes.setStorageInfo(info);
   attributes.setSize(info.getLegacySize());
   attributes.setAccessLatency(info.getLegacyAccessLatency());
   attributes.setRetentionPolicy(info.getLegacyRetentionPolicy());
   String cFlag = info.getKey("flag-c");
   if (cFlag != null) {
     attributes.setChecksums(
         Sets.newHashSet(
             transform(
                 Splitter.on(',').trimResults().omitEmptyStrings().split(cFlag),
                 new Function<String, Checksum>() {
                   @Override
                   public Checksum apply(String digest) {
                     return Checksum.parseChecksum(digest);
                   }
                 })));
   }
   String uid = info.getKey("uid");
   if (uid != null) {
     attributes.setOwner(Integer.parseInt(uid));
   }
   String gid = info.getKey("gid");
   if (gid != null) {
     attributes.setGroup(Integer.parseInt(gid));
   }
   attributes.setFlags(info.getMap());
   return attributes;
 }