Skip to content

Commit

Permalink
[Task 71441] added javadoc and minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Raf-atmire committed Jun 18, 2020
1 parent de357b5 commit 57d63c2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ public void appendFile(Context context, Process process, InputStream is, String
*/
int countTotal(Context context) throws SQLException;

/**
* This will return a list of Strings where each String represents the type of a Bitstream in the Process given
* @param context The DSpace context
* @param process The Process object that we'll use to find the bitstreams
* @return A list of Strings where each String represents a fileType that is in the Process
*/
public List<String> getFileTypesForProcessBitstreams(Context context, Process process);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

import org.dspace.app.rest.RestResourceController;

/**
* This class provides a way to list the filetypes present in a given Process by showing them as a list of Strings
* It'll be used by {@link org.dspace.app.rest.repository.ProcessFileTypesLinkRepository}
*/
public class ProcessFileTypesRest extends BaseObjectRest<String> {

public static final String NAME = "filetypes";
Expand All @@ -36,6 +40,10 @@ public void setValues(List<String> values) {
this.values = values;
}

/**
* Adds a value to the list of FileType Strings
* @param value The value to be added
*/
public void addValue(String value) {
if (values == null) {
values = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import org.dspace.app.rest.model.ProcessFileTypesRest;
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;

/**
* Resource object for {@link ProcessFileTypesRest}
*/
@RelNameDSpaceResource(ProcessFileTypesRest.NAME)
public class ProcessFileTypesResource extends HALResource<ProcessFileTypesRest> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,28 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;

/**
* This LinkRepository will deal with calls to the /filetypes endpoint of a given Process.
* It'll retrieve all the bitstreams for the given Process and return a {@link ProcessFileTypesRest} object that holds
* a list of Strings where each String represents a unique fileType of the Bitstreams for that Process
*/
@Component(ProcessRest.CATEGORY + "." + ProcessRest.NAME + "." + ProcessRest.FILE_TYPES)
public class ProcessFileTypesLinkRepository extends AbstractDSpaceRestRepository implements LinkRestRepository {

@Autowired
private ProcessService processService;

@Autowired
private ProcessRestRepository processRestRepository;

/**
* This will be the admin only endpoint that returns the {@link ProcessFileTypesRest} constructed with the values
* found in the Bitstreams of the Process with the given ProcessId
* @param request The relevant request
* @param processId The processId of the Process to be used
* @param optionalPageable Paging if applicable
* @param projection The current projection
* @return The {@link ProcessFileTypesRest} created from the Bitstreams of the given Process
* @throws SQLException If something goes wrong
* @throws AuthorizeException If something goes wrong
*/
@PreAuthorize("hasAuthority('ADMIN')")
public ProcessFileTypesRest getFileTypesFromProcess(@Nullable HttpServletRequest request,
Integer processId,
Expand Down

0 comments on commit 57d63c2

Please sign in to comment.