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); }
private Optional<Path> getInvoicingDirectory(Tenant tenant) { if (tenant != null) { Path localInvoicingDirectory = fileManager.resolvePermanentFilePath( Paths.get("tenants").resolve(tenant.getSlug()).resolve("invoicing")); if (localInvoicingDirectory.resolve(INVOICE_TEMPLATE_FILE_NAME).toFile().isFile()) { return Optional.of(localInvoicingDirectory); } } Path globalInvoicingDirectory = fileManager.resolvePermanentFilePath(Paths.get("invoicing")); if (globalInvoicingDirectory.resolve(INVOICE_TEMPLATE_FILE_NAME).toFile().isFile()) { return Optional.of(globalInvoicingDirectory); } return Optional.absent(); }
/** * @return this gateway global (server-level) configuration file * * @param fileName the name of the file to retrieve */ protected Optional<File> getTenantConfigurationFile(String fileName) { if (this.context.getTenant() == null) { return Optional.absent(); } return Optional.of(filesSettings.getPermanentDirectory() .resolve(TENANTS_DIRECTORY) .resolve(this.context.getTenant().getSlug()) .resolve(PAYMENTS_DIRECTORY) .resolve(this.getId()) .resolve(fileName).toFile()); }
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(); } } });
@Override public ContainerRequest filter(ContainerRequest request) { WebContext context = Utils.getComponent(WebContext.class); if (context.getTenant() == null) { return request; } URI requestURI = request.getRequestUri(); if (requestURI.getPath().indexOf("/api/") == 0 && requestURI.getPath().indexOf("/tenant/") != 0) { // API request routed via subdomain UriBuilder builder = UriBuilder.fromUri(requestURI); builder.replacePath("/tenant/" + context.getTenant().getSlug() + requestURI.getPath()); request.setUris(request.getBaseUri(), builder.build()); } return request; } }
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; } }
themeDirectory = getTenantThemeDirectory(tenant.get().getSlug(), themeId);
@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; } }
Tenant tenant = tenantStore.findBySlug(t.getSlug()); searchEngine.get().index(tenant, tenant); output.println("- indexing " + t.getSlug()); output.flush(); output.println("- indexing " + tenant.getSlug() + ":" + product.getSlug()); output.flush(); output.println("- indexing " + tenant.getSlug() + ":" + collection.getSlug()); output.flush();
siteName = Strings.isNullOrEmpty(tenant.getName()) ? tenant.getSlug() : tenant.getName(); } else { siteName = siteSettings.getName();
@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(); } }
put("name", Strings.isNullOrEmpty(tenant.getName()) ? tenant.getSlug() : tenant.getName()); put("description", tenant.getDescription()); }});
@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"); } }