Skip to content

Commit

Permalink
Customer UK - new release 3/June/2024 (#673)
Browse files Browse the repository at this point in the history
* ufal/downloading-restricted-bitstreams-not-working-properly (#457)

* The admin could download restricted bitstreams.

* The user cannot download bitstream if he/she is not signed in.

* Cannot obtain context with user.

* The user is already fetched from the context.

* Added docs.

* Do not use endpoint for downloading the single file because it already exists - remove it.

* Fixed AuthorizationRestControllerIT tests.

* ufal/be-cannot-download-and-preview-files-after-migration (#454)

* Find bitstream format using mimetype not ID.

* Updated tests according to fix.

* ufal/update-canonical-prefix-to-hdl (#460)

* Updated `handle.canonical.prefix` to hdl handle.

* Integration test cannot have changed handle.canonical.prefix.

* ufal/be-user-registration-missing (#463)

* The user registration is added when the eperson is created by the ui.

* try using newer checkout, same as upstream, since error is with git

---------

Co-authored-by: MajoBerger <[email protected]>

* ufal/be-license-download-statistics (#462)

* Add logging of downloading restricted bitstreams.

* Log downloading of every bitstream not only restricted ones.

* Added docs

* Refactored logging.

* ufal/be-shibboleth-headers-encoding (#464)

* givenname and last name values are converted to UTF-8 encoding

* Delete eperson in tests

* using our dspace-dependencies

because of #466

* ufal/be-fix-email-parameters

Fixed emails sending - added arguments and cfg properties that are sent in the email. (#470)

* ufal/be-provenance-subbmitter-missing (#469)

* DSpace#8585 Add submitter information to provenance metadata

* Cherry picked fix from vanilla and added test to check if the Item provenance metadata is added

---------

Co-authored-by: Adán Román Ruiz <[email protected]>

* ufal/be-get-user-ip-address (#468)

* Created endpoint for fetching IP address with tests.

* Made the code more understable

* ufal/publisher-ok-fix (#473)

* fixes ufal#1096 (#471)

* Added publisher filter in the integration test check

---------

Co-authored-by: Ondřej Košarko <[email protected]>

* ufal/zip-preview-configurable (#475)

* Made previewing of the file configurable.

* The default value of the previewing the file must be true in the integration tests.

* ufal/fe-oversized-file-upload-message

Exposed max file limit for upload from the cfg. (#477)

* ufal/be-email-restricted-download

* Fixed comments in the clarin emails (#484)

* ufal/be-not-show-shib-welcome-page (#485)

* Added cfg property to enable/disable showing of the page with attributes passed from the idp.

* ufal/be-s3-customization (#481)

* The bitstream data are stored in to local store after uploading to S3

* The bitstream is removed from the S3 and local assetstore

* Store number is specific if all storages are synchronized.

* Return store number in the BitstreamRest object

* Find out which store is used - it could be synchronized stores number.

* Constant is moved to the Bitstream class

* Synchronization of storages is not allowed by default - set up it in the test environment.

* Added docs

* Removed constant from the Bitstream class - it wasn't consistent

* Overriden BitstreamStorageServiceImpl by custom SyncBitstreamStorageServiceImpl

* Removed ClarinS3BitStoreService.java to SyncS3BitStoreService

* Added doc and refactoring.

* ufal/be-s3-checker-sync (#486)

* Fixed UserCheck - There was created a wrong select

* Fixed ChecksumCheck - the session was closed but there were some requests do the database then

* internal/load-version-from-file (#488)

* Load version from the specific file and show content in the root endpoint.

* Fixed checkstyle issue

* DO not log anything if the VERSION file does not exist. Added VERSION file path into cfg property.

* Append every line into final String.

* ufal/be-s3-checksum-fix (#487)

* Cherry picked fix S3 optimalization fixes from Vanilla

* Cherry picked adding of pagination on cleanup

* Updated Sync services according to S3 optimization fix

* The checksum value is compared between S3 and local assetstore and the new result is inserted to the database.

* Added docs and refactoring

* The checksum values are exposed by REST API

* Fixed failing tests

---------

Co-authored-by: Tim Donohue <[email protected]>
Co-authored-by: Luca Giamminonni <[email protected]>

* internal/versioning (#491)

* add version to docker

* Allow shell because it is using double quotes in the command string.

* removed cat and ls commands

---------

Co-authored-by: MajoBerger <[email protected]>

* ufal/comment-ever-failing-test

* Commented still failing tests (#490)

* internal/verion-update-path (#492)

* Updated `build.version.file.path` because the server cannot find `VERSION_D.txt` file

* Added VERSION_D.txt info `.gitignore`

* User ${dspace.dir} instead of absolute path

* internal/be-upgrade-clarin-dspace-7.6 (#497)

* Split docker image builds into separate jobs to allow them to run in parallel.

* Ensure 'main' code is tagged as 'latest' in DockerHub

* Fixes DSpace#8558 - set Solr UTC timezone

Set the timezone of the Solr date formatter to UTC

* remove obsolete code fragments

* Add action to automatically create a port PR when specified

(cherry picked from commit f6a898c)

* Run PR Port action as 'dspace-bot' to allow new PRs to trigger CI checks

* Minor update to label_merge_conflicts to ignore any errors (seem random at this time)

* Fix typo. Config must be a valid regex

(cherry picked from commit 7995289)

* Bump h2 from 2.1.214 to 2.2.220

Bumps [h2](https://github.com/h2database/h2database) from 2.1.214 to 2.2.220.
- [Release notes](https://github.com/h2database/h2database/releases)
- [Commits](h2database/h2database@version-2.1.214...version-2.2.220)

---
updated-dependencies:
- dependency-name: com.h2database:h2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update FullTextContentStreams.java

Fix NPE if bitstream is null

* Update FullTextContentStreams.java

Add additional NPE checks

* Update ItemUtils.java

Prevent npe if bitstream is null

* dspace.cfg: remove old webui.itemlist properties

These properties are no longer used in DSpace 7:

    webui.itemlist.widths
    webui.itemlist.*.widths
    webui.itemlist.tablewidth

(cherry picked from commit 16c46c4)

* dspace.cfg: remove old webui.browse.thumbnail.show property

The webui.browse.thumbnail.show property is no longer used as of
DSpace 7. Also remove subsequent references to adding thumbnails
to item view columns since these are from legacy DSpace.

(cherry picked from commit 213a546)

* dspace.cfg: remove old webui.itemlist.browse.* property

The webui.itemlist.browse.* properties are no longer used in DSpace
7.

(cherry picked from commit 35f72bc)

* Fix DSpace#8963: Remove deletion constraint from Groomer

* Enable entity type to submission form mapping by default

(cherry picked from commit b71eee8)

* [DURACOM-179] replaced 'null' value with exception actual value in sendErrorResponse method calls having 'null'

(cherry picked from commit aa35a47)

* DS-8935. webui.browse.link CrossLinks - Fix for multiple exact matches

Fixes DSpace#8935 when multiple exact match "webui.browse.link" configuration
entries are present that point to different indexes.

Modified the code to return the index associated with the given
metadata (which is used as the key in the hash map), instead of the key
from the keySet (which may not actually be the metadata value being
searched for).

DSpace#8935
(cherry picked from commit b846c53)

* DSpace#9006 fix referenced configuration file

(cherry picked from commit 29a88d7)

* DSpace#9006 fix referenced configuration file (Test)

(cherry picked from commit 309b0b3)

* Fix DSpace#8933: Only add the base statistic core if it hasn't already been added

* Remove duplicate code

* On failure log the name of the assetstore file and trace causes of exception.

(cherry picked from commit 22974e9)

* Report Throwable's type too.

(cherry picked from commit d6b612f)

* More description on OutOfMemoryError too.

(cherry picked from commit bbe5df3)

* Remove useless log.info

(cherry picked from commit 1f3ad99)

* 103837: Refactor GA config to list bundles

* README.md: Fix typo

(cherry picked from commit ca8abdd)

* Bump up versions of buildnumber-maven-plugin & build-helper-maven-plugin. add configuration for SCM failure

(cherry picked from commit 78ea9e8)

* 3331 - remove the --optimize feature of 'dspace stats-util'

(cherry picked from commit 08c6509)

* fix MissingOptionException on help

(cherry picked from commit 8ae5ffb)

* fix stylecheck

(cherry picked from commit b1377ca)

* ingore unrecognized arguments on help

(cherry picked from commit 82c9b6f)

* add DSpaceSkipUnknownArgumentsParser as parser to ignore/skip unknown arguments in cli by help, fix not necessary ParseException in help

(cherry picked from commit 86285d7)

* remove not necessary else

(cherry picked from commit 064e2ca)

* Enable new skip merge commit feature

* dspace-api: remove unnecessary trailing whitespace

* 103818 ItemServiceImpl#inheritCollectionDefaultPolicies now clears item READ policies if new parent collection has a default READ policy

* 103818 Add boolean parameter to ItemServiceImpl#inheritCollectionDefaultPolicies to decide whether to override item read policies

* 103818 Add boolean parameters to ItemServiceImpl methodds to decide whether to override read policies

* 103818 Extend ItemServiceTest#testMoveItemToCollectionWithMoreRestrictiveReadPolicy

* 104878 Fix error in ItemServiceTest related to inheriting collection policies upon item move

* 104878 Adjust ItemServiceTest to expect correct behavior of bundles when item is migrated

* Fix failing IT in BulkAccessControlIT

* 103837: Fix isContentBitstream() in GoogleAsyncEventListener

* Rename test suites that are really integration testing.

(cherry picked from commit f66ca33)

* Bump org.eclipse.jetty:jetty-xml

Bumps [org.eclipse.jetty:jetty-xml](https://github.com/eclipse/jetty.project) from 9.4.51.v20230217 to 9.4.52.v20230823.
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](jetty/jetty.project@jetty-9.4.51.v20230217...jetty-9.4.52.v20230823)

---
updated-dependencies:
- dependency-name: org.eclipse.jetty:jetty-xml
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
(cherry picked from commit 2bcc0b3)

* Add note that rebooting Tomcat required

* Add websvc.opensearch.autolink and websvc.opensearch.shortname to exposed REST configuration properties

(cherry picked from commit 80b35c9)

* Add a "container friendly" log4j2 cfg and output compose dspace log to console

(cherry picked from commit 9eefd56)

* Fix ClassCastException (Collection cannot be cast to Item) in Handle identifier classes

(cherry picked from commit 1271374)

* Fix checkstyle. Correct grammar of comment while doing so.

(cherry picked from commit ffa2683)

* Avoid double slashes in sitemap paths.

(cherry picked from commit eae4463)

* Remove 'cross join' from count query. Updates "countHandlesByPrefix" to use a query similar to existing "findByPrefix"

(cherry picked from commit 14223bd)

* fix logical bug when checking if field is controlled authority

* remove optimize option from oai import

* added authorization check for license bitstream in OAI import

* OAI: add support to extract embargo from bitstreams and expose it in OAI metadata

(cherry picked from commit db81d75)

* ItemUtils.java: added method doc

(cherry picked from commit 51e60fb)

* ItemUtils.java: improved method to account for multiple embargo policies and select the longest embargo

(cherry picked from commit 538be7f)

* Refactored access-status to include embargo date based on the DefaultAccessStatusHelper logic (look at primary or first bitstream)

(cherry picked from commit 895926f)

* Remove unused imports

(cherry picked from commit 4bd2cfd)

* Fix style issues

(cherry picked from commit 724a4ff)

* Fix style issues

(cherry picked from commit 6e2c8a4)

* Add null check

(cherry picked from commit 0de4c39)

* ItemUtils.java: refactored addEmbargoField

(cherry picked from commit 291afa7)

* uketd_dc.xsl: also expose access-status if embargo or restricted

(cherry picked from commit 4b40872)

* DefaultAccessStatusHelper: fix logic to take shortest embargo

(cherry picked from commit d17ef09)

* Remove currently unused customisation of ItemUtils

(cherry picked from commit 490a982)

* DefaultAccessStatusHelper: getEmbargoFromItem return null embargo if status than embargo

(cherry picked from commit e05e73a)

* Additional Item class cast fixes in handle providers

DSOs were not properly checked if they were instanceof Item before
attempting the cast in HandleIdentifierProvider and
VersionedHandleIdentifierProviderWithCanonicalHandles

* Remove Oracle script that accidentally made it in via DSpace#8800

(cherry picked from commit 5e04edf)

* 8968 - request-a-copy email: non ASCII characters are encoded as HTML character entity references

(cherry picked from commit db36d5e)

* unused import

(cherry picked from commit bf6e042)

* 8968 - added custom StringEscapper

(cherry picked from commit 103c8ee)

* checkstyle

(cherry picked from commit 2c2b3b1)

* 8968 - implementated using HtmlUtils scaping

(cherry picked from commit 090beed)

* checkstiye

(cherry picked from commit d12fbe2)

* Define _version_

* DSpace#8585 Add submitter information to provenance metadata

(cherry picked from commit c15ac0e)

* 8585 - added provenance to metadata-import and itemImport

(cherry picked from commit ea6307d)

* dspace-api: fix misaligned comment

(cherry picked from commit 4fba787)

* oai_openaire.xsl : change resourceTypeGeneral for thesis

Thesis are "Literature" resource type (resourceTypeGeneral), not "other research product"

ref:
openaire/guidelines-literature-repositories#43 (comment)
and
https://api.openaire.eu/vocabularies/dnet:result_typologies/publication

(cherry picked from commit 669ff34)

* Bump org.eclipse.jetty:jetty-http

Bumps [org.eclipse.jetty:jetty-http](https://github.com/eclipse/jetty.project) from 9.4.52.v20230823 to 9.4.53.v20231009.
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](jetty/jetty.project@jetty-9.4.52.v20230823...jetty-9.4.53.v20231009)

---
updated-dependencies:
- dependency-name: org.eclipse.jetty:jetty-http
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump org.json:json from 20230227 to 20231013 in /dspace-api

Bumps [org.json:json](https://github.com/douglascrockford/JSON-java) from 20230227 to 20231013.
- [Release notes](https://github.com/douglascrockford/JSON-java/releases)
- [Changelog](https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md)
- [Commits](https://github.com/douglascrockford/JSON-java/commits)

---
updated-dependencies:
- dependency-name: org.json:json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
(cherry picked from commit 11a08f1)

* Reading localized license file.

* Reading localized license file.

* Applying commit 6108c98

* quote Pattern for thumbnail resolution constructed from bitstream filename

(cherry picked from commit a124807)

* check null value of bitstream name before quoting name for regex

(cherry picked from commit a9bcc0c)

* extract bitstream thumbnail name pattern into own function

(cherry picked from commit c5466c2)

* Make workflow curation tasks actually work.

When curation runs, there was no "current user" and no claimed task,
so the code broke when trying to find people to notify about curation
failures.

(cherry picked from commit a76af35)

* Community request:  fake EPerson from configuration.

(cherry picked from commit bb9e88d)

* Correct some documentation.

(cherry picked from commit be22790)

* Handle missing role.

(cherry picked from commit 2e62fa3)

* Fix "Site cannot be indexed" error by ignoring ADD/REMOVE events on Site object

(cherry picked from commit ef7f02f)

* Add a null check when assigning ldap groups

Prevent NullReferenceException by checking if the group list is null

Fixes DSpace#8920

(cherry picked from commit bb6498e)

* 9043 use Templates for compiled XSLT instead of Transformer - use Templates are thread-safe and NOT Transformer

(cherry picked from commit 1160341)

* Update to newly released XOAI 3.4.0

(cherry picked from commit 160ebbd)

* add test and fix

(cherry picked from commit 48b0b71)

* unset primary bitstream on bitstream service

(cherry picked from commit 47ca74b)

* adding sql expression to fix deleted primary bitstreams from bundle

(cherry picked from commit 8a531ad)

* add bundle remove authorization

(cherry picked from commit 3255e07)

* adding missing bundle REMOVE authorization

(cherry picked from commit 4a05600)

* add missing head style check

(cherry picked from commit caba4bb)

* fix style errors

(cherry picked from commit 74605f1)

* new testDeleteBitstreamAndUnsetPrimaryBitstreamID test for primary bitstream verification

(cherry picked from commit e6d108a)

* new testDeleteBitstreamAndUnsetPrimaryBitstreamID test for primary bitstream verification

(cherry picked from commit ad0d22a)

* new testDeleteBitstreamAndUnsetPrimaryBitstreamID remove unnecessary stubs

(cherry picked from commit a3e506c)

* make comments more clear to understand

(cherry picked from commit c0bbd9d)

* typo

(cherry picked from commit 74cce86)

* Add basic pagination to /groups/[uuid]/epersons endpoint

(cherry picked from commit 74c7235)

* Bug fix. Only use pageSize and offset if >0

(cherry picked from commit 15de2d0)

* Add missing pagination test for /groups/[uuid]/epersons

(cherry picked from commit 457dd9a)

* Add pagination to /groups/[uuid]/subgroups endpoint, along with tests

(cherry picked from commit e7c4b9e)

* Add basic unit test for new EpersonService methods

(cherry picked from commit c000e54)

* Minor unit test fix. Use isEqualCollection to compare list with Hibernate results

(cherry picked from commit cdb68a6)

* Add countAllMembers() with tests. Update tests to use try/catch

(cherry picked from commit 58a15b7)

* Replace several usages of allMembers() with count methods to avoid performance issues

(cherry picked from commit 2c9165a)

* Fix bug in logic for determining whether a workflow group will be left empty. Need to check *both* EPerson and subgroup counts.

(cherry picked from commit 9832259)

* Use join instead of subquery as join seems slightly faster.

(cherry picked from commit 9c0bf08)

* Address feedback. Initialize HashSet sizes to avoid resizing. Correct comment about indeterminante ordering.

(cherry picked from commit f011a5a)

* Allow users with write permission to view hidden metadata

(cherry picked from commit 65a17d4)

* Test modification: allow users with write rights to see hidden metadata

(cherry picked from commit df7f6e9)

* Add test to check that user with read rights can see hidden metadata

(cherry picked from commit 03496c3)

* Verify optional message is not missing or a literal "null" value

(cherry picked from commit 534ee3a)

* Change the database mode to READ_ONLY during the indexing by discovery consumer (IndexEventConsumer)

(cherry picked from commit 94822b5)

* Add functions to do a manual flush of the db session and call flush before change to READ_ONLY mode to be sure we index the current object

(cherry picked from commit c33d3fa)

* Flush database changes after switching to READONLY mode

(cherry picked from commit 00a6531)

* Add test to check retrieving of policies after changing mode to READ_ONLY

(cherry picked from commit d19a959)

* Change class name to ContextIT and correct a test

(cherry picked from commit a556799)

* dspace/config: update spider agent list

Update list of spider user agents from the COUNTER-Robots project.

See: https://github.com/atmire/COUNTER-Robots
(cherry picked from commit 7566a79)

* removed options to ping search engines when generating sitemaps

(cherry picked from commit f8f8806)

* XmlWorkflowCuratorServiceImpl: add check to queue task if configured; Curation: remove obsolete code preventing curation running on workflow tasks as DSpace#3157 is now implemented

* Return both user and operational LDAP attributes

Explicitly request both user and operation attributes
for LDAP group search as the default searching does not
include operational attributes.

This is required to fetch the memberOf attribute when checking
LDAP group membership.

Fixes DSpace#9151

(cherry picked from commit 56b7cbf)

* [DURACOM-200] improvement of checker script

(cherry picked from commit 5a7c795)

* 108055: isClosed method should use xml configuration

(cherry picked from commit d800d80)

* [DURACOM-192] Authentication Method related special groups are put in claim set even if a different authentication method is used

(cherry picked from commit 6504d74)

* [DURACOM-192] Added test

(cherry picked from commit fa39251)

* 107891: Cache administrator group

(cherry picked from commit 1e82ca7)

* DURACOM-199 improved test to show bug related to restricted content

(cherry picked from commit dac4df9)

* DURACOM-199 fix sitemap generator for restricted content and improve performance

(cherry picked from commit 6d9ca38)

* [Port dspace-7_x] Event consumer for submission config reloading when a collection changes (DSpace#9196)

* initialization with refactoring

(cherry picked from commit e93dc1c)

* also consider SubmissionConfigReaderException

(cherry picked from commit 8a04b87)

* rename consumer file

(cherry picked from commit f6c92a4)

* init submission service factory

(cherry picked from commit fcc5239)

* set submissionconfig config settings by default

(cherry picked from commit e343d51)

* renaming SubmissionConfigReaderService

(cherry picked from commit 9ea7c32)

* support for SubmissionConfigService

(cherry picked from commit 61389fb)

* fixing style errors and renaming submissionConfigService

(cherry picked from commit 5f49491)

* fixing style errors and unused imports

(cherry picked from commit 31d9251)

* set default submission event configs

(cherry picked from commit 578198c)

* adding force indexing action to Consumer

(cherry picked from commit b912364)

* stylecheck fixes

(cherry picked from commit 89e89c3)

* undo event.dispatcher.noindex.consumers

(cherry picked from commit ae9dc5f)

---------

Co-authored-by: Paulo Graça <[email protected]>

* Add isNotMemberOf for groups, including unit and integration tests

(cherry picked from commit 9d271b2)

* Implement searchNonMembers for EPersonService. Add tests to prove it works (and tests for search()). Requires minor bug fix to AbstractHibernateDSODAO to allow for additional OR/AND clauses to be appended.

(cherry picked from commit f186dcf)

* Add /epersons/search/isNotMemberOf endpoint to REST API along with integration tests

(cherry picked from commit 5208a35)

* Bug fix to EPersonDAOImpl.  Correctly determine if excluded group needs to be preceded by AND or WHERE

(cherry picked from commit e5e0eaa)

* Updated IIIF Controller IT to text bitstream and bundle exclusions

(cherry picked from commit e92b4b7)

* Simplified the process of fixing the tests after adding new sidebar facets/search filters and sort options to discover.xml

(cherry picked from commit b40ad0d)

* 107671: Expose the handle.canonical.prefix to the frontend

(cherry picked from commit 6d86e65)

* Remove line breaks from default.license because they are being rendered in the frontend

(cherry picked from commit 56aae34)

* [Port dspace-7_x] subscription email: do not send email if nothing has changed (DSpace#9204)

* improved subscriptions email template

(cherry picked from commit 6e7b327)

* do not send emails without content

(cherry picked from commit 926b242)

* fixed coding style violations

(cherry picked from commit fdacec0)

* removed unnecessary isEmpty check as suggested by reviewer

(cherry picked from commit 30a837f)

* moved null check on indexableObjects in generateBodyMail

(cherry picked from commit b43c340)

* fixed unhandled IOException

(cherry picked from commit 9b3f7b6)

* fixed typo in bodyCommunities

(cherry picked from commit ac3d02e)

* do not use != to compare strings

(cherry picked from commit e460183)

* fixed improper handling of empty list

(cherry picked from commit ac72aae)

---------

Co-authored-by: Sascha Szott <[email protected]>

* [maven-release-plugin] prepare release dspace-7.6.1

* Fixed checkstyle issues

* Fixed compilation errors

* Removed redundant service definitions in the `core-factory-services.xml` because unit tests was failing

* Removed redundant bean in the `discovery.xml`

* Removed redundant `latestVersion` from `schema.xml`

* Fixed wrong resolved conflicts - the app cannot start running

* Used ClarinVersionedHandleIdentifierProvider instead of Vanilla one in the `identifier-service.xml`

* Fixed tests - the user has an authorization to remove bundle

* Fixed failing test in the `MetadataExportSearchIT` it was trying to test dateIssued filter, but the CLARIN DSpace doesn't use that.

* controlled.authority.dc.relation is changed in the configuration by CLARIN so the test VersioningWithRelationshipsIT is failing because of that.

* Fixed wrong license validation class

* Removed test which was accidentaly added durign resolving conflicts

* The ACL tag restricted loading of some input field which was missing in the assert

* The test cannot convert `Oct` from the xml to normal number because of Slovak default locale which doesn't know what `Oct` means in the date. I set up EN locale for the current test

* Added clarin set up of search Facets into integration tests - because src/test/java/org/dspace/app/rest/DiscoveryScopeBasedRestControllerIT.java was failing

* Added method `areSpecialGroupsApplicable` into ClarinShibAuthentication because after shib authentication the user wasn't assinged into special group because of some dspace new feature

* Change DEFAULT_AMOUNT_FORMATS in the BitstreamFormatRestRepositoryIT.java because vanila has added a new format.

* Ignored still failing RegistrationRestRepositoryIT test - it is ignored also in the 7.5 version

* fix: Failure of org.dspace.app.rest.SitemapRestControllerIT when running locally

* Ignore pubmedImportMetadataGetRecordsTest or allow ssl

* Let the pubmedImportMetadataGetRecordsTests ignored

* Fixed CurationIT - it failed on the Stream because Stream has null param. Null param was because of null handle on the Site object - the site handle was removed in the  `ClarinHandleImportControllerIT.java#createHandleWithoutDSpaceObjectTest`.

* Do not delete site handle in the HandleRestRepositoryIT

* Updated scripts for fast building 7.6.1

* Moved flyway script for updating checksum_results into separate file

* Added missing headers

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Tim Donohue <[email protected]>
Co-authored-by: Sean Kalynuk <[email protected]>
Co-authored-by: Sascha Szott <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Agustina Martinez <[email protected]>
Co-authored-by: Alan Orth <[email protected]>
Co-authored-by: Martin Walk <[email protected]>
Co-authored-by: corrado lombardi <[email protected]>
Co-authored-by: David P. Steelman <[email protected]>
Co-authored-by: Christian Bethge <[email protected]>
Co-authored-by: max.nuding <[email protected]>
Co-authored-by: Max Nuding <[email protected]>
Co-authored-by: Mark H. Wood <[email protected]>
Co-authored-by: Nona Luypaert <[email protected]>
Co-authored-by: Christian Clauss <[email protected]>
Co-authored-by: Hrafn Malmquist <[email protected]>
Co-authored-by: aroman-arvo <[email protected]>
Co-authored-by: Christian Bethge <[email protected]>
Co-authored-by: Koen Pauwels <[email protected]>
Co-authored-by: Mark Cooper <[email protected]>
Co-authored-by: nwoodward <[email protected]>
Co-authored-by: Kim Shepherd <[email protected]>
Co-authored-by: Marie-Hélène Vézina <[email protected]>
Co-authored-by: damian <[email protected]>
Co-authored-by: Gantner, Florian Klaus <[email protected]>
Co-authored-by: wwuck <[email protected]>
Co-authored-by: Paulo Graça <[email protected]>
Co-authored-by: Toni Prieto <[email protected]>
Co-authored-by: mohamed eskander <[email protected]>
Co-authored-by: Jens Vannerum <[email protected]>
Co-authored-by: Luca Giamminonni <[email protected]>
Co-authored-by: Andrea Bollini <[email protected]>
Co-authored-by: DSpace Bot <[email protected]>
Co-authored-by: Michael Spalti <[email protected]>
Co-authored-by: Alexandre Vryghem <[email protected]>
Co-authored-by: Shankeerthan Kasilingam <[email protected]>

* The cas.init() method is called in the VocabularyRestRepositoryIT#setup() method

* Update docker.yml (#502)

dspace-dependencies job was missing

* Update docker.yml (#503)

Fixed dspace-dependencies error

* Update docker.yml (#504)

* Empty commit - run actions

* use checkstyle before commit

* remove fix duplicate dependency

* remove discofeed related fetching from obsolete discojuice servers (#508)

* remove discofeed related fetching from obsolete discojuice servers

* check style, turned off in testing, turned of by default

* fix failing test

---------

Co-authored-by: jm <jm@maz>

* ufal/cannot-upload-big-file (#533)

* Do not compute localChecksum because it takes too long for the big files. The checksum is computed using DigestInputStream object.
Copy content into sync local assetstore using buffered copying.

* Fixed checkstyle issue

* Updated comment about creating required directories

* ufal/license-agreement-wrong-behaviour (#534)

* The all transactions are not updated in the user metadata after a new download..

* Return the user metadata depending on user registration, bitstream, mapping and the last translation.

* Fixed checkstyle issues

* Fixed failing integration tests - do not fetch user metadata for testing by ID where there are more tests which creates the user metadata

* internal/discofeed-it (#535)

* Disable SSL check for specific discofeed requests

* Fixed checkstyle issues

* Do not throw error in private constructor

* Fixed failing IT - ssl check wasn't disabled

* Ignore integration test which is trying to connect to our private network.

* allow running from branch rework-actions for testing

* ufal/s3-check-etag (#537)

* Temp commit - upload a file by uploading 50MB parts

* Added uploading the file by parts - for every part is computed checksum and compared with UploadPartResult's ETag. This feature could be enabled or disabled by cfg.

* Undo S3BitStoreService changes

* Fixed checkstyle issues

* Prettify the code

* Changed cfg property to be better understandable and file size is converted into constant.

* ufal/allow-impersonating

Allow impersonating by default (#539)

* correct branches for main gh actions

* Rework actions (#540)

* run correct actions on correct repos

* remove old docker job, separating it to several

* reusable build yml from upstream

* upstream docker.yml version

* first test run

* steppify docker.yml action to be able to add more steps

* added python version to reusable build

* fix incorrect usage of steps in gh action

* corect the type in reusable wf

* correct condition in python version script

* corrected the branch

* corrected image dockerhub owner

* no linux/arm64

* comment out unused tasks; minor corrections

* do not redepoy becuse jm said so

* do not use codecov

* disable deploy differently

* extend possibilities for using version script (#542)

* parametrized output of python version script

* RUUUN

* correct version placement

* correct branches for run of gh action

* Fix all mistakes in the /home page (#543)

* Configured browsing by language

* Updated tests following the browsing cfg

* reusable run provides links to run and it's ID

* first attempt at tag release action

* also release images under github.sha

* Improve version info, add release-tag action

add run link to version info

correct image for tests (remove dspace-dependencies from migrate to 7.5)

add action to release on tagging

* add necessary option to tag-action

* Fixed all mistakes in the Item View page (#551)

* Remove the xml info and bibtex tag from the citation refbox

* Show handle and DOI in the Item View following the new cfg property

* Made updating xml string more generic

* Updated the method name for the getting text content from the bibtex xml.

* Fixed all mistakes in the Search page (#549)

* File size in the MetadataBitstreamWrapperRest changed to `long` type instead of String, the FE transfer all bytes into readable form.

* Changed default sorting options

* Added a new search configuration for the homepage, because searching by `dc.date.accesioned` must be removed because of clarin requirements, but the homepage uses searching by `dc.date.accesioned`

* Configured searching by Item Type in the search page.

* Updated community indexing - added _filter and _keyword because they are needed to work as facet and filter

* Updated `Rights` and `Community` configuration. Changed to `text` type.

* Allow Site usage reports for the Anonymous user

* Fixed MetadataBitstreamRestRepositoryIT - the Matcher has a problem to compare long types.

* Fixed DiscoveryScopeBasedRestControllerIT - the expected facets and Matchers did must be updated.

* Fixed ClarinDiscoveryRestControllerIT - the expected facets and Matchers did must be updated.

* Use `dc.contributor.other` metadata field for mapping the authors (#557)

* Added `edm.xml` registry (#559)

* Added `edm.xml` registry

* Fixed cfg for `edm.xml`

* Updated shibboleth cfg properties (firstname, lastname, netid, email) (#558)

* Updated shibboleth cfg properties (firstname, lastname, netid, email)

* Keep vanilla shib headers for the integration tests

* during release, retag cli image as well

* Recent submissions are loaded on the collection page. (#567)

* Disabled showing `Accesioned sort option` by cfg (#568)

* Disabled showing `Accesioned sort option` by cfg

* Fixed when the `sort.options.filtered` property is empty

* Turned off signposting (#571)

* Turned off and tested on dev.

* Allowed signposting for the integration tests

* Show all values for the Subject facet in the search page. (#569)

* Updated fast building app after config change.

* Added a new search facet to return facet values with and without splitter. With - search page side bar, without - homepage.

* Show values in search page and do not show them on Home page, added tests.

* Fixed tests which were failing because of Solr indexing updates

* Updated interpolation of Subject following the update from 7.6.1 (#620)

* use true, for cmdi crosswalk (#629)

* use true, for cmdi crosswalk

* test fix

* migrate DIM2DataCite v4.5

[Port dspace-7_x] Update of DataCite crosswalk to metadata schema 4.5

Co-authored-by: Tim Donohue <[email protected]>

* Updated `submission-forms.xml` following actual v5 `input-forms.xml` (#633)

* Added missing inputs, defined a new complex inputs and copied vocabulary values without interpolation from v5

* Translated added vocabularies

* Removed sequence number from the complex input field

* Added `clariah-submission`

* Added teaching materials form

* Added czech translation of submission-forms.xml (#636)

* Created submission-forms_cs.xml for the czech translation of the submission-forms.xml. And allowed cs locale in the config.

* Added `webui.supported.locales = en` property into test cfg because IT expect only `en` locale.

* Added a new log4j appender for logging file downloads into `file_download.log` file. (#634)

* remove TUL references in code

* deTULify

* return required props

* do not mess with lines

* Synchronized spider config with ufal (#635)

* Copied `ufal.ignore.txt` spider

* Removed conflict IP address

* Fixed IP with `/` instead of `.`

* The IP address must be in the format `74.86.158.0/24`

* The max file preview size is loaded from the cfg (#630)

* The max file preview size is loaded from the cfg

* Removed a condition to not preview files longer less 3 chars. And updated condition to check if the file is file or a folder.

* Added email validation and input/output encodings are loaded from the cfg.

* Revert "Added email validation and input/output encodings are loaded from the cfg."

This reverts commit 9d40f00.

* load matomo url from cfg

* forgotten remove comment

* Reserve PID on the start of the submission. (#649)

* Upload big file differencies (#647)

* Update hint for big file upload

* Do not delete big file after upload by default - changed cfg property.

* Refactored checking if the file should be deleted after upload.

* Remove big file metadata after every save metadata

* Updated indexing of the hidden Item for the OAI-PMH (#650)

* Updated indexing of the Item for the OAI-PMH: show the Item if it is hidden from the search.

* Updated doc

* Send Authorization request if the User is not allowed to see restricted Item (#646)

* Shibboleth login - Added email validation (#644)

* Added email validation and input/output encodings are loaded from the cfg.

* Fixed checkstyle violation

* Refactored condition which check empty character in the email.

* Show Download all as ZIP button only when all conditions are met  (#641)

* Defined `local.files.count` and `local.files.size` and that values are added into metadata fields during updating of the Item.

* Defined downloading zip cfg properties

* Exposed download zip cfg properties

* Removed commit which starts active session and because of that some tests are failing.

* Removed VersioningWithRelationshipsTest.java because it is duplicate of VersioningWithRelationshipsIT and that is also removed from Vanilla

* Update Item's file metadata in other place - not in the ItemServiceImpl#update because it is causing errors

* Count files info only for the ORIGINAL bundle

* Updated StatisticsRestRepositoryIT.java in the way that creating of some bitstreams are done in the setup when the Item is still persisted and not detached

* Removed the function from the ItemServiceImpl#update method

* fix problems displaying oai in various formats (#653)

fixed wrong number of parameters expected in java code
and wrong number of parameters sent in xsl file

* Set up dtoken for every bitstream of the zip file. (#652)

* Updated xoai.xml - changed filters, conditions, refactored (#631)

* Updated xoia.xml following the actual xoai.xml in v5

* Empty commit to run actions

* Fixed path to the ColComFilter in the xoai.xml

* The bitstreams cannot be seen after the item is created (#657)

* Update Item's metadata when the bitstream is updated.

* Update Item's metadata about files after deleting the bitstream.

* Update Item's metadata before the bundle is deleted or touched

* Check if the bundle is not null before using it.

* prevent empty argument errors (#655)

Some xsl crosswalks call functions that expect parameters, but for various reasons, parameters are empty. That is now checked and logged.

* Edit Item's license (#654)

* Added authorization for the `Edit Item - License` menu option.

* Created endpoint for updating license of the Item.

* Added functionality only for detaching the license.

* Changed DOI identifier to `dc.identifier.doi` (#661)

* Complex input field issues (#651)

* The complex input field value could be empty - removed condition that requires complex input data to not be empty.

* Fixed issue when the `jsonValEvaluator` is null because of empty operation value.

* Updated doc.

* Mark inputs for funding as required. Added an exception when the openaire_id is not required.

* Updated `submission-forms` complex input field to be not required for Integration tests.

* Refactored and updated validation for complex input field

* Fixed the importing of the Item - if the Item has pre-registered PID it should be unbound (#659)

* local-typex differencies (#660)

* Added dataProvider Facet

* Replaced deprecated `sortOrder` with the new one.

* `searchFacetDataProvider` should be in the searchFilters

* Updated Integration test which checks the search filters

* Ufal/add olac description (#662)

Add olac description with lindat values

* add elg format (#658)

add elg format with appropriate functions

* The Item should not be exposed by the OAI

* Fix not exposing the Item by the OAI (#667)

* dso has never been asigned

* Use Factory for the Collection and Community service .

* Use Handle Service instead of HandleResolver which calls HandleService

* add extra appender for warns (#668)

* Update Item's date metadata - do not remove dc.date.issued (#669)

* Created method which updates properly the Item's date metadata.

* Fixed checkstyle issues

* The servlet request could be null.

* Update the comment to make description more clear.

* Fix encoding problems in refbox endpoint (#670)

Use correct middle part in special Output Stream.

* solr log modification (#671)

solr log modification with explanation

* Cherry picked and resolved conflicts. The submission-forms.xml and item-submission.xml are ignored. (#672)

Co-authored-by: Ondřej Košarko <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: MajoBerger <[email protected]>
Co-authored-by: MajoBerger <[email protected]>
Co-authored-by: Adán Román Ruiz <[email protected]>
Co-authored-by: Ondřej Košarko <[email protected]>
Co-authored-by: Tim Donohue <[email protected]>
Co-authored-by: Luca Giamminonni <[email protected]>
Co-authored-by: Sean Kalynuk <[email protected]>
Co-authored-by: Sascha Szott <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Agustina Martinez <[email protected]>
Co-authored-by: Alan Orth <[email protected]>
Co-authored-by: Martin Walk <[email protected]>
Co-authored-by: corrado lombardi <[email protected]>
Co-authored-by: David P. Steelman <[email protected]>
Co-authored-by: Christian Bethge <[email protected]>
Co-authored-by: max.nuding <[email protected]>
Co-authored-by: Max Nuding <[email protected]>
Co-authored-by: Mark H. Wood <[email protected]>
Co-authored-by: Nona Luypaert <[email protected]>
Co-authored-by: Christian Clauss <[email protected]>
Co-authored-by: Hrafn Malmquist <[email protected]>
Co-authored-by: Christian Bethge <[email protected]>
Co-authored-by: Koen Pauwels <[email protected]>
Co-authored-by: Mark Cooper <[email protected]>
Co-authored-by: nwoodward <[email protected]>
Co-authored-by: Kim Shepherd <[email protected]>
Co-authored-by: Marie-Hélène Vézina <[email protected]>
Co-authored-by: damian <[email protected]>
Co-authored-by: Gantner, Florian Klaus <[email protected]>
Co-authored-by: wwuck <[email protected]>
Co-authored-by: Paulo Graça <[email protected]>
Co-authored-by: Toni Prieto <[email protected]>
Co-authored-by: mohamed eskander <[email protected]>
Co-authored-by: Jens Vannerum <[email protected]>
Co-authored-by: Andrea Bollini <[email protected]>
Co-authored-by: DSpace Bot <[email protected]>
Co-authored-by: Michael Spalti <[email protected]>
Co-authored-by: Alexandre Vryghem <[email protected]>
Co-authored-by: Shankeerthan Kasilingam <[email protected]>
Co-authored-by: jm <jm@maz>
Co-authored-by: Jozef Misutka <[email protected]>
  • Loading branch information
Show file tree
Hide file tree
Showing 70 changed files with 4,833 additions and 4,497 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
import org.dspace.content.service.RelationshipService;
import org.dspace.content.service.RelationshipTypeService;
import org.dspace.content.service.WorkspaceItemService;
import org.dspace.content.service.clarin.ClarinItemService;
import org.dspace.content.service.clarin.ClarinLicenseResourceMappingService;
import org.dspace.content.service.clarin.ClarinLicenseService;
import org.dspace.core.Constants;
Expand Down Expand Up @@ -188,6 +189,8 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
protected ClarinLicenseService clarinLicenseService;
@Autowired(required = true)
protected ClarinLicenseResourceMappingService clarinLicenseResourceMappingService;
@Autowired(required = true)
protected ClarinItemService clarinItemService;

protected String tempWorkDir;

Expand Down Expand Up @@ -723,6 +726,8 @@ public void replaceItems(Context c, List<Collection> mycollections,
itemService.clearMetadata(c, newItem, "dc", "rights", "label", Item.ANY);
itemService.addMetadata(c, newItem, "dc", "rights", "label", Item.ANY,
license.getNonExtendedClarinLicenseLabel().getLabel());
clarinItemService.updateItemFilesMetadata(c, newItem);

itemService.update(c, newItem);
c.uncacheEntity(newItem);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

Expand Down Expand Up @@ -578,7 +579,7 @@ protected EPerson findEPerson(Context context, HttpServletRequest request) throw

// 2) Second, look for an email header.
if (eperson == null && emailHeader != null) {
String email = findSingleAttribute(request, emailHeader);
String email = getEmailAcceptedOrNull(findSingleAttribute(request, emailHeader));
if (StringUtils.isEmpty(email) && Objects.nonNull(clarinVerificationToken)) {
email = clarinVerificationToken.getEmail();
}
Expand Down Expand Up @@ -694,7 +695,7 @@ protected EPerson registerNewEPerson(Context context, HttpServletRequest request

// Header values
String netid = Util.formatNetId(findSingleAttribute(request, netidHeader), org);
String email = findSingleAttribute(request, emailHeader);
String email = getEmailAcceptedOrNull(findSingleAttribute(request, emailHeader));
String fname = Headers.updateValueByCharset(findSingleAttribute(request, fnameHeader));
String lname = Headers.updateValueByCharset(findSingleAttribute(request, lnameHeader));

Expand Down Expand Up @@ -816,7 +817,7 @@ protected void updateEPerson(Context context, HttpServletRequest request, EPerso
String lnameHeader = configurationService.getProperty("authentication-shibboleth.lastname-header");

String netid = Util.formatNetId(findSingleAttribute(request, netidHeader), shibheaders.get_idp());
String email = findSingleAttribute(request, emailHeader);
String email = getEmailAcceptedOrNull(findSingleAttribute(request, emailHeader));
String fname = Headers.updateValueByCharset(findSingleAttribute(request, fnameHeader));
String lname = Headers.updateValueByCharset(findSingleAttribute(request, lnameHeader));

Expand Down Expand Up @@ -1171,7 +1172,12 @@ protected String findAttribute(HttpServletRequest request, String name) {

if (!StringUtils.isEmpty(value) && reconvertAttributes) {
try {
value = new String(value.getBytes("ISO-8859-1"), "UTF-8");
String inputEncoding = configurationService.getProperty("shibboleth.name.conversion.inputEncoding",
"ISO-8859-1");
String outputEncoding = configurationService.getProperty("shibboleth.name.conversion.outputEncoding",
"UTF-8");

value = new String(value.getBytes(inputEncoding), outputEncoding);
} catch (UnsupportedEncodingException ex) {
log.warn("Failed to reconvert shibboleth attribute ("
+ name + ").", ex);
Expand Down Expand Up @@ -1324,5 +1330,13 @@ public boolean canChangePassword(Context context, EPerson ePerson, String curren
public boolean areSpecialGroupsApplicable(Context context, HttpServletRequest request) {
return true;
}

public String getEmailAcceptedOrNull(String email) {
// no whitespaces in mail
if (StringUtils.isEmpty(email) || Pattern.compile("\\s").matcher(email).find()) {
return null;
}
return email;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.dspace.content.service.BitstreamService;
import org.dspace.content.service.BundleService;
import org.dspace.content.service.ItemService;
import org.dspace.content.service.clarin.ClarinItemService;
import org.dspace.content.service.clarin.ClarinLicenseResourceMappingService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
Expand Down Expand Up @@ -66,6 +67,8 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
protected BitstreamStorageService bitstreamStorageService;
@Autowired(required = true)
protected ClarinLicenseResourceMappingService clarinLicenseResourceMappingService;
@Autowired(required = true)
protected ClarinItemService clarinItemService;

protected BitstreamServiceImpl() {
super();
Expand Down Expand Up @@ -275,6 +278,8 @@ public void delete(Context context, Bitstream bitstream) throws SQLException, Au
// Remove bitstream itself
bitstream.setDeleted(true);
update(context, bitstream);
// Update Item's metadata about bitstreams
clarinItemService.updateItemFilesMetadata(context, bitstream);

//Remove our bitstream from all our bundles
final List<Bundle> bundles = bitstream.getBundles();
Expand All @@ -286,7 +291,6 @@ public void delete(Context context, Bitstream bitstream) throws SQLException, Au
}
bundle.removeBitstream(bitstream);
}

//Remove all bundles from the bitstream object, clearing the connection in 2 ways
bundles.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.dspace.content.service.BitstreamService;
import org.dspace.content.service.BundleService;
import org.dspace.content.service.ItemService;
import org.dspace.content.service.clarin.ClarinItemService;
import org.dspace.content.service.clarin.ClarinLicenseResourceMappingService;
import org.dspace.content.service.clarin.ClarinLicenseService;
import org.dspace.core.Constants;
Expand Down Expand Up @@ -70,6 +71,8 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
protected ClarinLicenseService clarinLicenseService;
@Autowired(required = true)
protected ClarinLicenseResourceMappingService clarinLicenseResourceMappingService;
@Autowired(required = true)
protected ClarinItemService clarinItemService;

protected BundleServiceImpl() {
super();
Expand Down Expand Up @@ -215,6 +218,7 @@ public void addBitstream(Context context, Bundle bundle, Bitstream bitstream)
}
bitstreamService.update(context, bitstream);

clarinItemService.updateItemFilesMetadata(context, owningItem, bundle);
// Add clarin license to the bitstream and clarin license values to the item metadata
clarinLicenseService.addClarinLicenseToBitstream(context, owningItem, bundle, bitstream);
}
Expand All @@ -238,6 +242,7 @@ public void removeBitstream(Context context, Bundle bundle, Bitstream bitstream)
if (owningItem != null) {
itemService.updateLastModified(context, owningItem);
itemService.update(context, owningItem);
clarinItemService.updateItemFilesMetadata(context, owningItem, bundle);
}

// In the event that the bitstream to remove is actually
Expand Down Expand Up @@ -453,7 +458,7 @@ public void setOrder(Context context, Bundle bundle, UUID[] bitstreamIds) throws
if (owningItem != null) {
itemService.updateLastModified(context, owningItem);
itemService.update(context, owningItem);

clarinItemService.updateItemFilesMetadata(context, owningItem, bundle);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions dspace-api/src/main/java/org/dspace/content/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ public boolean isDiscoverable() {
public boolean isHidden() {
String valueOfHidden = getItemService().getMetadataFirstValue(this, "local",
"hidden", null, Item.ANY);
if (Objects.nonNull(valueOfHidden) && valueOfHidden.equalsIgnoreCase("hidden")) {

if (Objects.nonNull(valueOfHidden) && valueOfHidden.equalsIgnoreCase("hidden")) {
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,26 @@
package org.dspace.content.clarin;

import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.logging.log4j.Logger;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.content.MetadataField;
import org.dspace.content.MetadataValue;
import org.dspace.content.dao.clarin.ClarinItemDAO;
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;
Expand All @@ -35,12 +42,18 @@
public class ClarinItemServiceImpl implements ClarinItemService {

private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(ClarinItemServiceImpl.class);
private static final String DELIMETER = ",";
private static final String NO_YEAR = "0000";

@Autowired
ClarinItemDAO clarinItemDAO;

@Autowired
CollectionService collectionService;

@Autowired
ItemService itemService;

@Override
public List<Item> findByBitstreamUUID(Context context, UUID bitstreamUUID) throws SQLException {
return clarinItemDAO.findByBitstreamUUID(context, bitstreamUUID);
Expand Down Expand Up @@ -125,4 +138,135 @@ public Community getOwningCommunity(Context context, UUID owningCollectionId) th
}
return null;
}

@Override
public void updateItemFilesMetadata(Context context, Item item) throws SQLException {
List<Bundle> originalBundles = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
if (Objects.nonNull(originalBundles.get(0))) {
updateItemFilesMetadata(context, item, originalBundles.get(0));
} else {
log.error("Cannot update item files metadata because the ORIGINAL bundle is null.");
}
}

@Override
public void updateItemFilesMetadata(Context context, Item item, Bundle bundle) throws SQLException {
if (!Objects.equals(bundle.getName(), Constants.CONTENT_BUNDLE_NAME)) {
return;
}

int totalNumberOfFiles = 0;
long totalSizeofFiles = 0;

/* Add local.has.files metadata */
boolean hasFiles = false;
List<Bundle> origs = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
for (Bundle orig : origs) {
if (CollectionUtils.isNotEmpty(orig.getBitstreams())) {
hasFiles = true;
}
for (Bitstream bit : orig.getBitstreams()) {
totalNumberOfFiles ++;
totalSizeofFiles += bit.getSizeBytes();
}
}

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);
if ( hasFiles ) {
itemService.addMetadata(context, item, "local", "has", "files", Item.ANY, "yes");
} else {
itemService.addMetadata(context, item,"local", "has", "files", Item.ANY, "no");
}
itemService.addMetadata(context, item,"local", "files", "count", Item.ANY, "" + totalNumberOfFiles);
itemService.addMetadata(context, item,"local", "files", "size", Item.ANY, "" + totalSizeofFiles);
}

@Override
public void updateItemFilesMetadata(Context context, Bitstream bit) throws SQLException {
// Get the Item the bitstream is associated with
Item item = null;
Bundle bundle = null;
List<Bundle> origs = bit.getBundles();
for (Bundle orig : origs) {
if (!Constants.CONTENT_BUNDLE_NAME.equals(orig.getName())) {
continue;
}

List<Item> items = orig.getItems();
if (CollectionUtils.isEmpty(items)) {
continue;
}

item = items.get(0);
bundle = orig;
break;
}

// It could be null when the bundle name is e.g. `LICENSE`
if (Objects.isNull(item) || Objects.isNull(bundle)) {
return;
}
this.updateItemFilesMetadata(context, item, bundle);
}

@Override
public void updateItemDatesMetadata(Context context, Item item) throws SQLException {
if (Objects.isNull(context)) {
log.error("Cannot update item dates metadata because the context is null.");
return;
}

List<MetadataValue> approximatedDates =
itemService.getMetadata(item, "local", "approximateDate", "issued", Item.ANY, false);

if (CollectionUtils.isEmpty(approximatedDates) || StringUtils.isBlank(approximatedDates.get(0).getValue())) {
log.warn("Cannot update item dates metadata because the approximate date is empty.");
return;
}

// Get the approximate date value from the metadata
String approximateDateValue = approximatedDates.get(0).getValue();

// Split the approximate date value by the delimeter and get the list of years.
List<String> listOfYearValues = Arrays.asList(approximateDateValue.split(DELIMETER));
// Trim the list of years - remove leading and trailing whitespaces
listOfYearValues.replaceAll(String::trim);

try {
// Clear the current `dc.date.issued` metadata
itemService.clearMetadata(context, item, "dc", "date", "issued", Item.ANY);

// Update the `dc.date.issued` metadata with a new value: `0000` or the last year from the sequence
if (CollectionUtils.isNotEmpty(listOfYearValues) && isListOfNumbers(listOfYearValues)) {
// Take the last year from the list of years and add it to the `dc.date.issued` metadata
itemService.addMetadata(context, item, "dc", "date", "issued", Item.ANY,
getLastNumber(listOfYearValues));
} else {
// Add the `0000` value to the `dc.date.issued` metadata
itemService.addMetadata(context, item, "dc", "date", "issued", Item.ANY, NO_YEAR);
}
} catch (SQLException e) {
log.error("Cannot remove `dc.date.issued` metadata because: {}", e.getMessage());
}
}

public static boolean isListOfNumbers(List<String> values) {
for (String value : values) {
if (!NumberUtils.isCreatable(value)) {
return false;
}
}
return true;
}

private static String getLastNumber(List<String> values) {
if (CollectionUtils.isEmpty(values)) {
return NO_YEAR;
}
return values.get(values.size() - 1);
}


}
Loading

0 comments on commit 09ade7e

Please sign in to comment.