Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into coar-notify-NotifySer…
Browse files Browse the repository at this point in the history
…viceRestRepositoryIT-fix
  • Loading branch information
frabacche committed Apr 18, 2024
2 parents 59aa196 + 009642d commit 450dde5
Show file tree
Hide file tree
Showing 40 changed files with 292 additions and 192 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

# https://github.com/actions/setup-java
- name: Install JDK ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
Expand All @@ -65,14 +65,14 @@ jobs:
# (This artifact is downloadable at the bottom of any job's summary page)
- name: Upload Results of ${{ matrix.type }} to Artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
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@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.type }} coverage report
path: 'dspace/target/site/jacoco-aggregate/jacoco.xml'
Expand All @@ -91,7 +91,7 @@ jobs:

# Download artifacts from previous 'tests' job
- name: Download coverage artifacts
uses: actions/download-artifact@v3
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.
Expand All @@ -101,10 +101,11 @@ jobs:
- name: Upload coverage to Codecov.io
uses: Wandalen/[email protected]
with:
action: codecov/codecov-action@v3
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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codescan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

# https://github.com/actions/setup-java
- name: Install JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
needs: dspace-dependencies
uses: ./.github/workflows/reusable-docker-build.yml
with:
build_id: dspace
build_id: dspace-prod
image_name: dspace/dspace
dockerfile_path: ./Dockerfile
secrets:
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
if: github.repository == 'dspace/dspace'
uses: ./.github/workflows/reusable-docker-build.yml
with:
build_id: dspace-postgres-pgcrypto
build_id: dspace-postgres-pgcrypto-prod
image_name: dspace/dspace-postgres-pgcrypto
# Must build out of subdirectory to have access to install script for pgcrypto.
# NOTE: this context will build the image based on the Dockerfile in the specified directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue_opened.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# Only add to project board if issue is flagged as "needs triage" or has no labels
# NOTE: By default we flag new issues as "needs triage" in our issue template
if: (contains(github.event.issue.labels.*.name, 'needs triage') || join(github.event.issue.labels.*.name) == '')
uses: actions/add-to-project@v0.5.0
uses: actions/add-to-project@v1.0.0
# Note, the authentication token below is an ORG level Secret.
# It must be created/recreated manually via a personal access token with admin:org, project, public_repo permissions
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_opened.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
# Assign the PR to whomever created it. This is useful for visualizing assignments on project boards
# See https://github.com/toshimaru/auto-author-assign
- name: Assign PR to creator
uses: toshimaru/auto-author-assign@v2.0.1
uses: toshimaru/auto-author-assign@v2.1.0
26 changes: 18 additions & 8 deletions .github/workflows/reusable-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ env:
# See "Redeploy" steps below for more details.
REDEPLOY_SANDBOX_URL: ${{ secrets.REDEPLOY_SANDBOX_URL }}
REDEPLOY_DEMO_URL: ${{ secrets.REDEPLOY_DEMO_URL }}
# Current DSpace maintenance branch (and architecture) which is deployed to demo.dspace.org / sandbox.dspace.org
# (NOTE: No deployment branch specified for sandbox.dspace.org as it uses the default_branch)
# Current DSpace branches (and architecture) which are deployed to demo.dspace.org & sandbox.dspace.org respectively
DEPLOY_DEMO_BRANCH: 'dspace-7_x'
DEPLOY_SANDBOX_BRANCH: 'dspace-8.0-testathon'
DEPLOY_ARCH: 'linux/amd64'

jobs:
Expand All @@ -93,6 +93,14 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
# This step converts the slashes in the "arch" matrix values above into dashes & saves to env.ARCH_NAME
# E.g. "linux/amd64" becomes "linux-amd64"
# This is necessary because all upload artifacts CANNOT have special chars (like slashes)
- name: Prepare
run: |
platform=${{ matrix.arch }}
echo "ARCH_NAME=${platform//\//-}" >> $GITHUB_ENV
# https://github.com/actions/checkout
- name: Checkout codebase
uses: actions/checkout@v4
Expand Down Expand Up @@ -152,9 +160,9 @@ jobs:
# Upload digest to an artifact, so that it can be used in manifest below
- name: Upload Docker build digest to artifact
if: ${{ ! matrix.isPr }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: digests-${{ inputs.build_id }}
name: digests-${{ inputs.build_id }}-${{ env.ARCH_NAME }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
Expand All @@ -166,13 +174,13 @@ jobs:
!matrix.isPR &&
env.REDEPLOY_SANDBOX_URL != '' &&
matrix.arch == env.DEPLOY_ARCH &&
github.ref_name == github.event.repository.default_branch
github.ref_name == env.DEPLOY_SANDBOX_BRANCH
run: |
curl -X POST $REDEPLOY_SANDBOX_URL
# If this build is NOT a PR and passed in a REDEPLOY_DEMO_URL secret,
# Then redeploy https://demo.dspace.org if this build is for our deployment architecture and demo branch.
- name: Redeploy demo.dspace.org (based on maintenace branch)
- name: Redeploy demo.dspace.org (based on maintenance branch)
if: |
!matrix.isPR &&
env.REDEPLOY_DEMO_URL != '' &&
Expand All @@ -192,10 +200,12 @@ jobs:
- docker-build
steps:
- name: Download Docker build digests
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: digests-${{ inputs.build_id }}
path: /tmp/digests
# Download digests for both AMD64 and ARM64 into same directory
pattern: digests-${{ inputs.build_id }}-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
7 changes: 6 additions & 1 deletion dspace-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,12 @@
<artifactId>commons-validator</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.angus</groupId>
<artifactId>jakarta.mail</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Citation extends Base {
@JsonProperty("ietf:cite-as")
private String ietfCiteAs;

@JsonProperty("url")
@JsonProperty("ietf:item")
private Url url;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,42 +105,56 @@ private void performStatusUpdate(Context context) throws SearchServiceException,
solrQuery.addFilterQuery(dateRangeFilter);
solrQuery.addField(SearchUtils.RESOURCE_ID_FIELD);
solrQuery.addField(SearchUtils.RESOURCE_UNIQUE_ID);
solrQuery.setRows(0);
QueryResponse response = solrSearchCore.getSolr().query(solrQuery, solrSearchCore.REQUEST_METHOD);

if (response != null) {
logInfoAndOut(response.getResults().size() + " items found to process");

for (SolrDocument doc : response.getResults()) {
String uuid = (String) doc.getFirstValue(SearchUtils.RESOURCE_ID_FIELD);
String uniqueId = (String) doc.getFirstValue(SearchUtils.RESOURCE_UNIQUE_ID);
logDebugAndOut("Processing item with UUID: " + uuid);

Optional<IndexableObject> indexableObject = Optional.empty();
try {
indexableObject = indexObjectServiceFactory
.getIndexableObjectFactory(uniqueId).findIndexableObject(context, uuid);
} catch (SQLException e) {
log.warn("An exception occurred when attempting to retrieve item with UUID \"" + uuid +
"\" from the database, removing related solr document", e);
}

try {
if (indexableObject.isPresent()) {
logDebugAndOut("Item exists in DB, updating solr document");
updateItem(context, indexableObject.get());
} else {
logDebugAndOut("Item doesn't exist in DB, removing solr document");
removeItem(context, uniqueId);
}
} catch (SQLException | IOException e) {
log.error(e.getMessage(), e);
if (response != null && response.getResults() != null) {
long nrOfPreDBResults = response.getResults().getNumFound();
if (nrOfPreDBResults > 0) {
logInfoAndOut(nrOfPreDBResults + " items found to process");
int batchSize = configurationService.getIntProperty("script.solr-database-resync.batch-size", 100);
for (int start = 0; start < nrOfPreDBResults; start += batchSize) {
solrQuery.setStart(start);
solrQuery.setRows(batchSize);
performStatusUpdateOnNextBatch(context, solrQuery);
}
}
}

indexingService.commit();
}

private void performStatusUpdateOnNextBatch(Context context, SolrQuery solrQuery)
throws SolrServerException, IOException {
QueryResponse response = solrSearchCore.getSolr().query(solrQuery, solrSearchCore.REQUEST_METHOD);

for (SolrDocument doc : response.getResults()) {
String uuid = (String) doc.getFirstValue(SearchUtils.RESOURCE_ID_FIELD);
String uniqueId = (String) doc.getFirstValue(SearchUtils.RESOURCE_UNIQUE_ID);
logDebugAndOut("Processing item with UUID: " + uuid);

Optional<IndexableObject> indexableObject = Optional.empty();
try {
indexableObject = indexObjectServiceFactory
.getIndexableObjectFactory(uniqueId).findIndexableObject(context, uuid);
} catch (SQLException e) {
log.warn("An exception occurred when attempting to retrieve item with UUID \"" + uuid +
"\" from the database, removing related solr document", e);
}

try {
if (indexableObject.isPresent()) {
logDebugAndOut("Item exists in DB, updating solr document");
updateItem(context, indexableObject.get());
} else {
logDebugAndOut("Item doesn't exist in DB, removing solr document");
removeItem(context, uniqueId);
}
} catch (SQLException | IOException e) {
log.error(e.getMessage(), e);
}
}
}

private void updateItem(Context context, IndexableObject indexableObject) throws SolrServerException, IOException {
Map<String,Object> fieldModifier = new HashMap<>(1);
fieldModifier.put("remove", STATUS_FIELD_PREDB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ public void update(Context context, T dso) throws SQLException, AuthorizeExcepti
// E.g. for an Author relationship,
// the place should be updated using the same principle as dc.contributor.author.
StringUtils.startsWith(metadataValue.getAuthority(), Constants.VIRTUAL_AUTHORITY_PREFIX)
&& metadataValue instanceof RelationshipMetadataValue
&& ((RelationshipMetadataValue) metadataValue).isUseForPlace()
) {
int mvPlace = getMetadataValuePlace(fieldToLastPlace, metadataValue);
Expand Down
29 changes: 20 additions & 9 deletions dspace-api/src/main/java/org/dspace/content/EntityServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.dspace.content;

import java.sql.SQLException;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -51,12 +52,7 @@ public Entity findByItemId(Context context, UUID itemId, Integer limit, Integer
@Override
public EntityType getType(Context context, Entity entity) throws SQLException {
Item item = entity.getItem();
List<MetadataValue> list = itemService.getMetadata(item, "dspace", "entity", "type", Item.ANY, false);
if (!list.isEmpty()) {
return entityTypeService.findByEntityType(context, list.get(0).getValue());
} else {
return null;
}
return itemService.getEntityType(context, item);
}

@Override
Expand Down Expand Up @@ -103,7 +99,12 @@ public List<RelationshipType> getAllRelationshipTypes(Context context, Entity en
@Override
public List<RelationshipType> getAllRelationshipTypes(Context context, Entity entity, Integer limit, Integer offset)
throws SQLException {
return relationshipTypeService.findByEntityType(context, this.getType(context, entity), limit, offset);
EntityType entityType = this.getType(context, entity);
if (entityType != null) {
return relationshipTypeService.findByEntityType(context, entityType, limit, offset);
} else {
return Collections.emptyList();
}
}

@Override
Expand All @@ -115,7 +116,12 @@ public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity e
@Override
public List<RelationshipType> getLeftRelationshipTypes(Context context, Entity entity, boolean isLeft,
Integer limit, Integer offset) throws SQLException {
return relationshipTypeService.findByEntityType(context, this.getType(context, entity), isLeft, limit, offset);
EntityType entityType = this.getType(context, entity);
if (entityType != null) {
return relationshipTypeService.findByEntityType(context, entityType, isLeft, limit, offset);
} else {
return Collections.emptyList();
}
}

@Override
Expand All @@ -128,7 +134,12 @@ public List<RelationshipType> getRightRelationshipTypes(Context context, Entity
public List<RelationshipType> getRightRelationshipTypes(Context context, Entity entity, boolean isLeft,
Integer limit, Integer offset) throws SQLException {

return relationshipTypeService.findByEntityType(context, this.getType(context, entity), isLeft, limit, offset);
EntityType entityType = this.getType(context, entity);
if (entityType != null) {
return relationshipTypeService.findByEntityType(context, entityType, isLeft, limit, offset);
} else {
return Collections.emptyList();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,18 @@ public WorkspaceItem find(Context context, int id) throws SQLException {
@Override
public WorkspaceItem create(Context context, Collection collection, boolean template)
throws AuthorizeException, SQLException {
return create(context, collection, null, template);
return create(context, collection, null, template, false);
}

@Override
public WorkspaceItem create(Context context, Collection collection, UUID uuid, boolean template)
public WorkspaceItem create(Context context, Collection collection, boolean template, boolean isNewVersion)
throws AuthorizeException, SQLException {
return create(context, collection, null, template, isNewVersion);
}

@Override
public WorkspaceItem create(Context context, Collection collection, UUID uuid, boolean template,
boolean isNewVersion)
throws AuthorizeException, SQLException {
// Check the user has permission to ADD to the collection
authorizeService.authorizeAction(context, collection, Constants.ADD);
Expand Down Expand Up @@ -174,8 +181,10 @@ public WorkspaceItem create(Context context, Collection collection, UUID uuid, b

// If configured, register identifiers (eg handle, DOI) now. This is typically used with the Show Identifiers
// submission step which previews minted handles and DOIs during the submission process. Default: false
// Additional check needed: if we are creating a new version of an existing item we skip the identifier
// generation here, as this will be performed when the new version is created in VersioningServiceImpl
if (DSpaceServicesFactory.getInstance().getConfigurationService()
.getBooleanProperty("identifiers.submission.register", false)) {
.getBooleanProperty("identifiers.submission.register", false) && !isNewVersion) {
try {
// Get map of filters to use for identifier types, while the item is in progress
Map<Class<? extends Identifier>, Filter> filters = FilterUtils.getIdentifierFilters(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public static DSpaceObject createDSpaceObject(Context context, DSpaceObject pare
wsi = workspaceItemService.create(context, (Collection)parent, params.useCollectionTemplate());
} else {
wsi = workspaceItemService.create(context, (Collection)parent,
uuid, params.useCollectionTemplate());
uuid, params.useCollectionTemplate(), false);
}

// Please note that we are returning an Item which is *NOT* yet in the Archive,
Expand Down
Loading

0 comments on commit 450dde5

Please sign in to comment.