Skip to content

Commit

Permalink
UFAL/Release fixed conflicts (#866)
Browse files Browse the repository at this point in the history
* UFAL/Removed duplicities of the bitstreams in the cmdi (#766)

* Removed duplicities of the bitstreams in the cmdi.

* used lindat code instead of vanilla.

* Ufal/Preview issues (#764)

* Ensure the content preview doesn't overload maximum length of the column in the database. And encode the input stream into UTF-8.

* Do not store HTML content in the database because it could be longer than the limit of the database column.

* UFAL/Encoded the UTF-8 characters from the redirect URL to UTF (#758)

* Encoded the UTF-8 characters from the redirect URL to UTF

* Moved ClarinUtils into Utils class

* Added a new `dq` package into ComponentScan

* Moved dq.Utils into DSpace utils.Utils because the components with the same name causes conflicts.

* Removed *.dq component scan from the App

* Merge pull request DSpace#9790 from DSpace/backport-9775-to-dspace-7_x (#769)

[Port dspace-7_x] Make statistics autocommit much more frequently

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

* test for bitstream with null value of sizebytes

* Update README.md

* UFAL/Shibboleth - load more net-id headers e.g. persistent-id (#772)

* Load netid from more than one header. authentication-shibboleth.netid-header could be list, not only single value

* Shibboleth login - sort the emails passed in the shibboleth email header and get the first one.

* The user is redirected to the login page when it is trying to update eperson email which is already assigned to another eperson.

* Sorting emails is moved into specific method and ShibbolethLoginFilter is updated following the ShibAuthentication changes

* The ClarinShibbolethLoginFilter and ClarinShibAuthentication has duplicate code, I put it into static method.

* Propagate the verification token to the DB after the email is successfully sent. (#786)

* UFAL/Enhanced type-bind feature (#762)

* type bind is correctly rendered in the FE, but BE is still not working

* Synchronized the `submission-forms_cs.xml`

* Added doc into `submission-forms` about enhanced type-bind `field`

* Updated `local.cfg` for tests - added type-bind property

* Updated docs for the customized type-bind configuration property.

* Updated MetadataValidation following the type-bind customization.

* Added isAllowed function for multiple type-bind definitions

* Added some docs for the new method

* The values of the input wasn't loaded.

* Allowed fields could be empty when they should have values.

* Used isEmpty function and created constant for the `=>`.

* create preview content for tar files (#759)

* create preview content for tar files

* Added right logs

* devided extractFile funs into several separated smaller funs

* added comment and removed empty line

* added empty lines and removed unwanted comments

* removed empty line

* used consts

* try incorrect identification level

* log errors and removed unneeded consts

---------

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

* Internal/fix failing Clarin integration test (#796)

* Initial commit

* Ignore the test class from where the tests has started failing.

* Ignored half of tests in the ClarinShibbolethLoginFilterIT file

* Ignored all tests

* unignore some tests

* 3 tests ignored 3 allowed

* Maybe the problematic test is hidden between 3 unignored tests

* two candidates

* The last candidate

* Ignore just wrong test and all test should pass

* Clean up object created in the test.

* Removed unused import.

* Check the user which is going to be deleted is not null.

* Rest api for handle resolution with metadata

* decoded rawvalues and response json modification

* used static extractMetadata funct in HandlePlugin

* return dict:

* removed property for test from local

* Add default licenses - from ZCU update (#801)

* Added flyway file to insert default licenses with license labels and mappings

* Added required header

* UFAL/share submission by email (#780)

* Updated table workspace with share token, created endpoint to generate share token and it is sent via email

* Added method to get workspaceitem via share token.

* Added an endpoint for changing the submission's owner.

* Added license headers

* Added test for fetching item with share Token

* Added tests to check the owner is changed

* Added better explanation why the BE must return Page object in the search endpoint

* Validate the user in the SubmissionController, it cannot be null

* Updated email - some values are fetched directly from the configuration property

* Updated preAuthorization method to ADD instead of WRITE (write is used for controlling authorization for modifying the Item) and updated shareURL

* Authorize the submitter which is trying to take sharing item via shareToken.

* Update integration test following the feature update

* Import default licenses only if the license tables are empty. (#808)

* Oai elg crosswalk (#798)

* problem with language code

* fix amount and sizeUnitOther rest-tests errors

* added language coding

* new language and funding project mishmash array position

* added isoCodes

* removed handle from item submission (#812)

* UFAL/Shibboleth - netid-header should use getArrayProperty everywhere (#807)

* Fetch netid as array from the cfg. Now netid as array is used everywhere. Added integration test to ask for an email when the user send only persistent-id in the shib header.

* The user is not signed in without using link with the verification token from the email/ (#809)

* UFAL/Shibboleth - show error in the UI when shibboleth authentication is failed (#810)

* The user is not signed in without using link with the verification token from the email/

* Send a redirect to UI with specific parameter that the Shibboleth authorization wasn't successful

* UFAL/Autocomplete enhancement (#768)

* Added solr index `handle_title_ac` and `_comp` for the Item

* Added support for searching results from specific solr indexes.

1. Updated submission-forms autocomplete definition to specify a specific index. 2. Updated configuration is provided via REST API. 3. Create a new `/suggestions` endpoint for searching values from custom solr index - it returns VocabularyEntry page.

* Supported searching Item byHandle when passed a handle as parameter without handle canonical prefix.

* Added autocompleteCustom `solr-subject_ac` and `handle_title_ac`.

* Added autocompleteCustom `solr-publisher_ac`.

* Added cfg property to define a separator from the solr value to get only display value.

* Added autocompleteCustom `solr-dataProvider_ac`

* Refactored code and created integration test for the SuggestionRestController

* Updated suggestion integration tests because it has had a conflict with another IT

* Added doc and changed `autocomplete.custom.format` to `autocomplete.custom.separator` for proper naming.

* Added support for loading suggestions from the json file - need to refactor.

* Refactored and added docs.

* Created tests and fixed failing ones due to updated solr definition

* Synchronized submission-forms_cs.xml with the original-english one

* Added docs about magic constants

* Added doc why the handle is updated to canonical form in the searchbyHandle endpoint

* Allow searching only within the solr indexes or JSON files permitted by the configuration.

* Removed normalization of handle prefix because there could be more prefixes. Expect only handle value.

* Fixed if condition and config property default value.

* Fixed integration tests. Allowed autocomplete custom was missing in the test cfg.

* The suggestion endpoint is allowed only for authorized users

* Refactored method for the normalizing the query for the discoverQuery and added unit tests.

* UFAL/Changed position of rows in submission-forms.xml following v5 (#802)

* Changed position of rows in submission-forms.xml following v5

* Fixed the alignment of some text

* Removed rows which are not in the v5

* Removed license selector from the `teaching` and `clariah-data` collections

* Updated input differences in the submission-forms.xml following the v5.

---------

Co-authored-by: Juraj Roka <[email protected]>
Co-authored-by: milanmajchrak <[email protected]>

* Show db connection statistics in the log file or the `dbstatistics` endpoint (#815)

* Show db statistics in the log file or the `dbstatistics` endpoint

* Finding out why github checks are failed - undo hibernate.cfg

* Disabled automatic logging

* Use scheduled CRON job instead of PostConstruct

* hibernate generating property true

---------

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

* Translation of submission-forms to _cs (#816)

* Translation of submission-forms to _cs

* Translated bitstream metadata and complex input fields

* Translated the rest of submission-froms_cs.xml

* Fixed regex... it must contain regex value, not the message.

---------

Co-authored-by: Juraj Roka <[email protected]>
Co-authored-by: milanmajchrak <[email protected]>

* Updated cfg to pretify the author suggestions (#819)

* crosswalk-embargo (#821)

* added fn for embargo

* using of res policy end_date and added comments

* fix string format problem with %s

* integration tests are falling down

* removed findHandle duplicity

* For now the complex input field is without autocomplete for the size and contact person (#823)

* Send the custom type bind `field` to the FE configuration (#822)

* fix date converting to string

* cherry-picked DataCite related changes from customer/uk

* Add a script that adds a file from url to an item

* intended for large file workflows

* Add ways to influence the bitstream name

* add more options to specify an item

* Expose resourceId (DSpace#1134)

A BE part of DSpace#1127 - this exposes the resourceId so it can be used in the handle mgmt table

* fixes ufal#1135 - findEpersonByNetId should stop searching when it finds an eperson

- moved the `return eperson` inside the for cycle (after eperson non null
check).
- removed the eperson param (both callers were passing in `null`)

* Test release without db logs (#827)

* UFAL/Matomo statistics with dimension (#813)

* Updated the version of matomo dependency and tried to change request from Custom Variables to Dimension

* Added a custom dimension with item's handle URL

* Send custom dimension also in oai tracker

* Use only IPv4 address, the Matomo tracker has a problem with IPv6

* Do not change custom dimension when the Item is null

* First custom dimension should have ID '1'.

* Use a valid URL for Matomo tracker in the IT

* Configure handle custom dimension ID in the clarin-dspace.cfg

* Refactored ipv4 method to be more readable - return null

---------

Co-authored-by: Juraj Roka <[email protected]>
Co-authored-by: milanmajchrak <[email protected]>
Co-authored-by: milanmajchrak <[email protected]>

* The `dspace.name.short` is not working properly in the email, use `dspace.shortname` instead (#828)

* Assinging to JAVA_OPTS_HANDLE must be without $

* Transaction bug - close context in finally block (#845) (#852)

* Transaction bug - see differencies (#845)

* Logging hibernate statistics doesn't work as expected.

* Undo connection pool timeout contants

* Removed a huge amount of log.info

* Added abort to try catch blocks to check if it will solve IT

* Call aborting the context in the finally block of the StatelessAuthenticationFilter

---------

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

* Empty commit to run actions

* Added a warning message then the transaction is alive during initializing a new Context.

* Updated the `actions/upload-artifact` to v4 becausa of `https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/`

* Show warning when the transaction is alive when the dbConnection is created

---------

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

* metadata-added-provenance (#730)

* added provenance metadata for update, remove and add

* added provenance metadata for update and remove bitstream

* item test json added metadata provenance

* control provenance only by tests of item

* update and remove license

* provenance access control and upload bitstream

* provenance move item to different collection

* provenance make item non-discoverable

* provenance for mapped collection

* don't write provenance for bitstream without item

* move addProvenance to parent class

* separated class for provenance

* create class for provenance management

* added metadata item and bitstream tests

* tests for metadata provenance

* problem with access control test

* better service management:

* delete clarin license mapping

* added json to resources

* modified provenance patch messages

* messages bags

* used correct json

* log exception, replace ! by non conds, added doc comments

* added logs for replacing mtd

* make object from provenance service

* removed interface prom provenance msg provider

* Refactored method `removeReadPolicies` - add provenance after removing policy

* The message templates are loaded from the Enum instead of json file.

* The `getMessage` methods was overloaded.

* Renamed `getItem` to `findItemByBitstream` to clarify the method's purpose.

* Do not throw exception when adding to provenance

* The exceptions are caught in the ProvenanceProvider and changed order when calling provenance methods.

* Renamed ProvenanceProvider to ProvenanceService and refactored it to be used as Spring Service.

* The ProvenanceService wasn't initialized in the BundleAccessControl

* Removed the code without any effect

* Removed the logging which is not required

* Moved calling od the provenance service to better place.

---------

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

* Facet result for suggestion (#854)

* Retrieve the suggestions from the facet results instead of a specific bunch of results

* Removed not required log.

* Healthcheck process (#853)

* Checkouted files from the `healthcheck-process` branch and updated the code, also added integration test.

* Changed the name of the test.

* Updated the description to be consistent with another descriptions.

* Refactored the calling the check.run method, use `check.report` instead.

* Changed matomo url to some valid URL

* Update the url to some non-existing url.

* Oai indexing after res policy change (#855)

* Fixed nullpointer exception - when the dso object was null and was accessed.

* The condition was added to the boolean property.

* Run build action every 4 hours to be sure tests are still passing.

* The dc.type should not be repeatable (#861)

* UFAL/Health report send to more email adresses 

Co-authored-by: Matus Kasak <[email protected]>

* UFAL/Fixed missing `*` character in the required input field

* Res policy for submitter (#862)

* created res policy if eperson is submitter

* allowed submitter edit metadata only in collections from cfg

* test for ID collection allowed by cfg

* created res policy during item installation, tests

* added check if user is submitter

* renamed property, default value if is not defined

* added comments why the property is not commented

* Do not merge flyway script with default licenses.

* Removed unuseful comment

---------

Co-authored-by: Tim Donohue <[email protected]>
Co-authored-by: Paurikova2 <[email protected]>
Co-authored-by: Jozef Misutka <[email protected]>
Co-authored-by: jurinecko <[email protected]>
Co-authored-by: Juraj Roka <[email protected]>
Co-authored-by: Paurikova2 <[email protected]>
Co-authored-by: Ondřej Košarko <[email protected]>
Co-authored-by: jm <jm@maz>
Co-authored-by: Kasinhou <[email protected]>
Co-authored-by: Matus Kasak <[email protected]>
  • Loading branch information
11 people authored Feb 4, 2025
1 parent fc9124f commit 61a9166
Show file tree
Hide file tree
Showing 50 changed files with 2,535 additions and 118 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.dspace.content.service.ItemService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.ProvenanceService;
import org.dspace.discovery.DiscoverQuery;
import org.dspace.discovery.SearchService;
import org.dspace.discovery.SearchServiceException;
Expand Down Expand Up @@ -111,6 +112,8 @@ public class BulkAccessControl extends DSpaceRunnable<BulkAccessControlScriptCon

protected String eperson = null;

protected ProvenanceService provenanceService = ContentServiceFactory.getInstance().getProvenanceService();

@Override
@SuppressWarnings("unchecked")
public void setup() throws ParseException {
Expand Down Expand Up @@ -465,6 +468,7 @@ private void setItemPolicies(Item item, BulkAccessControlInput accessControl)
itemAccessConditions.get(accessCondition.getName())));

itemService.adjustItemPolicies(context, item, item.getOwningCollection(), false);
provenanceService.setItemPolicies(context, item, accessControl);
}

/**
Expand Down Expand Up @@ -580,6 +584,7 @@ private void setBitstreamPolicies(Bitstream bitstream, Item item, BulkAccessCont

itemService.adjustBitstreamPolicies(context, item, item.getOwningCollection(), bitstream);
mediaFilterService.updatePoliciesOfDerivativeBitstreams(context, item, bitstream);
provenanceService.setBitstreamPolicies(context, bitstream, item, accessControl);
}

/**
Expand Down
221 changes: 221 additions & 0 deletions dspace-api/src/main/java/org/dspace/app/healthreport/HealthReport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.healthreport;

import static org.apache.commons.io.IOUtils.toInputStream;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import javax.mail.MessagingException;

import org.apache.commons.cli.ParseException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.core.Context;
import org.dspace.core.Email;
import org.dspace.core.I18nUtil;
import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.eperson.service.EPersonService;
import org.dspace.health.Check;
import org.dspace.health.Report;
import org.dspace.health.ReportInfo;
import org.dspace.scripts.DSpaceRunnable;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.utils.DSpace;

/**
* This class is used to generate a health report of the DSpace instance.
* @author Matus Kasak (dspace at dataquest.sk)
* @author Milan Majchrak (dspace at dataquest.sk)
*/
public class HealthReport extends DSpaceRunnable<HealthReportScriptConfiguration> {
ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
private static final Logger log = LogManager.getLogger(HealthReport.class);
private EPersonService ePersonService;

/**
* Checks to be performed.
*/
private static final LinkedHashMap<String, Check> checks = Report.checks();

/**
* `-i`: Info, show help information.
*/
private boolean info = false;

/**
* `-e`: Email, send report to specified email address.
*/
private String[] emails;

/**
* `-c`: Check, perform only specific check by index (0-`getNumberOfChecks()`).
*/
private int specificCheck = -1;

/**
* `-f`: For, specify the last N days to consider.
* Default value is set in dspace.cfg.
*/
private int forLastNDays = configurationService.getIntProperty("healthcheck.last_n_days");

/**
* `-o`: Output, specify a file to save the report.
*/
private String fileName;

@Override
public HealthReportScriptConfiguration getScriptConfiguration() {
return new DSpace().getServiceManager()
.getServiceByName("health-report", HealthReportScriptConfiguration.class);
}

@Override
public void setup() throws ParseException {
ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
// `-i`: Info, show help information.
if (commandLine.hasOption('i')) {
info = true;
return;
}

// `-e`: Email, send report to specified email address.
if (commandLine.hasOption('e')) {
emails = commandLine.getOptionValues('e');
handler.logInfo("\nReport sent to this email address: " + String.join(", ", emails));
}

// `-c`: Check, perform only specific check by index (0-`getNumberOfChecks()`).
if (commandLine.hasOption('c')) {
String checkOption = commandLine.getOptionValue('c');
try {
specificCheck = Integer.parseInt(checkOption);
if (specificCheck < 0 || specificCheck >= getNumberOfChecks()) {
specificCheck = -1;
}
} catch (NumberFormatException e) {
log.info("Invalid value for check. It has to be a number from the displayed range.");
return;
}
}

// `-f`: For, specify the last N days to consider.
if (commandLine.hasOption('f')) {
String daysOption = commandLine.getOptionValue('f');
try {
forLastNDays = Integer.parseInt(daysOption);
} catch (NumberFormatException e) {
log.info("Invalid value for last N days. Argument f has to be a number.");
return;
}
}

// `-o`: Output, specify a file to save the report.
if (commandLine.hasOption('o')) {
fileName = commandLine.getOptionValue('o');
}
}

@Override
public void internalRun() throws Exception {
if (info) {
printHelp();
return;
}

ReportInfo ri = new ReportInfo(this.forLastNDays);

StringBuilder sbReport = new StringBuilder();
sbReport.append("\n\nHEALTH REPORT:\n");

int position = -1;
for (Map.Entry<String, Check> check_entry : Report.checks().entrySet()) {
++position;
if (specificCheck != -1 && specificCheck != position) {
continue;
}

String name = check_entry.getKey();
Check check = check_entry.getValue();

log.info("#{}. Processing [{}] at [{}]", position, name, new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss.SSS").format(new Date()));

sbReport.append("\n######################\n\n").append(name).append(":\n");
check.report(ri);
sbReport.append(check.getReport());
}

// save output to file
if (fileName != null) {
Context context = new Context();
context.setCurrentUser(ePersonService.find(context, this.getEpersonIdentifier()));

InputStream inputStream = toInputStream(sbReport.toString(), StandardCharsets.UTF_8);
handler.writeFilestream(context, fileName, inputStream, "export");

context.restoreAuthSystemState();
context.complete();
}

// send email to email address from argument
if (emails != null && emails.length > 0) {
try {
Email e = Email.getEmail(I18nUtil.getEmailFilename(Locale.getDefault(), "healthcheck"));
for (String recipient : emails) {
e.addRecipient(recipient);
}
e.addArgument(sbReport.toString());
e.send();
} catch (IOException | MessagingException e) {
log.error("Error sending email:", e);
}
}

handler.logInfo(sbReport.toString());
}

@Override
public void printHelp() {
handler.logInfo("\n\nINFORMATION\nThis process creates a health report of your DSpace.\n" +
"You can choose from these available options:\n" +
" -i, --info Show help information\n" +
" -e, --email Send report to specified email address\n" +
" -c, --check Perform only specific check by index (0-" + (getNumberOfChecks() - 1) + ")\n" +
" -f, --for Specify the last N days to consider\n" +
" -o, --output Specify a file to save the report\n\n" +
"If you want to execute only one check using -c, use check index:\n" + checksNamesToString() + "\n"
);
}

/**
* Convert checks names to string.
*/
private String checksNamesToString() {
StringBuilder names = new StringBuilder();
int pos = 0;
for (String name : checks.keySet()) {
names.append(String.format(" %d. %s\n", pos++, name));
}
return names.toString();
}

/**
* Get the number of checks. This is used for the `-c` option.
*/
public static int getNumberOfChecks() {
return checks.size();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.healthreport;

import org.apache.commons.cli.Options;
import org.dspace.scripts.configuration.ScriptConfiguration;

/**
* This class represents a HealthReport that is used in the CLI.
* @author Matus Kasak (dspace at dataquest.sk)
*/
public class HealthReportScriptConfiguration<T extends HealthReport> extends ScriptConfiguration<T> {

private Class<T> dspaceRunnableclass;

@Override
public Class<T> getDspaceRunnableClass() {
return dspaceRunnableclass;
}

@Override
public void setDspaceRunnableClass(Class<T> dspaceRunnableClass) {
this.dspaceRunnableclass = dspaceRunnableClass;
}

@Override
public Options getOptions() {
if (options == null) {
Options options = new Options();
options.addOption("i", "info", false,
"Show help information.");
options.addOption("e", "email", true,
"Send report to this email address.");
options.getOption("e").setType(String.class);
options.addOption("c", "check", true,
String.format("Perform only specific check (use index from 0 to %d, " +
"otherwise perform default checks).", HealthReport.getNumberOfChecks() - 1));
options.getOption("c").setType(String.class);
options.addOption("f", "for", true,
"Report for last N days. Used only in general information for now.");
options.getOption("f").setType(String.class);
options.addOption("o", "output", true,
"Save report to the file.");

super.options = options;
}
return options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.ProvenanceService;
import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group;
import org.dspace.eperson.service.GroupService;
Expand Down Expand Up @@ -51,6 +52,12 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService {
@Autowired
private GroupService groupService;

@Autowired
ProvenanceService provenanceService;

@Autowired
ResourcePolicyService resourcePolicyService;

protected ResourcePolicyServiceImpl() {
}

Expand Down Expand Up @@ -233,12 +240,17 @@ public void removePolicies(Context c, DSpaceObject o, String type) throws SQLExc
}

@Override
public void removePolicies(Context c, DSpaceObject o, String type, int action)
throws SQLException, AuthorizeException {
public void removePolicies(Context c, DSpaceObject o, String type, int action)
throws SQLException, AuthorizeException {
// Get all read policies of the dso before removing them
List<ResourcePolicy> resPolicies = resourcePolicyService.find(c, o, type);

resourcePolicyDAO.deleteByDsoAndTypeAndAction(c, o, type, action);
c.turnOffAuthorisationSystem();
contentServiceFactory.getDSpaceObjectService(o).updateLastModified(c, o);
c.restoreAuthSystemState();

provenanceService.removeReadPolicies(c, o, resPolicies);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.dspace.content.service.RelationshipService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.ProvenanceService;
import org.dspace.handle.service.HandleService;
import org.dspace.identifier.service.IdentifierService;
import org.dspace.utils.DSpace;
Expand Down Expand Up @@ -67,6 +68,8 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
protected MetadataAuthorityService metadataAuthorityService;
@Autowired(required = true)
protected RelationshipService relationshipService;
@Autowired(required = true)
protected ProvenanceService provenanceService;

public DSpaceObjectServiceImpl() {

Expand Down Expand Up @@ -377,6 +380,7 @@ public void clearMetadata(Context context, T dso, String schema, String element,
}
}
dso.setMetadataModified();
provenanceService.removeMetadata(context, dso, schema, element, qualifier);
}

@Override
Expand Down
Loading

0 comments on commit 61a9166

Please sign in to comment.