/** * Should throw {@link IllegalArgumentException} if the instanceIdStr is not a UUID. * The instanceIdStr may not be a UUID if the rest request came from an old gadget config. */ private ApplicationId toApplicationLinkId(String instanceIdStr) { return instanceIdStr == null ? null : new ApplicationId(instanceIdStr); }
public ApplicationOption(final ApplicationId id, final String name, final TypeId typeId, final String typeI18nKey, final boolean isUal, final String iconUri) { this.id = id.get(); this.name = name; this.typeId = typeId.get(); this.typeI18nKey = typeI18nKey; this.isUal = isUal; this.iconUri = iconUri; } }
@Override public boolean equals(Object o) { if (o instanceof Site) { Site other = (Site) o; return applicationId.equals(other.applicationId); } return false; }
@POST @Path ("primary/{id}") public Response makePrimary(@PathParam ("id") final String idString) throws TypeNotInstalledException { final ApplicationId id = new ApplicationId(idString); applicationLinkService.makePrimary(id); return updated(Link.self(applicationLinkService.createSelfLinkFor(id)), i18nResolver.getText("applinks.primary", id.get())); }
final UpgradeApplicationLinkRequestEntity upgradeApplicationLinkRequestEntity) throws TypeNotInstalledException { final ApplicationId applicationId = new ApplicationId(id); final MutableApplicationLink applicationLink = applicationLinkService.getApplicationLink(applicationId); if (applicationLink == null) { final Manifest manifest = manifestRetriever .getManifest(applicationLink.getRpcUrl(), applicationLink.getType()); if (!applicationLink.getId().equals(manifest.getId())) { if (manifest.getAppLinksVersion() != null && manifest.getAppLinksVersion().getMajor() >= 3) { return performUalUpgrade(applicationLink, upgradeApplicationLinkRequestEntity, manifest); TypeId.getTypeId( applicationLink.getType()).toString(), applicationLink.getId().toString());
private ApplicationLink getApplicationLinkByIdOrName(String id) throws TypeNotInstalledException { ApplicationId appId = null; try { appId = new ApplicationId(id); } catch (IllegalArgumentException ex) { // not a valid id, try for name; } for (ApplicationLink link : appLinkService.getApplicationLinks()) { if ((appId == null && link.getName().equals(id)) || (appId != null && link.getId().equals(appId))) { return link; } } return null; }
public void makePrimary(final ApplicationId id) throws TypeNotInstalledException { applicationIdsLock.lock(); if (LOG.isDebugEnabled()) { LOG.debug("Making application link id [{}] primary", id.get()); } try { final InternalApplicationLink internalApplicationLink = getApplicationLink(id); if (internalApplicationLink == null) { throw new IllegalArgumentException("No application link with ID=" + id); } final Iterable<InternalApplicationLink> applicationLinksOfType = getInternalApplicationLinks(internalApplicationLink.getType().getClass()); for (final InternalApplicationLink link : applicationLinksOfType) { if (link.getId().equals(id)) { link.setPrimaryFlag(true); } else { link.setPrimaryFlag(false); } } eventPublisher.publish(new ApplicationLinkMadePrimaryEvent(internalApplicationLink)); } finally { applicationIdsLock.unlock(); } }
final String[] elements = StringUtils.split(pathInfo, '/'); if (elements.length > 0) { final ApplicationId id = new ApplicationId(elements[0]); try { final ApplicationLink link = applicationLinkService.getApplicationLink(id); logger.warn(String.format("Unable to load ApplicationLink %s due to uninstalled type definition (%s).", id.toString(), e.getType()), e); throw new NotFoundException(messageFactory.newI18nMessage("auth.config.applink.notfound", id.toString()));
@Override public String marshal(final ApplicationId v) throws Exception { return v.toString(); } }
@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; } } });
@Override public int hashCode() { return id != null ? id.hashCode() : 0; } }
@POST @Path("primary/{id}") public Response makePrimary(@PathParam("id") final String idString) throws TypeNotInstalledException { final ApplicationId id = new ApplicationId(idString); applicationLinkService.makePrimary(id); return updated(Link.self(applicationLinkService.createSelfLinkFor(id)), i18nResolver.getText("applinks.primary", id.get())); }
@Path("legacy/{applinkId}") public Response upgrade(@PathParam("applinkId") final String id) throws TypeNotInstalledException { final ApplicationId applicationId = new ApplicationId(id); final MutableApplicationLink applicationLink = applicationLinkService.getApplicationLink(applicationId); if (applicationLink == null) { final Manifest manifest = manifestRetriever .getManifest(applicationLink.getRpcUrl(), applicationLink.getType()); if (!applicationLink.getId().equals(manifest.getId())) { if (manifest.getAppLinksVersion() != null && manifest.getAppLinksVersion().getMajor() >= 3) { error = i18nResolver.getText("applinks.legacy.upgrade.error.ual"); TypeId.getTypeId( applicationLink.getType()).toString(), applicationLink.getId().toString());
/** * The URL is passed in a path parameter by old client code, so we must accept requests of that form. * New clients should use the query parameter which survives proxies better. If the query parameter * is present, use it and ignore the path parameter. (APL-663) */ @GET @Path("id/{applinkId}/url/{url:.*$}") public Response rpcUrlIsReachable(@PathParam("applinkId") String applicationId, @PathParam("url") URI uri, @QueryParam("url") URI qUrl) { if (qUrl != null) { uri = qUrl; } try { final Manifest manifest = downloader.download(uri); if (manifest.getId().equals(new ApplicationId(applicationId))) { return ok(); } else { return notFound(""); } } catch (ManifestNotFoundException e) { return notFound(""); } } }
public EntityLink apply(@Nullable EntityLink oldEntityLink) { if (oldEntityLink.getApplicationLink().getId().equals(from.getId())) { final EntityLink newEntityLink = entityLinkBuilderFactory.builder() .applicationLink(to) if (value != null) { final Properties primary = (Properties) value; if (from.getId().get().equals(primary.get(APPLICATION_ID))) { primary.put(APPLICATION_ID, to.getId().get()); props.putProperty(primaryPropertyKey, primary);
final String[] elements = StringUtils.split(pathInfo, '/'); if (elements.length > 0) { final ApplicationId id = new ApplicationId(elements[0]); try { final ApplicationLink link = applicationLinkService.getApplicationLink(id); logger.warn(String.format("Unable to load ApplicationLink %s due to uninstalled type definition (%s).", id.toString(), e.getType()), e); throw new AbstractApplinksServlet.NotFoundException(messageFactory.newI18nMessage("auth.config.applink.notfound", id.toString()));
@Override public String marshal(final ApplicationId v) throws Exception { return v.toString(); } }
@Override public int hashCode() { return applicationId != null ? applicationId.hashCode() : 0; } }
@Override public ApplicationId unmarshal(final String v) throws Exception { return new ApplicationId(v); }
public void associate(final Integer instanceId, final ApplicationId applicationId) { //todo: think about concurrency concerns? fishEyeProperties.setText(INSTANCE_ID_TO_APPLINKS_ID, applicationId.get(), instanceId); fishEyeProperties.setText(getApplinksIdKey(applicationId), Integer.toString(instanceId, 10)); log.debug("Associated FishEye instance id [{}] to application link id [{}]", instanceId, applicationId.get()); }