Skip to content

Commit

Permalink
- Removing unecessary revision checking.
Browse files Browse the repository at this point in the history
- Fixing error message when checking user, group, and policy revision.
  • Loading branch information
mcgilman committed Jun 28, 2016
1 parent 4bfcf71 commit d8edda4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
*/
public class StandardNiFiServiceFacade implements NiFiServiceFacade {
private static final Logger logger = LoggerFactory.getLogger(StandardNiFiServiceFacade.class);
private static final String NON_ZERO_STARTING_REVISION = "The revision must start at 0.";

// nifi core components
private ControllerFacade controllerFacade;
Expand Down Expand Up @@ -1273,9 +1272,6 @@ public AccessPolicyEntity createAccessPolicy(final Revision revision, final Acce
// TODO read lock on users and groups (and resource+action?) while the policy is being created?
final Authorizable tenantAuthorizable = authorizableLookup.getTenantAuthorizable();
final String creator = NiFiUserUtils.getNiFiUserName();
if (revision.getVersion() != 0) {
throw new IllegalArgumentException(NON_ZERO_STARTING_REVISION);
}
final AccessPolicy newAccessPolicy = accessPolicyDAO.createAccessPolicy(accessPolicyDTO);
final AccessPolicyDTO newAccessPolicyDto = dtoFactory.createAccessPolicyDto(newAccessPolicy,
newAccessPolicy.getGroups().stream().map(mapUserGroupIdToTenantEntity()).collect(Collectors.toSet()),
Expand All @@ -1293,9 +1289,6 @@ public AccessPolicyEntity createAccessPolicy(final Revision revision, final Acce
public UserEntity createUser(final Revision revision, final UserDTO userDTO) {
final Authorizable tenantAuthorizable = authorizableLookup.getTenantAuthorizable();
final String creator = NiFiUserUtils.getNiFiUserName();
if (revision.getVersion() != 0) {
throw new IllegalArgumentException(NON_ZERO_STARTING_REVISION);
}
final User newUser = userDAO.createUser(userDTO);
final UserDTO newUserDto = dtoFactory.createUserDto(newUser, newUser.getGroups().stream()
.map(mapUserGroupIdToTenantEntity()).collect(Collectors.toSet()));
Expand All @@ -1308,9 +1301,6 @@ public UserEntity createUser(final Revision revision, final UserDTO userDTO) {
public UserGroupEntity createUserGroup(final Revision revision, final UserGroupDTO userGroupDTO) {
final Authorizable tenantAuthorizable = authorizableLookup.getTenantAuthorizable();
final String creator = NiFiUserUtils.getNiFiUserName();
if (revision.getVersion() != 0) {
throw new IllegalArgumentException(NON_ZERO_STARTING_REVISION);
}
final Group newUserGroup = userGroupDAO.createUserGroup(userGroupDTO);
final UserGroupDTO newUserGroupDto = dtoFactory.createUserGroupDto(newUserGroup, newUserGroup.getUsers().stream()
.map(userId -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public Response createAccessPolicy(
}

if (accessPolicyEntity.getRevision() == null || (accessPolicyEntity.getRevision().getVersion() == null || accessPolicyEntity.getRevision().getVersion() != 0)) {
throw new IllegalArgumentException("A revision of 0 must be specified when creating a new Processor.");
throw new IllegalArgumentException("A revision of 0 must be specified when creating a new Policy.");
}

if (accessPolicyEntity.getComponent().getId() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public Response createUser(
}

if (userEntity.getRevision() == null || (userEntity.getRevision().getVersion() == null || userEntity.getRevision().getVersion() != 0)) {
throw new IllegalArgumentException("A revision of 0 must be specified when creating a new Processor.");
throw new IllegalArgumentException("A revision of 0 must be specified when creating a new User.");
}

if (userEntity.getComponent().getId() != null) {
Expand Down Expand Up @@ -550,7 +550,7 @@ public Response createUserGroup(
}

if (userGroupEntity.getRevision() == null || (userGroupEntity.getRevision().getVersion() == null || userGroupEntity.getRevision().getVersion() != 0)) {
throw new IllegalArgumentException("A revision of 0 must be specified when creating a new Processor.");
throw new IllegalArgumentException("A revision of 0 must be specified when creating a new User Group.");
}

if (userGroupEntity.getComponent().getId() != null) {
Expand Down

0 comments on commit d8edda4

Please sign in to comment.