52 lines
2.3 KiB
Java
52 lines
2.3 KiB
Java
package eu.eudat.model.censorship;
|
|
|
|
import eu.eudat.authorization.Permission;
|
|
import eu.eudat.convention.ConventionService;
|
|
import eu.eudat.model.DmpDescriptionTemplate;
|
|
import eu.eudat.model.DmpReference;
|
|
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)
|
|
public class DmpDescriptionTemplateCensor extends BaseCensor{
|
|
|
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpDescriptionTemplateCensor.class));
|
|
|
|
protected final AuthorizationService authService;
|
|
|
|
protected final CensorFactory censorFactory;
|
|
|
|
public DmpDescriptionTemplateCensor(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;
|
|
|
|
this.authService.authorizeForce(Permission.BrowseDescription);
|
|
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._dmp));
|
|
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
|
FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._descriptionTemplates));
|
|
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(descriptionTemplatesFields, userId);
|
|
FieldSet currentDescriptionTemplateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._currentDescriptionTemplate));
|
|
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(currentDescriptionTemplateFields, userId);
|
|
}
|
|
|
|
}
|