Fix Shiro security context problem (hopefully), alerts for import status
parent
8893eebaff
commit
327fd624c8
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.libreccm.ui.admin.imexport;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.ImportExport;
|
||||
import org.libreccm.security.Shiro;
|
||||
|
|
@ -62,6 +64,7 @@ public class ImExportTasks {
|
|||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void importEntitites(@ObservesAsync final ImportTask task) {
|
||||
ThreadContext.bind(task.getSecurityManager());
|
||||
shiro.getSystemUser().execute(() -> executeImport(task));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.libreccm.ui.admin.imexport;
|
|||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.libreccm.imexport.Exportable;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -154,7 +155,12 @@ public class ImportExportTaskManager {
|
|||
taskStatus.setName(importName);
|
||||
taskStatus.setStarted(LocalDateTime.now());
|
||||
importTaskSender.fireAsync(
|
||||
new ImportTask(importName, LocalDate.now(), taskStatus)
|
||||
new ImportTask(
|
||||
importName,
|
||||
LocalDate.now(),
|
||||
taskStatus,
|
||||
SecurityUtils.getSecurityManager()
|
||||
)
|
||||
).handle((task, ex) -> handleImportTaskResult(task, ex, taskStatus));
|
||||
|
||||
taskStatus.setStatus(ImExportTaskStatus.RUNNING);
|
||||
|
|
|
|||
|
|
@ -41,15 +41,19 @@ public class ImportTask {
|
|||
* The status of the import task.
|
||||
*/
|
||||
private final ImportTaskStatus status;
|
||||
|
||||
private final org.apache.shiro.mgt.SecurityManager securityManager;
|
||||
|
||||
public ImportTask(
|
||||
final String name,
|
||||
final LocalDate started,
|
||||
final ImportTaskStatus status
|
||||
final ImportTaskStatus status,
|
||||
final org.apache.shiro.mgt.SecurityManager securityManager
|
||||
) {
|
||||
this.name = name;
|
||||
this.started = started;
|
||||
this.status = status;
|
||||
this.securityManager = securityManager;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
@ -63,5 +67,9 @@ public class ImportTask {
|
|||
public ImportTaskStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public org.apache.shiro.mgt.SecurityManager getSecurityManager() {
|
||||
return securityManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@
|
|||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>#{AdminMessages['imexport.activeimports.heading']}</h2>
|
||||
|
||||
|
|
@ -126,10 +126,19 @@
|
|||
<td>
|
||||
<c:choose>
|
||||
<c:when test="#{task.finished}">
|
||||
#{AdminMessages['imexport.activeimports.table.columns.status.finished']}
|
||||
<div class="alert alert-success" role="alert">
|
||||
#{AdminMessages['imexport.activeimports.table.columns.status.finished']}
|
||||
</div>
|
||||
</c:when>
|
||||
<c:when test="#{task.error}">
|
||||
<div class="alert alert-danger" role="alert">
|
||||
#{AdminMessages['imexport.activeimports.table.columns.status.error']}
|
||||
</div>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
#{AdminMessages['imexport.activeimports.table.columns.status.running']}
|
||||
<div class="alert alert-primary" role="alert">
|
||||
#{AdminMessages['imexport.activeimports.table.columns.status.running']}
|
||||
</div>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -562,3 +562,4 @@ imexport.import.archives.help=Select the archive to import
|
|||
imexport.import.archives.label=Available import archives
|
||||
imexport.import.cancel=Cancel
|
||||
imexport.import.submit=Start Import
|
||||
imexport.activeimports.table.columns.status.error=Failed
|
||||
|
|
|
|||
|
|
@ -562,3 +562,4 @@ imexport.import.archives.help=W\u00e4hlen Sie das zu importierende Archiv
|
|||
imexport.import.archives.label=Verf\u00fcgbare Import-Archive
|
||||
imexport.import.cancel=Abbrechen
|
||||
imexport.import.submit=Import starten
|
||||
imexport.activeimports.table.columns.status.error=Fehlgeschlagen
|
||||
|
|
|
|||
Loading…
Reference in New Issue