Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GA Changes #40028

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.storage.file.share;

import com.azure.core.http.HttpHeaders;
import com.azure.storage.file.share.implementation.accesshelpers.FileSmbPropertiesHelper;
import com.azure.storage.file.share.models.NtfsFileAttributes;

import java.time.OffsetDateTime;
Expand Down Expand Up @@ -214,7 +215,7 @@ static String parseFileSMBDate(OffsetDateTime time) {
*
* @param httpHeaders The headers to construct FileSmbProperties from
*/
public FileSmbProperties(HttpHeaders httpHeaders) {
FileSmbProperties(HttpHeaders httpHeaders) {
this.filePermissionKey = httpHeaders.getValue(FileConstants.HeaderConstants.FILE_PERMISSION_KEY);
String attributes = httpHeaders.getValue(FileConstants.HeaderConstants.FILE_ATTRIBUTES);
this.ntfsFileAttributes = attributes == null ? null : NtfsFileAttributes.toAttributes(attributes);
Expand All @@ -228,4 +229,13 @@ public FileSmbProperties(HttpHeaders httpHeaders) {
this.fileId = httpHeaders.getValue(FileConstants.HeaderConstants.FILE_ID);
this.parentId = httpHeaders.getValue(FileConstants.HeaderConstants.FILE_PARENT_ID);
}

static {
FileSmbPropertiesHelper.setAccessor(new FileSmbPropertiesHelper.FileSmbPropertiesAccessor() {
@Override
public FileSmbProperties create(HttpHeaders httpHeaders) {
return new FileSmbProperties(httpHeaders);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.storage.file.share.implementation.accesshelpers;

import com.azure.core.http.HttpHeaders;
import com.azure.storage.file.share.FileSmbProperties;

/**
* Helper class to access private values of {@link FileSmbProperties} across package boundaries.
*/
public final class FileSmbPropertiesHelper {

private static FileSmbPropertiesAccessor accessor;

private FileSmbPropertiesHelper() { }


/**
* Type defining the methods to set the non-public properties of a {@link FileSmbProperties} instance.
*/
public interface FileSmbPropertiesAccessor {
/**
* Creates a new instance of {@link FileSmbProperties} backed by an internal instance of
* {@link FileSmbProperties}.
*
* @param httpHeaders The internal headers.
* @return A new instance of {@link FileSmbProperties}.
*/
FileSmbProperties create(HttpHeaders httpHeaders);
}

/**
* The method called from {@link FileSmbProperties} to set it's accessor.
*
* @param accessor The accessor.
*/
public static void setAccessor(final FileSmbPropertiesAccessor accessor) {
FileSmbPropertiesHelper.accessor = accessor;
}

/**
* Creates a new instance of {@link FileSmbProperties} backed by an internal instance of
* {@link FileSmbProperties}.
*
* @param httpHeaders The internal headers.
* @return A new instance of {@link FileSmbProperties}.
*/
public static FileSmbProperties create(HttpHeaders httpHeaders) {
if (accessor == null) {
new FileSmbProperties();
}

assert accessor != null;
return accessor.create(httpHeaders);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.azure.storage.common.implementation.Constants;
import com.azure.storage.common.implementation.StorageImplUtils;
import com.azure.storage.file.share.FileSmbProperties;
import com.azure.storage.file.share.implementation.accesshelpers.FileSmbPropertiesHelper;
import com.azure.storage.file.share.implementation.MessageConstants;
import com.azure.storage.file.share.implementation.accesshelpers.ShareFileDownloadHeadersConstructorProxy;
import com.azure.storage.file.share.implementation.models.DeleteSnapshotsOptionType;
Expand Down Expand Up @@ -342,7 +343,7 @@ public static Response<ShareFileInfo> createFileInfoResponse(ResponseBase<FilesC
String eTag = response.getDeserializedHeaders().getETag();
OffsetDateTime lastModified = response.getDeserializedHeaders().getLastModified();
boolean isServerEncrypted = response.getDeserializedHeaders().isXMsRequestServerEncrypted();
FileSmbProperties smbProperties = new FileSmbProperties(response.getHeaders());
FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders());
ShareFileInfo shareFileInfo = new ShareFileInfo(eTag, lastModified, isServerEncrypted, smbProperties);
return new SimpleResponse<>(response, shareFileInfo);
}
Expand Down Expand Up @@ -375,7 +376,7 @@ public static Response<ShareFileProperties> getPropertiesResponse(
String copySource = headers.getXMsCopySource();
CopyStatusType copyStatus = headers.getXMsCopyStatus();
Boolean isServerEncrypted = headers.isXMsServerEncrypted();
FileSmbProperties smbProperties = new FileSmbProperties(response.getHeaders());
FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders());
ShareFileProperties shareFileProperties = new ShareFileProperties(eTag, lastModified, metadata, fileType,
contentLength, contentType, contentMD5, contentEncoding, cacheControl, contentDisposition,
leaseStatusType, leaseStateType, leaseDurationType, copyCompletionTime, copyStatusDescription, copyId,
Expand All @@ -388,7 +389,7 @@ public static Response<ShareFileInfo> setPropertiesResponse(
String eTag = response.getDeserializedHeaders().getETag();
OffsetDateTime lastModified = response.getDeserializedHeaders().getLastModified();
boolean isServerEncrypted = response.getDeserializedHeaders().isXMsRequestServerEncrypted();
FileSmbProperties smbProperties = new FileSmbProperties(response.getHeaders());
FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders());
ShareFileInfo shareFileInfo = new ShareFileInfo(eTag, lastModified, isServerEncrypted, smbProperties);
return new SimpleResponse<>(response, shareFileInfo);
}
Expand Down Expand Up @@ -515,7 +516,7 @@ public static Response<ShareDirectoryInfo> mapShareDirectoryInfo(
final ResponseBase<DirectoriesCreateHeaders, Void> response) {
String eTag = response.getDeserializedHeaders().getETag();
OffsetDateTime lastModified = response.getDeserializedHeaders().getLastModified();
FileSmbProperties smbProperties = new FileSmbProperties(response.getHeaders());
FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders());
ShareDirectoryInfo shareDirectoryInfo = new ShareDirectoryInfo(eTag, lastModified, smbProperties);
return new SimpleResponse<>(response, shareDirectoryInfo);
}
Expand All @@ -526,7 +527,7 @@ public static Response<ShareDirectoryProperties> mapShareDirectoryPropertiesResp
String eTag = response.getDeserializedHeaders().getETag();
OffsetDateTime offsetDateTime = response.getDeserializedHeaders().getLastModified();
boolean isServerEncrypted = response.getDeserializedHeaders().isXMsServerEncrypted();
FileSmbProperties smbProperties = new FileSmbProperties(response.getHeaders());
FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders());
ShareDirectoryProperties shareDirectoryProperties =
new ShareDirectoryProperties(metadata, eTag, offsetDateTime, isServerEncrypted, smbProperties);
return new SimpleResponse<>(response, shareDirectoryProperties);
Expand All @@ -536,7 +537,7 @@ public static Response<ShareDirectoryInfo> mapSetPropertiesResponse(
final ResponseBase<DirectoriesSetPropertiesHeaders, Void> response) {
String eTag = response.getDeserializedHeaders().getETag();
OffsetDateTime lastModified = response.getDeserializedHeaders().getLastModified();
FileSmbProperties smbProperties = new FileSmbProperties(response.getHeaders());
FileSmbProperties smbProperties = FileSmbPropertiesHelper.create(response.getHeaders());
ShareDirectoryInfo shareDirectoryInfo = new ShareDirectoryInfo(eTag, lastModified, smbProperties);
return new SimpleResponse<>(response, shareDirectoryInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@

package com.azure.storage.file.share.models;

import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.rest.ResponseBase;

import java.io.InputStream;

/**
* This class contains the response information returned from the server when downloading a file.
*/
Expand All @@ -22,19 +18,4 @@ public ShareFileDownloadResponse(ShareFileDownloadAsyncResponse response) {
super(response.getRequest(), response.getStatusCode(), response.getHeaders(), null,
response.getDeserializedHeaders());
}

/**
* Constructs a {@link ShareFileDownloadResponse}.
*
* @param request – The HTTP request which resulted in this response.
* @param statusCode – The status code of the HTTP response.
* @param headers – The headers of the HTTP response.
* @param value – The deserialized value of the HTTP response.
* @param deserializedHeaders – The deserialized headers of the HTTP response.
*
*/
public ShareFileDownloadResponse(HttpRequest request, int statusCode, HttpHeaders headers, InputStream value,
ShareFileDownloadHeaders deserializedHeaders) {
super(request, statusCode, headers, null, deserializedHeaders);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
module com.azure.storage.file.share {
requires transitive com.azure.storage.common;

requires com.azure.json;
requires com.azure.xml;
requires java.xml;

exports com.azure.storage.file.share;
exports com.azure.storage.file.share.models;
exports com.azure.storage.file.share.options;
Expand Down