mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
[CST-12108] added javaDoc
This commit is contained in:
@@ -25,10 +25,10 @@ public interface QAEventSecurityService {
|
||||
* Check if the specified user can see a specific QASource
|
||||
* @param context the context
|
||||
* @param user the eperson to consider
|
||||
* @param qaSource the qaSource involved
|
||||
* @param sourceName the source name
|
||||
* @return <code>true</code> if the specified user can eventually see events in the QASource
|
||||
*/
|
||||
boolean canSeeSource(Context context, EPerson user, String qaSource);
|
||||
boolean canSeeSource(Context context, EPerson user, String sourceName);
|
||||
|
||||
/**
|
||||
* Check if the specified user can see a specific QAEvent. It is expected that a QAEvent in a not visible QASource
|
||||
@@ -47,9 +47,9 @@ public interface QAEventSecurityService {
|
||||
*
|
||||
* @param context the context
|
||||
* @param user the eperson to consider
|
||||
* @param qaSource the qaSource involved
|
||||
* @param sourceName the source name
|
||||
* @return the solr filter query
|
||||
*/
|
||||
public Optional<String> generateQAEventFilterQuery(Context context, EPerson user, String qaSource);
|
||||
public Optional<String> generateQAEventFilterQuery(Context context, EPerson user, String sourceName);
|
||||
|
||||
}
|
||||
|
@@ -16,10 +16,23 @@ import org.dspace.eperson.EPerson;
|
||||
import org.dspace.qaevent.security.QASecurity;
|
||||
import org.dspace.qaevent.service.QAEventSecurityService;
|
||||
|
||||
/**
|
||||
* Implementation of the security service for QAEvents.
|
||||
* This implementation manages a configuration of {@link QASecurity} instances,
|
||||
* each responsible for security checks for a specific QA source.
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
|
||||
*/
|
||||
public class QAEventSecurityServiceImpl implements QAEventSecurityService {
|
||||
|
||||
/**
|
||||
* The default security settings to be used when specific configurations are not available for a QA source.
|
||||
*/
|
||||
private QASecurity defaultSecurity;
|
||||
|
||||
/**
|
||||
* A mapping of QA source names to their corresponding QASecurity configurations.
|
||||
*/
|
||||
private Map<String, QASecurity> qaSecurityConfiguration;
|
||||
|
||||
public void setQaSecurityConfiguration(Map<String, QASecurity> qaSecurityConfiguration) {
|
||||
@@ -30,27 +43,58 @@ public class QAEventSecurityServiceImpl implements QAEventSecurityService {
|
||||
this.defaultSecurity = defaultSecurity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a query to restrict the qa events returned by other search/find method to the only ones visible to the
|
||||
* specified user
|
||||
*
|
||||
* @param context the context
|
||||
* @param user the eperson to consider
|
||||
* @param sourceName the source name
|
||||
* @return the solr filter query
|
||||
*/
|
||||
@Override
|
||||
public Optional<String> generateQAEventFilterQuery(Context context, EPerson user, String qaSource) {
|
||||
QASecurity qaSecurity = getQASecurity(qaSource);
|
||||
public Optional<String> generateQAEventFilterQuery(Context context, EPerson user, String sourceName) {
|
||||
QASecurity qaSecurity = getQASecurity(sourceName);
|
||||
return qaSecurity.generateFilterQuery(context, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the QASecurity configuration for the specified QA source, or uses the default
|
||||
* configuration if not available.
|
||||
*
|
||||
* @param qaSource The name of the QA source.
|
||||
* @return The QASecurity configuration for the specified QA source, or the default configuration if not available.
|
||||
*/
|
||||
private QASecurity getQASecurity(String qaSource) {
|
||||
return qaSecurityConfiguration.getOrDefault(qaSource, defaultSecurity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the user is authorized to see the specified QA event.
|
||||
*
|
||||
* @param context the context
|
||||
* @param user the eperson to consider
|
||||
* @param qaEvent the qaevent to check
|
||||
* @return <code>true</code> if the specified user can see the specified event
|
||||
*/
|
||||
@Override
|
||||
public boolean canSeeEvent(Context context, EPerson user, QAEvent qaEvent) {
|
||||
String source = qaEvent.getSource();
|
||||
QASecurity qaSecurity = getQASecurity(source);
|
||||
return qaSecurity.canSeeQASource(context, user)
|
||||
&& qaSecurity.canSeeQAEvent(context, user, qaEvent);
|
||||
return qaSecurity.canSeeQASource(context, user) && qaSecurity.canSeeQAEvent(context, user, qaEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the user is authorized to see events from the specified QA source.
|
||||
* @param context The context.
|
||||
* @param user The EPerson to consider
|
||||
* @param sourceName The source name
|
||||
*
|
||||
* @return True if the user is authorized to see events from the source, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean canSeeSource(Context context, EPerson user, String qaSource) {
|
||||
QASecurity qaSecurity = getQASecurity(qaSource);
|
||||
public boolean canSeeSource(Context context, EPerson user, String sourceName) {
|
||||
QASecurity qaSecurity = getQASecurity(sourceName);
|
||||
return qaSecurity.canSeeQASource(context, user);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user