Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
issue-1257 adding organizationNameKey parameter when creating an account
  • Loading branch information
pmiller7 committed Feb 3, 2017
commit 5ddd61ac1064e35e28bd30e417f322b0e1452eaa
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,22 @@ public interface CreateAccountRequest {
*/
AccountOptions getAccountOptions() throws IllegalStateException;

/**
* Returns {@code true} if the request has specified an organizationNameKey
*
* @return {@code true} if the request has specified an organizationNameKey
*
* @since 1.6.0
*/
boolean isOrganizationNameKeySpecified();

/**
* Returns the organizationNameKey to be used in the CreateAccountRequest
*
* @return organizationNameKey to be used in the CreateAccountRequest
*
* @since 1.6.0
*/
String getOrganizationNameKey();

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public interface CreateAccountRequestBuilder {
*/
CreateAccountRequestBuilder withResponseOptions(AccountOptions options) throws IllegalArgumentException;

/**
* Ensures that the account will be created in the organization specified (given that it is mapped to the Application)
*
* @return the builder instance for method chaining.
*/
CreateAccountRequestBuilder withOrganizationNameKey(String organizationNameKey) throws IllegalArgumentException;

/**
* Creates a new {@code CreateAccountRequest} instance based on the current builder state.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ public class DefaultCreateAccountRequest implements CreateAccountRequest {

private final AccountOptions options;

private final String organizationNameKey;

private PasswordFormat passwordFormat;

public DefaultCreateAccountRequest(Account account, Boolean registrationWorkflowEnabled, AccountOptions options) {
public DefaultCreateAccountRequest(Account account, Boolean registrationWorkflowEnabled, AccountOptions options, String organizationNameKey) {
Assert.notNull(account, "Account cannot be null.");
this.account = account;
this.registrationWorkflowEnabled = registrationWorkflowEnabled;
this.options = options;
this.organizationNameKey = organizationNameKey;
}

public Account getAccount() {
Expand Down Expand Up @@ -88,4 +91,14 @@ public AccountOptions getAccountOptions() {
}
return this.options;
}

@Override
public boolean isOrganizationNameKeySpecified() {
return this.organizationNameKey != null;
}

@Override
public String getOrganizationNameKey() {
return organizationNameKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class DefaultCreateAccountRequestBuilder implements CreateAccountRequestB
private Boolean registrationWorkflowEnabled;
private PasswordFormat passwordFormat;
private AccountOptions options;
private String organizationNameKey;

public DefaultCreateAccountRequestBuilder(Account account) {
Assert.notNull(account, "Account cannot be null.");
Expand Down Expand Up @@ -56,8 +57,14 @@ public CreateAccountRequestBuilder withResponseOptions(AccountOptions options) {
return this;
}

@Override
public CreateAccountRequestBuilder withOrganizationNameKey(String organizationNameKey) throws IllegalArgumentException {
this.organizationNameKey = organizationNameKey;
return this;
}

@Override
public CreateAccountRequest build() {
return new DefaultCreateAccountRequest(this.account, this.registrationWorkflowEnabled, this.options).setPasswordFormat(this.passwordFormat);
return new DefaultCreateAccountRequest(this.account, this.registrationWorkflowEnabled, this.options, this.organizationNameKey).setPasswordFormat(this.passwordFormat);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ public Account createAccount(CreateAccountRequest request) {
href += querySeparator + "passwordFormat=" + request.getPasswordFormat();
}

if (request.isOrganizationNameKeySpecified()) {
href += querySeparator + "organizationNameKey=" + request.getOrganizationNameKey();
}

if (request.isAccountOptionsSpecified()) {
return getDataStore().create(href, account, request.getAccountOptions());
}
Expand Down