2023-10-24 17:47:13 +02:00
|
|
|
package eu.eudat.model.censorship;
|
|
|
|
|
|
|
|
import eu.eudat.authorization.Permission;
|
|
|
|
import eu.eudat.convention.ConventionService;
|
2023-10-26 11:07:04 +02:00
|
|
|
import eu.eudat.model.DmpReference;
|
2024-01-12 14:00:34 +01:00
|
|
|
import eu.eudat.model.censorship.dmpreference.DmpReferenceDataCensor;
|
2023-10-24 17:47:13 +02:00
|
|
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
|
|
import gr.cite.tools.data.censor.CensorFactory;
|
|
|
|
import gr.cite.tools.fieldset.FieldSet;
|
|
|
|
import gr.cite.tools.logging.DataLogEntry;
|
|
|
|
import gr.cite.tools.logging.LoggerService;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
|
|
import org.springframework.context.annotation.Scope;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
2023-10-26 11:07:04 +02:00
|
|
|
public class DmpReferenceCensor extends BaseCensor {
|
2023-10-24 17:47:13 +02:00
|
|
|
|
2023-10-26 11:07:04 +02:00
|
|
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpReferenceCensor.class));
|
2023-10-24 17:47:13 +02:00
|
|
|
|
|
|
|
protected final AuthorizationService authService;
|
|
|
|
protected final CensorFactory censorFactory;
|
|
|
|
|
2023-10-26 11:07:04 +02:00
|
|
|
public DmpReferenceCensor(ConventionService conventionService,
|
|
|
|
AuthorizationService authService,
|
|
|
|
CensorFactory censorFactory) {
|
2023-10-24 17:47:13 +02:00
|
|
|
super(conventionService);
|
|
|
|
this.authService = authService;
|
|
|
|
this.censorFactory = censorFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void censor(FieldSet fields, UUID userId) {
|
|
|
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
|
|
|
if (fields == null || fields.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2024-03-12 17:27:16 +01:00
|
|
|
this.authService.authorizeForce(Permission.BrowseDmpDescriptionTemplate, Permission.DeferredAffiliation);
|
2023-11-07 16:07:24 +01:00
|
|
|
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._dmp));
|
2023-10-26 11:07:04 +02:00
|
|
|
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
2023-11-07 16:07:24 +01:00
|
|
|
FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._reference));
|
|
|
|
this.censorFactory.censor(ReferenceCensor.class).censor(templateFields, userId);
|
2024-01-12 14:00:34 +01:00
|
|
|
FieldSet dataFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._data));
|
|
|
|
this.censorFactory.censor(DmpReferenceDataCensor.class).censor(dataFields, userId);
|
2023-10-24 17:47:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|