This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into mpa-8170-Update-Im…
…plemet-Integration-Tests-For-Organization-Serivce-1 # Conflicts: # ApiDocs/_apidoc.js
- Loading branch information
Showing
81 changed files
with
2,708 additions
and
2,001 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
scalecube-organization-api/src/main/java/io/scalecube/account/api/CreateUserResponse.java
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
scalecube-organization-api/src/main/java/io/scalecube/account/api/FindUserRequest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
scalecube-organization/src/main/java/io/scalecube/organization/domain/Entity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
scalecube-organization/src/main/java/io/scalecube/organization/domain/Organization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.