From f209b4b3d22b3a92b431c6f63ada637a64bd399a Mon Sep 17 00:00:00 2001 From: Paurikova2 Date: Wed, 27 Nov 2024 10:52:20 +0100 Subject: [PATCH] removed findHandle duplicity --- .../org/dspace/utils/SpecialItemService.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/dspace-oai/src/main/java/org/dspace/utils/SpecialItemService.java b/dspace-oai/src/main/java/org/dspace/utils/SpecialItemService.java index 1b402de34671..c801ccc156a6 100644 --- a/dspace-oai/src/main/java/org/dspace/utils/SpecialItemService.java +++ b/dspace-oai/src/main/java/org/dspace/utils/SpecialItemService.java @@ -300,7 +300,15 @@ public static String getAvailable(String identifierUri) { } // Retrieve the item using the handle - Item item = findItemByHandle(context, metadataField, identifierUri); + ClarinItemService clarinItemService = ClarinServiceFactory.getInstance().getClarinItemService(); + Item item; + try { + List itemList = clarinItemService.findByHandle(context, metadataField, identifierUri); + item = itemList.isEmpty() ? null : itemList.get(0); + } catch (SQLException e) { + log.error("Error retrieving item by handle.", e); + return null; + } if (Objects.isNull(item)) { log.error(String.format("Item for handle %s doesn't exist!", identifierUri)); return null; @@ -331,25 +339,6 @@ private static MetadataField findMetadataField(Context context, String mtd) { } } - /** - * Finds an item in DSpace using the provided handle and metadata field. - * - * @param context The DSpace context - * @param metadataField The metadata field used for item search - * @param handle The handle (identifier) of the item. - * @return The Item object, or null if no item is found. - */ - private static Item findItemByHandle(Context context, MetadataField metadataField, String handle) { - ClarinItemService clarinItemService = ClarinServiceFactory.getInstance().getClarinItemService(); - try { - List itemList = clarinItemService.findByHandle(context, metadataField, handle); - return (itemList.isEmpty()) ? null : itemList.get(0); - } catch (SQLException e) { - log.error("Error retrieving item by handle.", e); - return null; - } - } - /** * Retrieves the embargo start date for the given item bitstreams. * If an embargo has ended, the end date is returned.