Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4066 - Display document name on export failure #4067

Merged
merged 1 commit into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ File exportAnnotationDocument(SourceDocument document, String user, FormatSuppor
File exportAnnotationDocument(SourceDocument document, String user, FormatSupport aFormat,
String fileName, Mode mode, boolean stripExtension,
Map<Pair<Project, String>, Object> aBulkOperationContext)
throws UIMAException, IOException, ClassNotFoundException;
throws UIMAException, IOException;

File exportAnnotationDocument(SourceDocument aDocument, String aUser, FormatSupport aFormat,
Mode aMode, boolean aStripExtension,
Map<Pair<Project, String>, Object> aBulkOperationContext)
throws UIMAException, IOException, ClassNotFoundException;
throws UIMAException, IOException;

/**
* @return a type system with all the types that should be present in an exported CAS. This
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package de.tudarmstadt.ukp.clarin.webanno.api.export;

import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.zip.ZipEntry;
Expand All @@ -40,7 +41,7 @@ default List<Class<? extends ProjectExporter>> getExportDependencies()

void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception;
throws ProjectExportException, IOException, InterruptedException;

void importData(ProjectImportRequest aRequest, Project aProject, ExportedProject aExProject,
ZipFile aZip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package de.tudarmstadt.ukp.clarin.webanno.constraints.export;

import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -52,7 +53,7 @@ public class ConstraintsExporter
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
throws IOException
{
File constraintsDir = new File(aStage + CONSTRAINTS);
FileUtils.forceMkdir(constraintsDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.uima.UIMAException;
import org.slf4j.Logger;
Expand Down Expand Up @@ -102,11 +103,13 @@ public List<Class<? extends ProjectExporter>> getImportDependencies()
*
* @param aStage
* The folder where curated documents are copied to be exported as Zip File
* @throws IOException
* @throws ProjectExportException
*/
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
throws IOException, ProjectExportException
{
Project project = aRequest.getProject();

Expand Down Expand Up @@ -166,7 +169,7 @@ public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonit

private void exportAdditionalFormat(Map<Pair<Project, String>, Object> bulkOperationContext,
SourceDocument srcDoc, File curationDir, FormatSupport format)
throws ProjectExportException, IOException, ClassNotFoundException, UIMAException
throws ProjectExportException, IOException
{
File curationFile = null;
try {
Expand All @@ -175,6 +178,11 @@ private void exportAdditionalFormat(Map<Pair<Project, String>, Object> bulkOpera
var filename = CURATION_USER + "." + getExtension(curationFile.getName());
FileUtils.copyFile(curationFile, new File(curationDir, filename));
}
catch (UIMAException | IOException e) {
throw new ProjectExportException("Error exporting annotations of " + srcDoc.getName()
+ " for user [" + CURATION_USER + "] as [" + format.getName() + "]: "
+ ExceptionUtils.getRootCauseMessage(e), e);
}
finally {
if (curationFile != null) {
forceDelete(curationFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public CurationWorkflowExporter(CurationService aCurationService)
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
{
Project project = aRequest.getProject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public FormatSupport getFallbackFormat()
@Transactional
public File exportAnnotationDocument(SourceDocument aDocument, String aUser,
FormatSupport aFormat, Mode aMode)
throws UIMAException, IOException, ClassNotFoundException
throws UIMAException, IOException
{
return exportAnnotationDocument(aDocument, aUser, aFormat, aDocument.getName(), aMode, true,
null);
Expand All @@ -220,7 +220,7 @@ public File exportAnnotationDocument(SourceDocument aDocument, String aUser,
@Transactional
public File exportAnnotationDocument(SourceDocument aDocument, String aUser,
FormatSupport aFormat, String aFileName, Mode aMode)
throws UIMAException, IOException, ClassNotFoundException
throws UIMAException, IOException
{
return exportAnnotationDocument(aDocument, aUser, aFormat, aFileName, aMode, true, null);
}
Expand All @@ -230,7 +230,7 @@ public File exportAnnotationDocument(SourceDocument aDocument, String aUser,
public File exportAnnotationDocument(SourceDocument aDocument, String aUser,
FormatSupport aFormat, Mode aMode, boolean aStripExtension,
Map<Pair<Project, String>, Object> aBulkOperationContext)
throws UIMAException, IOException, ClassNotFoundException
throws IOException, UIMAException
{
return exportAnnotationDocument(aDocument, aUser, aFormat, aDocument.getName(), aMode,
aStripExtension, aBulkOperationContext);
Expand All @@ -241,7 +241,7 @@ public File exportAnnotationDocument(SourceDocument aDocument, String aUser,
public File exportAnnotationDocument(SourceDocument aDocument, String aUser,
FormatSupport aFormat, String aFileName, Mode aMode, boolean aStripExtension,
Map<Pair<Project, String>, Object> aBulkOperationContext)
throws UIMAException, IOException, ClassNotFoundException
throws IOException, UIMAException
{
try (var logCtx = withProjectLogger(aDocument.getProject())) {
Map<Pair<Project, String>, Object> bulkOperationContext = aBulkOperationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public ProjectSettingsExporter(ProjectService aProjectService)
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
{
Project project = aRequest.getProject();
aExProject.setDescription(project.getDescription());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ public GuidelinesExporter(GuidelinesService aGuidelinesService)

/**
* Copy Project guidelines from the file system of this project to the export folder
*
* @throws IOException
*/
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
throws IOException
{
File guidelineDir = new File(aStage + GUIDELINES_FOLDER);
FileUtils.forceMkdir(guidelineDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static java.util.Arrays.asList;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
Expand Down Expand Up @@ -83,7 +84,7 @@ public List<Class<? extends ProjectExporter>> getImportDependencies()
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
throws IOException
{
Project project = aRequest.getProject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static java.util.Arrays.asList;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
Expand Down Expand Up @@ -84,7 +85,7 @@ public List<Class<? extends ProjectExporter>> getImportDependencies()
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
throws IOException
{
Project project = aRequest.getProject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public List<Class<? extends ProjectExporter>> getImportDependencies()
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aFile)
throws Exception
throws InterruptedException, IOException
{
Project project = aRequest.getProject();
List<ExportedKnowledgeBase> exportedKnowledgeBases = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public List<Class<? extends ProjectExporter>> getImportDependencies()
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aFile)
throws Exception
throws IOException
{
Project project = aRequest.getProject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ private ExportedProject exportProjectToPath(FullProjectExportRequest aRequest,
}
}
}
catch (ProjectExportException e) {
throw e;
}
catch (InterruptedException | IOException e) {
// IOExceptions like java.nio.channels.ClosedByInterruptException should be thrown up
// as-is. This allows us to handle export cancellation in the project export UI panel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.springframework.messaging.simp.SimpMessagingTemplate;

import de.tudarmstadt.ukp.clarin.webanno.api.config.RepositoryProperties;
import de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExportException;
import de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExportRequest_ImplBase;
import de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExportTaskHandle;
import de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExportTaskMonitor;
Expand Down Expand Up @@ -108,10 +109,21 @@ public void run()
catch (ClosedByInterruptException | InterruptedException e) {
monitor.setStateAndProgress(CANCELLED, 100);
}
catch (ProjectExportException e) {
// This marks the progression as complete and causes ProgressBar#onFinished
// to be called where we display the messages
// Message needs to be added before setting the state, otherwise the notification for
// the
// message may be throttled and it may never be displayed
monitor.addMessage(LogMessage.error(this, "Project export failed: %s", e.getMessage()));
monitor.setStateAndProgress(FAILED, 100);
log.error("Error during project export", e);
}
catch (Throwable e) {
// This marks the progression as complete and causes ProgressBar#onFinished
// to be called where we display the messages
// Message needs to be aded before setting the state, otherwise the notification for the
// Message needs to be added before setting the state, otherwise the notification for
// the
// message may be throttled and it may never be displayed
monitor.addMessage(LogMessage.error(this, "Unexpected error during project export: %s",
getRootCauseMessage(e)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public ProjectPermissionsExporter(ProjectService aProjectService, UserDao aUserS
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
{
Project project = aRequest.getProject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.uima.UIMAException;
Expand All @@ -71,6 +72,7 @@
import de.tudarmstadt.ukp.clarin.webanno.api.DocumentService;
import de.tudarmstadt.ukp.clarin.webanno.api.config.RepositoryProperties;
import de.tudarmstadt.ukp.clarin.webanno.api.export.FullProjectExportRequest;
import de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExportException;
import de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExportTaskMonitor;
import de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectExporter;
import de.tudarmstadt.ukp.clarin.webanno.api.export.ProjectImportRequest;
Expand Down Expand Up @@ -134,7 +136,7 @@ public List<Class<? extends ProjectExporter>> getImportDependencies()
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws UIMAException, ClassNotFoundException, IOException, InterruptedException
throws IOException, InterruptedException, ProjectExportException
{
exportAnnotationDocuments(aMonitor, aRequest.getProject(), aExProject);
exportAnnotationDocumentContents(aRequest, aMonitor, aExProject, aStage);
Expand Down Expand Up @@ -165,7 +167,7 @@ private void exportAnnotationDocuments(ProjectExportTaskMonitor aMonitor, Projec

private void exportAnnotationDocumentContents(FullProjectExportRequest aRequest,
ProjectExportTaskMonitor aMonitor, ExportedProject aExProject, File aStage)
throws UIMAException, ClassNotFoundException, IOException, InterruptedException
throws IOException, InterruptedException, ProjectExportException
{
Project project = aRequest.getProject();

Expand Down Expand Up @@ -292,7 +294,7 @@ private void exportSerializedCas(File aStage, SourceDocument srcDoc, AnnotationD
private void exportAdditionalFormat(File aStage,
Map<Pair<Project, String>, Object> bulkOperationContext, SourceDocument srcDoc,
FormatSupport format, String aUsername)
throws UIMAException, IOException, ClassNotFoundException
throws IOException, ProjectExportException
{
File annDocDir = new File(
aStage.getAbsolutePath() + ANNOTATION_ORIGINAL_FOLDER + srcDoc.getName());
Expand All @@ -312,6 +314,11 @@ private void exportAdditionalFormat(File aStage,
copyFileToDirectory(annFile, annDocDir);
}
}
catch (UIMAException e) {
throw new ProjectExportException("Error exporting annotations of " + srcDoc.getName()
+ " for user [" + aUsername + "] as [" + format.getName() + "]: "
+ ExceptionUtils.getRootCauseMessage(e), e);
}
finally {
if (annFile != null) {
forceDelete(annFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public List<Class<? extends ProjectExporter>> getImportDependencies()
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
{
List<ExportedAnnotationLayer> exLayers = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public TagSetExporter(AnnotationSchemaService aAnnotationService)
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
{
List<ExportedTagSet> extTagSets = new ArrayList<>();
for (TagSet tagSet : annotationService.listTagSets(aRequest.getProject())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public ProjectInviteExporter(InviteService aInviteService)
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aStage)
throws Exception
{
Project project = aRequest.getProject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public WorkloadManagerExporter(WorkloadManagementService aWorkloadManagementServ
@Override
public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonitor aMonitor,
ExportedProject aExProject, File aFile)
throws Exception
{
Project project = aRequest.getProject();
WorkloadManager workloadManager = workloadManagementService
Expand Down