use of org.dishevelled.bio.assembly.gfa1.Link in project ddf by codice.
the class KmlEndpoint method createRootNetworkLink.
private Kml createRootNetworkLink(UriInfo uriInfo) throws UnknownHostException {
Kml kml = KmlFactory.createKml();
NetworkLink rootNetworkLink = kml.createAndSetNetworkLink();
rootNetworkLink.setName(this.productName);
rootNetworkLink.setSnippet(KmlFactory.createSnippet().withMaxLines(0));
UriBuilder baseUrlBuidler = UriBuilder.fromUri(uriInfo.getBaseUri());
baseUrlBuidler.replacePath("");
this.baseUrl = baseUrlBuidler.build().toString();
String descriptionHtml = description;
Handlebars handlebars = new Handlebars(templateLoader);
try {
Template template = handlebars.compile("description");
descriptionHtml = template.apply(this);
LOGGER.debug(descriptionHtml);
} catch (IOException e) {
LOGGER.debug("Failed to apply description Template", e);
}
rootNetworkLink.setDescription(descriptionHtml);
rootNetworkLink.setOpen(true);
rootNetworkLink.setVisibility(false);
Link link = rootNetworkLink.createAndSetLink();
UriBuilder builder = UriBuilder.fromUri(uriInfo.getBaseUri());
builder = generateEndpointUrl(SystemBaseUrl.EXTERNAL.constructUrl(FORWARD_SLASH + CATALOG_URL_PATH + FORWARD_SLASH + KML_TRANSFORM_PARAM + FORWARD_SLASH + "sources", true), builder);
link.setHref(builder.build().toString());
link.setViewRefreshMode(ViewRefreshMode.NEVER);
link.setRefreshMode(RefreshMode.ON_INTERVAL);
link.setRefreshInterval(REFRESH_INTERVAL);
return kml;
}
use of org.dishevelled.bio.assembly.gfa1.Link in project ddf by codice.
the class KmlEndpointTest method testGetKmlNetworkLink.
@Test
public void testGetKmlNetworkLink() {
when(mockUriInfo.getQueryParameters(false)).thenReturn(mockMap);
KmlEndpoint kmlEndpoint = new KmlEndpoint(mockBranding, mockFramework);
kmlEndpoint.setDescription("This is some description.");
kmlEndpoint.setLogo("https://tools.codice.org/wiki/download/attachments/3047457/DDF?version=1&modificationDate=1369422662164&api=v2");
kmlEndpoint.setWebSite("https://tools.codice.org/wiki/display/DDF/DDF+Home");
Kml response = kmlEndpoint.getKmlNetworkLink(mockUriInfo);
assertThat(response, notNullValue());
assertThat(response.getFeature(), instanceOf(NetworkLink.class));
NetworkLink networkLink = (NetworkLink) response.getFeature();
Link link = networkLink.getLink();
assertThat(link, notNullValue());
assertThat(link.getHref(), notNullValue());
UriBuilder builder = UriBuilder.fromUri(link.getHref());
URI uri = builder.build();
assertThat(uri.getHost(), is(TEST_HOST));
assertThat(String.valueOf(uri.getPort()), is(TEST_PORT));
assertThat(uri.getPath(), is("/services/catalog/kml/sources"));
}
use of org.dishevelled.bio.assembly.gfa1.Link in project candlepin by candlepin.
the class RootResourceTest method getMethodEntryWithTrailingSlash.
@Test
public void getMethodEntryWithTrailingSlash() throws NoSuchMethodException {
Method m = FooResource.class.getMethod("methodWithTrailingSlash");
Link result = rootResource.methodLink("hello_world", m);
assertEquals("hello_world", result.getRel());
assertEquals("/foo/trailingslash", result.getHref());
}
use of org.dishevelled.bio.assembly.gfa1.Link in project tapestry5-hotel-booking by ccordenier.
the class AuthenticationFilter method dispatchedToLoginPage.
private boolean dispatchedToLoginPage(String pageName) throws IOException {
if (authenticator.isLoggedIn()) {
// Logged user should not go back to Signin or Signup
if (signinPage.equalsIgnoreCase(pageName) || signupPage.equalsIgnoreCase(pageName)) {
Link link = renderLinkSource.createPageRenderLink(defaultPage);
response.sendRedirect(link);
return true;
}
return false;
}
Component page = componentSource.getPage(pageName);
if (page.getClass().isAnnotationPresent(AnonymousAccess.class)) {
return false;
}
Link link = renderLinkSource.createPageRenderLink("Signin");
response.sendRedirect(link);
return true;
}
use of org.dishevelled.bio.assembly.gfa1.Link in project candlepin by candlepin.
the class RootResourceTest method testLinkedAnnotation.
@Test
void testLinkedAnnotation() throws NoSuchMethodException {
Method m = FooResource.class.getMethod("methodWithLinkedAnnotation");
Link result = rootResource.methodLink("annotated_method", m);
assertEquals("annotated_method", result.getRel());
assertEquals("/foo/linked", result.getHref());
}
Aggregations