mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
implemented SubmissionAccessOptions endpoint
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* 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.submit.model;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
|
||||
*/
|
||||
public class AccessConditionConfiguration {
|
||||
|
||||
private String name;
|
||||
private Boolean discoverable;
|
||||
private List<AccessConditionOption> options;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Boolean getDiscoverable() {
|
||||
return discoverable;
|
||||
}
|
||||
|
||||
public void setDiscoverable(Boolean discoverable) {
|
||||
this.discoverable = discoverable;
|
||||
}
|
||||
|
||||
public List<AccessConditionOption> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(List<AccessConditionOption> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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.submit.model;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Simple bean to manage different Access Condition configurations
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
|
||||
*/
|
||||
public class AccessConditionConfigurationService {
|
||||
|
||||
/**
|
||||
* Mapping the submission step process identifier with the configuration
|
||||
* (see configuration at access-conditions.xml)
|
||||
*/
|
||||
private Map<String, AccessConditionConfiguration> map;
|
||||
|
||||
public Map<String, AccessConditionConfiguration> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map<String, AccessConditionConfiguration> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.converter;
|
||||
import org.dspace.app.rest.model.SubmissionAccessOptionRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.submit.model.AccessConditionConfiguration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* This converter will convert an object of {@Link AccessConditionConfiguration}
|
||||
* to an object of {@link SubmissionAccessOptionRest}.
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
|
||||
*/
|
||||
@Component
|
||||
public class SubmissionAccessOptionConverter
|
||||
implements DSpaceConverter<AccessConditionConfiguration, SubmissionAccessOptionRest> {
|
||||
|
||||
@Override
|
||||
public SubmissionAccessOptionRest convert(AccessConditionConfiguration obj, Projection projection) {
|
||||
SubmissionAccessOptionRest model = new SubmissionAccessOptionRest();
|
||||
model.setId(obj.getName());
|
||||
model.setDiscoverable(obj.getDiscoverable());
|
||||
model.setAccessConditionOptions(obj.getOptions());
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<AccessConditionConfiguration> getModelClass() {
|
||||
return AccessConditionConfiguration.class;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.dspace.app.rest.RestResourceController;
|
||||
import org.dspace.submit.model.AccessConditionOption;
|
||||
|
||||
/**
|
||||
* The Access Condition Section Configuration REST Resource
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
|
||||
*/
|
||||
public class SubmissionAccessOptionRest extends BaseObjectRest<String> {
|
||||
|
||||
private static final long serialVersionUID = -7708437586052984082L;
|
||||
|
||||
public static final String NAME = "submissionaccessoption";
|
||||
public static final String PLURAL = "submissionaccessoptions";
|
||||
public static final String CATEGORY = RestAddressableModel.CONFIGURATION;
|
||||
|
||||
private String id;
|
||||
|
||||
private Boolean discoverable;
|
||||
|
||||
private List<AccessConditionOption> accessConditionOptions;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Boolean getDiscoverable() {
|
||||
return discoverable;
|
||||
}
|
||||
|
||||
public void setDiscoverable(Boolean discoverable) {
|
||||
this.discoverable = discoverable;
|
||||
}
|
||||
|
||||
public List<AccessConditionOption> getAccessConditionOptions() {
|
||||
if (Objects.isNull(accessConditionOptions)) {
|
||||
accessConditionOptions = new ArrayList<>();
|
||||
}
|
||||
return accessConditionOptions;
|
||||
}
|
||||
|
||||
public void setAccessConditionOptions(List<AccessConditionOption> accessConditionOptions) {
|
||||
this.accessConditionOptions = accessConditionOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return CATEGORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class getController() {
|
||||
return RestResourceController.class;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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.SubmissionAccessOptionRest;
|
||||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
|
||||
/**
|
||||
* SubmissionAccessOption HAL Resource.
|
||||
* This resource adds the data from the REST object together with embedded objects
|
||||
* and a set of links if applicable.
|
||||
*
|
||||
* Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
|
||||
*/
|
||||
@RelNameDSpaceResource(SubmissionAccessOptionRest.NAME)
|
||||
public class SubmissionAccessOptionResource extends DSpaceResource<SubmissionAccessOptionRest> {
|
||||
|
||||
public SubmissionAccessOptionResource(SubmissionAccessOptionRest data, Utils utils) {
|
||||
super(data, utils);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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.util.Objects;
|
||||
|
||||
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
|
||||
import org.dspace.app.rest.model.SubmissionAccessOptionRest;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.submit.model.AccessConditionConfiguration;
|
||||
import org.dspace.submit.model.AccessConditionConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* This is the repository responsible to manage AccessCondition section
|
||||
* during the submission.
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
|
||||
*/
|
||||
@Component(SubmissionAccessOptionRest.CATEGORY + "." + SubmissionAccessOptionRest.NAME)
|
||||
public class SubmissionAccessOptionRestRepository extends DSpaceRestRepository<SubmissionAccessOptionRest, String> {
|
||||
|
||||
@Autowired
|
||||
private AccessConditionConfigurationService accessConditionConfigurationService;
|
||||
|
||||
@Override
|
||||
@PreAuthorize("permitAll()")
|
||||
public SubmissionAccessOptionRest findOne(Context context, String id) {
|
||||
AccessConditionConfiguration configuration = accessConditionConfigurationService.getMap().get(id);
|
||||
return Objects.nonNull(configuration) ? converter.toRest(configuration, utils.obtainProjection()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SubmissionAccessOptionRest> findAll(Context context, Pageable pageable) {
|
||||
throw new RepositoryMethodNotImplementedException(SubmissionAccessOptionRest.NAME, "findAll");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<SubmissionAccessOptionRest> getDomainClass() {
|
||||
return SubmissionAccessOptionRest.class;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user