Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into rest-demo
- Loading branch information
Showing
13 changed files
with
253 additions
and
76 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
34 changes: 0 additions & 34 deletions
34
dspace-api/src/main/java/org/dspace/content/factory/ProcessServiceFactory.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
dspace-api/src/main/java/org/dspace/scripts/ScriptServiceImpl.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,39 @@ | ||
/** | ||
* 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.scripts; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.dspace.core.Context; | ||
import org.dspace.scripts.service.ScriptService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
/** | ||
* The implementation for the {@link ScriptService} | ||
*/ | ||
public class ScriptServiceImpl implements ScriptService { | ||
|
||
@Autowired | ||
private List<DSpaceRunnable> dSpaceRunnables; | ||
|
||
@Override | ||
public DSpaceRunnable getScriptForName(String name) { | ||
return dSpaceRunnables.stream() | ||
.filter(dSpaceRunnable -> StringUtils.equalsIgnoreCase(dSpaceRunnable.getName(), name)) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
|
||
@Override | ||
public List<DSpaceRunnable> getDSpaceRunnables(Context context) { | ||
return dSpaceRunnables.stream().filter( | ||
dSpaceRunnable -> dSpaceRunnable.isAllowedToExecute(context)).collect(Collectors.toList()); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
dspace-api/src/main/java/org/dspace/scripts/factory/ScriptServiceFactory.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,41 @@ | ||
/** | ||
* 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.scripts.factory; | ||
|
||
import org.dspace.scripts.service.ProcessService; | ||
import org.dspace.scripts.service.ScriptService; | ||
import org.dspace.services.factory.DSpaceServicesFactory; | ||
|
||
/** | ||
* Abstract factory to get services for the Script workload, use ScriptServiceFactory.getInstance() to retrieve an | ||
* implementation | ||
* | ||
*/ | ||
public abstract class ScriptServiceFactory { | ||
|
||
/** | ||
* This method will return an instance of the ScriptService | ||
* @return An instance of the ScriptService | ||
*/ | ||
public abstract ScriptService getScriptService(); | ||
|
||
/** | ||
* This method will return an instance of the ProcessService | ||
* @return An instance of the ProcessService | ||
*/ | ||
public abstract ProcessService getProcessService(); | ||
|
||
/** | ||
* Use this method to retrieve an implementation of the ScriptServiceFactory to use to retrieve the different beans | ||
* @return An implementation of the ScriptServiceFactory | ||
*/ | ||
public static ScriptServiceFactory getInstance() { | ||
return DSpaceServicesFactory.getInstance().getServiceManager() | ||
.getServiceByName("scriptServiceFactory", ScriptServiceFactory.class); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
dspace-api/src/main/java/org/dspace/scripts/service/ScriptService.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,33 @@ | ||
/** | ||
* 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.scripts.service; | ||
|
||
import java.util.List; | ||
|
||
import org.dspace.core.Context; | ||
import org.dspace.scripts.DSpaceRunnable; | ||
|
||
/** | ||
* This service will deal with logic to handle DSpaceRunnable objects | ||
*/ | ||
public interface ScriptService { | ||
|
||
/** | ||
* This method will return the DSpaceRunnable that has the name that's equal to the name given in the parameters | ||
* @param name The name that the script has to match | ||
* @return The matching DSpaceRunnable script | ||
*/ | ||
DSpaceRunnable getScriptForName(String name); | ||
|
||
/** | ||
* This method will return a list of DSpaceRunnable objects for which the given Context is authorized to use them | ||
* @param context The relevant DSpace context | ||
* @return The list of accessible DSpaceRunnable scripts for this context | ||
*/ | ||
List<DSpaceRunnable> getDSpaceRunnables(Context context); | ||
} |
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.