mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ACS-1788 Implement RestApi endpoint for deleted renditions (#681)
* ACS-1788 deleted renditions * ACS-1913 Fix endpoint operation labels * ACS-1788 Updates from review
This commit is contained in:
@@ -105,22 +105,24 @@ public interface DeletedNodes
|
|||||||
* 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 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 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.
|
* @return A direct access {@code URL} object for the content.
|
||||||
*/
|
*/
|
||||||
default DirectAccessUrl requestContentDirectUrl(String archivedId, boolean attachment)
|
default DirectAccessUrl requestContentDirectUrl(String archivedId, String renditionId, boolean attachment)
|
||||||
{
|
{
|
||||||
return requestContentDirectUrl(archivedId, attachment, null);
|
return requestContentDirectUrl(archivedId, renditionId, attachment, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 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 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.
|
* @param validFor The time at which the direct access {@code URL} will expire.
|
||||||
* @return A direct access {@code URL} object for the content.
|
* @return A direct access {@code URL} object for the content.
|
||||||
*/
|
*/
|
||||||
DirectAccessUrl requestContentDirectUrl(String archivedId, boolean attachment, Long validFor);
|
DirectAccessUrl requestContentDirectUrl(String archivedId, String renditionId, boolean attachment, Long validFor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -250,10 +250,18 @@ public class DeletedNodesImpl implements DeletedNodes, RecognizedParamsExtractor
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DirectAccessUrl requestContentDirectUrl(String originalNodeId, boolean attachment, Long validFor)
|
public DirectAccessUrl requestContentDirectUrl(String originalNodeId, String renditionId, boolean attachment, Long validFor)
|
||||||
{
|
{
|
||||||
//First check the node is valid and has been archived.
|
//First check the node is valid and has been archived.
|
||||||
NodeRef validatedNodeRef = nodes.validateNode(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, originalNodeId);
|
NodeRef validatedNodeRef = nodes.validateNode(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, originalNodeId);
|
||||||
return nodes.requestContentDirectUrl(validatedNodeRef, attachment, validFor);
|
|
||||||
|
if (renditionId != null)
|
||||||
|
{
|
||||||
|
return renditions.requestContentDirectUrl(validatedNodeRef, null, renditionId, attachment, validFor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nodes.requestContentDirectUrl(validatedNodeRef, attachment, validFor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -112,7 +112,7 @@ public class TrashcanEntityResource implements
|
|||||||
DirectAccessUrl directAccessUrl;
|
DirectAccessUrl directAccessUrl;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
directAccessUrl = deletedNodes.requestContentDirectUrl(originalNodeId, attachment, validFor);
|
directAccessUrl = deletedNodes.requestContentDirectUrl(originalNodeId, null, attachment, validFor);
|
||||||
}
|
}
|
||||||
catch (DirectAccessUrlDisabledException ex)
|
catch (DirectAccessUrlDisabledException ex)
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -25,18 +25,27 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.trashcan;
|
package org.alfresco.rest.api.trashcan;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.alfresco.repo.content.directurl.DirectAccessUrlDisabledException;
|
||||||
import org.alfresco.rest.api.DeletedNodes;
|
import org.alfresco.rest.api.DeletedNodes;
|
||||||
|
import org.alfresco.rest.api.DirectAccessUrlHelper;
|
||||||
|
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
|
||||||
import org.alfresco.rest.api.model.Rendition;
|
import org.alfresco.rest.api.model.Rendition;
|
||||||
import org.alfresco.rest.framework.BinaryProperties;
|
import org.alfresco.rest.framework.BinaryProperties;
|
||||||
|
import org.alfresco.rest.framework.Operation;
|
||||||
import org.alfresco.rest.framework.WebApiDescription;
|
import org.alfresco.rest.framework.WebApiDescription;
|
||||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
import org.alfresco.rest.framework.WebApiParam;
|
||||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||||
|
import org.alfresco.rest.framework.core.exceptions.DisabledServiceException;
|
||||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
|
||||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
|
import org.alfresco.rest.framework.webscripts.WithResponse;
|
||||||
|
import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
@@ -46,12 +55,18 @@ public class TrashcanRenditionsRelation
|
|||||||
{
|
{
|
||||||
|
|
||||||
private DeletedNodes deletedNodes;
|
private DeletedNodes deletedNodes;
|
||||||
|
private DirectAccessUrlHelper directAccessUrlHelper;
|
||||||
|
|
||||||
public void setDeletedNodes(DeletedNodes deletedNodes)
|
public void setDeletedNodes(DeletedNodes deletedNodes)
|
||||||
{
|
{
|
||||||
this.deletedNodes = deletedNodes;
|
this.deletedNodes = deletedNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDirectAccessUrlHelper(DirectAccessUrlHelper directAccessUrlHelper)
|
||||||
|
{
|
||||||
|
this.directAccessUrlHelper = directAccessUrlHelper;
|
||||||
|
}
|
||||||
|
|
||||||
@WebApiDescription(title = "List renditions", description = "List available (created) renditions")
|
@WebApiDescription(title = "List renditions", description = "List available (created) renditions")
|
||||||
@Override
|
@Override
|
||||||
public CollectionWithPagingInfo<Rendition> readAll(String nodeId, Parameters parameters)
|
public CollectionWithPagingInfo<Rendition> readAll(String nodeId, Parameters parameters)
|
||||||
@@ -74,6 +89,27 @@ public class TrashcanRenditionsRelation
|
|||||||
return deletedNodes.getContent(nodeId, renditionId, parameters);
|
return deletedNodes.getContent(nodeId, renditionId, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation ("request-direct-access-url")
|
||||||
|
@WebApiParam (name = "requestArchivedNodeRenditionDirectAccessUrl", title = "Request direct access url", description = "Request direct access url", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
|
||||||
|
@WebApiDescription(title = "Request content url",
|
||||||
|
description="Generates a direct access URL.",
|
||||||
|
successStatus = HttpServletResponse.SC_OK)
|
||||||
|
public DirectAccessUrl requestContentDirectUrl(String originalNodeId, String renditionId, DirectAccessUrlRequest directAccessUrlRequest, Parameters parameters, WithResponse withResponse)
|
||||||
|
{
|
||||||
|
boolean attachment = directAccessUrlHelper.getAttachment(directAccessUrlRequest);
|
||||||
|
Long validFor = directAccessUrlHelper.getDefaultExpiryTimeInSec();
|
||||||
|
DirectAccessUrl directAccessUrl;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
directAccessUrl = deletedNodes.requestContentDirectUrl(originalNodeId, renditionId, attachment, validFor);
|
||||||
|
}
|
||||||
|
catch (DirectAccessUrlDisabledException ex)
|
||||||
|
{
|
||||||
|
throw new DisabledServiceException(ex.getMessage());
|
||||||
|
}
|
||||||
|
return directAccessUrl;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception
|
public void afterPropertiesSet() throws Exception
|
||||||
{
|
{
|
||||||
|
@@ -1438,6 +1438,7 @@
|
|||||||
|
|
||||||
<bean class="org.alfresco.rest.api.trashcan.TrashcanRenditionsRelation">
|
<bean class="org.alfresco.rest.api.trashcan.TrashcanRenditionsRelation">
|
||||||
<property name="deletedNodes" ref="DeletedNodes"/>
|
<property name="deletedNodes" ref="DeletedNodes"/>
|
||||||
|
<property name="directAccessUrlHelper" ref="directAccessUrlHelper" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- HeartBeat rest api renditions data collector -->
|
<!-- HeartBeat rest api renditions data collector -->
|
||||||
|
Reference in New Issue
Block a user