2024-01-15 14:06:50 +01:00
|
|
|
package eu.eudat.model.censorship.dmpproperties;
|
|
|
|
|
|
|
|
import eu.eudat.authorization.Permission;
|
|
|
|
import eu.eudat.convention.ConventionService;
|
|
|
|
import eu.eudat.model.censorship.BaseCensor;
|
|
|
|
import eu.eudat.model.censorship.UserCensor;
|
|
|
|
import eu.eudat.model.dmpproperties.DmpContact;
|
|
|
|
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("dmpcontactcensor")
|
|
|
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
|
|
public class DmpContactCensor extends BaseCensor {
|
|
|
|
|
|
|
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpContactCensor.class));
|
|
|
|
|
|
|
|
protected final AuthorizationService authService;
|
|
|
|
protected final CensorFactory censorFactory;
|
|
|
|
|
|
|
|
public DmpContactCensor(ConventionService conventionService,
|
|
|
|
AuthorizationService authService, CensorFactory censorFactory) {
|
|
|
|
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-14 10:23:46 +01:00
|
|
|
this.authService.authorizeForce(Permission.BrowseDmp, Permission.DeferredAffiliation);
|
2024-01-15 14:06:50 +01:00
|
|
|
FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(DmpContact._user));
|
|
|
|
this.censorFactory.censor(UserCensor.class).censor(userFields, userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|