Skip to content

Commit

Permalink
Added isDirectory property to pathProperties (#9528)
Browse files Browse the repository at this point in the history
  • Loading branch information
gapra-msft committed Mar 30, 2020
1 parent 2ba19d6 commit 7e3b7ea
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 28 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Release History

## 12.6.0-beta.1 (Unreleased)

- Added a constant for the directory metadata marker.

## 12.5.0 (2020-03-11)
- Added types that enabled buffered upload in datalake.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ public static final class HeaderConstants {

public static final String ETAG_WILDCARD = "*";

public static final String DIRECTORY_METADATA_KEY = "hdi_isfolder";

private HeaderConstants() {
// Private to prevent construction.
}
Expand Down
3 changes: 2 additions & 1 deletion sdk/storage/azure-storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release History

## 12.1.0-beta.1 (Unreleased)

- Fixed a NPE caused due to deserializing a non existant lastModifiedTime.
- Added an isDirectory property to PathProperties.

## 12.0.1 (2020-03-11)
- GA release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.azure.core.annotation.Immutable;

import com.azure.core.util.CoreUtils;
import com.azure.storage.common.implementation.Constants;

import java.time.OffsetDateTime;
import java.util.Map;

Expand Down Expand Up @@ -40,6 +42,7 @@ public class PathProperties {
private final String encryptionKeySha256;
private final OffsetDateTime accessTierChangeTime;
private final Map<String, String> metadata;
private final Boolean isDirectory;

/**
* Constructs a {@link PathProperties}.
Expand Down Expand Up @@ -107,116 +110,122 @@ public PathProperties(final OffsetDateTime creationTime, final OffsetDateTime la
this.encryptionKeySha256 = encryptionKeySha256;
this.accessTierChangeTime = accessTierChangeTime;
this.metadata = metadata;
/* Default isDirectory to false. */
if (this.metadata == null) {
this.isDirectory = false;
} else {
this.isDirectory = Boolean.parseBoolean(metadata.get(Constants.HeaderConstants.DIRECTORY_METADATA_KEY));
}
}
/**
* @return the time when the file was created
* @return the time when the path was created
*/
public OffsetDateTime getCreationTime() {
return creationTime;
}

/**
* @return the time when the file was last modified
* @return the time when the path was last modified
*/
public OffsetDateTime getLastModified() {
return lastModified;
}

/**
* @return the eTag of the file
* @return the eTag of the path
*/
public String getETag() {
return eTag;
}

/**
* @return the size of the file in bytes
* @return the size of the path in bytes
*/
public long getFileSize() {
return fileSize;
}

/**
* @return the content type of the file
* @return the content type of the path
*/
public String getContentType() {
return contentType;
}

/**
* @return the MD5 of the file's content
* @return the MD5 of the path's content
*/
public byte[] getContentMd5() {
return CoreUtils.clone(contentMd5);
}

/**
* @return the content encoding of the file
* @return the content encoding of the path
*/
public String getContentEncoding() {
return contentEncoding;
}

/**
* @return the content disposition of the file
* @return the content disposition of the path
*/
public String getContentDisposition() {
return contentDisposition;
}

/**
* @return the content language of the file
* @return the content language of the path
*/
public String getContentLanguage() {
return contentLanguage;
}

/**
* @return the cache control of the file
* @return the cache control of the path
*/
public String getCacheControl() {
return cacheControl;
}

/**
* @return the lease status of the file
* @return the lease status of the path
*/
public LeaseStatusType getLeaseStatus() {
return leaseStatus;
}

/**
* @return the lease state of the file
* @return the lease state of the path
*/
public LeaseStateType getLeaseState() {
return leaseState;
}

/**
* @return the lease duration if the file is leased
* @return the lease duration if the path is leased
*/
public LeaseDurationType getLeaseDuration() {
return leaseDuration;
}

/**
* @return the identifier of the last copy operation. If this file hasn't been the target of a copy operation or has
* @return the identifier of the last copy operation. If this path hasn't been the target of a copy operation or has
* been modified since this won't be set.
*/
public String getCopyId() {
return copyId;
}

/**
* @return the status of the last copy operation. If this file hasn't been the target of a copy operation or has
* @return the status of the last copy operation. If this path hasn't been the target of a copy operation or has
* been modified since this won't be set.
*/
public CopyStatusType getCopyStatus() {
return copyStatus;
}

/**
* @return the source file URL from the last copy operation. If this file hasn't been the target of a copy operation
* @return the source path URL from the last copy operation. If this path hasn't been the target of a copy operation
* or has been modified since this won't be set.
*/
public String getCopySource() {
Expand All @@ -225,14 +234,14 @@ public String getCopySource() {

/**
* @return the number of bytes copied and total bytes in the source from the last copy operation (bytes copied/total
* bytes). If this file hasn't been the target of a copy operation or has been modified since this won't be set.
* bytes). If this path hasn't been the target of a copy operation or has been modified since this won't be set.
*/
public String getCopyProgress() {
return copyProgress;
}

/**
* @return the completion time of the last copy operation. If this file hasn't been the target of a copy operation
* @return the completion time of the last copy operation. If this path hasn't been the target of a copy operation
* or has been modified since this won't be set.
*/
public OffsetDateTime getCopyCompletionTime() {
Expand All @@ -241,59 +250,66 @@ public OffsetDateTime getCopyCompletionTime() {

/**
* @return the description of the last copy failure, this is set when the {@link #getCopyStatus() getCopyStatus} is
* {@link CopyStatusType#FAILED failed} or {@link CopyStatusType#ABORTED aborted}. If this file hasn't been the
* {@link CopyStatusType#FAILED failed} or {@link CopyStatusType#ABORTED aborted}. If this path hasn't been the
* target of a copy operation or has been modified since this won't be set.
*/
public String getCopyStatusDescription() {
return copyStatusDescription;
}

/**
* @return the status of the file being encrypted on the server
* @return the status of the path being encrypted on the server
*/
public Boolean isServerEncrypted() {
return isServerEncrypted;
}

/**
* @return the status of the file being an incremental copy file
* @return the status of the path being an incremental copy file
*/
public Boolean isIncrementalCopy() {
return isIncrementalCopy;
}

/**
* @return the tier of the file.
* @return the tier of the path.
*/
public AccessTier getAccessTier() {
return accessTier;
}

/**
* @return the archive status of the file.
* @return the archive status of the path.
*/
public ArchiveStatus getArchiveStatus() {
return archiveStatus;
}

/**
* @return the key used to encrypt the file
* @return the key used to encrypt the path
*/
public String getEncryptionKeySha256() {
return encryptionKeySha256;
}

/**
* @return the time when the access tier for the file was last changed
* @return the time when the access tier for the path was last changed
*/
public OffsetDateTime getAccessTierChangeTime() {
return accessTierChangeTime;
}

/**
* @return the metadata associated to this file
* @return the metadata associated to this path
*/
public Map<String, String> getMetadata() {
return metadata;
}

/**
* @return whether or not this path represents a directory
*/
public Boolean isDirectory() {
return isDirectory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ class DirectoryAPITest extends APISpec {
properties.getMetadata()
!properties.getAccessTierChangeTime()
!properties.getEncryptionKeySha256()
properties.isDirectory()

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ class FileAPITest extends APISpec {
!properties.getMetadata() // new file does not have default metadata associated
!properties.getAccessTierChangeTime()
!properties.getEncryptionKeySha256()
!properties.isDirectory()

}

Expand Down

0 comments on commit 7e3b7ea

Please sign in to comment.