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