Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
397ff1e87a Bump aws-actions/configure-aws-credentials from 4 to 5
Bumps [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) from 4 to 5.
- [Release notes](https://github.com/aws-actions/configure-aws-credentials/releases)
- [Changelog](https://github.com/aws-actions/configure-aws-credentials/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws-actions/configure-aws-credentials/compare/v4...v5)

---
updated-dependencies:
- dependency-name: aws-actions/configure-aws-credentials
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-01 00:09:10 +00:00
44 changed files with 138 additions and 706 deletions

View File

@@ -676,7 +676,7 @@ jobs:
run: mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -Dskip.automationtests=false -Pags -Pall-tas-tests
- name: "Configure AWS credentials"
if: ${{ always() }}
uses: aws-actions/configure-aws-credentials@v4
uses: aws-actions/configure-aws-credentials@v5
with:
aws-access-key-id: ${{ secrets.AGS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AGS_AWS_SECRET_ACCESS_KEY }}

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-amps</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-parent</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<build>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-parent</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -31,7 +31,6 @@ import static org.alfresco.service.cmr.security.PermissionService.GROUP_PREFIX;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -248,7 +247,7 @@ public class ExtendedSecurityServiceImpl extends ServiceBaseImpl
*/
private Set<String> getAuthorities(String group)
{
Set<String> result = new LinkedHashSet<>();
Set<String> result = new HashSet<>();
result.addAll(authorityService.getContainedAuthorities(null, group, true));
return result;
}

View File

@@ -33,7 +33,6 @@ import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -326,8 +325,8 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
return aclReaders;
}
Set<String> assigned = new LinkedHashSet<>();
Set<String> readers = new LinkedHashSet<>();
HashSet<String> assigned = new HashSet<>();
HashSet<String> readers = new HashSet<>();
for (AccessControlEntry ace : acl.getEntries())
{
@@ -413,8 +412,8 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
return aclWriters;
}
Set<String> assigned = new LinkedHashSet<>();
Set<String> readers = new LinkedHashSet<>();
HashSet<String> assigned = new HashSet<>();
HashSet<String> readers = new HashSet<>();
for (AccessControlEntry ace : acl.getEntries())
{
@@ -486,7 +485,7 @@ public class ExtendedPermissionServiceImpl extends PermissionServiceImpl impleme
Set<String> writers = getWriters(aclId);
// add the current owner to the list of extended writers
Set<String> modifiedWrtiers = new LinkedHashSet<>(writers);
Set<String> modifiedWrtiers = new HashSet<>(writers);
String owner = ownableService.getOwner(nodeRef);
if (StringUtils.isNotBlank(owner) &&
!owner.equals(OwnableService.NO_OWNER) &&

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<build>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-amps</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -9,6 +9,6 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
</project>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<organization>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<developers>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<developers>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<properties>

10
pom.xml
View File

@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Alfresco Community Repo Parent</name>
@@ -51,8 +51,8 @@
<dependency.alfresco-server-root.version>7.0.2</dependency.alfresco-server-root.version>
<dependency.activiti-engine.version>5.23.0</dependency.activiti-engine.version>
<dependency.activiti.version>5.23.0</dependency.activiti.version>
<dependency.alfresco-transform-core.version>5.2.2</dependency.alfresco-transform-core.version>
<dependency.alfresco-transform-service.version>4.2.2</dependency.alfresco-transform-service.version>
<dependency.alfresco-transform-core.version>5.2.2-A.4</dependency.alfresco-transform-core.version>
<dependency.alfresco-transform-service.version>4.2.2-A.2</dependency.alfresco-transform-service.version>
<dependency.alfresco-greenmail.version>7.1</dependency.alfresco-greenmail.version>
<dependency.acs-event-model.version>1.0.11</dependency.acs-event-model.version>
@@ -115,7 +115,7 @@
<dependency.jakarta-json-path.version>2.9.0</dependency.jakarta-json-path.version>
<dependency.json-smart.version>2.5.2</dependency.json-smart.version>
<alfresco.googledrive.version>4.1.0</alfresco.googledrive.version>
<alfresco.aos-module.version>3.4.0</alfresco.aos-module.version>
<alfresco.aos-module.version>3.3.0</alfresco.aos-module.version>
<alfresco.api-explorer.version>25.2.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
<alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version>
@@ -154,7 +154,7 @@
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
<url>https://github.com/Alfresco/alfresco-community-repo</url>
<tag>25.3.0.60</tag>
<tag>HEAD</tag>
</scm>
<distributionManagement>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -31,10 +31,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.json.simple.JSONObject;
import org.owasp.html.PolicyFactory;
import org.owasp.html.Sanitizers;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
@@ -70,19 +67,6 @@ public class CommentsPost extends AbstractCommentsWebScript
// get json object from request
JSONObject json = parseJSON(req);
// Validating and Sanitizing comment content to prevent XSS
String commentContent = getOrNull(json, "content");
if (StringUtils.isBlank(commentContent))
{
throw new IllegalArgumentException("Comment content must not be empty");
}
else
{
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String safeContent = policy.sanitize(commentContent);
json.replace("content", safeContent);
}
/* MNT-10231, MNT-9771 fix */
this.behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);

View File

@@ -51,14 +51,6 @@ function main()
}
}
var contentChanged = false;
if (itemKind === "node") {
contentChanged = metadataExtractAction.isContentChanged(itemId,repoFormData);
}
if(logger.isLoggingEnabled() && contentChanged) {
logger.log("Content has been changed");
}
var persistedObject = null;
try
{
@@ -91,50 +83,9 @@ function main()
return;
}
if (itemKind === "node") {
checkAndExtractNodeMetadata(persistedObject, itemId, contentChanged);
}
model.persistedObject = persistedObject.toString();
model.message = "Successfully persisted form for item [" + itemKind + "]" + itemId;
}
function checkAndExtractNodeMetadata(persistedObject, itemId, isContentChanged) {
var nodeRefStr = toNodeRefString(persistedObject, itemId);
var node = search.findNode(nodeRefStr);
if (node == null) {
if (logger.isLoggingEnabled()) {
logger.log("Node not found: " + nodeRefStr);
}
} else if(isContentChanged) {
extractMetadata(node, isContentChanged);
} else {
if (logger.isLoggingEnabled()) {
logger.log("Content not changed, skipping metadata extraction for node: " + nodeRefStr);
}
}
}
function extractMetadata(file, isContentChanged) {
var emAction = metadataExtractAction.create(isContentChanged);
if (emAction) {
// readOnly=false, newTransaction=false
emAction.execute(file, false, false);
}
}
function toNodeRefString(persistedObject, itemId) {
// Prefer the NodeRef returned by saveForm (when kind=node).
if (persistedObject instanceof Packages.org.alfresco.service.cmr.repository.NodeRef) {
return persistedObject.toString();
}
// If the client passed a full noderef, keep it.
if (itemId && itemId.indexOf("://") !== -1) {
return itemId;
}
// Otherwise assume SpacesStore UUID.
return "workspace://SpacesStore/" + itemId;
}
main();

View File

@@ -45,11 +45,7 @@
"parentType": "${row.item.parentTypeShort!""}",
"isContainer": ${row.item.isContainer?string},
<#if row.container??>"container": "${row.container!""}",</#if>
<#if row.item.properties?? && row.item.properties.name??>
"name": "${row.item.properties.name!""}",
<#else>
"name": "${(row.item.name)!row.item?string!""}",
</#if>
<#if row.item.aspects??>
"aspects": [
<#list row.item.aspects as aspect>
@@ -58,15 +54,10 @@
</#list>
],
</#if>
<#if row.item.properties??>
"title":<#if row.item.properties["lnk:title"]??>"${row.item.properties["lnk:title"]}",
<#elseif row.item.properties["ia:whatEvent"]??>"${row.item.properties["ia:whatEvent"]}",
<#else>"${row.item.properties.title!""}",</#if>
"description": "${row.item.properties.description!""}",
<#else>
"title": "${(row.item.name)!row.item?string!""}",
"description": "",
</#if>
<#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}",</#if>
<#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}",</#if>
<#if row.item.siteShortName??>"site": "${row.item.siteShortName}",</#if>

View File

@@ -2,7 +2,7 @@ function extractMetadata(file)
{
// Extract metadata - via repository action for now.
// This should use the MetadataExtracter API to fetch properties, allowing for possible failures.
var emAction = metadataExtractAction.create(true);
var emAction = actions.create("extract-metadata");
if (emAction != null)
{
// Call using readOnly = false, newTransaction = false

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>25.3.0.60</version>
<version>25.3.0.51-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -1,67 +0,0 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.action.evaluator;
import java.util.List;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Content change condition evaluator implementation. Required only in Scripted Actions to allow determination if content has changed. <br>
* Usage in {@link org.alfresco.repo.jscript.MetaDataExtractAction#create(boolean)}
*
* @author Sayan Bhattacharya
*/
public class CompareContentConditionEvaluator extends ActionConditionEvaluatorAbstractBase
{
/**
* Evaluator constants
*/
public static final String NAME = "compare-content";
public static final String PARAM_IS_CONTENT_CHANGED = "isContentChanged";
/**
* @see ActionConditionEvaluatorAbstractBase#evaluateImpl(ActionCondition, NodeRef)
*/
@Override
public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef)
{
return true;
}
/**
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// No parameters to add
}
}

View File

@@ -51,14 +51,12 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.evaluator.CompareContentConditionEvaluator;
import org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter;
import org.alfresco.repo.content.metadata.AsynchronousExtractor;
import org.alfresco.repo.content.metadata.MetadataExtracter;
@@ -405,7 +403,6 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
((AbstractMappingMetadataExtracter) extracter).setEnableStringTagging(enableStringTagging);
}
MetadataExtracter.OverwritePolicy overwritePolicy = determineOverwritePolicy(ruleAction);
// Get all the node's properties
Map<QName, Serializable> nodeProperties = nodeService.getProperties(actionedUponNodeRef);
@@ -418,7 +415,7 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
modifiedProperties = extracter.extract(
actionedUponNodeRef,
reader,
overwritePolicy,
/* OverwritePolicy.PRAGMATIC, */
nodeProperties);
}
catch (Throwable e)
@@ -459,21 +456,6 @@ public class ContentMetadataExtracter extends ActionExecuterAbstractBase
stringTaggingSeparators);
}
private MetadataExtracter.OverwritePolicy determineOverwritePolicy(Action ruleAction)
{
return Optional.ofNullable(ruleAction.getActionConditions())
.flatMap(conditions -> conditions.stream()
.filter(e -> CompareContentConditionEvaluator.NAME.equals(e.getActionConditionDefinitionName()))
.findAny()
.map(e -> {
Serializable contentChanged = e.getParameterValue(CompareContentConditionEvaluator.PARAM_IS_CONTENT_CHANGED);
return Boolean.TRUE.equals(contentChanged)
? MetadataExtracter.OverwritePolicy.EAGER
: MetadataExtracter.OverwritePolicy.PRAGMATIC;
}))
.orElse(MetadataExtracter.OverwritePolicy.PRAGMATIC);
}
public static void addExtractedMetadataToNode(NodeRef actionedUponNodeRef, Map<QName, Serializable> nodeProperties,
Map<QName, Serializable> modifiedProperties,
NodeService nodeService, DictionaryService dictionaryService,

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2025 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
@@ -102,7 +102,6 @@ import org.alfresco.service.namespace.QName;
* @author Jesper Steen Møller
* @author Derek Hulley
*/
@SuppressWarnings("PMD.CyclomaticComplexity")
@AlfrescoPublicApi
abstract public class AbstractMappingMetadataExtracter implements MetadataExtracter, MetadataEmbedder, BeanNameAware, ApplicationContextAware
{
@@ -1119,15 +1118,6 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
return extract(nodeRef, reader, overwritePolicy, destination, mapping);
}
/**
* {@inheritDoc}
*/
@Override
public Map<QName, Serializable> extract(NodeRef nodeRef, ContentReader reader, OverwritePolicy overwritePolicy, Map<QName, Serializable> destination)
{
return extract(nodeRef, reader, overwritePolicy, destination, mapping);
}
/**
* {@inheritDoc}
*/
@@ -1164,7 +1154,7 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
// Check that the content has some meat
if (reader.getSize() > 0 && reader.exists())
{
rawMetadata = extractRaw(nodeRef, reader, getLimits(reader.getMimetype()), overwritePolicy);
rawMetadata = extractRaw(nodeRef, reader, getLimits(reader.getMimetype()));
}
else
{
@@ -2012,7 +2002,7 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
}
/**
* Exception wrapper to handle exceeded limits imposed by {@link MetadataExtracterLimits} {@link AbstractMappingMetadataExtracter#extractRaw(NodeRef, ContentReader, MetadataExtracterLimits,OverwritePolicy)}
* Exception wrapper to handle exceeded limits imposed by {@link MetadataExtracterLimits} {@link AbstractMappingMetadataExtracter#extractRaw(NodeRef, ContentReader, MetadataExtracterLimits)}
*/
private class LimitExceededException extends Exception
{
@@ -2042,7 +2032,7 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
* All exception conditions can be handled.
*/
private Map<String, Serializable> extractRaw(NodeRef nodeRef,
ContentReader reader, MetadataExtracterLimits limits, OverwritePolicy overwritePolicy) throws Throwable
ContentReader reader, MetadataExtracterLimits limits) throws Throwable
{
if (reader.getSize() > limits.getMaxDocumentSizeMB() * MEGABYTE_SIZE)
{
@@ -2069,12 +2059,6 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
}
}
return extractRawInThread(nodeRef, reader, limits, overwritePolicy);
}
protected Map<String, Serializable> extractRawInThread(NodeRef nodeRef, ContentReader reader, MetadataExtracterLimits limits, OverwritePolicy policy)
throws Throwable
{
return extractRawInThread(nodeRef, reader, limits);
}

View File

@@ -93,9 +93,6 @@ public class AsynchronousExtractor extends AbstractMappingMetadataExtracter
private static final String METADATA = "metadata";
private static final Map<String, Serializable> EMPTY_METADATA = Collections.emptyMap();
private static final OverwritePolicy DEFAULT_OVERWRITE_POLICY = OverwritePolicy.PRAGMATIC;
private OverwritePolicy extractOverwritePolicy = DEFAULT_OVERWRITE_POLICY;
private final ObjectMapper jsonObjectMapper = new ObjectMapper();
private NodeService nodeService;
@@ -263,9 +260,9 @@ public class AsynchronousExtractor extends AbstractMappingMetadataExtracter
}
@Override
protected Map<String, Serializable> extractRawInThread(NodeRef nodeRef, ContentReader reader, MetadataExtracterLimits limits, OverwritePolicy overwritePolicy) throws Throwable
protected Map<String, Serializable> extractRawInThread(NodeRef nodeRef, ContentReader reader, MetadataExtracterLimits limits)
throws Throwable
{
this.extractOverwritePolicy = overwritePolicy != null ? overwritePolicy : DEFAULT_OVERWRITE_POLICY;
Map<String, String> options = getExtractOptions(nodeRef, reader, limits);
transformInBackground(nodeRef, reader, MIMETYPE_METADATA_EXTRACT, EXTRACT, options);
return EMPTY_METADATA;
@@ -464,7 +461,7 @@ public class AsynchronousExtractor extends AbstractMappingMetadataExtracter
}
// Remove well know entries from the map that drive how the real metadata is applied.
OverwritePolicy overwritePolicy = removeOverwritePolicy(metadata, "sys:overwritePolicy", extractOverwritePolicy);
OverwritePolicy overwritePolicy = removeOverwritePolicy(metadata, "sys:overwritePolicy", OverwritePolicy.PRAGMATIC);
Boolean enableStringTagging = removeBoolean(metadata, "sys:enableStringTagging", false);
Boolean carryAspectProperties = removeBoolean(metadata, "sys:carryAspectProperties", true);
List<String> stringTaggingSeparators = removeTaggingSeparators(metadata, "sys:stringTaggingSeparators",

View File

@@ -404,24 +404,6 @@ public interface MetadataExtracter extends ContentWorker
return extract(reader, destination);
}
/**
* Identical to {@link #extract(ContentReader, OverwritePolicy ,Map)} but with the addition of the {@code NodeRef} being acted on. By default, the method without the {@code NodeRef} is called.
*
* @param nodeRef
* the node being acted on.
* @param reader
* the source of the content
* @param destination
* the map of properties to populate (essentially a return value)
* @return Returns a map of all properties on the destination map that were added or modified. If the return map is empty, then no properties were modified.
* @throws ContentIOException
* if a detectable error occurs
*/
default Map<QName, Serializable> extract(NodeRef nodeRef, ContentReader reader, OverwritePolicy overwritePolicy, Map<QName, Serializable> destination)
{
return extract(reader, overwritePolicy, destination);
}
/**
* Identical to {@link #extract(ContentReader, OverwritePolicy, Map, Map)} but with the addition of the {@code NodeRef} being acted on. By default, the method without the {@code NodeRef} is called.
*

View File

@@ -1,171 +0,0 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* Copyright (C) 2005 - 2025 Alfresco Software Limited
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.jscript;
import org.apache.commons.lang3.Strings;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.evaluator.CompareContentConditionEvaluator;
import org.alfresco.repo.forms.FormData;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* JavaScript wrapper for the "extract-metadata" action.
* <p>
* This class provides a scriptable interface to trigger metadata extraction actions within the Alfresco repository.</br>
* It is similar to {@link Actions} class but is dedicated to metadata extraction functionality.
*
* </br>
*
* @author Sayan Bhattacharya
*/
public final class MetaDataExtractAction extends BaseScopableProcessorExtension
{
private static final Log LOG = LogFactory.getLog(MetaDataExtractAction.class);
private final static String ACTION_NAME = "extract-metadata";
private ContentService contentService;
private ServiceRegistry services;
/**
* Set the service registry
*
* @param serviceRegistry
* the service registry
*/
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
this.services = serviceRegistry;
}
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
/**
* Create a new metadata extraction action instance
*
* @param setActionContext
* if true, sets the action context to "scriptaction".
* @return the newly created action
*/
public ScriptAction create(boolean isContentChanged)
{
ScriptAction scriptAction = null;
ActionService actionService = services.getActionService();
ActionDefinition actionDef = actionService.getActionDefinition(ACTION_NAME);
if (actionDef != null)
{
Action action = actionService.createAction(ACTION_NAME);
ActionCondition actionCondition = actionService.createActionCondition(CompareContentConditionEvaluator.NAME);
actionCondition.setParameterValue(CompareContentConditionEvaluator.PARAM_IS_CONTENT_CHANGED, isContentChanged);
action.addActionCondition(actionCondition);
scriptAction = new ScriptAction(this.services, action, actionDef);
scriptAction.setScope(getScope());
}
return scriptAction;
}
/**
* Check if the content has been updated in the form data compared to the existing content of the node.
*
* @param itemId
* @param formData
* @return true if content has changed, false otherwise
*/
public boolean isContentChanged(String itemId, FormData formData)
{
try
{
NodeRef nodeRef = NodeRef.isNodeRef(itemId) ? new NodeRef(itemId) : parseNodeRef(itemId);
if (nodeRef == null)
{
return false;
}
ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
String contentString = reader.getContentString();
FormData.FieldData fieldData = formData.getFieldData("prop_cm_content");
if (fieldData == null || fieldData.getValue() == null)
{
return false;
}
String propCmContent = String.valueOf(fieldData.getValue());
return !Strings.CS.equals(contentString, propCmContent);
}
catch (Exception e)
{
if (LOG.isDebugEnabled())
{
LOG.debug("Unable to determine if content has changed for node: " + itemId, e);
}
return false;
}
}
private NodeRef parseNodeRef(String itemId)
{
String[] parts = itemId.split("/");
return (parts.length == 3) ? new NodeRef(parts[0], parts[1], parts[2]) : null;
}
}

View File

@@ -237,12 +237,6 @@
<bean id="no-condition" class="org.alfresco.repo.action.evaluator.NoConditionEvaluator" parent="action-condition-evaluator">
</bean>
<bean id="compare-content" class="org.alfresco.repo.action.evaluator.CompareContentConditionEvaluator" parent="action-condition-evaluator">
<property name="publicCondition">
<value>false</value>
</property>
</bean>
<bean id="compare-property-value" class="org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator" parent="action-condition-evaluator">
<property name="nodeService">
<ref bean="nodeService" />

View File

@@ -104,17 +104,6 @@
</property>
</bean>
<bean id="metadataExtractServiceScript" parent="baseJavaScriptExtension"
class="org.alfresco.repo.jscript.MetaDataExtractAction">
<property name="extensionName">
<value>metadataExtractAction</value>
</property>
<property name="contentService" ref="ContentService" />
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
</bean>
<bean id="imapScript" parent="baseJavaScriptExtension" class="org.alfresco.repo.jscript.Imap">
<property name="extensionName">
<value>imap</value>

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -66,7 +66,6 @@ import org.alfresco.util.testing.category.NonBuildTests;
org.alfresco.repo.importer.FileImporterTest.class,
org.alfresco.repo.importer.ImporterComponentTest.class,
org.alfresco.repo.jscript.PeopleTest.class,
org.alfresco.repo.jscript.MetaDataExtractActionTest.class,
org.alfresco.repo.jscript.RhinoScriptTest.class,
// needs a clean DB to run

View File

@@ -28,7 +28,6 @@ package org.alfresco.repo.action.executer;
import static org.awaitility.Awaitility.await;
import java.io.Serializable;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -47,8 +46,6 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter;
import org.alfresco.repo.content.metadata.MetadataExtracterRegistry;
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
import org.alfresco.repo.jscript.MetaDataExtractAction;
import org.alfresco.repo.jscript.ScriptAction;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.ContentReader;
@@ -77,10 +74,6 @@ public class ContentMetadataExtracterTest extends BaseSpringTest
protected static final String QUICK_DESCRIPTION = "Pangram, fox, dog, Gym class featuring a brown fox and lazy dog";
protected static final String QUICK_CREATOR = "Nevin Nollop";
protected static final String QUICK_UPDATED_TITLE = "The hot dog is eaten by the city fox";
protected static final String QUICK_UPDATED_DESCRIPTION = "Pangram, fox, dog, Gym class featuring only brown fox";
protected static final String QUICK_UPDATED_CREATOR = "Friday";
private NodeService nodeService;
private ContentService contentService;
private MetadataExtracterRegistry registry;
@@ -91,8 +84,6 @@ public class ContentMetadataExtracterTest extends BaseSpringTest
private ContentMetadataExtracter executer;
private MetaDataExtractAction extractAction;
private final static String ID = GUID.generate();
@Before
@@ -125,9 +116,6 @@ public class ContentMetadataExtracterTest extends BaseSpringTest
// Get the executer instance
this.executer = (ContentMetadataExtracter) this.applicationContext.getBean("extract-metadata");
// get the js script action
this.extractAction = (MetaDataExtractAction) this.applicationContext.getBean("metadataExtractServiceScript");
}
/**
@@ -363,45 +351,4 @@ public class ContentMetadataExtracterTest extends BaseSpringTest
}
});
}
@Test
public void testUsingScriptAction_WhenContentChanged() throws Exception
{
// update the content
ContentWriter cw = this.contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
cw.setMimetype(MimetypeMap.MIMETYPE_PDF);
cw.putContent(AbstractContentTransformerTest.loadNamedQuickTestFile("quickupdated.pdf"));
// Make the nodeRef visible to other transactions as it will need to be in async requests
TestTransaction.flagForCommit();
TestTransaction.end();
// Execute the action
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
public Void execute() throws Throwable
{
ScriptAction action = extractAction.create(true);
action.execute(nodeRef, false, false);
return null;
}
});
// Need to wait for the async extract
await().pollInSameThread()
.atMost(Duration.ofSeconds(100))
.until(() -> nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION), Objects::nonNull);
// Check that the properties have been preserved, but that description has been set
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
public Void execute() throws Throwable
{
assertEquals(QUICK_UPDATED_TITLE, nodeService.getProperty(nodeRef, ContentModel.PROP_TITLE));
assertEquals(QUICK_UPDATED_CREATOR, nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHOR));
assertEquals(QUICK_UPDATED_DESCRIPTION, nodeService.getProperty(nodeRef, ContentModel.PROP_DESCRIPTION));
return null;
}
});
}
}

View File

@@ -1,128 +0,0 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2025 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* Copyright (C) 2005 Jesper Steen Møller
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.jscript;
import static org.junit.Assert.*;
import org.junit.Test;
import org.mockito.Mockito;
import org.alfresco.repo.forms.FormData;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
public class MetaDataExtractActionTest
{
@Test
public void testIsContentChangedReturnsTrue()
{
MetaDataExtractAction action = new MetaDataExtractAction();
ContentService contentService = Mockito.mock(ContentService.class);
ContentReader reader = Mockito.mock(ContentReader.class);
FormData formData = Mockito.mock(FormData.class);
FormData.FieldData fieldData = Mockito.mock(FormData.FieldData.class);
String nodeRefStr = "workspace://SpacesStore/abc/def";
Mockito.when(contentService.getReader(Mockito.any(), Mockito.any())).thenReturn(reader);
Mockito.when(reader.getContentString()).thenReturn("oldContent");
Mockito.when(formData.getFieldData("prop_cm_content")).thenReturn(fieldData);
Mockito.when(fieldData.getValue()).thenReturn("newContent");
action.setContentService(contentService);
boolean result = action.isContentChanged(nodeRefStr, formData);
assertTrue(result);
}
@Test
public void testIsContentChangedReturnsFalse()
{
MetaDataExtractAction action = new MetaDataExtractAction();
ContentService contentService = Mockito.mock(ContentService.class);
ContentReader reader = Mockito.mock(ContentReader.class);
FormData formData = Mockito.mock(FormData.class);
FormData.FieldData fieldData = Mockito.mock(FormData.FieldData.class);
String nodeRefStr = "workspace://SpacesStore/abc/def";
Mockito.when(contentService.getReader(Mockito.any(), Mockito.any())).thenReturn(reader);
Mockito.when(reader.getContentString()).thenReturn("sameContent");
Mockito.when(formData.getFieldData("prop_cm_content")).thenReturn(fieldData);
Mockito.when(fieldData.getValue()).thenReturn("sameContent");
action.setContentService(contentService);
boolean result = action.isContentChanged(nodeRefStr, formData);
assertFalse(result);
}
@Test
public void testCreateWhenContentChangedReturnsScriptAction()
{
MetaDataExtractAction action = new MetaDataExtractAction();
ServiceRegistry serviceRegistry = Mockito.mock(ServiceRegistry.class);
ActionService actionService = Mockito.mock(ActionService.class);
ActionDefinition actionDefinition = Mockito.mock(ActionDefinition.class);
Action alfrescoAction = Mockito.mock(Action.class);
ActionCondition actionCondition = Mockito.mock(ActionCondition.class);
Mockito.when(serviceRegistry.getActionService()).thenReturn(actionService);
Mockito.when(actionService.getActionDefinition(Mockito.anyString())).thenReturn(actionDefinition);
Mockito.when(actionService.createAction(Mockito.anyString())).thenReturn(alfrescoAction);
Mockito.when(actionService.createActionCondition(Mockito.anyString())).thenReturn(actionCondition);
action.setServiceRegistry(serviceRegistry);
ScriptAction result = action.create(true);
assertNotNull("ScriptAction should not be null when content has changed", result);
}
}