|
12 | 12 | import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
13 | 13 | import org.alfresco.repo.content.MimetypeMap;
|
14 | 14 | import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
15 |
| -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; |
16 | 15 | import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
17 | 16 | import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
18 | 17 | import org.alfresco.repo.version.VersionModel;
|
@@ -102,7 +101,7 @@ protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
|
102 | 101 | // Share action set asynchronous as mandatory due to variations in response time for OCR processes when server is busy
|
103 | 102 | if (forceAsync) {
|
104 | 103 |
|
105 |
| - Runnable runnable = new ExtractOCRTask(actionedUponNodeRef, contentData); |
| 104 | + Runnable runnable = new ExtractOCRTask(actionedUponNodeRef, contentData, AuthenticationUtil.getFullyAuthenticatedUser()); |
106 | 105 | threadPoolExecutor.execute(runnable);
|
107 | 106 |
|
108 | 107 | } else {
|
@@ -136,20 +135,23 @@ private class ExtractOCRTask implements Runnable {
|
136 | 135 |
|
137 | 136 | private NodeRef nodeToBeOCRd;
|
138 | 137 | private ContentData contentData;
|
| 138 | + private String userId; |
139 | 139 |
|
140 |
| - private ExtractOCRTask(NodeRef nodeToBeOCRd, ContentData contentData) { |
| 140 | + private ExtractOCRTask(NodeRef nodeToBeOCRd, ContentData contentData, String userId) { |
141 | 141 | this.nodeToBeOCRd = nodeToBeOCRd;
|
142 | 142 | this.contentData = contentData;
|
| 143 | + this.userId = userId; |
143 | 144 | }
|
144 | 145 |
|
145 | 146 | @Override
|
146 | 147 | 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 | + } |
153 | 155 | }
|
154 | 156 | }
|
155 | 157 |
|
|
0 commit comments