use of io.gravitee.am.service.model.NewOrganization in project gravitee-access-management by gravitee-io.
the class OrganizationCommandHandler method handle.
@Override
public Single<OrganizationReply> handle(OrganizationCommand command) {
OrganizationPayload organizationPayload = command.getPayload();
NewOrganization newOrganization = new NewOrganization();
newOrganization.setHrids(organizationPayload.getHrids());
newOrganization.setName(organizationPayload.getName());
newOrganization.setDescription(organizationPayload.getDescription());
newOrganization.setDomainRestrictions(organizationPayload.getDomainRestrictions());
return organizationService.createOrUpdate(organizationPayload.getId(), newOrganization, null).map(organization -> new OrganizationReply(command.getId(), CommandStatus.SUCCEEDED)).doOnSuccess(reply -> logger.info("Organization [{}] handled with id [{}].", organizationPayload.getName(), organizationPayload.getId())).doOnError(error -> logger.error("Error occurred when handling organization [{}] with id [{}].", organizationPayload.getName(), organizationPayload.getId(), error)).onErrorReturn(throwable -> new OrganizationReply(command.getId(), CommandStatus.ERROR));
}
Aggregations