diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39a6f41429fd..724131f16ba8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: - name: Run Maven ${{ matrix.type }} env: TEST_FLAGS: ${{ matrix.mvnflags }} - run: mvn --no-transfer-progress -V install -P-assembly -Pcoverage-report $TEST_FLAGS + run: mvn --no-transfer-progress -V install -P-assembly $TEST_FLAGS # If previous step failed, save results of tests to downloadable artifact for this job # (This artifact is downloadable at the bottom of any job's summary page) @@ -70,43 +70,4 @@ jobs: name: ${{ matrix.type }} results path: ${{ matrix.resultsdir }} - # Upload code coverage report to artifact, so that it can be shared with the 'codecov' job (see below) - - name: Upload code coverage report to Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.type }} coverage report - path: 'dspace/target/site/jacoco-aggregate/jacoco.xml' - retention-days: 14 - - # Codecov upload is a separate job in order to allow us to restart this separate from the entire build/test - # job above. This is necessary because Codecov uploads seem to randomly fail at times. - # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 - codecov: - # Must run after 'tests' job above - needs: tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - # Download artifacts from previous 'tests' job - - name: Download coverage artifacts - uses: actions/download-artifact@v4 - - # Now attempt upload to Codecov using its action. - # NOTE: We use a retry action to retry the Codecov upload if it fails the first time. - # - # Retry action: https://github.com/marketplace/actions/retry-action - # Codecov action: https://github.com/codecov/codecov-action - - name: Upload coverage to Codecov.io - uses: Wandalen/wretry.action@v1.3.0 - with: - action: codecov/codecov-action@v4 - # Ensure codecov-action throws an error when it fails to upload - with: | - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} - # Try re-running action 5 times max - attempt_limit: 5 - # Run again in 30 seconds - attempt_delay: 30000 diff --git a/.github/workflows/codescan.yml b/.github/workflows/codescan.yml index 3a563c6fa39c..cbdb4b880cbb 100644 --- a/.github/workflows/codescan.yml +++ b/.github/workflows/codescan.yml @@ -47,7 +47,7 @@ jobs: # Initializes the CodeQL tools for scanning. # https://github.com/github/codeql-action - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: # Codescan Javascript as well since a few JS files exist in REST API's interface languages: java, javascript @@ -56,8 +56,8 @@ jobs: # NOTE: Based on testing, this autobuild process works well for DSpace. A custom # DSpace build w/caching (like in build.yml) was about the same speed as autobuild. - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # Perform GitHub Code Scanning. - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.gitignore b/.gitignore index 529351edc5c2..ced5848992e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ ## Ignore the MVN compiled output directories from version tracking target/ +scripts/ ## Ignore tags index files created by Exuberant Ctags tags diff --git a/dspace-api/src/main/java/org/dspace/access/status/AccessStatusHelper.java b/dspace-api/src/main/java/org/dspace/access/status/AccessStatusHelper.java index 2d782dc3b82a..9bad258b5c82 100644 --- a/dspace-api/src/main/java/org/dspace/access/status/AccessStatusHelper.java +++ b/dspace-api/src/main/java/org/dspace/access/status/AccessStatusHelper.java @@ -10,6 +10,7 @@ import java.sql.SQLException; import java.util.Date; +import org.dspace.content.Bitstream; import org.dspace.content.Item; import org.dspace.core.Context; @@ -39,4 +40,27 @@ public String getAccessStatusFromItem(Context context, Item item, Date threshold * @throws SQLException An exception that provides information on a database access error or other errors. */ public String getEmbargoFromItem(Context context, Item item, Date threshold) throws SQLException; + + /** + * Calculate the access status for a bitstream. + * + * @param context the DSpace context + * @param bitstream the bitstream + * @param threshold the embargo threshold date + * @return an access status value + * @throws SQLException An exception that provides information on a database access error or other errors. + */ + public String getAccessStatusFromBitstream(Context context, Bitstream bitstream, Date threshold) + throws SQLException; + + /** + * Retrieve embargo information for a bitstream. + * + * @param context the DSpace context + * @param bitstream the bitstream to check for embargo information + * @param threshold the embargo threshold date + * @return an embargo date string + * @throws SQLException An exception that provides information on a database access error or other errors. + */ + public String getEmbargoFromBitstream(Context context, Bitstream bitstream, Date threshold) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/access/status/AccessStatusServiceImpl.java b/dspace-api/src/main/java/org/dspace/access/status/AccessStatusServiceImpl.java index 01b370747932..2b93560d40f1 100644 --- a/dspace-api/src/main/java/org/dspace/access/status/AccessStatusServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/access/status/AccessStatusServiceImpl.java @@ -13,6 +13,7 @@ import java.util.Date; import org.dspace.access.status.service.AccessStatusService; +import org.dspace.content.Bitstream; import org.dspace.content.Item; import org.dspace.core.Context; import org.dspace.core.service.PluginService; @@ -72,4 +73,14 @@ public String getAccessStatus(Context context, Item item) throws SQLException { public String getEmbargoFromItem(Context context, Item item) throws SQLException { return helper.getEmbargoFromItem(context, item, forever_date); } + + @Override + public String getAccessStatusFromBitstream(Context context, Bitstream bitstream) throws SQLException { + return helper.getAccessStatusFromBitstream(context, bitstream, forever_date); + } + + @Override + public String getEmbargoFromBitstream(Context context, Bitstream bitstream) throws SQLException { + return helper.getEmbargoFromBitstream(context, bitstream, forever_date); + } } diff --git a/dspace-api/src/main/java/org/dspace/access/status/DefaultAccessStatusHelper.java b/dspace-api/src/main/java/org/dspace/access/status/DefaultAccessStatusHelper.java index 52cdec3517bc..abc96d92a3a2 100644 --- a/dspace-api/src/main/java/org/dspace/access/status/DefaultAccessStatusHelper.java +++ b/dspace-api/src/main/java/org/dspace/access/status/DefaultAccessStatusHelper.java @@ -245,4 +245,40 @@ private Date retrieveShortestEmbargo(Context context, Bitstream bitstream) throw return embargoDate; } + + /** + * Calculate the access status for a single bitstream. + * + * @param context the DSpace context + * @param bitstream the bitstream + * @param threshold the embargo threshold date + * @return an access status value + */ + @Override + public String getAccessStatusFromBitstream(Context context, Bitstream bitstream, Date threshold) + throws SQLException { + return calculateAccessStatusForDso(context, bitstream, threshold); + } + + /** + * Retrieve the embargo date for a single bitstream. + * + * @param context the DSpace context + * @param bitstream the bitstream to check for embargo information + * @param threshold the embargo threshold date + * @return an embargo date string, or null if no embargo + */ + @Override + public String getEmbargoFromBitstream(Context context, Bitstream bitstream, Date threshold) + throws SQLException { + if (bitstream == null) { + return null; + } + String accessStatus = calculateAccessStatusForDso(context, bitstream, threshold); + if (!EMBARGO.equals(accessStatus)) { + return null; + } + Date embargoDate = retrieveShortestEmbargo(context, bitstream); + return embargoDate != null ? embargoDate.toString() : null; + } } diff --git a/dspace-api/src/main/java/org/dspace/access/status/service/AccessStatusService.java b/dspace-api/src/main/java/org/dspace/access/status/service/AccessStatusService.java index 2ed47bde4cd2..3ca44982cd4e 100644 --- a/dspace-api/src/main/java/org/dspace/access/status/service/AccessStatusService.java +++ b/dspace-api/src/main/java/org/dspace/access/status/service/AccessStatusService.java @@ -9,6 +9,7 @@ import java.sql.SQLException; +import org.dspace.content.Bitstream; import org.dspace.content.Item; import org.dspace.core.Context; @@ -54,4 +55,24 @@ public interface AccessStatusService { * @throws SQLException An exception that provides information on a database access error or other errors. */ public String getEmbargoFromItem(Context context, Item item) throws SQLException; + + /** + * Calculate the access status for a Bitstream. + * + * @param context the DSpace context + * @param bitstream the bitstream + * @return an access status value + * @throws SQLException An exception that provides information on a database access error or other errors. + */ + public String getAccessStatusFromBitstream(Context context, Bitstream bitstream) throws SQLException; + + /** + * Retrieve embargo information for a Bitstream. + * + * @param context the DSpace context + * @param bitstream the bitstream to check for embargo information + * @return an embargo date string + * @throws SQLException An exception that provides information on a database access error or other errors. + */ + public String getEmbargoFromBitstream(Context context, Bitstream bitstream) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemUpdate.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemUpdate.java index a93cc2eeaa5f..149afb9872de 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemUpdate.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemUpdate.java @@ -29,6 +29,7 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.dspace.content.Item; +import org.dspace.content.datashare.DatashareItemDataset; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.ItemService; import org.dspace.core.Context; @@ -38,10 +39,6 @@ import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.service.HandleService; -//DATASHARE - start -import org.dspace.content.datashare.DatashareItemDataset; -//DATASHARE - end - /** * Provides some batch editing capabilities for items in DSpace. *