mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
Satisfy sonar
This commit is contained in:
@@ -16,6 +16,6 @@ public abstract class PermissionDtoToPermissionMapper {
|
|||||||
* @param permissionDto the source dto
|
* @param permissionDto the source dto
|
||||||
* @return the mapped target permission object
|
* @return the mapped target permission object
|
||||||
*/
|
*/
|
||||||
public abstract Permission map(@MappingTarget Permission target, PermissionDto permissionDto);
|
public abstract Permission modify(@MappingTarget Permission target, PermissionDto permissionDto);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.webcohesion.enunciate.metadata.rs.TypeHint;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import sonia.scm.repository.NamespaceAndName;
|
import sonia.scm.repository.NamespaceAndName;
|
||||||
|
import sonia.scm.repository.Permission;
|
||||||
import sonia.scm.repository.PermissionAlreadyExistsException;
|
import sonia.scm.repository.PermissionAlreadyExistsException;
|
||||||
import sonia.scm.repository.PermissionNotFoundException;
|
import sonia.scm.repository.PermissionNotFoundException;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
@@ -155,13 +156,12 @@ public class PermissionRootResource {
|
|||||||
PermissionDto permission) throws RepositoryException {
|
PermissionDto permission) throws RepositoryException {
|
||||||
log.info("try to update the permission with name: {}. the modified permission is: {}", permissionName, permission);
|
log.info("try to update the permission with name: {}. the modified permission is: {}", permissionName, permission);
|
||||||
Repository repository = checkPermission(namespace, name);
|
Repository repository = checkPermission(namespace, name);
|
||||||
repository.getPermissions()
|
Permission existingPermission = repository.getPermissions()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(perm -> StringUtils.isNotBlank(perm.getName()) && perm.getName().equals(permissionName))
|
.filter(perm -> StringUtils.isNotBlank(perm.getName()) && perm.getName().equals(permissionName))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.map(p -> dtoToModelMapper.map(p, permission))
|
.orElseThrow(() -> new PermissionNotFoundException(repository, permissionName));
|
||||||
.orElseThrow(() -> new PermissionNotFoundException(repository, permissionName))
|
dtoToModelMapper.modify(existingPermission, permission);
|
||||||
;
|
|
||||||
manager.modify(repository);
|
manager.modify(repository);
|
||||||
log.info("the permission with name: {} is updated.", permissionName);
|
log.info("the permission with name: {} is updated.", permissionName);
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
|
|||||||
Reference in New Issue
Block a user