Merged HEAD (5.2) to 5.2.N (5.2.1)

126511 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
      122817 jvonka: (Quick) Shared Links API - retrieve rendition content (no auth required)
      - TODO add extra test
      RA-830


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126855 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-05-11 11:47:52 +00:00
parent 53d06c6ff8
commit e3925d1c06
6 changed files with 52 additions and 7 deletions

View File

@@ -487,6 +487,7 @@
<bean id="quickShareLinks" class="org.alfresco.rest.api.impl.QuickShareLinksImpl"> <bean id="quickShareLinks" class="org.alfresco.rest.api.impl.QuickShareLinksImpl">
<property name="quickShareService" ref="QuickShareService"/> <property name="quickShareService" ref="QuickShareService"/>
<property name="nodes" ref="nodes"/> <property name="nodes" ref="nodes"/>
<property name="renditions" ref="renditions"/>
<property name="serviceRegistry" ref="ServiceRegistry"/> <property name="serviceRegistry" ref="ServiceRegistry"/>
<property name="enabled" value="${system.quickshare.enabled}" /> <property name="enabled" value="${system.quickshare.enabled}" />
</bean> </bean>
@@ -1080,4 +1081,9 @@
<bean class="org.alfresco.rest.api.nodes.NodeRenditionsRelation"> <bean class="org.alfresco.rest.api.nodes.NodeRenditionsRelation">
<property name="renditions" ref="Renditions" /> <property name="renditions" ref="Renditions" />
</bean> </bean>
<bean class="org.alfresco.rest.api.quicksharelinks.QuickShareLinkRenditionsRelation">
<property name="quickShareLinks" ref="QuickShareLinks"/>
</bean>
</beans> </beans>

View File

@@ -41,6 +41,7 @@ import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationE
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction; import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction; import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
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.ResourceAction; import org.alfresco.rest.framework.resource.actions.interfaces.ResourceAction;
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;
@@ -158,6 +159,10 @@ public class PublicApiDeclarativeRegistry extends DeclarativeRegistry
{ {
resAction = BinaryResourceAction.Read.class; resAction = BinaryResourceAction.Read.class;
} }
else if (RelationshipResourceBinaryAction.Read.class.isAssignableFrom(rwm.getResource().getClass()))
{
resAction = RelationshipResourceBinaryAction.Read.class;
}
break; break;
default: default:
break; break;

View File

@@ -45,16 +45,17 @@ public interface QuickShareLinks
QuickShareLink readById(String sharedId, Parameters parameters); QuickShareLink readById(String sharedId, Parameters parameters);
/** /**
* Download content via shared link. * Download file content (or rendition content) via shared link.
* *
* Note: does *not* require authenticated access for (public) shared link. * Note: does *not* require authenticated access for (public) shared link.
* *
* @param sharedId * @param sharedId
* @param renditionId - optional
* @param parameters {@link Parameters} * @param parameters {@link Parameters}
* @return * @return
* @throws EntityNotFoundException * @throws EntityNotFoundException
*/ */
BinaryResource readProperty(String sharedId, final Parameters parameters) throws EntityNotFoundException; BinaryResource readProperty(String sharedId, String renditionId, Parameters parameters) throws EntityNotFoundException;
/** /**
* Delete the shared link. * Delete the shared link.

View File

@@ -27,6 +27,7 @@ import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.tenant.TenantUtil; import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.rest.api.Nodes; import org.alfresco.rest.api.Nodes;
import org.alfresco.rest.api.QuickShareLinks; import org.alfresco.rest.api.QuickShareLinks;
import org.alfresco.rest.api.Renditions;
import org.alfresco.rest.api.model.ContentInfo; import org.alfresco.rest.api.model.ContentInfo;
import org.alfresco.rest.api.model.QuickShareLink; import org.alfresco.rest.api.model.QuickShareLink;
import org.alfresco.rest.api.model.QuickShareLinkEmailRequest; import org.alfresco.rest.api.model.QuickShareLinkEmailRequest;
@@ -87,6 +88,8 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
private ServiceRegistry sr; private ServiceRegistry sr;
private QuickShareService quickShareService; private QuickShareService quickShareService;
private Nodes nodes; private Nodes nodes;
private Renditions renditions;
private NodeService nodeService; private NodeService nodeService;
private PersonService personService; private PersonService personService;
private AuthorityService authorityService; private AuthorityService authorityService;
@@ -109,6 +112,11 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
this.nodes = nodes; this.nodes = nodes;
} }
public void setRenditions(Renditions renditions)
{
this.renditions = renditions;
}
public void setEnabled(boolean enabled) public void setEnabled(boolean enabled)
{ {
this.enabled = enabled; this.enabled = enabled;
@@ -165,11 +173,12 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
* Note: does *not* require authenticated access for (public) shared link. * Note: does *not* require authenticated access for (public) shared link.
* *
* @param sharedId * @param sharedId
* @param renditionId - optional
* @param parameters {@link Parameters} * @param parameters {@link Parameters}
* @return * @return
* @throws EntityNotFoundException * @throws EntityNotFoundException
*/ */
public BinaryResource readProperty(String sharedId, final Parameters parameters) throws EntityNotFoundException public BinaryResource readProperty(String sharedId, final String renditionId, final Parameters parameters) throws EntityNotFoundException
{ {
checkEnabled(); checkEnabled();
checkValidShareId(sharedId); checkValidShareId(sharedId);
@@ -191,7 +200,16 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
throw new InvalidNodeRefException(nodeRef); throw new InvalidNodeRefException(nodeRef);
} }
return nodes.getContent(nodeRef.getId(), parameters); String nodeId = nodeRef.getId();
if (renditionId != null)
{
return renditions.getContent(nodeId, renditionId, parameters);
}
else
{
return nodes.getContent(nodeId, parameters);
}
} }
}, networkTenantDomain); }, networkTenantDomain);
} }

View File

@@ -92,9 +92,9 @@ public class QuickShareLinkEntityResource implements EntityResourceAction.ReadBy
@WebApiDescription(title = "Download shared link content", description = "Download content for shared link") @WebApiDescription(title = "Download shared link content", description = "Download content for shared link")
@WebApiNoAuth @WebApiNoAuth
@BinaryProperties({"content"}) @BinaryProperties({"content"})
public BinaryResource readProperty(String sharedId, final Parameters parameters) throws EntityNotFoundException public BinaryResource readProperty(String sharedId, Parameters parameters) throws EntityNotFoundException
{ {
return quickShareLinks.readProperty(sharedId, parameters); return quickShareLinks.readProperty(sharedId, null, parameters);
} }
/** /**

View File

@@ -46,6 +46,7 @@ import org.alfresco.rest.framework.core.exceptions.ApiException;
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper; import org.alfresco.rest.framework.jacksonextensions.JacksonHelper;
import org.alfresco.rest.framework.resource.actions.ActionExecutor; import org.alfresco.rest.framework.resource.actions.ActionExecutor;
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction; import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
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.content.ContentInfo; import org.alfresco.rest.framework.resource.content.ContentInfo;
import org.alfresco.rest.framework.resource.content.FileBinaryResource; import org.alfresco.rest.framework.resource.content.FileBinaryResource;
@@ -112,7 +113,21 @@ public abstract class AbstractResourceWebScript extends ApiWebScript implements
if (toSerialize instanceof BinaryResource) if (toSerialize instanceof BinaryResource)
{ {
// TODO review (experimental) - can we move earlier & wrap complete execute ? Also for QuickShare (in MT/Cloud) needs to be tenant for the nodeRef (TBC). // TODO review (experimental) - can we move earlier & wrap complete execute ? Also for QuickShare (in MT/Cloud) needs to be tenant for the nodeRef (TBC).
boolean noAuth = resource.getMetaData().isNoAuth(BinaryResourceAction.Read.class); boolean noAuth = false;
if (BinaryResourceAction.Read.class.isAssignableFrom(resource.getResource().getClass()))
{
noAuth = resource.getMetaData().isNoAuth(BinaryResourceAction.Read.class);
}
else if (RelationshipResourceBinaryAction.Read.class.isAssignableFrom(resource.getResource().getClass()))
{
noAuth = resource.getMetaData().isNoAuth(RelationshipResourceBinaryAction.Read.class);
}
else
{
logger.warn("Unexpected");
}
if (noAuth) if (noAuth)
{ {
String networkTenantDomain = TenantUtil.getCurrentDomain(); String networkTenantDomain = TenantUtil.getCurrentDomain();