Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab0dda9
UFAL/DOI - Added type of resource to data cite (#975)
Paurikova2 May 28, 2025
db5ae18
UFAL/The process output is not displayed because of S3 direct downloa…
milanmajchrak Jun 5, 2025
550927c
Check if type is html (#983)
Paurikova2 Jun 12, 2025
1136183
Ufal dtq sync062025 (#985)
kosarko Jun 13, 2025
7c920b2
UFAL/Improve file preview generating (#972)
Paurikova2 Jun 13, 2025
59a3ef1
Fix the file preview integration test (#989)
milanmajchrak Jun 16, 2025
ad83d4d
Use the correct checkbox for the input field - use repeatable (#991)
milanmajchrak Jun 16, 2025
466990f
UFAL/EU Sponsor openaire id should not be required (#1001)
milanmajchrak Jul 4, 2025
a19e004
Logging error message while emailing users (#1000)
Kasinhou Jul 7, 2025
558d647
UFAL/Teaching and clariah submissions does not have clarin-license (#…
jr-rk Jul 8, 2025
1418519
UFAL/Fix logging in LogoImportController (#1003)
Paurikova2 Jul 8, 2025
d32eca8
UFAL/Update the resource policy rights when changing submitter (#1002)
Paurikova2 Jul 10, 2025
edb5dbf
UFAL/Added date to title when creating new version (#984)
Paurikova2 Jul 10, 2025
33d330a
UFAL/Item handle info in email after download request (#1006)
Kasinhou Jul 10, 2025
c799313
UFAL/Incorrect password hash funct used during migration (#999)
Paurikova2 Jul 16, 2025
87062fe
[devOps] labelling reviewing process
Jul 18, 2025
8ae0f17
[devOps] labelling reviewing process
Jul 18, 2025
73424f7
UFAL/New version keeps the old identifier
Paurikova2 Jul 23, 2025
dc16917
UFAL/Send email to editor after submitting item (#1016)
Kasinhou Jul 23, 2025
90f7f7f
UFAL/Local file size is 0 for file with no zero size (#1017)
Paurikova2 Jul 24, 2025
0bbdc00
issue 1241: ItemFilesMetadataRepair script implementation (#1243) (#1…
kosarko Jul 24, 2025
8ddf0af
UFAL/Refbox upgrade (#1015)
milanmajchrak Jul 24, 2025
2a39643
UFAL/Added doc - issue link (#1023)
milanmajchrak Jul 24, 2025
f706166
Merge branch 'dtq-dev' into lindat-merge-dtq-dev-2025-07-24
milanmajchrak Jul 24, 2025
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
22 changes: 22 additions & 0 deletions .github/workflows/PM-label-review-process.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Reviewer Label Management

on:
pull_request:
types: [review_requested]
pull_request_review:
types: [submitted]

permissions:
pull-requests: write

jobs:
manage-reviewer-labels:
runs-on: ubuntu-latest
steps:
- name: Apply reviewer labels
uses: mazoea/ga-maz/label-review@master
with:
target-reviewer: 'vidiecan'
assigned-label: 'REVIEW-in-progress'
completed-label: 'REVIEW-done'
github-token: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.itemupdate;

import java.util.Iterator;
import java.util.List;
import java.util.UUID;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.content.Bundle;
import org.dspace.content.Collection;
import org.dspace.content.Item;
import org.dspace.content.MetadataValue;
import org.dspace.content.factory.ClarinServiceFactory;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.ItemService;
import org.dspace.content.service.clarin.ClarinItemService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.factory.EPersonServiceFactory;

/**
* Documentation for this class: https://github.com/ufal/clarin-dspace/pull/1243#issue-3236707035
*/
public class ItemFilesMetadataRepair {

private static final Logger log = LogManager.getLogger(ItemFilesMetadataRepair.class);

private ItemFilesMetadataRepair() {
}

public static void main(String[] args) throws Exception {
log.info("Fixing item files metadata started.");

Options options = new Options();
options.addRequiredOption("e", "email", true, "admin email");
options.addOption("c", "collection", true, "collection UUID");
options.addOption("i", "item", true, "item UUID");
options.addOption("d", "dry-run", false, "dry run - with no repair");
options.addOption("h", "help", false, "help");
options.addOption("v", "verbose", false, "verbose output");

CommandLineParser parser = new DefaultParser();
try {
CommandLine line = parser.parse(options, args);
if (line.hasOption('h') || !line.hasOption('e')) {
printHelpAndExit(options);
}
String adminEmail = line.getOptionValue('e');
String collectionUuid = line.getOptionValue('c');
String itemUuid = line.getOptionValue('i');
boolean verboseOutput = line.hasOption('v');
boolean dryRun = line.hasOption('d');
run(adminEmail, collectionUuid, itemUuid, dryRun, verboseOutput);
} catch (ParseException e) {
System.err.println("Failed to parse command line options: " + e.getMessage());
printHelpAndExit(options);
}

log.info("Fixing item files metadata finished.");
}

private static void run(String adminEmail,
String collectionUuid,
String itemUuid,
boolean dryRun,
boolean verboseOutput) throws Exception {

System.out.println("ItemFilesMetadataRepair Started.\n");

try (Context context = new Context(Context.Mode.READ_WRITE)) {
ItemService itemService = ContentServiceFactory.getInstance().getItemService();
ClarinItemService clarinItemService = ClarinServiceFactory.getInstance().getClarinItemService();

EPerson eperson = EPersonServiceFactory.getInstance().getEPersonService().findByEmail(context, adminEmail);
context.turnOffAuthorisationSystem();
context.setCurrentUser(eperson);
context.restoreAuthSystemState();

String messagePrefix = dryRun ? "Found incorrect files metadata in" : "Updated";
if (itemUuid != null) {
// fixing only one item
Item item = itemService.find(context, UUID.fromString(itemUuid));
if (item == null) {
throw new IllegalArgumentException("Item not found with the provided UUID");
}
boolean updated = updateItem(item, context, clarinItemService, itemService, dryRun, verboseOutput);
if (updated) {
System.out.println(dryRun ? "Files metadata are incorrect." : "Files metadata were updated.");
} else {
System.out.println("Files metadata are correct.");
}
} else if (collectionUuid != null) {
// fixing items in collection
CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
Collection collection = collectionService.find(context, UUID.fromString(collectionUuid));
if (collection == null) {
throw new IllegalArgumentException("Invalid Collection UUID");
}
Iterator<Item> itemIterator = itemService.findAllByCollection(context, collection);
Results results =
updateItems(itemIterator, context, clarinItemService, itemService, dryRun, verboseOutput);
System.out.printf("Checked %d items in Collection: \"%s\".\n",
results.getItemsCount(), collection.getName());
System.out.printf("%s %d items.\n", messagePrefix, results.getUpdatedItemsCount());
} else {
// fixing all items
Iterator<Item> itemIterator = itemService.findAll(context);
Results results =
updateItems(itemIterator, context, clarinItemService, itemService, dryRun, verboseOutput);
System.out.printf("Checked %d items.\n", results.getItemsCount());
System.out.printf("%s %d items.\n", messagePrefix, results.getUpdatedItemsCount());
}
context.complete();
}

System.out.println("\nItemFilesMetadataRepair Finished");
}

private static Results updateItems(Iterator<Item> itemIterator,
Context context,
ClarinItemService clarinItemService,
ItemService itemService,
boolean dryRun,
boolean verboseOutput) throws Exception {
int itemsCount = 0;
int updatedItemsCount = 0;
while (itemIterator.hasNext()) {
itemsCount++;
boolean updated =
updateItem(itemIterator.next(), context, clarinItemService, itemService, dryRun, verboseOutput);
if (updated) {
updatedItemsCount++;
}
}

return new Results(itemsCount, updatedItemsCount);
}

private static boolean updateItem(Item item,
Context context,
ClarinItemService clarinItemService,
ItemService itemService,
boolean dryRun,
boolean verboseOutput) throws Exception {
boolean updated = false;

List<MetadataValue> filesCountValues =
itemService.getMetadata(item, "local", "files", "count", Item.ANY);
List<MetadataValue> filesSizeValues =
itemService.getMetadata(item, "local", "files", "size", Item.ANY);
List<MetadataValue> hasFilesValues =
itemService.getMetadata(item, "local", "has", "files", Item.ANY);

int filesCount = 0;
String filesCountValue = "undefined";
if (!filesCountValues.isEmpty()) {
filesCountValue = filesCountValues.get(0).getValue();
try {
filesCount = Integer.parseInt(filesCountValue);
} catch (NumberFormatException ex) {
// filesCount = 0
}
}
long filesSize = 0;
String filesSizeValue = "undefined";
if (!filesSizeValues.isEmpty()) {
filesSizeValue = filesSizeValues.get(0).getValue();
try {
filesSize = Long.parseLong(filesSizeValue);
} catch (NumberFormatException ex) {
// filesSize = 0
}
}
String hasFiles = hasFilesValues.isEmpty() ? "no" : hasFilesValues.get(0).getValue();

List<Bundle> originalBundles = item.getBundles(Constants.CONTENT_BUNDLE_NAME);
if (!CollectionUtils.isEmpty(originalBundles)) {
Bundle bundle = originalBundles.get(0);
boolean hasBitstreams = !CollectionUtils.isEmpty(bundle.getBitstreams());
if (hasBitstreams && (filesCount == 0 || filesSize == 0 || !"yes".equals(hasFiles))) {
if (verboseOutput) {
String message = "Incorrect metadata: [files.count: %s, files.size: %s, has.files: %s], " +
"in item '%s' with files.";
System.out.printf((message) + "%n", filesCountValue, filesSizeValue, hasFiles, item.getHandle());
}
if (!dryRun) {
clarinItemService.updateItemFilesMetadata(context, item, bundle);
}
updated = true;
} else if (!hasBitstreams && (filesCount > 0 || filesSize > 0 || "yes".equals(hasFiles))) {
if (verboseOutput) {
String message = "Incorrect metadata: [files.count: %s, files.size: %s, has.files: %s], " +
"in item '%s' without files.";
System.out.printf((message) + "%n", filesCountValue, filesSizeValue, hasFiles, item.getHandle());
}
if (!dryRun) {
itemService.clearMetadata(
context, item, "local", "has", "files", Item.ANY);
itemService.clearMetadata(
context, item, "local", "files", "count", Item.ANY);
itemService.clearMetadata(
context, item, "local", "files", "size", Item.ANY);
itemService.addMetadata(
context, item, "local", "has", "files", Item.ANY, "no");
itemService.addMetadata(
context, item, "local", "files", "count", Item.ANY, "0");
itemService.addMetadata(
context, item, "local", "files", "size", Item.ANY, "0");
}
updated = true;
}
}
return updated;
}

private static void printHelpAndExit(Options options) {
// print the help message
HelpFormatter myHelp = new HelpFormatter();
myHelp.printHelp("dsrun org.dspace.app.itemupdate.ItemFilesMetadataRepair \n", options);
System.exit(0);
}

private static class Results {
private final int itemsCount;
private final int updatedItemsCount;

public Results(int itemsCount, int updatedItemsCount) {
this.itemsCount = itemsCount;
this.updatedItemsCount = updatedItemsCount;
}

public int getItemsCount() {
return itemsCount;
}

public int getUpdatedItemsCount() {
return updatedItemsCount;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ public void alertUsersOnTaskActivation(Context c, XmlWorkflowItem wfi, String em
mail.addArgument(argument);
}
for (EPerson anEpa : epa) {
mail.addRecipient(anEpa.getEmail());
String email = anEpa.getEmail();
if (email != null && email.contains(";")) {
email = email.split(";")[0].trim();
}
mail.addRecipient(email);
}

mail.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.dspace.content.service.BundleService;
import org.dspace.content.service.ItemService;
import org.dspace.content.service.clarin.ClarinBitstreamService;
import org.dspace.content.service.clarin.ClarinItemService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -72,6 +73,8 @@ public class ClarinBitstreamImportController {
private Utils utils;
@Autowired
private MostRecentChecksumService checksumService;
@Autowired
protected ClarinItemService clarinItemService;

/**
* Endpoint for import bitstream, whose file already exists in assetstore under internal_id
Expand Down Expand Up @@ -197,6 +200,9 @@ public BitstreamRest importBitstreamForExistingFile(HttpServletRequest request)
throw new AccessDeniedException("You do not have write rights to update the Bundle's item");
}
if (item != null) {
// Update item file metadata after the bitstream size has changed
clarinItemService.updateItemFilesMetadata(context,
item, bundle);
itemService.update(context, item);
}
bundleService.update(context, bundle);
Expand Down
Loading