mirror of
https://github.com/ilri/cgspace-java-helpers.git
synced 2024-11-28 09:38:21 +01:00
Compare commits
4 Commits
8e01595cc1
...
dbd8721579
Author | SHA1 | Date | |
---|---|---|---|
dbd8721579 | |||
a234b39064 | |||
80a336f94d | |||
5ebf4930cf |
@ -13,3 +13,6 @@ 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
|
||||||
|
@ -59,10 +59,9 @@ 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.COLLECTION:
|
case Constants.SITE:
|
||||||
process(
|
process(context, itemService.findAll(context));
|
||||||
context,
|
context.commit();
|
||||||
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();
|
||||||
@ -71,9 +70,13 @@ public class FixJpgJpgThumbnails {
|
|||||||
context,
|
context,
|
||||||
itemService.findAllByCollection(context, collection));
|
itemService.findAllByCollection(context, collection));
|
||||||
}
|
}
|
||||||
|
context.commit();
|
||||||
break;
|
break;
|
||||||
case Constants.SITE:
|
case Constants.COLLECTION:
|
||||||
process(context, itemService.findAll(context));
|
process(
|
||||||
|
context,
|
||||||
|
itemService.findByCollection(context, (Collection) parent));
|
||||||
|
context.commit();
|
||||||
break;
|
break;
|
||||||
case Constants.ITEM:
|
case Constants.ITEM:
|
||||||
processItem(context, (Item) parent);
|
processItem(context, (Item) parent);
|
||||||
|
@ -76,10 +76,9 @@ 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.COLLECTION:
|
case Constants.SITE:
|
||||||
process(
|
process(context, itemService.findAll(context));
|
||||||
context,
|
context.commit();
|
||||||
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();
|
||||||
@ -88,9 +87,13 @@ public class FixLowQualityThumbnails {
|
|||||||
context,
|
context,
|
||||||
itemService.findAllByCollection(context, collection));
|
itemService.findAllByCollection(context, collection));
|
||||||
}
|
}
|
||||||
|
context.commit();
|
||||||
break;
|
break;
|
||||||
case Constants.SITE:
|
case Constants.COLLECTION:
|
||||||
process(context, itemService.findAll(context));
|
process(
|
||||||
|
context,
|
||||||
|
itemService.findByCollection(context, (Collection) parent));
|
||||||
|
context.commit();
|
||||||
break;
|
break;
|
||||||
case Constants.ITEM:
|
case Constants.ITEM:
|
||||||
processItem(context, (Item) parent);
|
processItem(context, (Item) parent);
|
||||||
@ -119,6 +122,8 @@ 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;
|
||||||
|
|
||||||
@ -159,7 +164,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("Deleting (" + item.getHandle() + "):");
|
System.out.println("> Action: remove old thumbnail from THUMBNAIL bundle");
|
||||||
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");
|
||||||
@ -173,7 +178,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("Deleting (" + item.getHandle() + "):");
|
System.out.println("> Action: remove manually uploaded thumbnail from THUMBNAIL bundle");
|
||||||
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");
|
||||||
@ -185,7 +190,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("Skipping (" + item.getHandle() + "):");
|
System.out.println("> Action: skip other thumbnail in THUMBNAIL bundle");
|
||||||
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");
|
||||||
@ -250,7 +255,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("Removing (" + item.getHandle() + "):");
|
System.out.println("> Action: remove thumbnail from ORIGINAL bundle");
|
||||||
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");
|
||||||
@ -260,7 +265,7 @@ public class FixLowQualityThumbnails {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
System.out.print("\u001b[34m");
|
System.out.print("\u001b[34m");
|
||||||
System.out.println("Skipping (" + item.getHandle() + "):");
|
System.out.println("> Action: skip other bitstream in ORIGINAL bundle");
|
||||||
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");
|
||||||
|
Loading…
Reference in New Issue
Block a user