mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Update code based on feedback
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user