use of com.epam.ta.reportportal.ws.model.EntryCreatedRS in project service-api by reportportal.
the class CreateWidgetHandlerImpl method createWidget.
@Override
public EntryCreatedRS createWidget(WidgetRQ createWidgetRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
List<UserFilter> userFilter = getUserFilters(createWidgetRQ.getFilterIds(), projectDetails.getProjectId(), user.getUsername());
BusinessRule.expect(widgetRepository.existsByNameAndOwnerAndProjectId(createWidgetRQ.getName(), user.getUsername(), projectDetails.getProjectId()), BooleanUtils::isFalse).verify(ErrorType.RESOURCE_ALREADY_EXISTS, createWidgetRQ.getName());
Widget widget = new WidgetBuilder().addWidgetRq(createWidgetRQ).addProject(projectDetails.getProjectId()).addFilters(userFilter).addOwner(user.getUsername()).get();
widgetContentFieldsValidator.validate(widget);
widgetPostProcessors.stream().filter(widgetPostProcessor -> widgetPostProcessor.supports(widget)).forEach(widgetPostProcessor -> widgetPostProcessor.postProcess(widget));
widgetRepository.save(widget);
aclHandler.initAcl(widget, user.getUsername(), projectDetails.getProjectId(), BooleanUtils.isTrue(createWidgetRQ.getShare()));
if (widget.isShared()) {
ofNullable(widget.getFilters()).ifPresent(filters -> updateUserFilterHandler.updateSharing(filters, projectDetails.getProjectId(), widget.isShared()));
}
messageBus.publishActivity(new WidgetCreatedEvent(TO_ACTIVITY_RESOURCE.apply(widget), user.getUserId(), user.getUsername()));
return new EntryCreatedRS(widget.getId());
}
use of com.epam.ta.reportportal.ws.model.EntryCreatedRS in project service-api by reportportal.
the class CreateProjectSettingsHandlerImpl method createPatternTemplate.
@Override
public EntryCreatedRS createPatternTemplate(String projectName, CreatePatternTemplateRQ createPatternTemplateRQ, ReportPortalUser user) {
Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
PatternTemplate patternTemplate = createPatternTemplateMapping.get(PatternTemplateType.fromString(createPatternTemplateRQ.getType()).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, Suppliers.formattedSupplier("Unknown pattern template type - '{}'", createPatternTemplateRQ.getType()).get()))).createPatternTemplate(project.getId(), createPatternTemplateRQ);
messageBus.publishActivity(new PatternCreatedEvent(user.getUserId(), user.getUsername(), PatternTemplateConverter.TO_ACTIVITY_RESOURCE.apply(patternTemplate)));
return new EntryCreatedRS(patternTemplate.getId());
}
Aggregations