mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
MNT-14308: CMIS - optionally request rendition(s) when uploading docs (#263)
* MNT-14308: CMIS - optionally request rendition(s) when uploading docs - add new configurable option to request set of renditions when uploading via CMIS (none by default) - note: in the event a client *relied* on previous behaviour (rather than dynamic requests) the property can be overridden & set to "doclib" - add info message to show new property when initialising CMIS, ie. set of requested renditions set (empty by default) - note: set following log4j.properties: log4j.logger.org.alfresco.opencmis=info
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -25,7 +25,10 @@
|
||||
*/
|
||||
package org.alfresco.opencmis;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionInterceptor;
|
||||
@@ -58,6 +61,8 @@ public class AlfrescoCmisServiceFactory extends AbstractServiceFactory
|
||||
private CMISTransactionAwareHolderInterceptor cmisHolder;
|
||||
private AuthorityService authorityService;
|
||||
|
||||
private String cmisCreateDocRequestRenditionsSet = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param memoryThreshold in KB
|
||||
@@ -139,6 +144,14 @@ public class AlfrescoCmisServiceFactory extends AbstractServiceFactory
|
||||
this.cmisHolder = cmisHolder;
|
||||
}
|
||||
|
||||
public String getCmisCreateDocRequestRenditionsSet() {
|
||||
return cmisCreateDocRequestRenditionsSet;
|
||||
}
|
||||
|
||||
public void setCmisCreateDocRequestRenditionsSet(String cmisCreateDocRequestRenditionsSet) {
|
||||
this.cmisCreateDocRequestRenditionsSet = cmisCreateDocRequestRenditionsSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
@@ -217,6 +230,30 @@ public class AlfrescoCmisServiceFactory extends AbstractServiceFactory
|
||||
|
||||
protected AlfrescoCmisService getCmisServiceTarget(CMISConnector connector)
|
||||
{
|
||||
return new AlfrescoCmisServiceImpl(connector);
|
||||
AlfrescoCmisServiceImpl cmisService = new AlfrescoCmisServiceImpl(connector);
|
||||
|
||||
Set<String> stringSet = parseCommaSeparatedSet(getCmisCreateDocRequestRenditionsSet());
|
||||
logger.info("getCmisServiceTarget: cmis.create.doc.request.renditions.set="+stringSet);
|
||||
cmisService.setCmisRequestRenditionsOnCreateDoc(stringSet);
|
||||
|
||||
return cmisService;
|
||||
}
|
||||
|
||||
private Set<String> parseCommaSeparatedSet(String str)
|
||||
{
|
||||
Set<String> stringSet = new HashSet<>();
|
||||
if (str != null)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(str, ",");
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
String entry = st.nextToken().trim();
|
||||
if (!entry.isEmpty())
|
||||
{
|
||||
stringSet.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stringSet;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -166,6 +166,16 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
private Map<String, CMISNodeInfo> nodeInfoMap;
|
||||
private Map<String, ObjectInfo> objectInfoMap;
|
||||
|
||||
private Set<String> cmisRequestRenditionsOnCreateDoc = null;
|
||||
|
||||
public Set<String> getCmisRequestRenditionsOnCreateDoc() {
|
||||
return cmisRequestRenditionsOnCreateDoc;
|
||||
}
|
||||
|
||||
public void setCmisRequestRenditionsOnCreateDoc(Set<String> cmisRequestRenditionsOnCreateDoc) {
|
||||
this.cmisRequestRenditionsOnCreateDoc = cmisRequestRenditionsOnCreateDoc;
|
||||
}
|
||||
|
||||
public AlfrescoCmisServiceImpl(CMISConnector connector)
|
||||
{
|
||||
this.connector = connector;
|
||||
@@ -1306,9 +1316,9 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
writer.putContent(contentStream.getStream());
|
||||
}
|
||||
|
||||
// extract metadata and generate thumbnail asynchronously
|
||||
// extract metadata and generate thumbnail asynchronously (if configured - see a-g.p)
|
||||
connector.extractMetadata(nodeRef);
|
||||
connector.createThumbnails(nodeRef, Collections.singleton("doclib"));
|
||||
connector.createThumbnails(nodeRef, getCmisRequestRenditionsOnCreateDoc());
|
||||
|
||||
connector.applyVersioningState(nodeRef, versioningState);
|
||||
|
||||
@@ -1384,9 +1394,9 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
connector.applyPolicies(nodeRef, type, policies);
|
||||
connector.applyACL(nodeRef, type, addAces, removeAces);
|
||||
|
||||
// extract metadata and generate thumbnail asynchronously
|
||||
// extract metadata and generate thumbnail asynchronously (if configured - see a-g.p)
|
||||
connector.extractMetadata(nodeRef);
|
||||
connector.createThumbnails(nodeRef, Collections.singleton("doclib"));
|
||||
connector.createThumbnails(nodeRef, getCmisRequestRenditionsOnCreateDoc());
|
||||
|
||||
connector.applyVersioningState(nodeRef, versioningState);
|
||||
|
||||
|
@@ -86,6 +86,7 @@
|
||||
<property name="cmisStreams" ref="CMISService_Streams" />
|
||||
<property name="cmisHolder" ref="CMISTransactionAwareHolderInterceptor" />
|
||||
<property name="authorityService" ref="AuthorityService" />
|
||||
<property name="cmisCreateDocRequestRenditionsSet" value="${cmis.create.doc.request.renditions.set}" />
|
||||
</bean>
|
||||
|
||||
<bean id="CMISTransactionAwareHolderInterceptor" class="org.alfresco.opencmis.CMISTransactionAwareHolderInterceptor" />
|
||||
|
@@ -471,6 +471,9 @@ renditionService2.enabled=true
|
||||
# Thumbnail Service
|
||||
system.thumbnail.generate=true
|
||||
|
||||
# when creating doc via CMIS - optionally configure set of renditions names to request async
|
||||
cmis.create.doc.request.renditions.set=
|
||||
|
||||
# Default thumbnail limits
|
||||
# When creating thumbnails, only use the first pageLimit pages
|
||||
system.thumbnail.definition.default.timeoutMs=-1
|
||||
|
Reference in New Issue
Block a user