mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 04:23:13 +00:00
[CST-7756] monor fix
This commit is contained in:
@@ -17,7 +17,9 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -49,7 +51,9 @@ public class SubscribeServiceImpl implements SubscribeService {
|
|||||||
if (StringUtils.isBlank(resourceType)) {
|
if (StringUtils.isBlank(resourceType)) {
|
||||||
return subscriptionDAO.findAllOrderedByDSO(context, limit, offset);
|
return subscriptionDAO.findAllOrderedByDSO(context, limit, offset);
|
||||||
} else {
|
} else {
|
||||||
if (resourceType.equals("Item") || resourceType.equals("Collection") || resourceType.equals("Community")) {
|
if (resourceType.equals(Item.class.getSimpleName()) ||
|
||||||
|
resourceType.equals(Collection.class.getSimpleName()) ||
|
||||||
|
resourceType.equals(Community.class.getSimpleName())) {
|
||||||
return subscriptionDAO.findAllOrderedByIDAndResourceType(context, resourceType, limit, offset);
|
return subscriptionDAO.findAllOrderedByIDAndResourceType(context, resourceType, limit, offset);
|
||||||
} else {
|
} else {
|
||||||
log.error("Resource type must be Item, Collection or Community");
|
log.error("Resource type must be Item, Collection or Community");
|
||||||
@@ -71,7 +75,7 @@ public class SubscribeServiceImpl implements SubscribeService {
|
|||||||
subscriptionParameterList.forEach(subscriptionParameter ->
|
subscriptionParameterList.forEach(subscriptionParameter ->
|
||||||
newSubscription.addParameter(subscriptionParameter));
|
newSubscription.addParameter(subscriptionParameter));
|
||||||
newSubscription.setEPerson(eperson);
|
newSubscription.setEPerson(eperson);
|
||||||
newSubscription.setdSpaceObject(dSpaceObject);
|
newSubscription.setDSpaceObject(dSpaceObject);
|
||||||
newSubscription.setSubscriptionType(type);
|
newSubscription.setSubscriptionType(type);
|
||||||
return newSubscription;
|
return newSubscription;
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +158,7 @@ public class SubscribeServiceImpl implements SubscribeService {
|
|||||||
Subscription subscriptionDB = subscriptionDAO.findByID(context, Subscription.class, id);
|
Subscription subscriptionDB = subscriptionDAO.findByID(context, Subscription.class, id);
|
||||||
subscriptionDB.removeParameterList();
|
subscriptionDB.removeParameterList();
|
||||||
subscriptionDB.setSubscriptionType(type);
|
subscriptionDB.setSubscriptionType(type);
|
||||||
subscriptionDB.setdSpaceObject(dSpaceObject);
|
subscriptionDB.setDSpaceObject(dSpaceObject);
|
||||||
subscriptionParameterList.forEach(x -> subscriptionDB.addParameter(x));
|
subscriptionParameterList.forEach(x -> subscriptionDB.addParameter(x));
|
||||||
subscriptionDB.setEPerson(eperson);
|
subscriptionDB.setEPerson(eperson);
|
||||||
subscriptionDAO.save(context, subscriptionDB);
|
subscriptionDAO.save(context, subscriptionDB);
|
||||||
|
@@ -87,10 +87,6 @@ public class Subscription implements ReloadableEntity<Integer> {
|
|||||||
this.ePerson = ePerson;
|
this.ePerson = ePerson;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setdSpaceObject(DSpaceObject dSpaceObject) {
|
|
||||||
this.dSpaceObject = dSpaceObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubscriptionType() {
|
public String getSubscriptionType() {
|
||||||
return subscriptionType;
|
return subscriptionType;
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,10 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.IndexableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.Subscription;
|
import org.dspace.eperson.Subscription;
|
||||||
@@ -82,13 +85,14 @@ public class SubscriptionEmailNotificationServiceImpl implements SubscriptionEma
|
|||||||
DSpaceObject dSpaceObject = subscription.getDSpaceObject();
|
DSpaceObject dSpaceObject = subscription.getDSpaceObject();
|
||||||
|
|
||||||
if (dSpaceObject.getType() == COMMUNITY) {
|
if (dSpaceObject.getType() == COMMUNITY) {
|
||||||
communities.addAll(contentUpdates.get("community")
|
communities.addAll(contentUpdates.get(Community.class.getSimpleName())
|
||||||
.findUpdates(context, dSpaceObject, frequency));
|
.findUpdates(context, dSpaceObject, frequency));
|
||||||
} else if (dSpaceObject.getType() == COLLECTION) {
|
} else if (dSpaceObject.getType() == COLLECTION) {
|
||||||
collections.addAll(contentUpdates.get("collection")
|
collections.addAll(contentUpdates.get(Collection.class.getSimpleName())
|
||||||
.findUpdates(context, dSpaceObject, frequency));
|
.findUpdates(context, dSpaceObject, frequency));
|
||||||
} else if (dSpaceObject.getType() == ITEM) {
|
} else if (dSpaceObject.getType() == ITEM) {
|
||||||
items.addAll(contentUpdates.get("item").findUpdates(context, dSpaceObject, frequency));
|
items.addAll(contentUpdates.get(Item.class.getSimpleName())
|
||||||
|
.findUpdates(context, dSpaceObject, frequency));
|
||||||
}
|
}
|
||||||
|
|
||||||
var ePerson = subscription.getEPerson();
|
var ePerson = subscription.getEPerson();
|
||||||
|
@@ -15,13 +15,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import org.dspace.app.rest.model.DSpaceObjectRest;
|
import org.dspace.app.rest.model.DSpaceObjectRest;
|
||||||
import org.dspace.app.rest.model.SubscriptionRest;
|
import org.dspace.app.rest.model.SubscriptionRest;
|
||||||
import org.dspace.app.rest.projection.Projection;
|
import org.dspace.app.rest.projection.Projection;
|
||||||
import org.dspace.content.Collection;
|
|
||||||
import org.dspace.content.Community;
|
|
||||||
import org.dspace.content.Item;
|
|
||||||
import org.dspace.eperson.Subscription;
|
import org.dspace.eperson.Subscription;
|
||||||
import org.dspace.eperson.service.SubscribeService;
|
import org.dspace.eperson.service.SubscribeService;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
|
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
|
||||||
@@ -45,15 +40,7 @@ public class SubscriptionDSpaceObjectLinkRepository extends AbstractDSpaceRestRe
|
|||||||
if (Objects.isNull(subscription)) {
|
if (Objects.isNull(subscription)) {
|
||||||
throw new ResourceNotFoundException("No such subscription: " + subscriptionId);
|
throw new ResourceNotFoundException("No such subscription: " + subscriptionId);
|
||||||
}
|
}
|
||||||
if (subscription.getDSpaceObject() instanceof Item ||
|
return converter.toRest(subscription.getDSpaceObject(), projection);
|
||||||
subscription.getDSpaceObject() instanceof Community ||
|
|
||||||
subscription.getDSpaceObject() instanceof Collection) {
|
|
||||||
return converter.toRest(subscription.getDSpaceObject(), projection);
|
|
||||||
} else {
|
|
||||||
HibernateProxy hibernateProxy = (HibernateProxy) subscription.getDSpaceObject();
|
|
||||||
LazyInitializer initializer = hibernateProxy.getHibernateLazyInitializer();
|
|
||||||
return converter.toRest(initializer.getImplementation(), projection);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e.getMessage(), e);
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user