Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2115 from mwoodiupui/DS-3951
[DS-3951] Send Request Copy email to multiple recipients, and some new recipient strategies
- Loading branch information
Showing
14 changed files
with
443 additions
and
94 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...src/main/java/org/dspace/app/requestitem/CollectionAdministratorsRequestItemStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* 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.requestitem; | ||
|
||
import java.sql.SQLException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.dspace.content.Collection; | ||
import org.dspace.content.Item; | ||
import org.dspace.core.Context; | ||
import org.dspace.eperson.EPerson; | ||
import org.springframework.lang.NonNull; | ||
|
||
/** | ||
* Derive request recipients from groups of the Collection which owns an Item. | ||
* The list will include all members of the administrators group. If the | ||
* resulting list is empty, delegates to {@link RequestItemHelpdeskStrategy}. | ||
* | ||
* @author Mark H. Wood <mwood@iupui.edu> | ||
*/ | ||
public class CollectionAdministratorsRequestItemStrategy | ||
extends RequestItemHelpdeskStrategy { | ||
@Override | ||
@NonNull | ||
public List<RequestItemAuthor> getRequestItemAuthor(Context context, | ||
Item item) | ||
throws SQLException { | ||
List<RequestItemAuthor> recipients = new ArrayList<>(); | ||
Collection collection = item.getOwningCollection(); | ||
for (EPerson admin : collection.getAdministrators().getMembers()) { | ||
recipients.add(new RequestItemAuthor(admin)); | ||
} | ||
if (recipients.isEmpty()) { | ||
return super.getRequestItemAuthor(context, item); | ||
} else { | ||
return recipients; | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
dspace-api/src/main/java/org/dspace/app/requestitem/CombiningRequestItemStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* 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.requestitem; | ||
|
||
import java.sql.SQLException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.dspace.content.Item; | ||
import org.dspace.core.Context; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.util.Assert; | ||
|
||
/** | ||
* Assemble a list of recipients from the results of other strategies. | ||
* The list of strategy classes is injected as the constructor argument | ||
* {@code strategies}. | ||
* If the strategy list is not configured, returns an empty List. | ||
* | ||
* @author Mark H. Wood <mwood@iupui.edu> | ||
*/ | ||
public class CombiningRequestItemStrategy | ||
implements RequestItemAuthorExtractor { | ||
/** The strategies to combine. */ | ||
private final List<RequestItemAuthorExtractor> strategies; | ||
|
||
/** | ||
* Initialize a combination of strategies. | ||
* @param strategies the author extraction strategies to combine. | ||
*/ | ||
public CombiningRequestItemStrategy(@NonNull List<RequestItemAuthorExtractor> strategies) { | ||
Assert.notNull(strategies, "Strategy list may not be null"); | ||
this.strategies = strategies; | ||
} | ||
|
||
/** | ||
* Do not call. | ||
* @throws IllegalArgumentException always | ||
*/ | ||
private CombiningRequestItemStrategy() { | ||
throw new IllegalArgumentException(); | ||
} | ||
|
||
@Override | ||
@NonNull | ||
public List<RequestItemAuthor> getRequestItemAuthor(Context context, Item item) | ||
throws SQLException { | ||
List<RequestItemAuthor> recipients = new ArrayList<>(); | ||
|
||
for (RequestItemAuthorExtractor strategy : strategies) { | ||
recipients.addAll(strategy.getRequestItemAuthor(context, item)); | ||
} | ||
|
||
return recipients; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.