mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge branch 'main' into DURACOM-127
This commit is contained in:
@@ -654,60 +654,6 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Policies policies READ for the date in input adding reason. New policies are assigned automatically
|
||||
* at the groups that
|
||||
* have right on the collection. E.g., if the anonymous can access the collection policies are assigned to
|
||||
* anonymous.
|
||||
*
|
||||
* @param context The relevant DSpace Context.
|
||||
* @param embargoDate embargo end date
|
||||
* @param reason embargo reason
|
||||
* @param dso DSpace object
|
||||
* @param owningCollection collection to get group policies from
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
@Override
|
||||
public void generateAutomaticPolicies(Context context, Date embargoDate,
|
||||
String reason, DSpaceObject dso, Collection owningCollection)
|
||||
throws SQLException, AuthorizeException {
|
||||
|
||||
if (embargoDate != null || (embargoDate == null && dso instanceof Bitstream)) {
|
||||
|
||||
List<Group> authorizedGroups = getAuthorizedGroups(context, owningCollection, Constants.DEFAULT_ITEM_READ);
|
||||
|
||||
removeAllPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);
|
||||
|
||||
// look for anonymous
|
||||
boolean isAnonymousInPlace = false;
|
||||
for (Group g : authorizedGroups) {
|
||||
if (StringUtils.equals(g.getName(), Group.ANONYMOUS)) {
|
||||
isAnonymousInPlace = true;
|
||||
}
|
||||
}
|
||||
if (!isAnonymousInPlace) {
|
||||
// add policies for all the groups
|
||||
for (Group g : authorizedGroups) {
|
||||
ResourcePolicy rp = createOrModifyPolicy(null, context, null, g, null, embargoDate, Constants.READ,
|
||||
reason, dso);
|
||||
if (rp != null) {
|
||||
resourcePolicyService.update(context, rp);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// add policy just for anonymous
|
||||
ResourcePolicy rp = createOrModifyPolicy(null, context, null,
|
||||
groupService.findByName(context, Group.ANONYMOUS), null,
|
||||
embargoDate, Constants.READ, reason, dso);
|
||||
if (rp != null) {
|
||||
resourcePolicyService.update(context, rp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson,
|
||||
int type, String rpType) throws SQLException, AuthorizeException {
|
||||
|
@@ -470,24 +470,6 @@ public interface AuthorizeService {
|
||||
public ResourcePolicy findByTypeGroupAction(Context c, DSpaceObject dso, Group group, int action)
|
||||
throws SQLException;
|
||||
|
||||
|
||||
/**
|
||||
* Generate Policies policies READ for the date in input adding reason. New policies are assigned automatically
|
||||
* at the groups that
|
||||
* have right on the collection. E.g., if the anonymous can access the collection policies are assigned to
|
||||
* anonymous.
|
||||
*
|
||||
* @param context current context
|
||||
* @param embargoDate date
|
||||
* @param reason reason
|
||||
* @param dso DSpaceObject
|
||||
* @param owningCollection collection
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
public void generateAutomaticPolicies(Context context, Date embargoDate, String reason, DSpaceObject dso,
|
||||
Collection owningCollection) throws SQLException, AuthorizeException;
|
||||
|
||||
public ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson,
|
||||
int type, String rpType) throws SQLException, AuthorizeException;
|
||||
|
||||
@@ -603,7 +585,7 @@ public interface AuthorizeService {
|
||||
|
||||
/**
|
||||
* Replace all the policies in the target object with exactly the same policies that exist in the source object
|
||||
*
|
||||
*
|
||||
* @param context DSpace Context
|
||||
* @param source source of policies
|
||||
* @param dest destination of inherited policies
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.content;
|
||||
|
||||
import static org.dspace.core.Constants.ADD;
|
||||
import static org.dspace.core.Constants.READ;
|
||||
import static org.dspace.core.Constants.REMOVE;
|
||||
import static org.dspace.core.Constants.WRITE;
|
||||
|
||||
@@ -34,6 +35,7 @@ import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogHelper;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.event.Event;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -74,14 +76,14 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
if (bundle == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(LogHelper.getHeader(context, "find_bundle",
|
||||
"not_found,bundle_id=" + id));
|
||||
"not_found,bundle_id=" + id));
|
||||
}
|
||||
|
||||
return null;
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(LogHelper.getHeader(context, "find_bundle",
|
||||
"bundle_id=" + id));
|
||||
"bundle_id=" + id));
|
||||
}
|
||||
|
||||
return bundle;
|
||||
@@ -106,7 +108,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
|
||||
|
||||
log.info(LogHelper.getHeader(context, "create_bundle", "bundle_id="
|
||||
+ bundle.getID()));
|
||||
+ bundle.getID()));
|
||||
|
||||
// if we ever use the identifier service for bundles, we should
|
||||
// create the bundle before we create the Event and should add all
|
||||
@@ -132,12 +134,12 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
|
||||
@Override
|
||||
public void addBitstream(Context context, Bundle bundle, Bitstream bitstream)
|
||||
throws SQLException, AuthorizeException {
|
||||
throws SQLException, AuthorizeException {
|
||||
// Check authorisation
|
||||
authorizeService.authorizeAction(context, bundle, Constants.ADD);
|
||||
|
||||
log.info(LogHelper.getHeader(context, "add_bitstream", "bundle_id="
|
||||
+ bundle.getID() + ",bitstream_id=" + bitstream.getID()));
|
||||
+ bundle.getID() + ",bitstream_id=" + bitstream.getID()));
|
||||
|
||||
// First check that the bitstream isn't already in the list
|
||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||
@@ -167,28 +169,61 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
|
||||
|
||||
context.addEvent(new Event(Event.ADD, Constants.BUNDLE, bundle.getID(),
|
||||
Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()),
|
||||
getIdentifiers(context, bundle)));
|
||||
Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()),
|
||||
getIdentifiers(context, bundle)));
|
||||
|
||||
// copy authorization policies from bundle to bitstream
|
||||
// FIXME: multiple inclusion is affected by this...
|
||||
authorizeService.inheritPolicies(context, bundle, bitstream);
|
||||
// The next logic is a bit overly cautious but ensures that if there are any future start dates
|
||||
// on the item or bitstream read policies, that we'll skip inheriting anything from the owning collection
|
||||
// just in case. In practice, the item install process would overwrite these anyway but it may satisfy
|
||||
// some other bitstream creation methods and integration tests
|
||||
boolean isEmbargoed = false;
|
||||
for (ResourcePolicy resourcePolicy : authorizeService.getPoliciesActionFilter(context, owningItem, READ)) {
|
||||
if (!resourcePolicyService.isDateValid(resourcePolicy)) {
|
||||
isEmbargoed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (owningItem != null && !isEmbargoed) {
|
||||
// Resolve owning collection
|
||||
Collection owningCollection = owningItem.getOwningCollection();
|
||||
if (owningCollection != null) {
|
||||
// Get DEFAULT_BITSTREAM_READ policy from the collection
|
||||
List<Group> defaultBitstreamReadGroups =
|
||||
authorizeService.getAuthorizedGroups(context, owningCollection,
|
||||
Constants.DEFAULT_BITSTREAM_READ);
|
||||
log.info(defaultBitstreamReadGroups.size());
|
||||
// If this collection is configured with a DEFAULT_BITSTREAM_READ group, overwrite the READ policy
|
||||
// inherited from the bundle with this policy.
|
||||
if (!defaultBitstreamReadGroups.isEmpty()) {
|
||||
// Remove read policies from the bitstream
|
||||
authorizeService.removePoliciesActionFilter(context, bitstream, Constants.READ);
|
||||
for (Group defaultBitstreamReadGroup : defaultBitstreamReadGroups) {
|
||||
// Inherit this policy as READ, directly from the collection roles
|
||||
authorizeService.addPolicy(context, bitstream,
|
||||
Constants.READ, defaultBitstreamReadGroup, ResourcePolicy.TYPE_INHERITED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bitstreamService.update(context, bitstream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBitstream(Context context, Bundle bundle, Bitstream bitstream)
|
||||
throws AuthorizeException, SQLException, IOException {
|
||||
throws AuthorizeException, SQLException, IOException {
|
||||
// Check authorisation
|
||||
authorizeService.authorizeAction(context, bundle, Constants.REMOVE);
|
||||
|
||||
log.info(LogHelper.getHeader(context, "remove_bitstream",
|
||||
"bundle_id=" + bundle.getID() + ",bitstream_id=" + bitstream.getID()));
|
||||
"bundle_id=" + bundle.getID() + ",bitstream_id=" + bitstream.getID()));
|
||||
|
||||
|
||||
context.addEvent(new Event(Event.REMOVE, Constants.BUNDLE, bundle.getID(),
|
||||
Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()),
|
||||
getIdentifiers(context, bundle)));
|
||||
Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()),
|
||||
getIdentifiers(context, bundle)));
|
||||
|
||||
//Ensure that the last modified from the item is triggered !
|
||||
Item owningItem = (Item) getParentObject(context, bundle);
|
||||
@@ -221,9 +256,9 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
|
||||
@Override
|
||||
public void inheritCollectionDefaultPolicies(Context context, Bundle bundle, Collection collection)
|
||||
throws SQLException, AuthorizeException {
|
||||
throws SQLException, AuthorizeException {
|
||||
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, collection,
|
||||
Constants.DEFAULT_BITSTREAM_READ);
|
||||
Constants.DEFAULT_BITSTREAM_READ);
|
||||
|
||||
// change the action to just READ
|
||||
// just don't call update on the resourcepolicies!!!
|
||||
@@ -231,7 +266,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
|
||||
if (!i.hasNext()) {
|
||||
throw new java.sql.SQLException("Collection " + collection.getID()
|
||||
+ " has no default bitstream READ policies");
|
||||
+ " has no default bitstream READ policies");
|
||||
}
|
||||
|
||||
List<ResourcePolicy> newPolicies = new ArrayList<ResourcePolicy>();
|
||||
@@ -246,7 +281,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
|
||||
@Override
|
||||
public void replaceAllBitstreamPolicies(Context context, Bundle bundle, List<ResourcePolicy> newpolicies)
|
||||
throws SQLException, AuthorizeException {
|
||||
throws SQLException, AuthorizeException {
|
||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||
if (CollectionUtils.isNotEmpty(bitstreams)) {
|
||||
for (Bitstream bs : bitstreams) {
|
||||
@@ -368,16 +403,16 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
if (bitstream == null) {
|
||||
//This should never occur but just in case
|
||||
log.warn(LogHelper.getHeader(context, "Invalid bitstream id while changing bitstream order",
|
||||
"Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId));
|
||||
"Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId));
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we have a Bitstream not in the current list, log a warning & exit immediately
|
||||
if (!currentBitstreams.contains(bitstream)) {
|
||||
log.warn(LogHelper.getHeader(context,
|
||||
"Encountered a bitstream not in this bundle while changing bitstream " +
|
||||
"order. Bitstream order will not be changed.",
|
||||
"Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId));
|
||||
"Encountered a bitstream not in this bundle while changing bitstream " +
|
||||
"order. Bitstream order will not be changed.",
|
||||
"Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId));
|
||||
return;
|
||||
}
|
||||
updatedBitstreams.add(bitstream);
|
||||
@@ -386,9 +421,9 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
// If our lists are different sizes, exit immediately
|
||||
if (updatedBitstreams.size() != currentBitstreams.size()) {
|
||||
log.warn(LogHelper.getHeader(context,
|
||||
"Size of old list and new list do not match. Bitstream order will not be " +
|
||||
"changed.",
|
||||
"Bundle: " + bundle.getID()));
|
||||
"Size of old list and new list do not match. Bitstream order will not be " +
|
||||
"changed.",
|
||||
"Bundle: " + bundle.getID()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -434,7 +469,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
} else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamDeletion()) {
|
||||
adminObject = collection;
|
||||
} else if (AuthorizeConfiguration
|
||||
.canCommunityAdminPerformBitstreamDeletion()) {
|
||||
.canCommunityAdminPerformBitstreamDeletion()) {
|
||||
adminObject = community;
|
||||
}
|
||||
break;
|
||||
@@ -442,10 +477,10 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
if (AuthorizeConfiguration.canItemAdminPerformBitstreamCreation()) {
|
||||
adminObject = item;
|
||||
} else if (AuthorizeConfiguration
|
||||
.canCollectionAdminPerformBitstreamCreation()) {
|
||||
.canCollectionAdminPerformBitstreamCreation()) {
|
||||
adminObject = collection;
|
||||
} else if (AuthorizeConfiguration
|
||||
.canCommunityAdminPerformBitstreamCreation()) {
|
||||
.canCommunityAdminPerformBitstreamCreation()) {
|
||||
adminObject = community;
|
||||
}
|
||||
break;
|
||||
@@ -477,7 +512,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
// Check authorisation
|
||||
//AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE);
|
||||
log.info(LogHelper.getHeader(context, "update_bundle", "bundle_id="
|
||||
+ bundle.getID()));
|
||||
+ bundle.getID()));
|
||||
|
||||
super.update(context, bundle);
|
||||
bundleDAO.save(context, bundle);
|
||||
@@ -485,10 +520,10 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
if (bundle.isModified() || bundle.isMetadataModified()) {
|
||||
if (bundle.isMetadataModified()) {
|
||||
context.addEvent(new Event(Event.MODIFY_METADATA, bundle.getType(), bundle.getID(), bundle.getDetails(),
|
||||
getIdentifiers(context, bundle)));
|
||||
getIdentifiers(context, bundle)));
|
||||
}
|
||||
context.addEvent(new Event(Event.MODIFY, Constants.BUNDLE, bundle.getID(),
|
||||
null, getIdentifiers(context, bundle)));
|
||||
null, getIdentifiers(context, bundle)));
|
||||
bundle.clearModified();
|
||||
bundle.clearDetails();
|
||||
}
|
||||
@@ -497,12 +532,12 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
|
||||
@Override
|
||||
public void delete(Context context, Bundle bundle) throws SQLException, AuthorizeException, IOException {
|
||||
log.info(LogHelper.getHeader(context, "delete_bundle", "bundle_id="
|
||||
+ bundle.getID()));
|
||||
+ bundle.getID()));
|
||||
|
||||
authorizeService.authorizeAction(context, bundle, Constants.DELETE);
|
||||
|
||||
context.addEvent(new Event(Event.DELETE, Constants.BUNDLE, bundle.getID(),
|
||||
bundle.getName(), getIdentifiers(context, bundle)));
|
||||
bundle.getName(), getIdentifiers(context, bundle)));
|
||||
|
||||
// Remove bitstreams
|
||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||
|
@@ -7,15 +7,20 @@
|
||||
*/
|
||||
package org.dspace.app.rest.converter;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.model.PageRest;
|
||||
import org.dspace.app.rest.model.SearchEventRest;
|
||||
import org.dspace.app.rest.model.SearchResultsRest;
|
||||
import org.dspace.app.rest.utils.ScopeResolver;
|
||||
import org.dspace.app.util.service.DSpaceObjectUtils;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.discovery.IndexableObject;
|
||||
import org.dspace.usage.UsageEvent;
|
||||
@@ -25,15 +30,39 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SearchEventConverter {
|
||||
/* Log4j logger */
|
||||
private static final Logger log = Logger.getLogger(SearchEventConverter.class);
|
||||
|
||||
@Autowired
|
||||
private ScopeResolver scopeResolver;
|
||||
|
||||
@Autowired
|
||||
private DSpaceObjectUtils dSpaceObjectUtils;
|
||||
|
||||
private final Integer[] allowedClickedObjectTypes =
|
||||
new Integer[]{Constants.COMMUNITY, Constants.COLLECTION, Constants.ITEM};
|
||||
|
||||
public UsageSearchEvent convert(Context context, HttpServletRequest request, SearchEventRest searchEventRest) {
|
||||
UsageSearchEvent usageSearchEvent = new UsageSearchEvent(UsageEvent.Action.SEARCH, request, context,
|
||||
null);
|
||||
usageSearchEvent.setQuery(searchEventRest.getQuery());
|
||||
usageSearchEvent.setDsoType(searchEventRest.getDsoType());
|
||||
if (searchEventRest.getClickedObject() != null) {
|
||||
try {
|
||||
DSpaceObject clickedObject =
|
||||
dSpaceObjectUtils.findDSpaceObject(context, searchEventRest.getClickedObject());
|
||||
if (clickedObject != null &&
|
||||
Arrays.asList(allowedClickedObjectTypes).contains(clickedObject.getType())) {
|
||||
usageSearchEvent.setObject(clickedObject);
|
||||
} else {
|
||||
throw new IllegalArgumentException("UUID " + searchEventRest.getClickedObject() +
|
||||
" was expected to resolve to a Community, Collection or Item, but didn't resolve to any");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.warn("Unable to retrieve DSpace Object with ID " + searchEventRest.getClickedObject() +
|
||||
" from the database", e);
|
||||
}
|
||||
}
|
||||
if (searchEventRest.getScope() != null) {
|
||||
IndexableObject scopeObject =
|
||||
scopeResolver.resolveScope(context, String.valueOf(searchEventRest.getScope()));
|
||||
|
@@ -25,6 +25,7 @@ public class SearchEventRest extends BaseObjectRest<UUID> {
|
||||
private UUID scope;
|
||||
private String configuration;
|
||||
private String dsoType;
|
||||
private UUID clickedObject;
|
||||
private List<SearchResultsRest.AppliedFilter> appliedFilters;
|
||||
private SearchResultsRest.Sorting sort;
|
||||
private PageRest page;
|
||||
@@ -97,4 +98,12 @@ public class SearchEventRest extends BaseObjectRest<UUID> {
|
||||
public void setDsoType(String dsoType) {
|
||||
this.dsoType = dsoType;
|
||||
}
|
||||
|
||||
public UUID getClickedObject() {
|
||||
return clickedObject;
|
||||
}
|
||||
|
||||
public void setClickedObject(UUID clickedObject) {
|
||||
this.clickedObject = clickedObject;
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ import static org.dspace.builder.BitstreamFormatBuilder.createBitstreamFormat;
|
||||
import static org.dspace.builder.ResourcePolicyBuilder.createResourcePolicy;
|
||||
import static org.dspace.content.BitstreamFormat.KNOWN;
|
||||
import static org.dspace.content.BitstreamFormat.SUPPORTED;
|
||||
import static org.dspace.core.Constants.DEFAULT_BITSTREAM_READ;
|
||||
import static org.dspace.core.Constants.READ;
|
||||
import static org.dspace.core.Constants.WRITE;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
@@ -56,6 +57,7 @@ import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.text.PDFTextStripper;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.authorize.service.ResourcePolicyService;
|
||||
import org.dspace.builder.BitstreamBuilder;
|
||||
import org.dspace.builder.CollectionBuilder;
|
||||
@@ -70,6 +72,7 @@ import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.disseminate.CitationDocumentServiceImpl;
|
||||
import org.dspace.eperson.EPerson;
|
||||
@@ -112,6 +115,12 @@ public class BitstreamRestControllerIT extends AbstractControllerIntegrationTest
|
||||
@Autowired
|
||||
private BitstreamFormatService bitstreamFormatService;
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
@Autowired
|
||||
private CollectionService collectionService;
|
||||
|
||||
private Bitstream bitstream;
|
||||
private BitstreamFormat supportedFormat;
|
||||
private BitstreamFormat knownFormat;
|
||||
@@ -626,6 +635,54 @@ public class BitstreamRestControllerIT extends AbstractControllerIntegrationTest
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBitstreamDefaultReadInheritanceFromCollection() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community and one collections.
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
|
||||
Group internalGroup = GroupBuilder.createGroup(context)
|
||||
.withName("Internal Group")
|
||||
.build();
|
||||
// Explicitly create a restrictive default bitstream read policy on the collection
|
||||
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
|
||||
authorizeService.removePoliciesActionFilter(context, col1, DEFAULT_BITSTREAM_READ);
|
||||
authorizeService.addPolicy(context, col1, DEFAULT_BITSTREAM_READ, internalGroup);
|
||||
|
||||
//2. A public item with a new bitstream that is not explicitly restricted
|
||||
// but should instead inherit
|
||||
Item publicItem1 = ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Public item 1")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
||||
.build();
|
||||
// make sure this item has no default policies for a new bundle to inherit
|
||||
authorizeService.removePoliciesActionFilter(context, publicItem1, DEFAULT_BITSTREAM_READ);
|
||||
|
||||
String bitstreamContent = "Private!";
|
||||
try (InputStream is = IOUtils.toInputStream(bitstreamContent, CharEncoding.UTF_8)) {
|
||||
bitstream = BitstreamBuilder
|
||||
.createBitstream(context, publicItem1, is)
|
||||
.withName("Test Restricted Bitstream")
|
||||
.withDescription("This bitstream is restricted")
|
||||
.withMimeType("text/plain")
|
||||
.build();
|
||||
}
|
||||
context.restoreAuthSystemState();
|
||||
//** WHEN **
|
||||
//We download the bitstream
|
||||
getClient().perform(get("/api/core/bitstreams/" + bitstream.getID() + "/content"))
|
||||
//** THEN **
|
||||
.andExpect(status().isUnauthorized());
|
||||
|
||||
//An unauthorized request should not log statistics
|
||||
checkNumberOfStatsRecords(bitstream, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restrictedGroupBitstreamForbiddenTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
@@ -411,4 +411,114 @@ public class SearchEventRestRepositoryIT extends AbstractControllerIntegrationTe
|
||||
.andExpect(status().isCreated());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postTestWithClickedObjectSuccess() throws Exception {
|
||||
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community with sub-community and two collections.
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
|
||||
.withName("Sub Community")
|
||||
.build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
||||
Collection col2 = CollectionBuilder.createCollection(context, child1).withName("Collection 2").build();
|
||||
|
||||
//2. Three public items that are readable by Anonymous with different subjects
|
||||
Item publicItem1 = ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Public item 1")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
SearchEventRest searchEventRest = new SearchEventRest();
|
||||
|
||||
searchEventRest.setQuery("test");
|
||||
searchEventRest.setScope(col1.getID());
|
||||
searchEventRest.setConfiguration("default");
|
||||
searchEventRest.setDsoType("item");
|
||||
searchEventRest.setClickedObject(publicItem1.getID());
|
||||
|
||||
SearchResultsRest.Sorting sort = new SearchResultsRest.Sorting("title", "desc");
|
||||
searchEventRest.setSort(sort);
|
||||
|
||||
PageRest pageRest = new PageRest(5, 20, 4, 1);
|
||||
searchEventRest.setPage(pageRest);
|
||||
|
||||
SearchResultsRest.AppliedFilter appliedFilter =
|
||||
new SearchResultsRest.AppliedFilter("author", "contains", "test","test");
|
||||
List<SearchResultsRest.AppliedFilter> appliedFilterList = new LinkedList<>();
|
||||
appliedFilterList.add(appliedFilter);
|
||||
searchEventRest.setAppliedFilters(appliedFilterList);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
getClient().perform(post("/api/statistics/searchevents")
|
||||
.content(mapper.writeValueAsBytes(searchEventRest))
|
||||
.contentType(contentType))
|
||||
.andExpect(status().isCreated());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postTestWithClickedObjectNotExisting() throws Exception {
|
||||
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community with sub-community and two collections.
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
|
||||
.withName("Sub Community")
|
||||
.build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
||||
Collection col2 = CollectionBuilder.createCollection(context, child1).withName("Collection 2").build();
|
||||
|
||||
//2. Three public items that are readable by Anonymous with different subjects
|
||||
Item publicItem1 = ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Public item 1")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
SearchEventRest searchEventRest = new SearchEventRest();
|
||||
|
||||
searchEventRest.setQuery("test");
|
||||
searchEventRest.setScope(col1.getID());
|
||||
searchEventRest.setConfiguration("default");
|
||||
searchEventRest.setDsoType("item");
|
||||
searchEventRest.setClickedObject(UUID.randomUUID());
|
||||
|
||||
SearchResultsRest.Sorting sort = new SearchResultsRest.Sorting("title", "desc");
|
||||
searchEventRest.setSort(sort);
|
||||
|
||||
PageRest pageRest = new PageRest(5, 20, 4, 1);
|
||||
searchEventRest.setPage(pageRest);
|
||||
|
||||
SearchResultsRest.AppliedFilter appliedFilter =
|
||||
new SearchResultsRest.AppliedFilter("author", "contains", "test","test");
|
||||
List<SearchResultsRest.AppliedFilter> appliedFilterList = new LinkedList<>();
|
||||
appliedFilterList.add(appliedFilter);
|
||||
searchEventRest.setAppliedFilters(appliedFilterList);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
getClient().perform(post("/api/statistics/searchevents")
|
||||
.content(mapper.writeValueAsBytes(searchEventRest))
|
||||
.contentType(contentType))
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ dspace.ui.url = http://localhost:4000
|
||||
|
||||
# Name of the site
|
||||
dspace.name = DSpace at My University
|
||||
dspace.shortname = DSpace
|
||||
|
||||
# Assetstore configurations have moved to config/modules/assetstore.cfg
|
||||
# and config/spring/api/bitstore.xml.
|
||||
|
@@ -4,19 +4,15 @@
|
||||
##
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'Change Password Request')
|
||||
#set($subject = "${config.get('dspace.name')}: Change Password Request")
|
||||
#set($phone = ${config.get('mail.message.helpdesk.telephone')})
|
||||
To change the password for your DSpace account, please click the link
|
||||
below:
|
||||
To change the password for your ${config.get('dspace.name')} account, please click the link below:
|
||||
|
||||
${params[0]}
|
||||
|
||||
If you need assistance with your account, please email
|
||||
|
||||
${config.get("mail.helpdesk")}
|
||||
If you need assistance with your account, please email ${config.get("mail.helpdesk")}
|
||||
#if( $phone )
|
||||
|
||||
or call us at ${phone}.
|
||||
#end
|
||||
|
||||
The DSpace Team
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -10,9 +10,11 @@
|
||||
##
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = "DSpace: Error ${params[0]} DOI ${params[3]}")
|
||||
#set($subject = "${config.get('dspace.name')}: Error ${params[0]} DOI ${params[3]}")
|
||||
|
||||
Date: ${params[1]}
|
||||
|
||||
${params[0]} DOI ${params[4]} for ${params[2]} with ID ${params[3]} failed:
|
||||
${params[5]}
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -6,14 +6,11 @@
|
||||
##
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'DSpace - The item export you requested was not completed.')
|
||||
#set($subject = "${config.get('dspace.name')}: The item export you requested was not completed.")
|
||||
The item export you requested was not completed, due to the following reason:
|
||||
${params[0]}
|
||||
|
||||
For more information you may contact your system administrator:
|
||||
${params[1]}
|
||||
|
||||
|
||||
|
||||
The DSpace Team
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -5,7 +5,7 @@
|
||||
##
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'DSpace - Item export requested is ready for download')
|
||||
#set($subject = "${config.get('dspace.name')}: Item export requested is ready for download")
|
||||
The item export you requested from the repository is now ready for download.
|
||||
|
||||
You may download the compressed file using the following link:
|
||||
@@ -13,6 +13,4 @@ ${params[0]}
|
||||
|
||||
This file will remain available for at least ${params[1]} hours.
|
||||
|
||||
|
||||
The DSpace Team
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -10,7 +10,7 @@
|
||||
##
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'Feedback Form Information')
|
||||
#set($subject = "${config.get('dspace.name')}: Feedback Form Information")
|
||||
|
||||
Comments:
|
||||
|
||||
@@ -24,3 +24,4 @@ Referring Page: ${params[3]}
|
||||
User Agent: ${params[4]}
|
||||
Session: ${params[5]}
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -7,7 +7,7 @@
|
||||
## {4} Task result
|
||||
## {5} Workflow action taken
|
||||
##
|
||||
#set($subject = 'DSpace: Curation Task Report')
|
||||
#set($subject = "${config.get('dspace.name')}: Curation Task Report")
|
||||
|
||||
Title: ${params[0]}
|
||||
Collection: ${params[1]}
|
||||
@@ -20,4 +20,4 @@ ${params[4]}
|
||||
|
||||
Action taken on the submission: ${params[5]}
|
||||
|
||||
DSpace
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -8,7 +8,7 @@
|
||||
##
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'DSpace: Harvesting Error')
|
||||
#set($subject = "${config.get('dspace.name')}: Harvesting Error")
|
||||
Collection ${params[0]} failed on harvest:
|
||||
|
||||
Date: ${params[1]}
|
||||
@@ -18,3 +18,5 @@ ${params[3]}
|
||||
|
||||
Exception:
|
||||
${params[4]}
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -3,7 +3,7 @@
|
||||
## Parameters: {0} is the output of healthcheck command
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'Repository healthcheck')
|
||||
#set($subject = "${config.get('dspace.name')}: Repository healthcheck")
|
||||
The healthcheck finished with the following output:
|
||||
|
||||
${params[0]}
|
||||
|
@@ -10,7 +10,7 @@
|
||||
##
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'DSpace: Internal Server Error')
|
||||
#set($subject = "${config.get('dspace.name')}: Internal Server Error")
|
||||
An internal server error occurred on ${params[0]}:
|
||||
|
||||
Date: ${params[1]}
|
||||
|
@@ -6,17 +6,13 @@
|
||||
##
|
||||
#set($subject = "${config.get('dspace.name')} Account Registration")
|
||||
#set($phone = ${config.get('mail.message.helpdesk.telephone')})
|
||||
To complete registration for a DSpace account, please click the link
|
||||
below:
|
||||
To complete registration for a ${config.get('dspace.name')} account, please click the link below:
|
||||
|
||||
${params[0]}
|
||||
|
||||
If you need assistance with your account, please email
|
||||
|
||||
${config.get("mail.helpdesk")}
|
||||
If you need assistance with your account, please email ${config.get("mail.helpdesk")}
|
||||
#if( $phone )
|
||||
|
||||
or call us at ${phone}.
|
||||
#end
|
||||
|
||||
The DSpace Team
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -8,10 +8,12 @@
|
||||
##
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'DSpace: Registration Notification')
|
||||
#set($subject = "${config.get('dspace.name')}: Registration Notification")
|
||||
|
||||
A new user has registered on ${params[0]} at ${params[1]}:
|
||||
|
||||
Name: ${params[2]}
|
||||
Email: ${params[3]}
|
||||
Date: ${params[4]}
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -8,11 +8,13 @@
|
||||
## {4} the approver's email address
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = 'Request for Open Access')
|
||||
#set($subject = "${config.get('dspace.name')}: Request for Open Access")
|
||||
|
||||
${params[3]}, with address ${params[4]},
|
||||
requested the following document/file to be in Open Access:
|
||||
|
||||
Document Handle:${params[1]}
|
||||
Document Handle: ${params[1]}
|
||||
File ID: ${params[0]}
|
||||
Token:${params[2]}
|
||||
Token: ${params[2]}
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -11,7 +11,7 @@
|
||||
## 8 corresponding author email
|
||||
## 9 configuration property "dspace.name"
|
||||
## 10 configuration property "mail.helpdesk"
|
||||
#set($subject = 'Request copy of document')
|
||||
#set($subject = "${config.get('dspace.name')}: Request copy of document")
|
||||
|
||||
Dear ${params[7]},
|
||||
|
||||
@@ -21,10 +21,12 @@ This request came along with the following message:
|
||||
|
||||
"${params[5]}"
|
||||
|
||||
To answer, click ${params[6]}. Whether you choose to grant or deny the request, we think that it''s in your best interest to respond.
|
||||
To answer, click ${params[6]}. Whether you choose to grant or deny the request, we think that it's in your best interest to respond.
|
||||
|
||||
IF YOU ARE NOT AN AUTHOR OF THIS DOCUMENT, and only submitted the document on the author''s behalf, PLEASE REDIRECT THIS MESSAGE TO THE AUTHOR(S). Only the author(s) should answer the request to send a copy.
|
||||
IF YOU ARE NOT AN AUTHOR OF THIS DOCUMENT, and only submitted the document on the author's behalf, PLEASE REDIRECT THIS MESSAGE TO THE AUTHOR(S). Only the author(s) should answer the request to send a copy.
|
||||
|
||||
IF YOU ARE AN AUTHOR OF THE REQUESTED DOCUMENT, thank you for your cooperation!
|
||||
|
||||
If you have any questions concerning this request, please contact ${params[10]}.
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -4,13 +4,13 @@
|
||||
## {1} Name of collection
|
||||
## {2} handle
|
||||
##
|
||||
#set($subject = 'DSpace: Submission Approved and Archived')
|
||||
#set($subject = "${config.get('dspace.name')}: Submission Approved and Archived")
|
||||
|
||||
You submitted: ${params[0]}
|
||||
|
||||
To collection: ${params[1]}
|
||||
|
||||
Your submission has been accepted and archived in DSpace,
|
||||
Your submission has been accepted and archived in ${config.get('dspace.name')},
|
||||
and it has been assigned the following identifier:
|
||||
${params[2]}
|
||||
|
||||
@@ -18,4 +18,4 @@ Please use this identifier when citing your submission.
|
||||
|
||||
Many thanks!
|
||||
|
||||
DSpace
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -6,7 +6,7 @@
|
||||
## {3} Reason for the rejection
|
||||
## {4} Link to 'My DSpace' page
|
||||
##
|
||||
#set($subject = 'DSpace: Submission Rejected')
|
||||
#set($subject = "${config.get('dspace.name')}: Submission Rejected")
|
||||
|
||||
You submitted: ${params[0]}
|
||||
|
||||
@@ -17,7 +17,6 @@ with the following explanation:
|
||||
|
||||
${params[3]}
|
||||
|
||||
Your submission has not been deleted. You can access it from your
|
||||
"My DSpace" page: ${params[4]}
|
||||
Your submission has not been deleted. You can access it from your "My${config.get('dspace.shortname')}" page: ${params[4]}
|
||||
|
||||
DSpace
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -6,7 +6,7 @@
|
||||
## {3} Description of task
|
||||
## {4} link to 'my DSpace' page
|
||||
##
|
||||
#set($subject = 'DSpace: You have a new task')
|
||||
#set($subject = "${config.get('dspace.name')}: You have a new task")
|
||||
|
||||
A new item has been submitted:
|
||||
|
||||
@@ -16,9 +16,9 @@ Submitted by: ${params[2]}
|
||||
|
||||
${params[3]}
|
||||
|
||||
To claim this task, please visit your "My DSpace"
|
||||
To claim this task, please visit your "My${config.get('dspace.shortname')}"
|
||||
page: ${params[4]}
|
||||
|
||||
Many thanks!
|
||||
|
||||
DSpace
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
@@ -2,9 +2,9 @@
|
||||
##
|
||||
## Parameters: {0} Collections updates
|
||||
## {1} Communities updates
|
||||
#set($subject = 'DSpace Subscription')
|
||||
#set($subject = "${config.get('dspace.name')} Subscription")
|
||||
|
||||
This email is sent from DSpace based on the chosen subscription preferences.
|
||||
This email is sent from ${config.get('dspace.name')} based on the chosen subscription preferences.
|
||||
|
||||
Communities
|
||||
-----------
|
||||
|
@@ -3,13 +3,12 @@
|
||||
## See org.dspace.core.Email for information on the format of this file.
|
||||
##
|
||||
#set($subject = "Welcome new registered ${config.get('dspace.name')} user!")
|
||||
Thank you for registering an account. Your new account can be used immediately
|
||||
Thank you for registering an account. Your new account can be used immediately
|
||||
to subscribe to notices of new content arriving in collections of your choice.
|
||||
|
||||
Your new account can also be granted privileges to submit new content, or to
|
||||
edit and/or approve submissions.
|
||||
|
||||
If you need assistance with your account, please email
|
||||
${config.get("mail.admin")}.
|
||||
If you need assistance with your account, please email ${config.get("mail.helpdesk")}.
|
||||
|
||||
The ${config.get('dspace.name')} Team
|
||||
|
Reference in New Issue
Block a user