Skip to content

Commit 7a490fd

Browse files
Preserve original user for versioning history
1 parent f910cf4 commit 7a490fd

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This addon provides an action to extract OCR text from images or plain PDFs in A
88
The plugin is licensed under the [LGPL v3.0](http://www.gnu.org/licenses/lgpl-3.0.html).
99

1010
**State**
11-
Current addon release is 2.3.0
11+
Current addon release is 2.3.1
1212

1313
**Compatibility**
1414
The current version has been developed using Alfresco 5.2 and Alfresco SDK 3.0.2, although it should also run in Alfresco 5.1, 5.0 & 4.2 (as it is developed by using Alfresco SDK 3.0)
@@ -36,8 +36,8 @@ Downloading the ready-to-deploy-plugin
3636
--------------------------------------
3737
The binary distribution is made of two jar files to be deployed in Alfresco as modules:
3838

39-
* [repo JAR](https://github.com/keensoft/alfresco-simple-ocr/releases/download/2.3.0/simple-ocr-repo-2.3.0.jar)
40-
* [share JAR](https://github.com/keensoft/alfresco-simple-ocr/releases/download/2.3.0/simple-ocr-share-2.3.0.jar)
39+
* [repo JAR](https://github.com/keensoft/alfresco-simple-ocr/releases/download/2.3.1/simple-ocr-repo-2.3.1.jar)
40+
* [share JAR](https://github.com/keensoft/alfresco-simple-ocr/releases/download/2.3.1/simple-ocr-share-2.3.1.jar)
4141

4242
You can install them by putting the jar files in [module folder](http://docs.alfresco.com/community/concepts/dev-extensions-packaging-techniques-jar-files.html)
4343

simple-ocr-repo/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>es.keensoft</groupId>
66
<artifactId>simple-ocr-repo</artifactId>
7-
<version>2.3.0</version>
7+
<version>2.3.1</version>
88
<name>simple-ocr-repo Platform Jar Module - SDK 3</name>
99
<description>Platform JAR Module (to be included in the alfresco.war) - SDK 3</description>
1010
<packaging>jar</packaging>

simple-ocr-repo/src/main/java/es/keensoft/alfresco/ocr/OCRExtractAction.java

+11-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
1313
import org.alfresco.repo.content.MimetypeMap;
1414
import org.alfresco.repo.security.authentication.AuthenticationUtil;
15-
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
1615
import org.alfresco.repo.transaction.RetryingTransactionHelper;
1716
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
1817
import org.alfresco.repo.version.VersionModel;
@@ -102,7 +101,7 @@ protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
102101
// Share action set asynchronous as mandatory due to variations in response time for OCR processes when server is busy
103102
if (forceAsync) {
104103

105-
Runnable runnable = new ExtractOCRTask(actionedUponNodeRef, contentData);
104+
Runnable runnable = new ExtractOCRTask(actionedUponNodeRef, contentData, AuthenticationUtil.getFullyAuthenticatedUser());
106105
threadPoolExecutor.execute(runnable);
107106

108107
} else {
@@ -136,20 +135,23 @@ private class ExtractOCRTask implements Runnable {
136135

137136
private NodeRef nodeToBeOCRd;
138137
private ContentData contentData;
138+
private String userId;
139139

140-
private ExtractOCRTask(NodeRef nodeToBeOCRd, ContentData contentData) {
140+
private ExtractOCRTask(NodeRef nodeToBeOCRd, ContentData contentData, String userId) {
141141
this.nodeToBeOCRd = nodeToBeOCRd;
142142
this.contentData = contentData;
143+
this.userId = userId;
143144
}
144145

145146
@Override
146147
public void run() {
147-
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
148-
public Void doWork() throws Exception {
149-
executeInNewTransaction(nodeToBeOCRd, contentData);
150-
return null;
151-
}
152-
});
148+
AuthenticationUtil.pushAuthentication();
149+
try {
150+
AuthenticationUtil.setRunAsUser(userId);
151+
executeInNewTransaction(nodeToBeOCRd, contentData);
152+
} finally {
153+
AuthenticationUtil.popAuthentication();
154+
}
153155
}
154156
}
155157

simple-ocr-share/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>es.keensoft</groupId>
66
<artifactId>simple-ocr-share</artifactId>
7-
<version>2.3.0</version>
7+
<version>2.3.1</version>
88
<name>simple-ocr-share Share Jar Module - SDK 3</name>
99
<description>Share JAR Module (to be included in the share.war) - SDK 3</description>
1010
<packaging>jar</packaging>

0 commit comments

Comments
 (0)