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

#4933 - Exporting project fails if a curation CAS is missing or document state is wrong #4934

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
20 changes: 19 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,38 @@ on:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
jdk: [17]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}

- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
cache: maven

- name: Set up cache date
run: echo "CACHE_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Cache Maven repository
id: maven-cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.CACHE_DATE }}
restore-keys: |
${{ runner.os }}-maven-

- name: Build with Maven
run: mvn --no-transfer-progress -B clean verify --file pom.xml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,35 +122,50 @@ public void exportData(FullProjectExportRequest aRequest, ProjectExportTaskMonit
try (var session = CasStorageSession.openNested()) {
// If depending on aInProgress, include only the the curation documents that are
// finished or also the ones that are in progress
if (documentService.existsCas(sourceDocument, CURATION_USER)
&& (aRequest.isIncludeInProgress()
&& CURATION_IN_PROGRESS.equals(sourceDocument.getState()))
|| CURATION_FINISHED.equals(sourceDocument.getState())) {
// Copy CAS - this is used when importing the project again
exportSerializedCas(sourceDocument, aStage);

// Determine which format to use for export
if (aRequest.getFormat() != null) {
var formatId = FORMAT_AUTO.equals(aRequest.getFormat())
? sourceDocument.getFormat()
: aRequest.getFormat();

var format = importExportService.getWritableFormatById(formatId)
.orElseGet(() -> {
var fallbackFormat = importExportService.getFallbackFormat();
aMonitor.addMessage(LogMessage.warn(this,
"Curation: %s No writer found for original format [%s] "
+ "- exporting as [%s] instead.",
sourceDocument, formatId, fallbackFormat.getName()));
return fallbackFormat;
});

// Copy secondary export format for convenience - not used during import
exportAdditionalFormat(bulkOperationContext, sourceDocument, aStage,
format);
}
var shouldExport = (aRequest.isIncludeInProgress()
&& CURATION_IN_PROGRESS == sourceDocument.getState())
|| CURATION_FINISHED == sourceDocument.getState();
if (!shouldExport) {
aMonitor.setProgress(
initProgress + (int) ceil(((double) i) / documents.size() * 10.0));
i++;
continue;
}

if (!documentService.existsCas(sourceDocument, CURATION_USER)) {
aMonitor.addMessage(LogMessage.warn(this,
"Curation CAS for document %s could not be found!", sourceDocument));
LOG.warn("Curation CAS for document {} could not be found!", sourceDocument);
aMonitor.setProgress(
initProgress + (int) ceil(((double) i) / documents.size() * 10.0));
i++;
continue;
}

// Copy CAS - this is used when importing the project again
exportSerializedCas(sourceDocument, aStage);

// Determine which format to use for export
if (aRequest.getFormat() != null) {
var formatId = FORMAT_AUTO.equals(aRequest.getFormat())
? sourceDocument.getFormat()
: aRequest.getFormat();

var format = importExportService.getWritableFormatById(formatId)
.orElseGet(() -> {
var fallbackFormat = importExportService.getFallbackFormat();
aMonitor.addMessage(LogMessage.warn(this,
"Curation: %s No writer found for original format [%s] "
+ "- exporting as [%s] instead.",
sourceDocument, formatId, fallbackFormat.getName()));
return fallbackFormat;
});

// Copy secondary export format for convenience - not used during import
exportAdditionalFormat(bulkOperationContext, sourceDocument, aStage, format);
}
}

aMonitor.setProgress(initProgress + (int) ceil(((double) i) / documents.size() * 10.0));
i++;
}
Expand Down
Loading