Skip to content

Commit

Permalink
Fixed issue where non-administrator tool editor was unable to save en…
Browse files Browse the repository at this point in the history
…tities
  • Loading branch information
oleg-odysseus authored and alex-odysseus committed Dec 17, 2024
1 parent 2cfa1a1 commit 5acc126
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/main/java/org/ohdsi/webapi/tool/ToolServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import java.util.List;
import java.util.stream.Collectors;

import javax.ws.rs.ForbiddenException;

import org.ohdsi.webapi.service.AbstractDaoService;
import org.ohdsi.webapi.shiro.Entities.UserEntity;
import org.ohdsi.webapi.tool.converter.ToolConvertor;
Expand All @@ -25,17 +22,11 @@ public ToolServiceImpl(ToolRepository toolRepository, ToolConvertor toolConverto
public List<ToolDTO> getTools() {
List<Tool> tools = isAdmin() ? toolRepository.findAll() : toolRepository.findAllByIsEnabled(true);
return tools.stream()
.map(tool -> {
ToolDTO dto = toolConvertor.toDTO(tool);
return dto;
}).collect(Collectors.toList());
.map(toolConvertor::toDTO).collect(Collectors.toList());
}

@Override
public ToolDTO saveTool(ToolDTO toolDTO) {
if (!isAdmin()) {
throw new ForbiddenException();
}
Tool tool = saveToolFromDTO(toolDTO, getCurrentUser());
return toolConvertor.toDTO(toolRepository.saveAndFlush(tool));
}
Expand All @@ -56,9 +47,6 @@ public ToolDTO getById(Integer id) {

@Override
public void delete(Integer id) {
if (!isAdmin()) {
throw new ForbiddenException();
}
toolRepository.delete(id);
}
}

0 comments on commit 5acc126

Please sign in to comment.