forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
502028f
commit 4703934
Showing
13 changed files
with
854 additions
and
39 deletions.
There are no files selected for viewing
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
60 changes: 60 additions & 0 deletions
60
...pp/src/main/java/org/dspace/app/rest/repository/WorkflowItemCollectionLinkRepository.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,60 @@ | ||
/** | ||
* 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.rest.repository; | ||
|
||
import java.sql.SQLException; | ||
import javax.annotation.Nullable; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.dspace.app.rest.model.CollectionRest; | ||
import org.dspace.app.rest.model.WorkflowItemRest; | ||
import org.dspace.app.rest.projection.Projection; | ||
import org.dspace.core.Context; | ||
import org.dspace.workflow.WorkflowItem; | ||
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.rest.webmvc.ResourceNotFoundException; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Link repository for "collection" subresource of a workflow item. | ||
*/ | ||
@Component(WorkflowItemRest.CATEGORY + "." + WorkflowItemRest.NAME + "." + WorkflowItemRest.COLLECTION) | ||
public class WorkflowItemCollectionLinkRepository extends AbstractDSpaceRestRepository | ||
implements LinkRestRepository { | ||
|
||
@Autowired | ||
XmlWorkflowItemService wis; | ||
|
||
/** | ||
* Retrieve the item for a workflow collection. | ||
* | ||
* @param request - The current request | ||
* @param id - The workflow item ID for which to retrieve the collection | ||
* @param optionalPageable - optional pageable object | ||
* @param projection - the current projection | ||
* @return the item for the workflow collection | ||
*/ | ||
@PreAuthorize("hasPermission(#id, 'WORKFLOWITEM', 'READ')") | ||
public CollectionRest getWorkflowItemCollection(@Nullable HttpServletRequest request, Integer id, | ||
@Nullable Pageable optionalPageable, Projection projection) { | ||
try { | ||
Context context = obtainContext(); | ||
WorkflowItem witem = wis.find(context, id); | ||
if (witem == null) { | ||
throw new ResourceNotFoundException("No such workflow item: " + id); | ||
} | ||
|
||
return converter.toRest(witem.getCollection(), projection); | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...r-webapp/src/main/java/org/dspace/app/rest/repository/WorkflowItemItemLinkRepository.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,60 @@ | ||
/** | ||
* 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.rest.repository; | ||
|
||
import java.sql.SQLException; | ||
import javax.annotation.Nullable; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.dspace.app.rest.model.ItemRest; | ||
import org.dspace.app.rest.model.WorkflowItemRest; | ||
import org.dspace.app.rest.projection.Projection; | ||
import org.dspace.core.Context; | ||
import org.dspace.workflow.WorkflowItem; | ||
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.rest.webmvc.ResourceNotFoundException; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Link repository for "item" subresource of a workflow item. | ||
*/ | ||
@Component(WorkflowItemRest.CATEGORY + "." + WorkflowItemRest.NAME + "." + WorkflowItemRest.ITEM) | ||
public class WorkflowItemItemLinkRepository extends AbstractDSpaceRestRepository | ||
implements LinkRestRepository { | ||
|
||
@Autowired | ||
XmlWorkflowItemService wis; | ||
|
||
/** | ||
* Retrieve the item for a workflow item. | ||
* | ||
* @param request - The current request | ||
* @param id - The workflow item ID for which to retrieve the item | ||
* @param optionalPageable - optional pageable object | ||
* @param projection - the current projection | ||
* @return the item for the workflow item | ||
*/ | ||
@PreAuthorize("hasPermission(#id, 'WORKFLOWITEM', 'READ')") | ||
public ItemRest getWorkflowItemItem(@Nullable HttpServletRequest request, Integer id, | ||
@Nullable Pageable optionalPageable, Projection projection) { | ||
try { | ||
Context context = obtainContext(); | ||
WorkflowItem witem = wis.find(context, id); | ||
if (witem == null) { | ||
throw new ResourceNotFoundException("No such workflow item: " + id); | ||
} | ||
|
||
return converter.toRest(witem.getItem(), projection); | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...app/src/main/java/org/dspace/app/rest/repository/WorkflowItemSubmitterLinkRepository.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,60 @@ | ||
/** | ||
* 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.rest.repository; | ||
|
||
import java.sql.SQLException; | ||
import javax.annotation.Nullable; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.dspace.app.rest.model.EPersonRest; | ||
import org.dspace.app.rest.model.WorkflowItemRest; | ||
import org.dspace.app.rest.projection.Projection; | ||
import org.dspace.core.Context; | ||
import org.dspace.workflow.WorkflowItem; | ||
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.rest.webmvc.ResourceNotFoundException; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Link repository for "submitter" subresource of a workflow item. | ||
*/ | ||
@Component(WorkflowItemRest.CATEGORY + "." + WorkflowItemRest.NAME + "." + WorkflowItemRest.SUBMITTER) | ||
public class WorkflowItemSubmitterLinkRepository extends AbstractDSpaceRestRepository | ||
implements LinkRestRepository { | ||
|
||
@Autowired | ||
XmlWorkflowItemService wis; | ||
|
||
/** | ||
* Retrieve the submitter for a workflow item. | ||
* | ||
* @param request - The current request | ||
* @param id - The workflow item ID for which to retrieve the submitter | ||
* @param optionalPageable - optional pageable object | ||
* @param projection - the current projection | ||
* @return the submitter for the workflow item | ||
*/ | ||
@PreAuthorize("hasPermission(#id, 'WORKFLOWITEM', 'READ')") | ||
public EPersonRest getWorkflowItemSubmitter(@Nullable HttpServletRequest request, Integer id, | ||
@Nullable Pageable optionalPageable, Projection projection) { | ||
try { | ||
Context context = obtainContext(); | ||
WorkflowItem witem = wis.find(context, id); | ||
if (witem == null) { | ||
throw new ResourceNotFoundException("No such workflow item: " + id); | ||
} | ||
|
||
return converter.toRest(witem.getSubmitter(), projection); | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.