ResponseEntity createGroup()

in service/src/main/java/org/apache/fineract/cn/group/rest/GroupRestController.java [93:105]


  ResponseEntity<Void> createGroup(@RequestBody @Valid final Group group) {
    this.groupService.findByIdentifier(group.getIdentifier())
        .ifPresent(g -> {
          throw ServiceException.conflict("Group {0} already exists.", g.getIdentifier());
        });

    if (!this.groupDefinitionService.findByIdentifier(group.getGroupDefinitionIdentifier()).isPresent()) {
      throw ServiceException.notFound("Unknown group definition {0}.", group.getGroupDefinitionIdentifier());
    }

    this.commandGateway.process(new CreateGroupCommand(group));
    return ResponseEntity.accepted().build();
  }