Update code based on feedback

This commit is contained in:
canpan14
2023-07-12 15:12:07 -04:00
parent 3215bc50c6
commit cb4dde6035
7 changed files with 76 additions and 27 deletions

View File

@@ -102,16 +102,28 @@ public interface DeletedNodes
CollectionWithPagingInfo<Rendition> getRenditions(String archivedId, Parameters parameters);
/**
* Gets a presigned URL to directly access content.
* Gets a presigned URL to directly access content.
*
* @param archivedId The node id for which to obtain the direct access {@code URL}
* @param renditionId The rendition id for which to obtain the direct access {@code URL}
* @param attachment {@code true} if an attachment {@code URL} is requested, {@code false} for an embedded {@code URL}, {@code true} by default.
* @return A direct access {@code URL} object for the content.
*/
* @param archivedId The node id for which to obtain the direct access {@code URL}
* @param renditionId The rendition id for which to obtain the direct access {@code URL}
* @param attachment {@code true} if an attachment {@code URL} is requested, {@code false} for an embedded {@code URL}, {@code true} by default.
* @return A direct access {@code URL} object for the content.
*/
default DirectAccessUrl requestContentDirectUrl(String archivedId, String renditionId, boolean attachment)
{
return requestContentDirectUrl(archivedId, renditionId, attachment, null, null);
return requestContentDirectUrl(archivedId, renditionId, attachment, null);
}
/**
* @param archivedId The node id for which to obtain the direct access {@code URL}
* @param renditionId The rendition id for which to obtain the direct access {@code URL}
* @param attachment {@code true} if an attachment {@code URL} is requested, {@code false} for an embedded {@code URL}, {@code true} by default.
* @param validFor The time at which the direct access {@code URL} will expire.
* @return A direct access {@code URL} object for the content.
*/
default DirectAccessUrl requestContentDirectUrl(String archivedId, String renditionId, boolean attachment, Long validFor)
{
return requestContentDirectUrl(archivedId, renditionId, attachment, validFor, null);
}
/**

View File

@@ -67,11 +67,6 @@ public class DirectAccessUrlHelper
public String getFileName(DirectAccessUrlRequest directAccessUrlRequest)
{
String fileName = null;
if (directAccessUrlRequest != null )
{
fileName = directAccessUrlRequest.getFileName();
}
return fileName;
return directAccessUrlRequest != null ? directAccessUrlRequest.getFileName() : null;
}
}

View File

@@ -301,7 +301,7 @@ public interface Nodes
*/
default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, boolean attachment)
{
return requestContentDirectUrl(nodeRef, attachment, null, null);
return requestContentDirectUrl(nodeRef, attachment, null);
}
/**
@@ -313,7 +313,19 @@ public interface Nodes
*/
default DirectAccessUrl requestContentDirectUrl(String nodeId, boolean attachment, Long validFor)
{
return requestContentDirectUrl(validateNode(nodeId), attachment, validFor, null);
return requestContentDirectUrl(validateNode(nodeId), attachment, validFor);
}
/**
* Gets a presigned URL to directly access content.
* @param nodeRef The node reference for which to obtain the direct access {@code URL}
* @param attachment {@code true} if an attachment {@code URL} is requested, {@code false} for an embedded {@code URL}.
* @param validFor The time at which the direct access {@code URL} will expire.
* @return A direct access {@code URL} object for the content.
*/
default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, boolean attachment, Long validFor)
{
return requestContentDirectUrl(nodeRef, attachment, validFor, null);
}
/**

View File

@@ -234,7 +234,7 @@ public interface Renditions
default DirectAccessUrl requestContentDirectUrl(String nodeId, String versionId, String renditionId, boolean attachment, Long validFor)
{
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId);
return requestContentDirectUrl(nodeRef, versionId, renditionId, attachment, validFor, null);
return requestContentDirectUrl(nodeRef, versionId, renditionId, attachment, validFor);
}
/**
@@ -247,7 +247,20 @@ public interface Renditions
*/
default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, String versionId, String renditionId, boolean attachment)
{
return requestContentDirectUrl(nodeRef, versionId, renditionId, attachment, null, null);
return requestContentDirectUrl(nodeRef, versionId, renditionId, attachment, null);
}
/**
* @param nodeRef the node reference for which to obtain the direct access {@code URL}
* @param versionId the version id (aka version label)
* @param renditionId the rendition id
* @param attachment {@code true} if an attachment {@code URL} is requested, {@code false} for an embedded {@code URL}
* @param validFor the time at which the direct access {@code URL} will expire
* @return a direct access {@code URL} object for the content.
*/
default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, String versionId, String renditionId, boolean attachment, Long validFor)
{
return requestContentDirectUrl(nodeRef, versionId, renditionId, attachment, validFor);
}
/**

View File

@@ -213,7 +213,7 @@ public interface ContentService
*/
default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment)
{
return requestContentDirectUrl(nodeRef, propertyQName, attachment, null, null);
return requestContentDirectUrl(nodeRef, propertyQName, attachment, null);
}
/**
@@ -230,7 +230,24 @@ public interface ContentService
@Deprecated
default public DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, boolean attachment, Long validFor)
{
return requestContentDirectUrl(nodeRef, ContentModel.PROP_CONTENT, attachment, validFor, null);
return requestContentDirectUrl(nodeRef, ContentModel.PROP_CONTENT, attachment, validFor);
}
/**
* Gets a presigned URL to directly access the content. It is up to the actual store
* implementation if it can fulfil this request with an expiry time or not.
*
* @param nodeRef Node ref for which to obtain the direct access {@code URL}.
* @param propertyQName the name of the property, which must be of type <b>content</b>
* @param attachment {@code true} if an attachment URL is requested, {@code false} for an embedded {@code URL}.
* @param validFor The time at which the direct access {@code URL} will expire.
* @return A direct access {@code URL} object for the content.
* @throws UnsupportedOperationException if the store is unable to provide the information.
*/
@Auditable(parameters = {"nodeRef", "propertyQName", "validFor"})
default DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment, Long validFor)
{
return requestContentDirectUrl(nodeRef, propertyQName, attachment, validFor);
}
/**

View File

@@ -136,7 +136,7 @@ public class ContentServiceImplUnitTest
{
setupSystemWideDirectAccessConfig(DISABLED);
assertThrows(DirectAccessUrlDisabledException.class, () -> {
contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME, true, 20L, null);
contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME, true, 20L);
});
verify(mockContentStore, never()).isContentDirectUrlEnabled();
}
@@ -147,7 +147,7 @@ public class ContentServiceImplUnitTest
setupSystemWideDirectAccessConfig(ENABLED);
when(mockContentStore.isContentDirectUrlEnabled()).thenReturn(DISABLED);
DirectAccessUrl directAccessUrl = contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME,true, 20L, null);
DirectAccessUrl directAccessUrl = contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME,true, 20L);
assertNull(directAccessUrl);
verify(mockContentStore, never()).requestContentDirectUrl(anyString(), eq(true), anyString(), anyString(), anyLong());
}
@@ -158,7 +158,7 @@ public class ContentServiceImplUnitTest
setupSystemWideDirectAccessConfig(ENABLED);
when(mockContentStore.isContentDirectUrlEnabled()).thenReturn(ENABLED);
DirectAccessUrl directAccessUrl = contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME, true, 20L, null);
DirectAccessUrl directAccessUrl = contentService.requestContentDirectUrl(NODE_REF, PROP_CONTENT_QNAME, true, 20L);
assertNull(directAccessUrl);
verify(mockContentStore, times(1)).requestContentDirectUrl(anyString(), eq(true), anyString(), anyString(), anyLong());
}

View File

@@ -164,11 +164,11 @@ public class ContentServiceImplTest extends BaseVersionStoreTest
NodeRef nodeRef = this.dbNodeService
.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}MyNoContentNode"), TEST_TYPE_QNAME, this.nodeProperties).getChildRef();
assertNull(contentService.requestContentDirectUrl(nodeRef, QNAME, true, validFor, null));
assertNull(contentService.requestContentDirectUrl(nodeRef, QNAME, true, validFor));
});
assertThrows("nodeRef is null", IllegalArgumentException.class, () -> {
assertNull(contentService.requestContentDirectUrl(null, null, true, null, null));
assertNull(contentService.requestContentDirectUrl(null, null, true, null));
});
assertThrows("propertyQName has no content", NullPointerException.class, () -> {
@@ -176,13 +176,13 @@ public class ContentServiceImplTest extends BaseVersionStoreTest
NodeRef nodeRef = this.dbNodeService
.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}MyNoContentNode"), TEST_TYPE_QNAME, this.nodeProperties).getChildRef();
contentService.requestContentDirectUrl(nodeRef, null, true, validFor, null);
contentService.requestContentDirectUrl(nodeRef, null, true, validFor);
});
// Create a node with content
NodeRef nodeRef = createNewVersionableNode();
assertNull(contentService.requestContentDirectUrl(nodeRef, QNAME, true, null, null));
assertNull(contentService.requestContentDirectUrl(nodeRef, QNAME, true, validFor, null));
assertNull(contentService.requestContentDirectUrl(nodeRef, QNAME, true, null));
assertNull(contentService.requestContentDirectUrl(nodeRef, QNAME, true, validFor));
}
}