Feature/acs 1904 fix node ref vs content url (#680)

* ACS-1904 Fix NodeRef vs ContentUrl and remove deprecated methods

* ACS-1904 remove unused imports
This commit is contained in:
Sara
2021-08-25 17:22:59 +01:00
committed by GitHub
parent 439a9254a3
commit c7c40b06e1
7 changed files with 12 additions and 66 deletions

View File

@@ -25,8 +25,6 @@
*/ */
package org.alfresco.repo.content; package org.alfresco.repo.content;
import java.util.Date;
import org.alfresco.api.AlfrescoPublicApi; import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.service.cmr.repository.ContentAccessor; import org.alfresco.service.cmr.repository.ContentAccessor;
import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentIOException;
@@ -34,7 +32,6 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentStreamListener; import org.alfresco.service.cmr.repository.ContentStreamListener;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.DirectAccessUrl; import org.alfresco.service.cmr.repository.DirectAccessUrl;
import org.alfresco.service.cmr.repository.NodeRef;
/** /**
@@ -254,9 +251,10 @@ public interface ContentStore
/** /**
* Checks if the store supports the retrieving of a direct access URL for the given node. * Checks if the store supports the retrieving of a direct access URL for the given node.
* *
* @param contentUrl the {@code URL} of the content for which to request a direct access {@code URL}
* @return {@code true} if direct access URLs retrieving is supported for the node, {@code false} otherwise * @return {@code true} if direct access URLs retrieving is supported for the node, {@code false} otherwise
*/ */
default boolean isContentDirectUrlEnabled(NodeRef nodeRef) default boolean isContentDirectUrlEnabled(String contentUrl)
{ {
return false; return false;
} }
@@ -292,31 +290,4 @@ public interface ContentStore
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Retrieving direct access URLs is not supported by this content store."); "Retrieving direct access URLs is not supported by this content store.");
} }
/**
* Gets a presigned URL to directly access a binary content. It is up to the actual store
* implementation if it can fulfil this request with an expiry time or not.
*
* @param contentUrl A content store URL
* @param expiresAt An optional expiry date, so the direct access url would become invalid when the expiry date is reached
* @return A direct access URL object for a binary content
* @throws UnsupportedOperationException if the store is unable to provide the information
*/
@Deprecated
default DirectAccessUrl getDirectAccessUrl(String contentUrl, Date expiresAt)
{
throw new UnsupportedOperationException(
"Retrieving direct access URLs is not supported by this content store.");
}
/**
* Checks if the store supports the retrieving of direct access URLs.
*
* @return true if direct access URLs retrieving is supported, false otherwise
*/
@Deprecated
default boolean isDirectAccessSupported()
{
return false;
}
} }

View File

@@ -27,7 +27,6 @@ package org.alfresco.repo.content;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -520,12 +519,6 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
return tempStore.getWriter(ContentContext.NULL_CONTEXT); return tempStore.getWriter(ContentContext.NULL_CONTEXT);
} }
@Deprecated
public DirectAccessUrl getDirectAccessUrl(NodeRef nodeRef, Date expiresAt)
{
return requestContentDirectUrl(nodeRef, true, null);
}
/** /**
* Ensures that, upon closure of the output stream, the node is updated with * Ensures that, upon closure of the output stream, the node is updated with
* the latest URL of the content to which it refers. * the latest URL of the content to which it refers.
@@ -612,7 +605,7 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
throw new IllegalArgumentException("The supplied nodeRef " + nodeRef + " has no content."); throw new IllegalArgumentException("The supplied nodeRef " + nodeRef + " has no content.");
} }
contentDirectUrlEnabled = (store.isContentDirectUrlEnabled(nodeRef)); contentDirectUrlEnabled = (store.isContentDirectUrlEnabled(getContentUrl(nodeRef)));
} }
return contentDirectUrlEnabled; return contentDirectUrlEnabled;

View File

@@ -489,9 +489,9 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public boolean isContentDirectUrlEnabled(NodeRef nodeRef) public boolean isContentDirectUrlEnabled(String contentUrl)
{ {
return backingStore.isContentDirectUrlEnabled(nodeRef); return backingStore.isContentDirectUrlEnabled(contentUrl);
} }
/** /**

View File

@@ -294,10 +294,10 @@ public class AggregatingContentStore extends AbstractContentStore
/** /**
* @return Returns {@code true} if at least one store supports direct access URL for node * @return Returns {@code true} if at least one store supports direct access URL for node
*/ */
public boolean isContentDirectUrlEnabled(NodeRef nodeRef) public boolean isContentDirectUrlEnabled(String contentUrl)
{ {
// Check the primary store // Check the primary store
boolean isContentDirectUrlEnabled = primaryStore.isContentDirectUrlEnabled(nodeRef); boolean isContentDirectUrlEnabled = primaryStore.isContentDirectUrlEnabled(contentUrl);
if (!isContentDirectUrlEnabled) if (!isContentDirectUrlEnabled)
{ {
@@ -305,7 +305,7 @@ public class AggregatingContentStore extends AbstractContentStore
// other stores // other stores
for (ContentStore store : secondaryStores) for (ContentStore store : secondaryStores)
{ {
isContentDirectUrlEnabled = store.isContentDirectUrlEnabled(nodeRef); isContentDirectUrlEnabled = store.isContentDirectUrlEnabled(contentUrl);
if (isContentDirectUrlEnabled) if (isContentDirectUrlEnabled)
{ {

View File

@@ -25,7 +25,6 @@
*/ */
package org.alfresco.service.cmr.repository; package org.alfresco.service.cmr.repository;
import java.util.Date;
import org.alfresco.api.AlfrescoPublicApi; import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.service.Auditable; import org.alfresco.service.Auditable;
@@ -155,23 +154,6 @@ public interface ContentService
@Auditable @Auditable
public ContentWriter getTempWriter(); public ContentWriter getTempWriter();
/**
* Gets a presigned URL to directly access a binary content. It is up to the
* content store if it can fulfil this request with an expiry time (in
* milliseconds) or not.
*
* @param nodeRef
* a reference to a node having a content property
* @param expiresAt
* an optional expiry date, so the direct access url would become
* invalid when the expiry date is reached
* @return A direct access URL object for a binary content or returns null if not supported
* @throws IllegalArgumentException if there is no binary content for the node
*/
@Deprecated
@Auditable(parameters = {"nodeRef", "expiresAt"})
public DirectAccessUrl getDirectAccessUrl(NodeRef nodeRef, Date expiresAt);
/** /**
* Checks if the system and at least one store supports the retrieving of direct access URLs. * Checks if the system and at least one store supports the retrieving of direct access URLs.
* *

View File

@@ -492,7 +492,7 @@ public class CachingContentStoreTest
} }
@Test @Test
public void isDirectAccessSupported() public void isContentDirectUrlSupported()
{ {
assertFalse(cachingStore.isContentDirectUrlEnabled()); assertFalse(cachingStore.isContentDirectUrlEnabled());
@@ -501,7 +501,7 @@ public class CachingContentStoreTest
} }
@Test @Test
public void getDirectAccessUrlUnsupported() public void getRequestContentDirectUrlUnsupported()
{ {
try try
{ {
@@ -516,7 +516,7 @@ public class CachingContentStoreTest
} }
@Test @Test
public void getDirectAccessUrl() public void getRequestContentDirectUrl()
{ {
when(backingStore.requestContentDirectUrl(anyString(), eq(true), anyString(), anyLong())).thenReturn(new DirectAccessUrl()); when(backingStore.requestContentDirectUrl(anyString(), eq(true), anyString(), anyLong())).thenReturn(new DirectAccessUrl());
cachingStore.requestContentDirectUrl("url", true,"someFile", 30L); cachingStore.requestContentDirectUrl("url", true,"someFile", 30L);

View File

@@ -216,7 +216,7 @@ public class AggregatingContentStoreTest extends AbstractWritableContentStoreTes
} }
@Test @Test
public void testGetDirectAccessUrl() public void testRequestContentDirectUrl()
{ {
// Create the aggregating store // Create the aggregating store
AggregatingContentStore aggStore = new AggregatingContentStore(); AggregatingContentStore aggStore = new AggregatingContentStore();