From 7a490fdcd3235e705dd4b2aef72f05f9d53968c8 Mon Sep 17 00:00:00 2001 From: Angel Borroy Date: Thu, 17 Aug 2017 14:36:57 +0200 Subject: [PATCH] Preserve original user for versioning history --- README.md | 6 +++--- simple-ocr-repo/pom.xml | 2 +- .../alfresco/ocr/OCRExtractAction.java | 20 ++++++++++--------- simple-ocr-share/pom.xml | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d68ec92..442cd56 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This addon provides an action to extract OCR text from images or plain PDFs in A The plugin is licensed under the [LGPL v3.0](http://www.gnu.org/licenses/lgpl-3.0.html). **State** -Current addon release is 2.3.0 +Current addon release is 2.3.1 **Compatibility** 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 -------------------------------------- The binary distribution is made of two jar files to be deployed in Alfresco as modules: -* [repo JAR](https://github.com/keensoft/alfresco-simple-ocr/releases/download/2.3.0/simple-ocr-repo-2.3.0.jar) -* [share JAR](https://github.com/keensoft/alfresco-simple-ocr/releases/download/2.3.0/simple-ocr-share-2.3.0.jar) +* [repo JAR](https://github.com/keensoft/alfresco-simple-ocr/releases/download/2.3.1/simple-ocr-repo-2.3.1.jar) +* [share JAR](https://github.com/keensoft/alfresco-simple-ocr/releases/download/2.3.1/simple-ocr-share-2.3.1.jar) 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) diff --git a/simple-ocr-repo/pom.xml b/simple-ocr-repo/pom.xml index db39d95..df83ecf 100644 --- a/simple-ocr-repo/pom.xml +++ b/simple-ocr-repo/pom.xml @@ -4,7 +4,7 @@ 4.0.0 es.keensoft simple-ocr-repo - 2.3.0 + 2.3.1 simple-ocr-repo Platform Jar Module - SDK 3 Platform JAR Module (to be included in the alfresco.war) - SDK 3 jar diff --git a/simple-ocr-repo/src/main/java/es/keensoft/alfresco/ocr/OCRExtractAction.java b/simple-ocr-repo/src/main/java/es/keensoft/alfresco/ocr/OCRExtractAction.java index aab84db..6df94e8 100644 --- a/simple-ocr-repo/src/main/java/es/keensoft/alfresco/ocr/OCRExtractAction.java +++ b/simple-ocr-repo/src/main/java/es/keensoft/alfresco/ocr/OCRExtractAction.java @@ -12,7 +12,6 @@ import org.alfresco.repo.action.executer.ActionExecuterAbstractBase; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.version.VersionModel; @@ -102,7 +101,7 @@ protected void executeImpl(Action action, NodeRef actionedUponNodeRef) { // Share action set asynchronous as mandatory due to variations in response time for OCR processes when server is busy if (forceAsync) { - Runnable runnable = new ExtractOCRTask(actionedUponNodeRef, contentData); + Runnable runnable = new ExtractOCRTask(actionedUponNodeRef, contentData, AuthenticationUtil.getFullyAuthenticatedUser()); threadPoolExecutor.execute(runnable); } else { @@ -136,20 +135,23 @@ private class ExtractOCRTask implements Runnable { private NodeRef nodeToBeOCRd; private ContentData contentData; + private String userId; - private ExtractOCRTask(NodeRef nodeToBeOCRd, ContentData contentData) { + private ExtractOCRTask(NodeRef nodeToBeOCRd, ContentData contentData, String userId) { this.nodeToBeOCRd = nodeToBeOCRd; this.contentData = contentData; + this.userId = userId; } @Override public void run() { - AuthenticationUtil.runAsSystem(new RunAsWork() { - public Void doWork() throws Exception { - executeInNewTransaction(nodeToBeOCRd, contentData); - return null; - } - }); + AuthenticationUtil.pushAuthentication(); + try { + AuthenticationUtil.setRunAsUser(userId); + executeInNewTransaction(nodeToBeOCRd, contentData); + } finally { + AuthenticationUtil.popAuthentication(); + } } } diff --git a/simple-ocr-share/pom.xml b/simple-ocr-share/pom.xml index 3360463..fa36a48 100644 --- a/simple-ocr-share/pom.xml +++ b/simple-ocr-share/pom.xml @@ -4,7 +4,7 @@ 4.0.0 es.keensoft simple-ocr-share - 2.3.0 + 2.3.1 simple-ocr-share Share Jar Module - SDK 3 Share JAR Module (to be included in the share.war) - SDK 3 jar