Code cleanup, execute import as system user.
parent
a72945501d
commit
a0ac634d1f
|
|
@ -26,7 +26,7 @@ import java.util.Objects;
|
|||
|
||||
/**
|
||||
* Status of an export task.
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ExportTaskStatus implements Comparable<ExportTaskStatus> {
|
||||
|
|
@ -142,9 +142,9 @@ public class ExportTaskStatus implements Comparable<ExportTaskStatus> {
|
|||
+ " }",
|
||||
super.toString(),
|
||||
name,
|
||||
DateTimeFormatter.ISO_DATE_TIME.withZone(
|
||||
ZoneId.systemDefault()
|
||||
).format(started),
|
||||
DateTimeFormatter.ISO_DATE_TIME
|
||||
.withZone(ZoneId.systemDefault())
|
||||
.format(started),
|
||||
Objects.toString(status),
|
||||
Objects.toString(exception)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ public class ImExportController {
|
|||
TreeMap::new
|
||||
)
|
||||
)
|
||||
//.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
return "org/libreccm/ui/admin/imexport/export.xhtml";
|
||||
|
|
@ -268,9 +267,9 @@ public class ImExportController {
|
|||
"%s from server %s created on %s with types %s",
|
||||
manifest.getImportName(),
|
||||
manifest.getOnServer(),
|
||||
DateTimeFormatter.ISO_DATE_TIME.withZone(
|
||||
ZoneOffset.systemDefault()
|
||||
).format(manifest.getCreated().toInstant()),
|
||||
DateTimeFormatter.ISO_DATE_TIME
|
||||
.withZone(ZoneOffset.systemDefault())
|
||||
.format(manifest.getCreated().toInstant()),
|
||||
manifest.getTypes().stream().collect(Collectors.joining(", "))
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.libreccm.ui.admin.imexport;
|
|||
|
||||
import org.libreccm.imexport.Exportable;
|
||||
import org.libreccm.imexport.ImportExport;
|
||||
import org.libreccm.security.Shiro;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
|
@ -29,8 +30,9 @@ import javax.inject.Inject;
|
|||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* Listens for CDI events fired by {@link org.libreccm.ui.admin.imexport.ImportExportTaskManager}
|
||||
* and executes tasks.
|
||||
* Listens for CDI events fired by
|
||||
* {@link org.libreccm.ui.admin.imexport.ImportExportTaskManager} and executes
|
||||
* tasks.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
|
|
@ -40,10 +42,14 @@ public class ImExportTasks {
|
|||
@Inject
|
||||
private ImportExport importExport;
|
||||
|
||||
@Inject
|
||||
private Shiro shiro;
|
||||
|
||||
/**
|
||||
* Listens for {@link org.libreccm.ui.admin.imexport.ExportTask}s.
|
||||
*
|
||||
*
|
||||
* @param task The task to execute.
|
||||
*
|
||||
* @return The task.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
|
|
@ -58,15 +64,16 @@ public class ImExportTasks {
|
|||
|
||||
/**
|
||||
* Listens for {@link org.libreccm.ui.admin.imexport.ImportTask}s.
|
||||
*
|
||||
*
|
||||
* @param task The task to execute.
|
||||
* @return The task.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void importEntitites(@ObservesAsync final ImportTask task) {
|
||||
final String importName = task.getName();
|
||||
|
||||
importExport.importEntities(importName);
|
||||
shiro.getSystemUser().execute(
|
||||
() -> importExport.importEntities(importName)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ public class ImportExportTaskManager {
|
|||
* @param status The status of the task.
|
||||
*
|
||||
* @return The task.
|
||||
*
|
||||
*
|
||||
* @see CompletionStage#handle(java.util.function.BiFunction)
|
||||
*/
|
||||
private Object handleExportTaskResult(
|
||||
|
|
|
|||
|
|
@ -140,9 +140,9 @@ public class ImportTaskStatus implements Comparable<ImportTaskStatus> {
|
|||
+ " }",
|
||||
super.toString(),
|
||||
name,
|
||||
DateTimeFormatter.ISO_DATE_TIME.withZone(
|
||||
ZoneId.systemDefault()
|
||||
).format(started),
|
||||
DateTimeFormatter.ISO_DATE_TIME
|
||||
.withZone(ZoneId.systemDefault())
|
||||
.format(started),
|
||||
Objects.toString(status)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue