private Optional<Path> resolveTenantTemplate(MailTemplate mail, Tenant tenant) { if (tenant == null) { return Optional.absent(); } String tenantSlug = tenant.getSlug(); return this.resolveTemplate(Paths.get("tenants").resolve(tenantSlug), mail); }
@Override public void delete(@Valid Tenant entity) throws EntityDoesNotExistException { this.dao.deleteEntityAndChildrenById(entity.getId()); }
Tenant tenant = new Tenant((UUID) result.getObject("id"), slug, configuration); tenant.setFeaturedImageId((UUID) result.getObject("featured_image_id")); tenant.setSlug(slug); tenant.setDefaultHost(defaultHost); tenant.setCreationDate(result.getTimestamp("creation_date")); tenant.setName(result.getString("name")); tenant.setDescription(result.getString("description")); tenant.setContactEmail(result.getString("contact_email"));
private String getTenantDomainName(String domainName, Tenant tenant) { if (!multitenancySettings.isActivated() || tenant == null) { return domainName; } else { } return Strings.isNullOrEmpty(tenant.getDefaultHost()) ? tenant.getSlug() + "." + domainName : tenant.getDefaultHost(); }
@Override public Map<String, Serializable> call() { synchronized (lock) { logger.debug("loading cache configuration value for tenant {}", tenant.getSlug()); Map<String, Serializable> tenantConfiguration = tenant.getConfiguration(); Map<String, Serializable> platformConfiguration = getExposedPlatformSettingsAsJson(); ConfigurationJsonMerger merger = new ConfigurationJsonMerger(platformConfiguration, tenantConfiguration); return merger.merge(); } } });
public Map<String, Object> purveyDocument(Tenant tenant) { Preconditions.checkNotNull(tenant); this.dao = this.dbi.get().onDemand(CollectionDAO.class); Map<String, Object> extracted = extractSourceFromEntity(tenant, tenant); List<Collection> collections = dao.findAll("collection", tenant.getId()); List<Map<String, Object>> collectionsSource = Lists.newArrayList(); for (Collection collection : collections) { Map<String, Object> collectionSource = extractSourceFromEntity(collection, tenant); collectionSource .put("api_url", urlHelper.getContextPlatformURL("/marketplace/api/shop/" + tenant.getSlug() + "/collections/" + collection.getSlug()).toString()); collectionsSource.add(collectionSource); } extracted.put("collections", collectionsSource); return extracted; } }
@Override public void update(Tenant tenant) throws InvalidEntityException, EntityDoesNotExistException { this.dao.begin(); Tenant originalProduct = this.findBySlug(tenant.getSlug()); if (originalProduct == null) { this.dao.commit(); throw new EntityDoesNotExistException(); } tenant.setId(originalProduct.getId()); Integer updatedRows = this.dao.update(tenant); this.dao.createOrUpdateAddons(tenant); this.dao.commit(); if (updatedRows <= 0) { throw new StoreException("No rows was updated when updating tenant"); } }
put("name", Strings.isNullOrEmpty(tenant.getName()) ? tenant.getSlug() : tenant.getName()); put("description", tenant.getDescription()); }});
@Override public Tenant create(Tenant tenant) throws EntityAlreadyExistsException, InvalidEntityException { if (this.dao.findBySlug(TENANT_TABLE_NAME, tenant.getSlug()) != null) { throw new EntityAlreadyExistsException(); } this.dao.begin(); TenantConfiguration configuration = tenant.getConfiguration(); try { String configurationAsJson = convertConfigurationToJSON(configuration); UUID id = UUID.randomUUID(); tenant.setId(id); this.dao.createEntity(tenant, TENANT_TABLE_NAME); this.dao.create(tenant, configuration.getVersion(), configurationAsJson); this.dao.createOrUpdateAddons(tenant); return tenant; } catch (JsonProcessingException e) { throw new RuntimeException("Failed to create tenant", e); } finally { this.dao.commit(); } }
site.put(SITE_TITLE, tenant.getName()); site.put(SITE_DESCRIPTION, tenant.getDescription()); ImageContextBuilder imageContextBuilder = new ImageContextBuilder(theme); if (tenant.getAddons().isLoaded()) { Map<String, Object> addons = addonsWebObjectBuilder.build(tenantData); site.put("addons", addons);
@Override public void supply(Map<String, Object> data) { if (context.getTenant() == null) { return; } data.put(THEME_PATH, ResourceResource.PATH); if (!data.containsKey(PAGE_TITLE)) { // Page title probably has been set already by when building the initial web view data : // for example a product page will set it to the product's title. // Here we handle the case where it has not been set, and set it to the name of the shop (of the tenant) data.put(PAGE_TITLE, context.getTenant().getName()); } } }
public static void main(String[] args) { Tenant tenant = new Tenant(); Apartment apartment = new Apartment(); tenant.setApartment(apartment); List<Tenant> tenants = new ArrayList<Tenant>(); tenants.add(tenant); apartment.setTenants(tenants); Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.persist(apartment); session.getTransaction().commit(); session.close(); }
public Tenant(String slug, TenantConfiguration configuration) { setSlug(slug); this.configuration = configuration; }
public boolean apply(@Nullable Tenant input) { return input.getDefaultHost().equals(host); } };
@Override public Tenant createDefaultTenant() throws EntityAlreadyExistsException { if (this.tenantStore.get().findAll(1, 0).size() != 0) { throw new EntityAlreadyExistsException("Cannot create default tenant : a tenant already exists"); } String slug = multitenancySettings.getDefaultTenantSlug(); TenantConfiguration configuration = new TenantConfiguration(); Tenant tenant = new Tenant(slug, configuration); try { this.tenantStore.get().create(tenant); } catch (InvalidEntityException e) { } return this.tenantStore.get().findBySlug(slug); }
Tenant tenant = tenantStore.findBySlug(t.getSlug()); searchEngine.get().index(tenant, tenant); output.println("- indexing " + t.getSlug()); output.flush(); for (Product product : this.productDAO.findAll("product", tenant.getId())) { output.println("- indexing " + tenant.getSlug() + ":" + product.getSlug()); output.flush(); for (Collection collection : this.collectionDAO.findAll("collection", tenant.getId())) { output.println("- indexing " + tenant.getSlug() + ":" + collection.getSlug()); output.flush();
@Override public Object get() { Tenant tenant = context.getTenant(); Map<String, Object> result = Maps.newHashMap(); String domain = null; if (multitenancySettings.isActivated()) { if (tenant != null) { domain = !Strings.isNullOrEmpty(tenant.getDefaultHost()) ? tenant.getDefaultHost() : tenant.getSlug() + "." + siteSettings.getDomainName(); } } if (domain == null) { domain = siteSettings.getDomainName(); } result.put("domain", domain); result.put("url", "http://" + domain); return result; } }
context.put("siteName", tenant.getName()); context.put("itemsTotal", itemsTotal); context.put("orderId", order.getSlug());