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