/** * Get the texts for the local entity type * * @return the {@link LocalTypeI18n} with text Strings */ @GET @Path("i18n") public LocalTypeI18n getI18n() { EntityType entityType = hostApplicationFacade.getEntityType(); return new LocalTypeI18n(i18nResolver.getText(entityType.getShortenedI18nKey()), i18nResolver.getText(entityType.getI18nKey())); }
@Nullable public static URI resolveIconUri(@Nonnull EntityType type) { checkNotNull(type, "type"); if (type instanceof IconizedType) { return ((IconizedType) type).getIconUri(); } else { return type.getIconUrl(); } }
public boolean apply(final EntityType input) { return input.getApplicationType().isAssignableFrom(type.getClass()); } });
@GET public Response getTypes() { List<BaseRestEntity> entityList = new ArrayList<BaseRestEntity>(); for (EntityType type : typeAccessor.getEnabledEntityTypes()) { BaseRestEntity.Builder builder = new BaseRestEntity.Builder(); builder.add("name", type.getI18nKey()); builder.add("iconUrl", type.getIconUrl()); builder.add("iconUri", resolveIconUri(type)); entityList.add(builder.build()); } return ok(entityList).build(); } }
@GET @Path("primaryLinks/{type}/{key}") public Response getEntityLinks(@PathParam("type") final TypeId localTypeId, @PathParam("key") final String localKey) { final EntityType localType = typeAccessor.loadEntityType(localTypeId.get()); checkPermissionToManageEntityLink(localKey, localType); final Map<String, Set<EntityLinkEntity>> linkMap = new HashMap<String, Set<EntityLinkEntity>>(); for (final EntityLink link : entityLinkService.getEntityLinksForKey(localKey, localType.getClass())) { Set<EntityLinkEntity> links = linkMap.get(link.getType().getI18nKey()); if (links == null) { links = new TreeSet<EntityLinkEntity>(PRIMARY_FIRST); linkMap.put(link.getType().getI18nKey(), links); } links.add(new EntityLinkEntity(link)); } return ok(linkMap); }
private BaseRestEntity getAllTypes() { BaseRestEntity.Builder singularTypes = new BaseRestEntity.Builder(); BaseRestEntity.Builder pluralTypes = new BaseRestEntity.Builder(); for (EntityType entityType : typeAccessor.getEnabledEntityTypes()) { String id = resolveEntityTypeId(entityType); singularTypes.add(id, i18nResolver.getText(entityType.getI18nKey())); pluralTypes.add(id, i18nResolver.getText(entityType.getPluralizedI18nKey())); } return new BaseRestEntity.Builder() .add("singular", singularTypes.build()) .add("plural", pluralTypes.build()) .build(); } }
private void parsePathParams(final String typeId) { if (!internalHostApplication.doesEntityExist(key, typeAccessor.loadEntityType(typeId).getClass())) { throw new AbstractApplinksServlet.BadRequestException(messageFactory.newLocalizedMessage( String.format("No entity exists with key %s of type %s", key, typeId))); } final EntityType entityType = typeAccessor.loadEntityType(typeId); assertPermission(entityType.getClass(), key); final EntityReference entityReference = internalHostApplication.toEntityReference(key, entityType.getClass()); type = typeId; typeLabel = messageFactory.newI18nMessage(entityType.getShortenedI18nKey()).toString(); name = entityReference.getName(); }
public EntityLink build() { // be nice - some entities keys will be equivalent to names if (name == null) { name = key; } return new DefaultEntityLink(checkNotNull(key, "key"), checkNotNull(type, "type"), checkNotNull(name, "name"), type.getDisplayUrl(checkNotNull(applicationLink), key), checkNotNull(applicationLink, "applicationLink"), propertyService, primary); } }
@Nonnull public static String resolveEntityTypeId(@Nonnull EntityType type) { return isIdentifiable(type) ? asIdentifiableType(type).getId().get() : type.getI18nKey(); }
/** * Add i18n properties for all enabled {@link ApplicationType}, {@link EntityType} and * {@link AuthenticationProvider}s * * @return the builder */ public BatchedJSONI18nBuilder withPluggableApplinksModules() { for (final ApplicationType applicationType : typeAccessor.getEnabledApplicationTypes()) { final String key = "applinks.application.type." + TypeId.getTypeId(applicationType); put(key, i18nResolver.getText(applicationType.getI18nKey())); } for (final EntityType entityType : typeAccessor.getEnabledEntityTypes()) { final String key = "applinks.entity.type." + TypeId.getTypeId(entityType); put(key, i18nResolver.getText(entityType.getI18nKey())); final String pluralKey = "applinks.entity.type.plural." + TypeId.getTypeId(entityType); put(pluralKey, i18nResolver.getText(entityType.getPluralizedI18nKey())); } for (final AuthenticationProviderModuleDescriptor authProvider : pluginAccessor.getEnabledModuleDescriptorsByClass(AuthenticationProviderModuleDescriptor.class)) { final String key = "applinks.auth.provider." + authProvider.getModule().getAuthenticationProviderClass().getName(); put(key, i18nResolver.getText(authProvider.getI18nNameKey())); } return this; }
public String apply(final EntityLink from) { final Map<String, String> propertyMap = new HashMap<String, String>(); propertyMap.put(KEY, from.getKey()); propertyMap.put(NAME, from.getName()); propertyMap.put(TYPE, getTypeId(from.getType()).get()); propertyMap.put(TYPE_I18N, from.getType().getI18nKey()); propertyMap.put(APPLICATION_ID, from.getApplicationLink().getId().get()); final StringWriter sw = new StringWriter(); try { new JSONObject(propertyMap).write(sw); } catch (JSONException e) { throw new RuntimeException(e); } return sw.getBuffer().toString(); } }));
@Nullable public static URI resolveIconUri(@Nonnull EntityType type) { checkNotNull(type, "type"); if (type instanceof IconizedType) { return ((IconizedType) type).getIconUri(); } else { return type.getIconUrl(); } }
public boolean apply(final EntityType input) { return input.getApplicationType().isAssignableFrom(type.getClass()); } });
} catch (ReciprocalActionException e) { final String warning = i18nResolver.getText("applinks.ual.upgrade.reciprocate.entitylinks.failed", i18nResolver.getText(entityLink.getType().getI18nKey()), // from "Charlie" i18nResolver.getText(entityReference.getType().getI18nKey()), // to "Charlie"
public ReferenceEntity apply(final EntityReference from) { return new ReferenceEntity( from.getKey(), from.getName(), TypeId.getTypeId(from.getType()), IconUriResolver.resolveIconUri(from.getType()), from.getType().getIconUrl()); } }));
public boolean apply(@Nullable EntityType input) { return input.getApplicationType().isAssignableFrom(applicationType.getClass()); } });
public EntityLinkEntity(final EntityLink entity) { this(entity.getApplicationLink().getId(), entity.getKey(), TypeId.getTypeId(entity.getType()), entity.getName(), entity.getDisplayUrl(), IconUriResolver.resolveIconUri(entity.getType()), entity.getType().getIconUrl(), entity.isPrimary()); }
public boolean apply(@Nullable EntityType input) { return input.getApplicationType().isAssignableFrom(applicationType.getClass()); } });
public boolean apply(@Nullable final EntityType input) { return TypeId.getTypeId(applicationLink.getType()).equals(TypeId.getTypeId(typeAccessor.getApplicationType(input.getApplicationType()))); } });
public boolean apply(@Nullable final EntityType input) { return TypeId.getTypeId(internalHostApplication.getType()).equals(TypeId.getTypeId(typeAccessor.getApplicationType(input.getApplicationType()))); } });