ソースを参照

check for duplicate network name, add string resources for setting ssh key when creating plan

tags/v0.1.6
Jonathan Cobb 4年前
コミット
d35c29901a
5個のファイルの変更31行の追加16行の削除
  1. +4
    -0
      bubble-server/src/main/java/bubble/dao/cloud/BubbleNetworkDAO.java
  2. +5
    -2
      bubble-server/src/main/java/bubble/model/cloud/BubbleNetwork.java
  3. +16
    -13
      bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java
  4. +5
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties
  5. +1
    -1
      bubble-web

+ 4
- 0
bubble-server/src/main/java/bubble/dao/cloud/BubbleNetworkDAO.java ファイルの表示

@@ -67,6 +67,10 @@ public class BubbleNetworkDAO extends AccountOwnedEntityDAO<BubbleNetwork> {
return domainUuids;
}

public BubbleNetwork findByNameAndDomainName(String name, String domainName) {
return findByUniqueFields("name", name, "domainName", domainName);
}

@Override public void delete(String uuid) { delete(uuid, false); }
@Override public void forceDelete(String uuid) { delete(uuid, true); }



+ 5
- 2
bubble-server/src/main/java/bubble/model/cloud/BubbleNetwork.java ファイルの表示

@@ -42,7 +42,10 @@ import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.ENC_PAD;
@ECTypeChild(type=BubbleNode.class, backref="network")
})
@Entity @NoArgsConstructor @Accessors(chain=true)
@ECIndexes({ @ECIndex(unique=true, of={"account", "name"}) })
@ECIndexes({
@ECIndex(unique=true, of={"account", "name"}),
@ECIndex(unique=true, of={"name", "domainName"})
})
public class BubbleNetwork extends IdentifiableBase implements HasNetwork, HasBubbleTags<BubbleNetwork> {

public static final String[] UPDATE_FIELDS = {"footprint", "description", "locale", "timezone", "plan", "state"};
@@ -82,7 +85,7 @@ public class BubbleNetwork extends IdentifiableBase implements HasNetwork, HasBu

@ECSearchable(filter=true) @ECField(index=40)
@ECIndex @Column(nullable=false, updatable=false, length=DOMAIN_NAME_MAXLEN)
@Getter @Setter private String domainName; // denormalized from BubbleNetwork
@Getter @Setter private String domainName; // denormalized from BubbleDomain

@Transient @JsonIgnore public String getNetworkDomain () { return name + "." + domainName; }



+ 16
- 13
bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java ファイルの表示

@@ -77,14 +77,14 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco

@Override protected AccountPlan setReferences(ContainerRequest ctx, Account caller, AccountPlan request) {

final ValidationResult result = new ValidationResult();
if (!request.hasTimezone()) result.addViolation("err.timezone.required");
if (!request.hasLocale()) result.addViolation("err.locale.required");
final ValidationResult errors = new ValidationResult();
if (!request.hasTimezone()) errors.addViolation("err.timezone.required");
if (!request.hasLocale()) errors.addViolation("err.locale.required");

if (request.hasSshKey()) {
final AccountSshKey sshKey = sshKeyDAO.findByAccountAndId(caller.getUuid(), request.getSshKey());
if (sshKey == null) {
result.addViolation("err.sshPublicKey.notFound");
errors.addViolation("err.sshPublicKey.notFound");
} else {
request.setSshKey(sshKey.getUuid());
}
@@ -95,29 +95,32 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco
final BubbleDomain domain = domainDAO.findByAccountAndId(caller.getUuid(), request.getDomain());
if (domain == null) {
log.info("setReferences: domain not found: "+request.getDomain()+" for caller: "+caller.getUuid());
result.addViolation("err.domain.required");
errors.addViolation("err.domain.required");
} else {
request.setDomain(domain.getUuid());

final BubbleNetwork existingNetwork = networkDAO.findByNameAndDomainName(request.getName(), domain.getName());
if (existingNetwork != null) errors.addViolation("err.name.networkNameAlreadyExists");
}

final BubblePlan plan = planDAO.findByAccountOrParentAndId(caller, request.getPlan());
if (plan == null) {
result.addViolation("err.plan.required");
errors.addViolation("err.plan.required");
} else {
request.setPlan(plan.getUuid());
}

final BubbleNetwork network = networkDAO.findByAccountAndId(caller.getUuid(), request.getNetwork());
if (network != null) {
result.addViolation("err.network.exists", "A plan already exists for this network", request.getNetwork());
errors.addViolation("err.network.exists", "A plan already exists for this network", request.getNetwork());
}

final CloudService storage = selectStorageCloud(ctx, caller, request, result);
final CloudService storage = selectStorageCloud(ctx, caller, request, errors);

if (request.hasFootprint()) {
final BubbleFootprint footprint = footprintDAO.findByAccountAndId(caller.getUuid(), request.getFootprint());
if (footprint == null) {
result.addViolation("err.footprint.required");
errors.addViolation("err.footprint.required");
} else {
request.setFootprint(footprint.getUuid());
}
@@ -129,20 +132,20 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco
AccountPaymentMethod paymentMethod = null;
if (configuration.paymentsEnabled()) {
if (!request.hasPaymentMethodObject()) {
result.addViolation("err.paymentMethod.required");
errors.addViolation("err.paymentMethod.required");
} else {
if (request.getPaymentMethodObject().hasUuid()) {
paymentMethod = paymentMethodDAO.findByUuid(request.getPaymentMethodObject().getUuid());
if (paymentMethod == null) result.addViolation("err.purchase.paymentMethodNotFound");
if (paymentMethod == null) errors.addViolation("err.purchase.paymentMethodNotFound");
} else {
paymentMethod = request.getPaymentMethodObject();
}
if (paymentMethod != null) {
paymentMethod.setAccount(caller.getUuid()).validate(result, configuration);
paymentMethod.setAccount(caller.getUuid()).validate(errors, configuration);
}
}
}
if (result.isInvalid()) throw invalidEx(result);
if (errors.isInvalid()) throw invalidEx(errors);

if (domain != null && plan != null && storage != null) {
final BubbleNetwork newNetwork = networkDAO.create(request.bubbleNetwork(caller, domain, plan, storage));


+ 5
- 0
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties ファイルの表示

@@ -193,8 +193,12 @@ form_title_new_network=New Bubble
field_label_network_name=Name
field_label_network_domain=Domain
field_label_plan=Plan
field_label_show_advanced_plan_options=Show All Options
field_label_region=Location
field_label_footprint=Footprint
field_label_network_ssh_key=SSH Key
field_description_network_ssh_key=You can SSH into the Bubble with this key
message_network_ssh_key_do_not_install=Do not install any SSH key
field_label_paymentMethod=Payment
err_noPaymentMethods=No payment methods are configured. Contact the administrator of this system.
msg_km_distance_away=km away
@@ -392,6 +396,7 @@ err.label.invalid=Label is invalid
err.label.length=Label is too long
err.latlon.invalid=lat/lon is invalid
err.name.invalid=Name is invalid
err.name.networkNameAlreadyExists=Name is already in use
err.name.regexFailed=Name must start with a letter and can only contain letters, numbers, hyphens, periods and underscores
err.node.name.alreadyExists=A node already exists with the same FQDN
err.nodeOperationTimeout.required=Node operation timeout is required


+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit 110d70bde5bbb0ec675623a7c73d9377f772b87a
Subproject commit 8dbb686cfc8374050dc3223e0dddc7c3a30c173c

読み込み中…
キャンセル
保存