Explorar el Código

use uuid/ctime/mtime constants. add http_url types to url fields

tags/v0.3.0
Jonathan Cobb hace 4 años
padre
commit
b7e9dff710
Se han modificado 19 ficheros con 42 adiciones y 21 borrados
  1. +2
    -1
      bubble-server/src/main/java/bubble/dao/account/AccountOwnedEntityDAO.java
  2. +3
    -1
      bubble-server/src/main/java/bubble/dao/account/AccountOwnedTemplateDAO.java
  3. +2
    -1
      bubble-server/src/main/java/bubble/dao/app/AppMatcherDAO.java
  4. +3
    -1
      bubble-server/src/main/java/bubble/dao/app/AppTemplateEntityDAO.java
  5. +3
    -1
      bubble-server/src/main/java/bubble/dao/bill/AccountPaymentDAO.java
  6. +3
    -1
      bubble-server/src/main/java/bubble/dao/bill/BillDAO.java
  7. +4
    -2
      bubble-server/src/main/java/bubble/dao/cloud/BubbleBackupDAO.java
  8. +2
    -1
      bubble-server/src/main/java/bubble/dao/cloud/BubbleNetworkDAO.java
  9. +2
    -1
      bubble-server/src/main/java/bubble/dao/cloud/BubbleNodeKeyDAO.java
  10. +2
    -1
      bubble-server/src/main/java/bubble/dao/cloud/CloudServiceDAO.java
  11. +3
    -1
      bubble-server/src/main/java/bubble/dao/cloud/CloudServiceDataDAO.java
  12. +1
    -1
      bubble-server/src/main/java/bubble/dao/device/DeviceDAO.java
  13. +2
    -2
      bubble-server/src/main/java/bubble/model/account/Account.java
  14. +2
    -1
      bubble-server/src/main/java/bubble/model/account/AccountContact.java
  15. +2
    -1
      bubble-server/src/main/java/bubble/model/app/AppSite.java
  16. +2
    -1
      bubble-server/src/main/java/bubble/model/app/BubbleApp.java
  17. +2
    -1
      bubble-server/src/main/java/bubble/model/app/RuleDriver.java
  18. +1
    -1
      bubble-server/src/main/java/bubble/model/device/Device.java
  19. +1
    -1
      utils/cobbzilla-wizard

+ 2
- 1
bubble-server/src/main/java/bubble/dao/account/AccountOwnedEntityDAO.java Ver fichero

@@ -16,6 +16,7 @@ import java.util.List;
import static bubble.ApiConstants.HOME_DIR;
import static org.cobbzilla.util.reflect.ReflectionUtil.getFirstTypeParam;
import static org.cobbzilla.util.security.ShaUtil.sha256_hex;
import static org.cobbzilla.wizard.model.Identifiable.UUID;
import static org.hibernate.criterion.Restrictions.eq;
import static org.hibernate.criterion.Restrictions.or;

@@ -31,7 +32,7 @@ public abstract class AccountOwnedEntityDAO<E extends HasAccount>
public List<E> findByAccount(String accountUuid) { return findByField("account", accountUuid); }

public E findByAccountAndId(String accountUuid, String id) {
final E found = findByUniqueFields("account", accountUuid, "uuid", id);
final E found = findByUniqueFields("account", accountUuid, UUID, id);
return found != null || !getHasNameField() ? found : findByUniqueFields("account", accountUuid, getNameField(), id);
}



+ 3
- 1
bubble-server/src/main/java/bubble/dao/account/AccountOwnedTemplateDAO.java Ver fichero

@@ -4,6 +4,8 @@ import bubble.model.account.AccountTemplate;

import java.util.List;

import static org.cobbzilla.wizard.model.Identifiable.UUID;

public class AccountOwnedTemplateDAO<E extends AccountTemplate> extends AccountOwnedEntityDAO<E> {

public List<E> findPublicTemplates(String accountUuid) {
@@ -11,7 +13,7 @@ public class AccountOwnedTemplateDAO<E extends AccountTemplate> extends AccountO
}

public E findPublicTemplate(String parentUuid, String id) {
final E found = findByUniqueFields("account", parentUuid, "enabled", true, "template", true, "uuid", id);
final E found = findByUniqueFields("account", parentUuid, "enabled", true, "template", true, UUID, id);
return found != null ? found : findByUniqueFields("account", parentUuid, "enabled", true, "template", true, getNameField(), id);
}



+ 2
- 1
bubble-server/src/main/java/bubble/dao/app/AppMatcherDAO.java Ver fichero

@@ -12,6 +12,7 @@ import org.springframework.stereotype.Repository;
import java.util.List;

import static org.cobbzilla.util.daemon.ZillaRuntime.die;
import static org.cobbzilla.wizard.model.Identifiable.MTIME;
import static org.hibernate.criterion.Restrictions.*;

@Repository @Slf4j
@@ -64,6 +65,6 @@ public class AppMatcherDAO extends AppTemplateEntityDAO<AppMatcher> {
}

public List<AppMatcher> findAllChangesSince(Long lastMod) {
return list(criteria().add(gt("mtime", lastMod)));
return list(criteria().add(gt(MTIME, lastMod)));
}
}

+ 3
- 1
bubble-server/src/main/java/bubble/dao/app/AppTemplateEntityDAO.java Ver fichero

@@ -5,6 +5,8 @@ import bubble.model.app.AppTemplateEntity;

import java.util.List;

import static org.cobbzilla.wizard.model.Identifiable.UUID;

public class AppTemplateEntityDAO<E extends AppTemplateEntity> extends AccountOwnedTemplateDAO<E> {

public E findByAccountAndAppAndName(String accountUuid, String appUuid, String name) {
@@ -16,7 +18,7 @@ public class AppTemplateEntityDAO<E extends AppTemplateEntity> extends AccountOw
}

public E findByAccountAndAppAndId(String account, String app, String id) {
final E found = findByUniqueFields("account", account, "app", app, "uuid", id);
final E found = findByUniqueFields("account", account, "app", app, UUID, id);
if (found != null) return found;
return findByUniqueFields("account", account, "app", app, getNameField(), id);
}


+ 3
- 1
bubble-server/src/main/java/bubble/dao/bill/AccountPaymentDAO.java Ver fichero

@@ -8,11 +8,13 @@ import org.springframework.stereotype.Repository;

import java.util.List;

import static org.cobbzilla.wizard.model.Identifiable.CTIME;

@Repository
public class AccountPaymentDAO extends AccountOwnedEntityDAO<AccountPayment> {

// newest first
@Override public Order getDefaultSortOrder() { return Order.desc("ctime"); }
@Override public Order getDefaultSortOrder() { return Order.desc(CTIME); }

public List<AccountPayment> findByAccountAndPlan(String accountUuid, String accountPlanUuid) {
return findByFields("account", accountUuid, "plan", accountPlanUuid);


+ 3
- 1
bubble-server/src/main/java/bubble/dao/bill/BillDAO.java Ver fichero

@@ -7,11 +7,13 @@ import org.springframework.stereotype.Repository;

import java.util.List;

import static org.cobbzilla.wizard.model.Identifiable.CTIME;

@Repository
public class BillDAO extends AccountOwnedEntityDAO<Bill> {

// newest first
@Override public Order getDefaultSortOrder() { return Order.desc("ctime"); }
@Override public Order getDefaultSortOrder() { return Order.desc(CTIME); }

public List<Bill> findByAccountAndAccountPlan(String accountUuid, String accountPlanUuid) {
return findByFields("account", accountUuid, "accountPlan", accountPlanUuid);


+ 4
- 2
bubble-server/src/main/java/bubble/dao/cloud/BubbleBackupDAO.java Ver fichero

@@ -13,6 +13,8 @@ import java.util.List;

import static org.cobbzilla.util.daemon.ZillaRuntime.die;
import static org.cobbzilla.util.time.TimeUtil.formatDuration;
import static org.cobbzilla.wizard.model.Identifiable.CTIME;
import static org.cobbzilla.wizard.model.Identifiable.UUID;
import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx;

@Repository
@@ -37,7 +39,7 @@ public class BubbleBackupDAO extends AccountOwnedEntityDAO<BubbleBackup> {
return findByFieldAndFieldIn("network", uuid, "status", BackupStatus.STUCK);
}

@Override public Order getDefaultSortOrder() { return Order.desc("ctime"); }
@Override public Order getDefaultSortOrder() { return Order.desc(CTIME); }

public BubbleBackup findByNetworkAndPath(String networkUuid, String path) {
return findByNetwork(networkUuid).stream()
@@ -54,7 +56,7 @@ public class BubbleBackupDAO extends AccountOwnedEntityDAO<BubbleBackup> {
}

public BubbleBackup findByNetworkAndId(String networkUuid, String id) {
BubbleBackup found = findByUniqueFields("network", networkUuid, "uuid", id);
BubbleBackup found = findByUniqueFields("network", networkUuid, UUID, id);
if (found != null) return found;
found = findByNetworkAndPath(networkUuid, id);
return found != null ? found : findByNetworkAndLabel(networkUuid, id);


+ 2
- 1
bubble-server/src/main/java/bubble/dao/cloud/BubbleNetworkDAO.java Ver fichero

@@ -19,6 +19,7 @@ import java.util.stream.Collectors;

import static bubble.model.cloud.BubbleNetwork.validateHostname;
import static bubble.server.BubbleConfiguration.getDEFAULT_LOCALE;
import static org.cobbzilla.wizard.model.Identifiable.UUID;
import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx;

@Repository @Slf4j
@@ -57,7 +58,7 @@ public class BubbleNetworkDAO extends AccountOwnedEntityDAO<BubbleNetwork> {
public BubbleNetwork findByDomainAndId(String domainUuid, String id) {
final List<String> domainUuids = getAllDomainUuids(domainUuid);

List<BubbleNetwork> found = findByFieldAndFieldIn("uuid", id, "domain", domainUuids);
List<BubbleNetwork> found = findByFieldAndFieldIn(UUID, id, "domain", domainUuids);
if (found != null && !found.isEmpty()) return found.get(0);

found = findByFieldAndFieldIn("name", id, "domain", domainUuids);


+ 2
- 1
bubble-server/src/main/java/bubble/dao/cloud/BubbleNodeKeyDAO.java Ver fichero

@@ -13,6 +13,7 @@ import java.util.List;
import java.util.stream.Collectors;

import static bubble.model.cloud.BubbleNodeKey.defaultExpiration;
import static org.cobbzilla.wizard.model.Identifiable.UUID;

@Repository @Slf4j
public class BubbleNodeKeyDAO extends AccountOwnedEntityDAO<BubbleNodeKey> {
@@ -63,7 +64,7 @@ public class BubbleNodeKeyDAO extends AccountOwnedEntityDAO<BubbleNodeKey> {
}

public BubbleNodeKey findByNodeAndUuid(String nodeUuid, String keyUuid) {
return filterValid(findByUniqueFields("node", nodeUuid, "uuid", keyUuid));
return filterValid(findByUniqueFields("node", nodeUuid, UUID, keyUuid));
}

public String findRemoteHostForNode(String nodeUuid) {


+ 2
- 1
bubble-server/src/main/java/bubble/dao/cloud/CloudServiceDAO.java Ver fichero

@@ -18,6 +18,7 @@ import java.util.List;
import static bubble.ApiConstants.ROOT_NETWORK_UUID;
import static bubble.cloud.storage.local.LocalStorageDriver.LOCAL_STORAGE;
import static bubble.model.cloud.CloudService.testDriver;
import static org.cobbzilla.wizard.model.Identifiable.UUID;
import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx;

@Repository
@@ -86,7 +87,7 @@ public class CloudServiceDAO extends AccountOwnedTemplateDAO<CloudService> {
}

public CloudService findByAccountAndTypeAndId(String accountUuid, CloudServiceType csType, String id) {
final CloudService found = findByUniqueFields("account", accountUuid, "type", csType, "enabled", true, "uuid", id);
final CloudService found = findByUniqueFields("account", accountUuid, "type", csType, "enabled", true, UUID, id);
return found != null ? found : findByUniqueFields("account", accountUuid, "type", csType, "enabled", true, "name", id);
}



+ 3
- 1
bubble-server/src/main/java/bubble/dao/cloud/CloudServiceDataDAO.java Ver fichero

@@ -6,6 +6,8 @@ import org.springframework.stereotype.Repository;

import java.util.List;

import static org.cobbzilla.wizard.model.Identifiable.UUID;

@Repository
public class CloudServiceDataDAO extends AccountOwnedEntityDAO<CloudServiceData> {

@@ -17,7 +19,7 @@ public class CloudServiceDataDAO extends AccountOwnedEntityDAO<CloudServiceData>

public CloudServiceData findByAccountAndCloudAndId(String accountUuid, String cloudUuid, String id) {
final CloudServiceData found = findByUniqueFields("account", accountUuid, "cloud", cloudUuid, "key", id);
return found != null ? found : findByUniqueFields("account", accountUuid, "cloud", cloudUuid, "uuid", id);
return found != null ? found : findByUniqueFields("account", accountUuid, "cloud", cloudUuid, UUID, id);
}

public CloudServiceData findByCloudAndKey(String cloudUuid, String key) {


+ 1
- 1
bubble-server/src/main/java/bubble/dao/device/DeviceDAO.java Ver fichero

@@ -26,7 +26,7 @@ public class DeviceDAO extends AccountOwnedEntityDAO<Device> {

@Autowired private BubbleConfiguration configuration;

@Override public Order getDefaultSortOrder() { return Order.asc("ctime"); }
@Override public Order getDefaultSortOrder() { return Order.asc(CTIME); }

public Device findByAccountAndName(String accountUuid, String name) {
return findByUniqueFields("account", accountUuid, "name", name);


+ 2
- 2
bubble-server/src/main/java/bubble/model/account/Account.java Ver fichero

@@ -81,7 +81,7 @@ public class Account extends IdentifiableBase implements TokenPrincipal, SqlView
return masked;
}

public static String accountField(String table) { return table.equalsIgnoreCase("account") ? "uuid" : "account"; }
public static String accountField(String table) { return table.equalsIgnoreCase("account") ? UUID : "account"; }

@ECSearchable(filter=true) @ECField(index=10)
@HasValue(message="err.name.required")
@@ -104,7 +104,7 @@ public class Account extends IdentifiableBase implements TokenPrincipal, SqlView
@Getter @Setter private String parent;
public boolean hasParent () { return parent != null; }

@ECSearchable(filter=true) @ECField(index=30)
@ECSearchable(filter=true) @ECField(index=30, type=EntityFieldType.http_url)
@Size(max=1024, message="err.url.length")
@Type(type=ENCRYPTED_STRING) @Column(columnDefinition="varchar("+(1024+ENC_PAD)+")")
@Getter @Setter private String url;


+ 2
- 1
bubble-server/src/main/java/bubble/model/account/AccountContact.java Ver fichero

@@ -29,13 +29,14 @@ import static org.cobbzilla.util.daemon.ZillaRuntime.*;
import static org.cobbzilla.util.json.JsonUtil.COMPACT_MAPPER;
import static org.cobbzilla.util.json.JsonUtil.json;
import static org.cobbzilla.util.reflect.ReflectionUtil.copy;
import static org.cobbzilla.wizard.model.Identifiable.UUID;
import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx;

@NoArgsConstructor @Accessors(chain=true) @EqualsAndHashCode(of={"info", "type"}) @ToString @Slf4j
public class AccountContact implements Serializable {

public static final int MAX_NICK_LENGTH = 100;
public static final String[] UPDATE_EXCLUDE_FIELDS = {"uuid", "type", "info"};
public static final String[] UPDATE_EXCLUDE_FIELDS = {UUID, "type", "info"};

public AccountContact(AccountContact other) { copy(this, other); }



+ 2
- 1
bubble-server/src/main/java/bubble/model/app/AppSite.java Ver fichero

@@ -8,6 +8,7 @@ import lombok.experimental.Accessors;
import org.cobbzilla.util.collection.ArrayUtil;
import org.cobbzilla.wizard.model.Identifiable;
import org.cobbzilla.wizard.model.IdentifiableBase;
import org.cobbzilla.wizard.model.entityconfig.EntityFieldType;
import org.cobbzilla.wizard.model.entityconfig.annotations.*;

import javax.persistence.Column;
@@ -69,7 +70,7 @@ public class AppSite extends IdentifiableBase implements AppTemplateEntity {
@Column(nullable=false, length=10000)
@Getter @Setter private String description;

@ECSearchable(filter=true) @ECField(index=70)
@ECSearchable(filter=true) @ECField(index=70, type=EntityFieldType.http_url)
@Column(nullable=false, length=1024)
@Getter @Setter private String url;



+ 2
- 1
bubble-server/src/main/java/bubble/model/app/BubbleApp.java Ver fichero

@@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.cobbzilla.wizard.model.Identifiable;
import org.cobbzilla.wizard.model.entityconfig.EntityFieldType;
import org.cobbzilla.wizard.model.entityconfig.IdentifiableBaseParentEntity;
import org.cobbzilla.wizard.model.entityconfig.annotations.*;
import org.cobbzilla.wizard.validation.HasValue;
@@ -53,7 +54,7 @@ public class BubbleApp extends IdentifiableBaseParentEntity implements AccountTe
@Column(length=UUID_MAXLEN, nullable=false, updatable=false)
@Getter @Setter private String account;

@ECSearchable(filter=true) @ECField(index=30)
@ECSearchable(filter=true) @ECField(index=30, type=EntityFieldType.http_url)
@HasValue(message="err.url.required")
@Size(max=1024, message="err.url.length")
@Type(type=ENCRYPTED_STRING) @Column(columnDefinition="varchar("+(1024+ENC_PAD)+") NOT NULL")


+ 2
- 1
bubble-server/src/main/java/bubble/model/app/RuleDriver.java Ver fichero

@@ -14,6 +14,7 @@ import org.cobbzilla.util.collection.NameAndValue;
import org.cobbzilla.wizard.model.Identifiable;
import org.cobbzilla.wizard.model.IdentifiableBase;
import org.cobbzilla.wizard.model.SemanticVersion;
import org.cobbzilla.wizard.model.entityconfig.EntityFieldType;
import org.cobbzilla.wizard.model.entityconfig.annotations.*;
import org.cobbzilla.wizard.validation.HasValue;

@@ -80,7 +81,7 @@ public class RuleDriver extends IdentifiableBase implements AccountTemplate {
@Column(length=200)
@Getter @Setter private String author;

@ECSearchable(filter=true) @ECField(index=60)
@ECSearchable(filter=true) @ECField(index=60, type=EntityFieldType.http_url)
@Column(length=1024)
@Getter @Setter private String url;



+ 1
- 1
bubble-server/src/main/java/bubble/model/device/Device.java Ver fichero

@@ -33,7 +33,7 @@ import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.ENC_PAD;
})
public class Device extends IdentifiableBase implements HasAccount {

public static final String[] CREATE_FIELDS = { "uuid", "name", "enabled", "totpKey" };
public static final String[] CREATE_FIELDS = { UUID, "name", "enabled", "totpKey" };
public static final String[] UPDATE_FIELDS = { "name", "enabled" };

public static final String UNINITIALIZED_DEVICE = "__uninitialized_device__";


+ 1
- 1
utils/cobbzilla-wizard

@@ -1 +1 @@
Subproject commit 60db678ffa4344acea2e470f776cec7e2bfb33f8
Subproject commit 7c53947a0987c4ae80b835ff0d9cbef32de8efb8

Cargando…
Cancelar
Guardar