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:
montgolfiere
2021-02-01 10:43:37 +00:00
committed by GitHub
parent 503b50738a
commit e8e2ded02a
4 changed files with 58 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Repository * Alfresco Repository
* %% * %%
* 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,7 +25,10 @@
*/ */
package org.alfresco.opencmis; package org.alfresco.opencmis;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionInterceptor; import org.alfresco.repo.transaction.RetryingTransactionInterceptor;
@@ -58,6 +61,8 @@ public class AlfrescoCmisServiceFactory extends AbstractServiceFactory
private CMISTransactionAwareHolderInterceptor cmisHolder; private CMISTransactionAwareHolderInterceptor cmisHolder;
private AuthorityService authorityService; private AuthorityService authorityService;
private String cmisCreateDocRequestRenditionsSet = null;
/** /**
* *
* @param memoryThreshold in KB * @param memoryThreshold in KB
@@ -139,6 +144,14 @@ public class AlfrescoCmisServiceFactory extends AbstractServiceFactory
this.cmisHolder = cmisHolder; this.cmisHolder = cmisHolder;
} }
public String getCmisCreateDocRequestRenditionsSet() {
return cmisCreateDocRequestRenditionsSet;
}
public void setCmisCreateDocRequestRenditionsSet(String cmisCreateDocRequestRenditionsSet) {
this.cmisCreateDocRequestRenditionsSet = cmisCreateDocRequestRenditionsSet;
}
@Override @Override
public void init(Map<String, String> parameters) public void init(Map<String, String> parameters)
{ {
@@ -217,6 +230,30 @@ public class AlfrescoCmisServiceFactory extends AbstractServiceFactory
protected AlfrescoCmisService getCmisServiceTarget(CMISConnector connector) 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;
} }
} }

View File

@@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Repository * Alfresco Repository
* %% * %%
* Copyright (C) 2005 - 2020 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
@@ -166,6 +166,16 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
private Map<String, CMISNodeInfo> nodeInfoMap; private Map<String, CMISNodeInfo> nodeInfoMap;
private Map<String, ObjectInfo> objectInfoMap; 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) public AlfrescoCmisServiceImpl(CMISConnector connector)
{ {
this.connector = connector; this.connector = connector;
@@ -1306,9 +1316,9 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
writer.putContent(contentStream.getStream()); 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.extractMetadata(nodeRef);
connector.createThumbnails(nodeRef, Collections.singleton("doclib")); connector.createThumbnails(nodeRef, getCmisRequestRenditionsOnCreateDoc());
connector.applyVersioningState(nodeRef, versioningState); connector.applyVersioningState(nodeRef, versioningState);
@@ -1384,9 +1394,9 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
connector.applyPolicies(nodeRef, type, policies); connector.applyPolicies(nodeRef, type, policies);
connector.applyACL(nodeRef, type, addAces, removeAces); 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.extractMetadata(nodeRef);
connector.createThumbnails(nodeRef, Collections.singleton("doclib")); connector.createThumbnails(nodeRef, getCmisRequestRenditionsOnCreateDoc());
connector.applyVersioningState(nodeRef, versioningState); connector.applyVersioningState(nodeRef, versioningState);

View File

@@ -86,6 +86,7 @@
<property name="cmisStreams" ref="CMISService_Streams" /> <property name="cmisStreams" ref="CMISService_Streams" />
<property name="cmisHolder" ref="CMISTransactionAwareHolderInterceptor" /> <property name="cmisHolder" ref="CMISTransactionAwareHolderInterceptor" />
<property name="authorityService" ref="AuthorityService" /> <property name="authorityService" ref="AuthorityService" />
<property name="cmisCreateDocRequestRenditionsSet" value="${cmis.create.doc.request.renditions.set}" />
</bean> </bean>
<bean id="CMISTransactionAwareHolderInterceptor" class="org.alfresco.opencmis.CMISTransactionAwareHolderInterceptor" /> <bean id="CMISTransactionAwareHolderInterceptor" class="org.alfresco.opencmis.CMISTransactionAwareHolderInterceptor" />

View File

@@ -471,6 +471,9 @@ renditionService2.enabled=true
# Thumbnail Service # Thumbnail Service
system.thumbnail.generate=true 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 # Default thumbnail limits
# When creating thumbnails, only use the first pageLimit pages # When creating thumbnails, only use the first pageLimit pages
system.thumbnail.definition.default.timeoutMs=-1 system.thumbnail.definition.default.timeoutMs=-1