Compare commits

..

No commits in common. "dbd87215794f50e549dd34d2d34cb8324edcd561" and "8e01595cc112964de84197d6f4f540232c0903b6" have entirely different histories.

3 changed files with 17 additions and 28 deletions

View File

@ -13,6 +13,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- New `FixLowQualityThumbnails` script to detect and remove more low-quality thumbnails - New `FixLowQualityThumbnails` script to detect and remove more low-quality thumbnails
### Fixed
- `FixJpgJpgThumbnails` and `FixLowQualityThumbnails` scripts not commiting changes when operating on a site, community, or collection

View File

@ -59,9 +59,10 @@ public class FixJpgJpgThumbnails {
DSpaceObject parent = handleService.resolveToObject(context, parentHandle); DSpaceObject parent = handleService.resolveToObject(context, parentHandle);
if (parent != null) { if (parent != null) {
switch (parent.getType()) { switch (parent.getType()) {
case Constants.SITE: case Constants.COLLECTION:
process(context, itemService.findAll(context)); process(
context.commit(); context,
itemService.findByCollection(context, (Collection) parent));
break; break;
case Constants.COMMUNITY: case Constants.COMMUNITY:
List<Collection> collections = ((Community) parent).getCollections(); List<Collection> collections = ((Community) parent).getCollections();
@ -70,13 +71,9 @@ public class FixJpgJpgThumbnails {
context, context,
itemService.findAllByCollection(context, collection)); itemService.findAllByCollection(context, collection));
} }
context.commit();
break; break;
case Constants.COLLECTION: case Constants.SITE:
process( process(context, itemService.findAll(context));
context,
itemService.findByCollection(context, (Collection) parent));
context.commit();
break; break;
case Constants.ITEM: case Constants.ITEM:
processItem(context, (Item) parent); processItem(context, (Item) parent);

View File

@ -76,9 +76,10 @@ public class FixLowQualityThumbnails {
DSpaceObject parent = handleService.resolveToObject(context, parentHandle); DSpaceObject parent = handleService.resolveToObject(context, parentHandle);
if (parent != null) { if (parent != null) {
switch (parent.getType()) { switch (parent.getType()) {
case Constants.SITE: case Constants.COLLECTION:
process(context, itemService.findAll(context)); process(
context.commit(); context,
itemService.findByCollection(context, (Collection) parent));
break; break;
case Constants.COMMUNITY: case Constants.COMMUNITY:
List<Collection> collections = ((Community) parent).getCollections(); List<Collection> collections = ((Community) parent).getCollections();
@ -87,13 +88,9 @@ public class FixLowQualityThumbnails {
context, context,
itemService.findAllByCollection(context, collection)); itemService.findAllByCollection(context, collection));
} }
context.commit();
break; break;
case Constants.COLLECTION: case Constants.SITE:
process( process(context, itemService.findAll(context));
context,
itemService.findByCollection(context, (Collection) parent));
context.commit();
break; break;
case Constants.ITEM: case Constants.ITEM:
processItem(context, (Item) parent); processItem(context, (Item) parent);
@ -122,8 +119,6 @@ public class FixLowQualityThumbnails {
private static void processItem(Context context, Item item) private static void processItem(Context context, Item item)
throws SQLException, AuthorizeException, IOException { throws SQLException, AuthorizeException, IOException {
System.out.println("FixLowQualityThumbnails: processing item: " + item.getHandle());
// Set some state for the item before we iterate over the THUMBNAIL bundle // Set some state for the item before we iterate over the THUMBNAIL bundle
boolean itemHasImThumbnail = false; boolean itemHasImThumbnail = false;
@ -164,7 +159,7 @@ public class FixLowQualityThumbnails {
// ption will *always* be "Generated Thumbnail". // ption will *always* be "Generated Thumbnail".
if ("Generated Thumbnail".equals(thumbnailDescription)) { if ("Generated Thumbnail".equals(thumbnailDescription)) {
System.out.print("\u001b[33m"); System.out.print("\u001b[33m");
System.out.println("> Action: remove old thumbnail from THUMBNAIL bundle"); System.out.println("Deleting (" + item.getHandle() + "):");
System.out.println("> Name: »" + thumbnailName + "«"); System.out.println("> Name: »" + thumbnailName + "«");
System.out.println("> Description: »" + thumbnailDescription + "«"); System.out.println("> Description: »" + thumbnailDescription + "«");
System.out.print("\u001b[0m"); System.out.print("\u001b[0m");
@ -178,7 +173,7 @@ public class FixLowQualityThumbnails {
} else if (thumbnailDescription.toLowerCase().contains("thumbnail") } else if (thumbnailDescription.toLowerCase().contains("thumbnail")
&& !"IM Thumbnail".equals(thumbnailDescription)) { && !"IM Thumbnail".equals(thumbnailDescription)) {
System.out.print("\u001b[33m"); System.out.print("\u001b[33m");
System.out.println("> Action: remove manually uploaded thumbnail from THUMBNAIL bundle"); System.out.println("Deleting (" + item.getHandle() + "):");
System.out.println("> Name: »" + thumbnailName + "«"); System.out.println("> Name: »" + thumbnailName + "«");
System.out.println("> Description: »" + thumbnailDescription + "«"); System.out.println("> Description: »" + thumbnailDescription + "«");
System.out.print("\u001b[0m"); System.out.print("\u001b[0m");
@ -190,7 +185,7 @@ public class FixLowQualityThumbnails {
// a thumbnail for a journal or a limited access item. // a thumbnail for a journal or a limited access item.
} else { } else {
System.out.print("\u001b[34m"); System.out.print("\u001b[34m");
System.out.println("> Action: skip other thumbnail in THUMBNAIL bundle"); System.out.println("Skipping (" + item.getHandle() + "):");
System.out.println("> Name: »" + thumbnailName + "«"); System.out.println("> Name: »" + thumbnailName + "«");
System.out.println("> Description: »" + thumbnailDescription + "«"); System.out.println("> Description: »" + thumbnailDescription + "«");
System.out.print("\u001b[0m"); System.out.print("\u001b[0m");
@ -255,7 +250,7 @@ public class FixLowQualityThumbnails {
&& (originalName.toLowerCase().contains("thumbnail") && (originalName.toLowerCase().contains("thumbnail")
|| originalDescription.toLowerCase().contains("thumbnail"))) { || originalDescription.toLowerCase().contains("thumbnail"))) {
System.out.print("\u001b[33m"); System.out.print("\u001b[33m");
System.out.println("> Action: remove thumbnail from ORIGINAL bundle"); System.out.println("Removing (" + item.getHandle() + "):");
System.out.println("> Name: »" + originalName + "«"); System.out.println("> Name: »" + originalName + "«");
System.out.println("> Description: »" + originalDescription + "«"); System.out.println("> Description: »" + originalDescription + "«");
System.out.print("\u001b[0m"); System.out.print("\u001b[0m");
@ -265,7 +260,7 @@ public class FixLowQualityThumbnails {
} else { } else {
System.out.print("\u001b[34m"); System.out.print("\u001b[34m");
System.out.println("> Action: skip other bitstream in ORIGINAL bundle"); System.out.println("Skipping (" + item.getHandle() + "):");
System.out.println("> Name: »" + originalName + "«"); System.out.println("> Name: »" + originalName + "«");
System.out.println("> Description: »" + originalDescription + "«"); System.out.println("> Description: »" + originalDescription + "«");
System.out.print("\u001b[0m"); System.out.print("\u001b[0m");