@Override public URL create(E entity, Tenant tenant) { return this.create(entity, tenant, URLType.PUBLIC); }
protected String getPluralForm(E entity) { if (entity.getClass().isAnnotationPresent(PluralForm.class)) { return entity.getClass().getAnnotation(PluralForm.class).value(); } return Noun.pluralOf(getEntityName(entity)); }
@Override public URL create(E entity, Tenant tenant, URLType type) { String path = "/" + getPluralForm(entity) + "/" + entity.getSlug(); switch (type) { case API: path = "/api/" + path; return urlHelper.getTenantPlatformURL(tenant, path); case PUBLIC: default: return urlHelper.getTenantWebURL(tenant, path); } }
@Override public URL create(E entity) { return this.create(entity, context.getTenant(), URLType.PUBLIC); }
@Override public URL create(Entity entity, Tenant tenant, URLType type) { Preconditions.checkNotNull(entity, "Cannot create URL for a null entity"); // Check against CM if there is a entity URL factory registered with the type reference of // EntityURLFactory<EntityClass>, if not, use the "generic" (in the sense of default) // URL creation provided by super.create() try { EntityURLFactory urlFactory = this.componentManager.getInstance(entityURLFactoryOf(entity.getClass()).getType()); if (urlFactory != null) { return urlFactory.create(entity, tenant, type); } } catch (ComponentLookupException e) { // Ignore, will return later } return super.create(entity, tenant, type); }