Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into mpa-8170-Update-Im…
Browse files Browse the repository at this point in the history
…plemet-Integration-Tests-For-Organization-Serivce-1

# Conflicts:
#	ApiDocs/_apidoc.js
  • Loading branch information
PavloPetrina committed Apr 17, 2019
2 parents 158def6 + b0c66b8 commit 95504ec
Show file tree
Hide file tree
Showing 81 changed files with 2,708 additions and 2,001 deletions.
1,742 changes: 1,742 additions & 0 deletions ApiDocs/_apidoc.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-parent-pom</artifactId>
<version>0.0.18</version>
<version>0.0.19</version>
</parent>

<artifactId>scalecube-organization-parent</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>2.1.3-SNAPSHOT</version>

<packaging>pom</packaging>

Expand All @@ -25,15 +25,15 @@

<properties>
<scalecube.config.version>0.3.9</scalecube.config.version>
<scalecube-services.version>2.4.10</scalecube-services.version>
<scalecube-security-jwt.version>1.0.3</scalecube-security-jwt.version>
<scalecube-services.version>2.5.4</scalecube-services.version>
<scalecube-security-jwt.version>1.0.7</scalecube-security-jwt.version>
<junit-jupiter.version>5.3.2</junit-jupiter.version>
<jackson.version>2.9.8</jackson.version>
<vault-java-driver.version>3.1.0</vault-java-driver.version>
<couchbase-client.version>2.6.0</couchbase-client.version>
<couchbase-client.version>2.7.3</couchbase-client.version>
<slf4j.version>1.7.7</slf4j.version>
<log4j.version>2.11.1</log4j.version>
<netty.version>4.1.31.Final</netty.version>
<netty.version>4.1.34.Final</netty.version>
<hamcrest-library.version>1.3</hamcrest-library.version>
<auth0-jwks-rsa.version>0.6.0</auth0-jwks-rsa.version>
<reactor.version>Californium-SR5</reactor.version>
Expand Down
2 changes: 1 addition & 1 deletion scalecube-organization-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-organization-parent</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>2.1.3-SNAPSHOT</version>
</parent>

<artifactId>scalecube-organization-api</artifactId>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package io.scalecube.account.api;

import java.util.Objects;
import java.util.StringJoiner;

/** Represents an organization member. */
public class OrganizationMember {
private String id;

private String id;
private String role;

/** Constructs an empty organization member. */
public OrganizationMember() {}
OrganizationMember() {}

/**
* Constructs an organization member using the user and role arguments.
Expand Down Expand Up @@ -45,6 +46,9 @@ public int hashCode() {

@Override
public String toString() {
return super.toString() + String.format("[userId=%s, role=%s]", id, role);
return new StringJoiner(", ", OrganizationMember.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("role='" + role + "'")
.toString();
}
}
2 changes: 1 addition & 1 deletion scalecube-organization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-organization-parent</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>2.1.3-SNAPSHOT</version>
</parent>

<artifactId>scalecube-organization</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import io.scalecube.organization.operation.LeaveOrganization;
import io.scalecube.organization.operation.UpdateOrganization;
import io.scalecube.organization.operation.UpdateOrganizationMemberRole;
import io.scalecube.organization.repository.OrganizationsDataAccess;
import io.scalecube.organization.repository.OrganizationsRepository;
import io.scalecube.organization.tokens.TokenVerifier;
import io.scalecube.organization.tokens.store.KeyStore;
import java.security.KeyPairGenerator;
Expand All @@ -54,7 +54,7 @@ public class OrganizationServiceImpl implements OrganizationService {
private static final Logger logger = LoggerFactory.getLogger(OrganizationServiceImpl.class);

private final TokenVerifier tokenVerifier;
private final OrganizationsDataAccess repository;
private final OrganizationsRepository repository;
private final KeyStore keyStore;
private final KeyPairGenerator keyPairGenerator;

Expand All @@ -66,7 +66,7 @@ public class OrganizationServiceImpl implements OrganizationService {
* @param tokenVerifier token verifier
*/
public OrganizationServiceImpl(
OrganizationsDataAccess repository, KeyStore keyStore, TokenVerifier tokenVerifier) {
OrganizationsRepository repository, KeyStore keyStore, TokenVerifier tokenVerifier) {
this.repository = repository;
this.keyStore = keyStore;
this.tokenVerifier = tokenVerifier;
Expand All @@ -92,7 +92,7 @@ public Mono<CreateOrganizationResponse> createOrganization(CreateOrganizationReq
logger.debug("createOrganization: exit, return: {}", response);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("createOrganization: ERROR: {}", ex);
logger.error("createOrganization: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -117,7 +117,7 @@ public Mono<GetMembershipResponse> getUserOrganizationsMembership(GetMembershipR
response.organizations().length);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("getUserOrganizationsMembership: ERROR: {}", ex);
logger.error("getUserOrganizationsMembership: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -139,7 +139,7 @@ public Mono<DeleteOrganizationResponse> deleteOrganization(DeleteOrganizationReq
logger.debug("deleteOrganization: exit, request: {}, response: {}", request, response);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("deleteOrganization: ERROR: {}", ex);
logger.error("deleteOrganization: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -161,7 +161,7 @@ public Mono<UpdateOrganizationResponse> updateOrganization(UpdateOrganizationReq
logger.debug("updateOrganization: exit, response: {}, request: {}", response, request);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("updateOrganization: ERROR: {}", ex);
logger.error("updateOrganization: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -185,7 +185,7 @@ public Mono<GetOrganizationMembersResponse> getOrganizationMembers(
response.members().length);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("getOrganizationMembers: ERROR: {}", ex);
logger.error("getOrganizationMembers: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -207,7 +207,7 @@ public Mono<InviteOrganizationMemberResponse> inviteMember(
logger.debug("inviteMember: return response: {}, request: {}", response, request);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("inviteMember: ERROR: {}", ex);
logger.error("inviteMember: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -229,7 +229,7 @@ public Mono<KickoutOrganizationMemberResponse> kickoutMember(
logger.debug("kickoutMember: exit, response: {}, request: {}", response, request);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("kickoutMember: ERROR: {}", ex);
logger.error("kickoutMember: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -250,7 +250,7 @@ public Mono<LeaveOrganizationResponse> leaveOrganization(LeaveOrganizationReques
logger.debug("leaveOrganization: exit, response: {}, request: {}", response, request);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("leaveOrganization: ERROR: {}", ex);
logger.error("leaveOrganization: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -274,7 +274,7 @@ public Mono<GetOrganizationResponse> addOrganizationApiKey(AddOrganizationApiKey
"addOrganizationApiKey: exit, response: {}, request: {}", response, request);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("addOrganizationApiKey: ERROR: {}", ex);
logger.error("addOrganizationApiKey: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -297,7 +297,7 @@ public Mono<GetOrganizationResponse> deleteOrganizationApiKey(
"deleteOrganizationApiKey: exit, response: {}, request: {}", response, request);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("deleteOrganizationApiKey: ERROR: {}", ex);
logger.error("deleteOrganizationApiKey: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -318,7 +318,7 @@ public Mono<GetOrganizationResponse> getOrganization(GetOrganizationRequest requ
logger.debug("getOrganization: exit, response: {}, request: {}", response, request);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("getOrganization: ERROR: {}", ex);
logger.error("getOrganization: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -341,7 +341,7 @@ public Mono<UpdateOrganizationMemberRoleResponse> updateOrganizationMemberRole(
"updateOrganizationMemberRole: exit, response: {}, request: {}", response, request);
result.success(response);
} catch (ServiceOperationException ex) {
logger.error("updateOrganizationMemberRole: ERROR: {}", ex);
logger.error("updateOrganizationMemberRole: ERROR", ex);
result.error(ex.getCause());
}
});
Expand All @@ -361,7 +361,7 @@ public Mono<GetPublicKeyResponse> getPublicKey(GetPublicKeyRequest request) {
.doOnSuccess(
response ->
logger.debug("getPublicKey: exit: response: {}, request: {}", response, request))
.doOnError(th -> logger.error("getPublicKey: ERROR: {}", th));
.doOnError(th -> logger.error("getPublicKey: ERROR", th));
}

private KeyPairGenerator keyPairGenerator() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.scalecube.organization.domain;

public abstract class Entity {

protected String id;
private long version;

public String id() {
return id;
}

public long version() {
return version;
}

public void version(long version) {
this.version = version;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package io.scalecube.organization.domain;

import static java.util.Objects.requireNonNull;

import io.scalecube.account.api.ApiKey;
import io.scalecube.account.api.OrganizationMember;
import io.scalecube.account.api.Role;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.StringJoiner;

/** Represents an Organization. */
public class Organization extends Entity {

private String name;
private String email;
private String keyId;
private Set<OrganizationMember> members = new HashSet<>();
private Set<ApiKey> apiKeys = new HashSet<>();

Organization() {}

/**
* Creates new instance of organization.
*
* @param id organization id.
* @param name organization name.
* @param email organization email.
* @param keyId organization key id.
* @param creatorUserId user id of organization creator.
*/
public Organization(String id, String name, String email, String keyId, String creatorUserId) {
this.id = requireNonNull(id, "organization id cannot be null");
this.name = requireNonNull(name, "organization name cannot be null");
this.email = requireNonNull(email, "organization email cannot be null");
this.keyId = requireNonNull(keyId, "organization keyId cannot be null");

addMember(
new OrganizationMember(
requireNonNull(creatorUserId, "organization creator id cannot be null"),
Role.Owner.name()));
}

public String name() {
return name;
}

public String email() {
return email;
}

public String keyId() {
return keyId;
}

public Set<OrganizationMember> members() {
return Collections.unmodifiableSet(members);
}

public Set<ApiKey> apiKeys() {
return Collections.unmodifiableSet(apiKeys);
}

public void changeName(String name) {
this.name = name;
}

public void changeEmail(String email) {
this.email = email;
}

public void addMember(OrganizationMember member) {
members.add(member);
}

public void removeMember(String userId) {
members.removeIf(member -> member.id().equals(userId));
}

public boolean isMember(String userId) {
return members.stream().anyMatch(member -> member.id().equals(userId));
}

public void updateMemberRole(String userId, Role role) {
removeMember(userId);
addMember(new OrganizationMember(userId, role.name()));
}

public void addApiKey(ApiKey apiKey) {
apiKeys.add(apiKey);
}

public void removeApiKey(String apiKeyName) {
apiKeys.removeIf(apiKey -> apiKey.name().equals(apiKeyName));
}

@Override
public String toString() {
return new StringJoiner(", ", Organization.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("name='" + name + "'")
.add("email='" + email + "'")
.add("keyId='" + keyId + "'")
.add("members=" + members)
.toString();
}
}
Loading

0 comments on commit 95504ec

Please sign in to comment.