/** * Convenience method for looking up {@link TypeId}s from {@link ApplicationType}s. The * {@code applinks-application-type} descriptor enforces that all registered {@link ApplicationType}s implement the * {@link IdentifiableType} interface, so the cast in the delegate method is safe. */ public static TypeId getTypeId(final ApplicationType type) { return get(type); }
@Override public TypeId unmarshal(final String v) throws Exception { return new TypeId(v); }
public EntityTypeEntity(final EntityType type) { this.typeId = TypeId.getTypeId(type); }
final TypeId typeId = new TypeId(getRequiredJSONString(obj, TYPE)); final EntityType type = typeAccessor.loadEntityType(typeId); PrimaryRef primaryRef = this.getPrimaryRef(localKey, lookUpTypeId(localType), getTypeId(type)); final boolean isPrimary; if (primaryRef != null) { isPrimary = primaryRef.refersTo(key, getTypeId(type), applicationLink.getId()); } else { isPrimary = false;
@Override public ApplicationLinkState callWithContext() throws Exception { if (manifestRetriever.getApplicationStatus(applicationLink.getRpcUrl(), applicationLink.getType()) == ApplicationStatus.UNAVAILABLE) { return ApplicationLinkState.OFFLINE; } else { try { final Manifest manifest = manifestRetriever.getManifest(applicationLink.getRpcUrl(), applicationLink.getType()); if (!applicationLink.getId().equals(manifest.getId())) { if (manifest.getAppLinksVersion() != null && manifest.getAppLinksVersion().getMajor() >= 3) { return ApplicationLinkState.UPGRADED_TO_UAL; } else { return ApplicationLinkState.UPGRADED; } } } catch (ManifestNotFoundException e) { // unknown application type LOG.error("The {} application type failed to produce a " + "Manifest for Application Link {}, so we cannot " + "determine the link status.", TypeId.getTypeId( applicationLink.getType()).toString(), applicationLink.getId().toString()); } return ApplicationLinkState.OK; } } });
public boolean refersTo(final String key, final TypeId type, final ApplicationId applicationId) { return this.key.equals(key) && this.type.equals(type) && this.applicationId.equals(applicationId); }
@Override public String toString() { return getId().toString(); }
/** * @param localType the {@link Class} of the {@link EntityType} to resolve an {@link TypeId} for * @return the {@link TypeId} of the specified {@link EntityType} * @throws IllegalStateException if the supplied class does not have an enabled implementation registered via the * {@code applinks-entity-link} module descriptor */ private TypeId lookUpTypeId(final Class<? extends EntityType> localType) { final EntityType type = typeAccessor.getEntityType(localType); if (type == null) { throw new IllegalStateException("Couldn't load " + localType.getName() + ", type not installed?"); } return TypeId.getTypeId(type); }
public Manifest getManifest(final URI url) throws ManifestNotFoundException { try { final Manifest downloadedManifest = downloader.download(url); if (downloadedManifest != null && getApplicationTypeId().equals(downloadedManifest.getTypeId())) { return downloadedManifest; } } catch (ManifestNotFoundException e) { LOG.debug("Failed to obtain an AppLinks manifest from the peer. " + "Treating the peer as a non-AppLinks capable host instead."); } return createManifest(url); }
@Override public String toString() { return getId().toString(); }
@Override public String marshal(final TypeId v) throws Exception { return v.get(); } }
ListApplicationLinksContext(final InternalHostApplication internalHostApplication, final InternalTypeAccessor typeAccessor, final I18nResolver i18nResolver, final DocumentationLinker documentationLinker, final OrphanedTrustDetector orphanedTrustDetector, final String contextPath, final boolean isSysadmin) { super(contextPath, internalHostApplication, typeAccessor, documentationLinker); this.i18nResolver = i18nResolver; this.orphanedTrustDetector = orphanedTrustDetector; this.isSysadmin = isSysadmin; entityTypeIdStrings = Sets.newHashSet( Iterables.transform(typeAccessor.getEntityTypesForApplicationType(TypeId.getTypeId(internalHostApplication.getType())), new Function<EntityType, String>() { public String apply(@Nullable EntityType from) { return TypeId.getTypeId(from).get(); } })); }
public TypeId getId() { return new TypeId("dummy"); } };