From c9f48f042bd600e07331e641b68be4e1274bf9d5 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 19 Mar 2022 17:40:23 +0100 Subject: [PATCH] Removed depcrecated package com.arsdigita.ui.admin.importexport from ccm-core --- .../ui/admin/importexport/ExportSection.java | 182 --------------- .../importexport/ImportExportController.java | 113 ---------- .../importexport/ImportExportMonitor.java | 155 ------------- .../admin/importexport/ImportExportTab.java | 182 --------------- .../ui/admin/importexport/ImportSection.java | 213 ------------------ 5 files changed, 845 deletions(-) delete mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ExportSection.java delete mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportController.java delete mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportMonitor.java delete mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportTab.java delete mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportSection.java diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ExportSection.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ExportSection.java deleted file mode 100644 index a2552faad..000000000 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ExportSection.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2017 LibreCCM Foundation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ -package com.arsdigita.ui.admin.importexport; - -import com.arsdigita.bebop.BoxPanel; -import com.arsdigita.bebop.Form; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.SaveCancelSection; -import com.arsdigita.bebop.Text; -import com.arsdigita.bebop.event.FormProcessListener; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.Submit; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.ui.admin.AdminUiConstants; - -import org.libreccm.cdi.utils.CdiUtil; - -import java.util.ArrayList; - -/** - * - * @author Jens Pelzetter - */ -public class ExportSection extends BoxPanel { - - public ExportSection() { - super(BoxPanel.VERTICAL); - - add(new ExportForm()); - add(new StatusLabel()); - add(new ReportForm()); - - } - - private class ExportForm extends Form implements FormProcessListener { - - private final SaveCancelSection saveCancelSection; - - public ExportForm() { - super("exportForm"); - - // This placeholder will be replaced with a list of the available - // exporters and checkboxes to select the exporters to use. - add(new Text("export section placeholder")); - - saveCancelSection = new SaveCancelSection(); - saveCancelSection.getSaveButton().setButtonLabel( - new GlobalizedMessage("ui.admin.importexport.export.start", - AdminUiConstants.ADMIN_BUNDLE)); - add(saveCancelSection); - addProcessListener(this); - } - - @Override - public boolean isVisible(final PageState state) { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ImportExportMonitor monitor = cdiUtil - .findBean(ImportExportMonitor.class); - return !monitor.isLocked(); - } - - @Override - public void process(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - if (saveCancelSection.getSaveButton().isSelected(state)) { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ImportExportController controller = cdiUtil - .findBean(ImportExportController.class); - controller.export(new ArrayList<>()); - } - } - - } - - private class StatusLabel extends Label { - - public StatusLabel() { - super(event -> { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ImportExportMonitor monitor = cdiUtil - .findBean(ImportExportMonitor.class); - final Label target = (Label) event.getTarget(); - if (monitor.isExportActive()) { - target.setLabel(new GlobalizedMessage( - "ui.admin.importexport.export.status.export_active", - AdminUiConstants.ADMIN_BUNDLE)); - } else if (monitor.isImportActive()) { - target.setLabel(new GlobalizedMessage( - "ui.admin.importexport.export.status.import_active", - AdminUiConstants.ADMIN_BUNDLE)); - } else { - target.setLabel(new GlobalizedMessage( - "ui.admin.importexport.export.status.locked", - AdminUiConstants.ADMIN_BUNDLE)); - } - }); - } - - @Override - public boolean isVisible(final PageState state) { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ImportExportMonitor monitor = cdiUtil - .findBean(ImportExportMonitor.class); - return monitor.isLocked(); - } - - } - - private class ReportForm extends Form { - - public ReportForm() { - - super("exportReportForm", new BoxPanel(BoxPanel.VERTICAL)); - - final Label title = new Label(event -> { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ImportExportMonitor monitor = cdiUtil - .findBean(ImportExportMonitor.class); - - final Label target = (Label) event.getTarget(); - - if (monitor.isExportActive()) { - target.setLabel(new GlobalizedMessage( - "ui.admin.importexport.export.current_status", - AdminUiConstants.ADMIN_BUNDLE)); - } else if (monitor.isExportReportAvailable()) { - target.setLabel(new GlobalizedMessage( - "ui.admin.importexport.export.report", - AdminUiConstants.ADMIN_BUNDLE)); - } - }); - add(title); - - final Text text = new Text(event -> { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ImportExportMonitor monitor = cdiUtil - .findBean(ImportExportMonitor.class); - final Text target = (Text) event.getTarget(); - target.setText(monitor.getReport().toString()); - }); - text.setClassAttr("preformatted-text"); - add(text); - - add(new Submit(new GlobalizedMessage( - "ui.admin.importexport.report.update", - AdminUiConstants.ADMIN_BUNDLE))); - } - - @Override - public boolean isVisible(final PageState state) { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ImportExportMonitor monitor = cdiUtil - .findBean(ImportExportMonitor.class); - - return monitor.isExportActive() - || monitor.isExportReportAvailable(); - } - - } - - -} diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportController.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportController.java deleted file mode 100644 index 4d3da4329..000000000 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportController.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2017 LibreCCM Foundation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ -package com.arsdigita.ui.admin.importexport; - -import com.arsdigita.kernel.KernelConfig; - -import org.libreccm.configuration.ConfigurationManager; -import org.libreccm.core.UnexpectedErrorException; -import org.libreccm.files.CcmFiles; -import org.libreccm.files.FileAccessException; -import org.libreccm.files.FileDoesNotExistException; -import org.libreccm.files.InsufficientPermissionsException; - -import java.util.Date; -import java.util.List; - -import javax.ejb.Asynchronous; -import javax.ejb.Stateless; -import javax.inject.Inject; - -/** - * - * @author Jens Pelzetter - */ -@Stateless -public class ImportExportController { - - @Inject - private ConfigurationManager confManager; - - @Inject - private ImportExportMonitor monitor; - - @Inject - private CcmFiles ccmFiles; - - /** - * Return the fully qualified class names for all available exporters. - * - * @return - */ - public List getAvailableExporters() { - // Note: Return value may needs to be adjusted. Possibly we need a - // data structure which contains some more information like a - // localised label for the exporters etc. - throw new UnsupportedOperationException("Not implemented yet."); - } - - /** - * Create an export into the directory configured by - * {@link KernelConfig#exportPath} using the provided exporters. - * - * @param exporters The exporters to use. - */ - @Asynchronous - public void export(final List exporters) { - monitor.startExport(); - - final long start = System.currentTimeMillis(); - - while (System.currentTimeMillis() < start + 60 * 1000) { - try { - Thread.sleep(3 * 1000); - } catch (InterruptedException ex) { - throw new UnexpectedErrorException(ex); - } - monitor.getReport().append(String.format("...%tF % getAvailableImportFiles() { - - final KernelConfig kernelConfig = confManager - .findConfiguration(KernelConfig.class); - final String importPath = kernelConfig.getImportPath(); - - try { - return ccmFiles.listFiles(importPath); - } catch (FileAccessException - | FileDoesNotExistException - | InsufficientPermissionsException ex) { - throw new UnexpectedErrorException(ex); - } - } - - public void importFiles(final List filesToImport) { - monitor.startImport(); - - // ToDol Import code here - - monitor.finishImport(); - } - -} diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportMonitor.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportMonitor.java deleted file mode 100644 index cb2253498..000000000 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/importexport/ImportExportMonitor.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2017 LibreCCM Foundation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ -package com.arsdigita.ui.admin.importexport; - -import java.util.Date; -import java.util.UUID; - -import javax.enterprise.context.ApplicationScoped; - -/** - * - * - * @author Jens Pelzetter - */ -@ApplicationScoped -public class ImportExportMonitor { - - /** - * Indicates that an export process is running. - */ - private boolean exportActive = false; - - /** - * Indicates that an import process is running. - */ - private boolean importActive = false; - - private boolean exportReportAvailable = false; - - private boolean importReportAvailable = false; - - /** - * A UUID to identify to the import/export process. - */ - private String importExportProcessUuid; - - /** - * A {@link StringBuffer} for creating a report of the import/export - * process. The report of the last import/export process will be stored - * until another import/export process is started or the application is - * restarted. - */ - private StringBuffer report; - - public boolean isExportActive() { - return exportActive; - } - - public boolean isImportActive() { - return importActive; - } - - /** - * Returns {@code true} if either an import process or an export process is - * active. - * - * @return {@code true} if an import or export process is active. - */ - public boolean isLocked() { - return exportActive || importActive; - } - - public boolean isExportReportAvailable() { - return exportReportAvailable; - } - - public boolean isImportReportAvailable() { - return importReportAvailable; - } - - public void startExport() { - if (exportActive) { - throw new IllegalStateException( - "Can't start a new export process " - + "because there is already an export process running"); - } - - if (importActive) { - throw new IllegalStateException( - "Can't start a export process " - + "because there is already an import process running"); - } - - exportActive = true; - importExportProcessUuid = UUID.randomUUID().toString(); - report = new StringBuffer(); - report.append(String - .format("Lock for export process %s accquired at %tF %Jens Pelzetter - */ -public class ImportExportTab extends LayoutPanel { - - private List sections; - private final java.util.List components = new ArrayList<>(); - private final java.util.List