Skip to content

Commit c055946

Browse files
authored
Merge pull request DSpace#12247 from kshepherd/researcherprofile_claim_by_item
Allow claiming of researcher profile by Item object in ResearcherProfileService
2 parents e58457d + 2d27397 commit c055946

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

dspace-api/src/main/java/org/dspace/profile/ResearcherProfileServiceImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ public ResearcherProfile claim(Context context, EPerson ePerson, URI uri)
199199
Item item = findItemByURI(context, uri)
200200
.orElseThrow(() -> new IllegalArgumentException("No item found by URI " + uri));
201201

202+
return claim(context, ePerson, item);
203+
}
204+
205+
@Override
206+
public ResearcherProfile claim(Context context, EPerson ePerson, Item item)
207+
throws SQLException, AuthorizeException {
208+
209+
if (item == null) {
210+
throw new IllegalArgumentException("The provided item is null");
211+
}
212+
202213
if (!item.isArchived() || item.isWithdrawn()) {
203214
throw new IllegalArgumentException(
204215
"Only archived items can be claimed to create a researcher profile. Item ID: " + item.getID());

dspace-api/src/main/java/org/dspace/profile/service/ResearcherProfileService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ public void changeVisibility(Context context, ResearcherProfile profile, boolean
9393
ResearcherProfile claim(Context context, EPerson ePerson, URI uri)
9494
throws SQLException, AuthorizeException, SearchServiceException;
9595

96+
/**
97+
* Claims and links an eperson to an existing DSpaceObject directly, without
98+
* resolving a URI to an object
99+
* @param context the relevant DSpace Context.
100+
* @param ePerson the ePerson
101+
* @param item DSpace item to convert to a researcher profile
102+
* @return the created profile
103+
* @throws IllegalArgumentException if the given dso is null or cannot be claimed
104+
*/
105+
ResearcherProfile claim(Context context, EPerson ePerson, Item item)
106+
throws SQLException, AuthorizeException;
107+
96108
/**
97109
* Check if the given item has an entity type compatible with that of the
98110
* researcher profile. If the given item does not have an entity type, the check

0 commit comments

Comments
 (0)