use of org.talend.dataprep.security.Security in project data-prep by Talend.
the class PreparationConversions method toStudioPreparation.
private PreparationSummary toStudioPreparation(Preparation source, PreparationSummary target, ApplicationContext applicationContext) {
if (target.getOwner() == null) {
final Security security = applicationContext.getBean(Security.class);
Owner owner = new Owner(security.getUserId(), security.getUserDisplayName(), StringUtils.EMPTY);
target.setOwner(owner);
}
final PreparationRepository preparationRepository = applicationContext.getBean(PreparationRepository.class);
final ActionRegistry actionRegistry = applicationContext.getBean(ActionRegistry.class);
// Get preparation actions
PreparationActions prepActions = preparationRepository.get(source.getHeadId(), PreparationActions.class);
if (prepActions != null) {
List<Action> actions = prepActions.getActions();
boolean allowDistributedRun = true;
for (Action action : actions) {
final ActionDefinition actionDefinition = actionRegistry.get(action.getName());
if (actionDefinition.getBehavior().contains(ActionDefinition.Behavior.FORBID_DISTRIBUTED)) {
// Disallow distributed run
allowDistributedRun = false;
break;
}
}
target.setAllowDistributedRun(allowDistributedRun);
}
return target;
}
use of org.talend.dataprep.security.Security in project data-prep by Talend.
the class DataSetConversions method doWith.
@Override
public BeanConversionService doWith(BeanConversionService conversionService, String beanName, ApplicationContext applicationContext) {
conversionService.register(//
fromBean(DataSetMetadata.class).toBeans(//
UserDataSetMetadata.class).using(UserDataSetMetadata.class, (dataSetMetadata, userDataSetMetadata) -> {
final Security security = applicationContext.getBean(Security.class);
final UserDataRepository userDataRepository = applicationContext.getBean(UserDataRepository.class);
String userId = security.getUserId();
// update the dataset favorites
final UserData userData = userDataRepository.get(userId);
if (userData != null) {
userDataSetMetadata.setFavorite(userData.getFavoritesDatasets().contains(dataSetMetadata.getId()));
}
// and the owner (if not already present).
if (userDataSetMetadata.getOwner() == null) {
userDataSetMetadata.setOwner(new Owner(userId, security.getUserDisplayName(), StringUtils.EMPTY));
}
return userDataSetMetadata;
}).build());
return conversionService;
}
use of org.talend.dataprep.security.Security in project data-prep by Talend.
the class PreparationConversions method toUserPreparation.
private UserPreparation toUserPreparation(UserPreparation target, ApplicationContext applicationContext) {
if (target.getOwner() == null) {
final Security security = applicationContext.getBean(Security.class);
Owner owner = new Owner(security.getUserId(), security.getUserDisplayName(), StringUtils.EMPTY);
target.setOwner(owner);
}
return target;
}
Aggregations