mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
[DSC-183] New endpoint, IT tests changed
This commit is contained in:
@@ -60,17 +60,13 @@ public class SubscribeServiceImpl implements SubscribeService {
|
||||
if (authorizeService.isAdmin(context)
|
||||
|| ((context.getCurrentUser() != null) && (context
|
||||
.getCurrentUser().getID().equals(eperson.getID())))) {
|
||||
if (!isSubscribed(context, eperson, dSpaceObject)) {
|
||||
Subscription new_subscription = subscriptionDAO.create(context, new Subscription());
|
||||
subscriptionParameterList.forEach(subscriptionParameter -> new_subscription.addParameter(subscriptionParameter));
|
||||
Subscription new_subscription = subscriptionDAO.create(context, new Subscription());
|
||||
subscriptionParameterList.forEach(subscriptionParameter -> new_subscription.addParameter(subscriptionParameter));
|
||||
// new_subscription.setSubscriptionParameterList(subscriptionParameterList);
|
||||
new_subscription.setePerson(eperson);
|
||||
new_subscription.setdSpaceObject(dSpaceObject);
|
||||
new_subscription.setType(type);
|
||||
return new_subscription;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Subscription already exists");
|
||||
}
|
||||
new_subscription.setePerson(eperson);
|
||||
new_subscription.setdSpaceObject(dSpaceObject);
|
||||
new_subscription.setType(type);
|
||||
return new_subscription;
|
||||
} else {
|
||||
throw new AuthorizeException(
|
||||
"Only admin or e-person themselves can subscribe");
|
||||
@@ -106,6 +102,12 @@ public class SubscribeServiceImpl implements SubscribeService {
|
||||
return subscriptionDAO.findByEPerson(context, eperson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Subscription> getSubscriptionsByEPersonAndDso(Context context, EPerson eperson, DSpaceObject dSpaceObject)
|
||||
throws SQLException {
|
||||
return subscriptionDAO.findByEPerson(context, eperson);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Collection> getAvailableSubscriptions(Context context)
|
||||
throws SQLException {
|
||||
@@ -127,12 +129,12 @@ public class SubscribeServiceImpl implements SubscribeService {
|
||||
@Override
|
||||
public boolean isSubscribed(Context context, EPerson eperson,
|
||||
DSpaceObject dSpaceObject) throws SQLException {
|
||||
return subscriptionDAO.findByCollectionAndEPerson(context, eperson, dSpaceObject) != null;
|
||||
return subscriptionDAO.findByEPersonAndDso(context, eperson, dSpaceObject) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByCollection(Context context, Collection collection) throws SQLException {
|
||||
subscriptionDAO.deleteByCollection(context, collection);
|
||||
public void deleteByDspaceObject(Context context, DSpaceObject dSpaceObject) throws SQLException {
|
||||
subscriptionDAO.deleteByDspaceObject(context, dSpaceObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,7 +169,7 @@ public class SubscribeServiceImpl implements SubscribeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subscription addSubscriptionParameter(Context context, Integer id, SubscriptionParameter subscriptionParameter) throws SQLException, AuthorizeException {
|
||||
public Subscription addSubscriptionParameter(Context context, Integer id, SubscriptionParameter subscriptionParameter) throws SQLException, AuthorizeException {
|
||||
// must be admin or the subscriber of the subscription
|
||||
Subscription subscriptionDB = subscriptionDAO.findByID(context, Subscription.class, id);
|
||||
if (authorizeService.isAdmin(context, context.getCurrentUser()) || subscriptionDB.getePerson().equals(context.getCurrentUser())) {
|
||||
@@ -178,8 +180,9 @@ public class SubscribeServiceImpl implements SubscribeService {
|
||||
throw new AuthorizeException("Only admin or e-person themselves can edit the subscription");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subscription removeSubscriptionParameter(Context context, Integer id, SubscriptionParameter subscriptionParameter) throws SQLException, AuthorizeException {
|
||||
public Subscription removeSubscriptionParameter(Context context, Integer id, SubscriptionParameter subscriptionParameter) throws SQLException, AuthorizeException {
|
||||
// must be admin or the subscriber of the subscription
|
||||
Subscription subscriptionDB = subscriptionDAO.findByID(context, Subscription.class, id);
|
||||
if (authorizeService.isAdmin(context, context.getCurrentUser()) || subscriptionDB.getePerson().equals(context.getCurrentUser())) {
|
||||
@@ -190,6 +193,7 @@ public class SubscribeServiceImpl implements SubscribeService {
|
||||
throw new AuthorizeException("Only admin or e-person themselves can edit the subscription");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSubscription(Context context, Integer id) throws SQLException, AuthorizeException {
|
||||
// initially find the eperson associated with the subscription
|
||||
|
Reference in New Issue
Block a user