-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Task 71441] altered the processFiles endpoint and added the process …
…filetypes endpoint with tests
- Loading branch information
1 parent
31c87c2
commit de357b5
Showing
11 changed files
with
281 additions
and
126 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
60 changes: 60 additions & 0 deletions
60
dspace-server-webapp/src/main/java/org/dspace/app/rest/model/ProcessFileTypesRest.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.model; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.dspace.app.rest.RestResourceController; | ||
|
||
public class ProcessFileTypesRest extends BaseObjectRest<String> { | ||
|
||
public static final String NAME = "filetypes"; | ||
public static final String PLURAL_NAME = "filetypes"; | ||
public static final String CATEGORY = RestAddressableModel.SYSTEM; | ||
|
||
private List<String> values; | ||
|
||
/** | ||
* Generic getter for the values | ||
* @return the values value of this ProcessFileTypesRest | ||
*/ | ||
public List<String> getValues() { | ||
return values; | ||
} | ||
|
||
/** | ||
* Generic setter for the values | ||
* @param values The values to be set on this ProcessFileTypesRest | ||
*/ | ||
public void setValues(List<String> values) { | ||
this.values = values; | ||
} | ||
|
||
public void addValue(String value) { | ||
if (values == null) { | ||
values = new LinkedList<>(); | ||
} | ||
values.add(value); | ||
} | ||
|
||
@Override | ||
public String getCategory() { | ||
return CATEGORY; | ||
} | ||
|
||
@Override | ||
public Class getController() { | ||
return RestResourceController.class; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return NAME; | ||
} | ||
} |
52 changes: 0 additions & 52 deletions
52
dspace-server-webapp/src/main/java/org/dspace/app/rest/model/ProcessFileWrapperRest.java
This file was deleted.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
...rver-webapp/src/main/java/org/dspace/app/rest/model/hateoas/ProcessFileTypesResource.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,19 @@ | ||
/** | ||
* 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.model.hateoas; | ||
|
||
import org.dspace.app.rest.model.ProcessFileTypesRest; | ||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource; | ||
|
||
@RelNameDSpaceResource(ProcessFileTypesRest.NAME) | ||
public class ProcessFileTypesResource extends HALResource<ProcessFileTypesRest> { | ||
|
||
public ProcessFileTypesResource(ProcessFileTypesRest content) { | ||
super(content); | ||
} | ||
} |
53 changes: 0 additions & 53 deletions
53
...er-webapp/src/main/java/org/dspace/app/rest/model/hateoas/ProcessFileWrapperResource.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
...r-webapp/src/main/java/org/dspace/app/rest/repository/ProcessFileTypesLinkRepository.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,54 @@ | ||
/** | ||
* 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 java.util.List; | ||
import javax.annotation.Nullable; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.dspace.app.rest.model.ProcessFileTypesRest; | ||
import org.dspace.app.rest.model.ProcessRest; | ||
import org.dspace.app.rest.projection.Projection; | ||
import org.dspace.authorize.AuthorizeException; | ||
import org.dspace.core.Context; | ||
import org.dspace.scripts.Process; | ||
import org.dspace.scripts.service.ProcessService; | ||
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; | ||
|
||
@Component(ProcessRest.CATEGORY + "." + ProcessRest.NAME + "." + ProcessRest.FILE_TYPES) | ||
public class ProcessFileTypesLinkRepository extends AbstractDSpaceRestRepository implements LinkRestRepository { | ||
|
||
@Autowired | ||
private ProcessService processService; | ||
|
||
@Autowired | ||
private ProcessRestRepository processRestRepository; | ||
|
||
@PreAuthorize("hasAuthority('ADMIN')") | ||
public ProcessFileTypesRest getFileTypesFromProcess(@Nullable HttpServletRequest request, | ||
Integer processId, | ||
@Nullable Pageable optionalPageable, | ||
Projection projection) throws SQLException, AuthorizeException { | ||
|
||
Context context = obtainContext(); | ||
Process process = processService.find(context, processId); | ||
if (process == null) { | ||
throw new ResourceNotFoundException("Process with id " + processId + " was not found"); | ||
} | ||
List<String> fileTypes = processService.getFileTypesForProcessBitstreams(context, process); | ||
ProcessFileTypesRest processFileTypesRest = new ProcessFileTypesRest(); | ||
processFileTypesRest.setId("filetypes-" + processId); | ||
processFileTypesRest.setValues(fileTypes); | ||
return processFileTypesRest; | ||
} | ||
} |
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.