Skip to content

Commit

Permalink
Preserve original user for versioning history
Browse files Browse the repository at this point in the history
  • Loading branch information
angelborroy-ks committed Aug 17, 2017
1 parent f910cf4 commit 7a490fd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion simple-ocr-repo/pom.xml
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>es.keensoft</groupId>
<artifactId>simple-ocr-repo</artifactId>
<version>2.3.0</version>
<version>2.3.1</version>
<name>simple-ocr-repo Platform Jar Module - SDK 3</name>
<description>Platform JAR Module (to be included in the alfresco.war) - SDK 3</description>
<packaging>jar</packaging>
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Void>() {
public Void doWork() throws Exception {
executeInNewTransaction(nodeToBeOCRd, contentData);
return null;
}
});
AuthenticationUtil.pushAuthentication();
try {
AuthenticationUtil.setRunAsUser(userId);
executeInNewTransaction(nodeToBeOCRd, contentData);
} finally {
AuthenticationUtil.popAuthentication();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion simple-ocr-share/pom.xml
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>es.keensoft</groupId>
<artifactId>simple-ocr-share</artifactId>
<version>2.3.0</version>
<version>2.3.1</version>
<name>simple-ocr-share Share Jar Module - SDK 3</name>
<description>Share JAR Module (to be included in the share.war) - SDK 3</description>
<packaging>jar</packaging>
Expand Down

0 comments on commit 7a490fd

Please sign in to comment.