/** * Add new child with text value. * @param nam The name of child * @param txt The text * @return The child bundle (use {@link #up()} on it in order to get back to * the parent bundle) */ @NotNull public JaxbBundle add(@NotNull final String nam, @NotNull final String txt) { final JaxbBundle child = new JaxbBundle(this, nam, txt); this.children.add(child); return child; }
/** * Get all locks of a user. * @return Locks * @throws IOException If fails */ private JaxbBundle list() throws IOException { return new JaxbBundle("locks").add( new JaxbBundle.Group<Map.Entry<String, String>>( this.user().locks().names().entrySet() ) { @Override public JaxbBundle bundle(final Map.Entry<String, String> ent) { return new JaxbBundle("lock") .add("name", ent.getKey()).up() .add("label", ent.getValue()).up(); } } ); }
/** * Get entrance page JAX-RS response. * @return The JAX-RS response * @throws IOException If fails */ @GET @Path("/") public Response index() throws IOException { return new PageBuilder() .stylesheet("/xsl/index.xsl") .build(StPage.class) .init(this) .append(new JaxbBundle("menu", "home")) .append( new JaxbBundle( "documentation", IOUtils.toString( this.getClass().getResourceAsStream( "doc-index.html" ) ) ) ) .render() .build(); }
/** * Make a bundle. * @param level Logging level * @param msg Message * @param msec Time spent * @return JaxbBundle injectable into the page */ public static JaxbBundle bundle(@NotNull final Level level, @NotNull final String msg, final long msec) { return new JaxbBundle("flash") .add("message", msg).up() .add("level", level.toString()).up() .add("msec", Long.toString(msec)).up(); }
@Override public void render(@NotNull final BasePage<?, ?> page, @NotNull final Response.ResponseBuilder builder) { page.append( new JaxbBundle("version", "") .add("name", this.version) .up() .add("revision", this.revision) .up() .add("date", this.date) .up() ); }
/** * Get entrance page JAX-RS response. * @return The JAX-RS response * @throws Exception If some problem inside */ @GET @Path("/") public Response index() throws Exception { return new PageBuilder() .stylesheet("/xsl/counters.xsl") .build(StPage.class) .init(this) .append( new JaxbBundle( "documentation", IOUtils.toString( this.getClass().getResourceAsStream( "doc-counters.html" ) ) ) ) .append(this.list()) .append(new JaxbBundle("menu", "counters")) .link(new Link("add", "./add")) .render() .build(); }
@Override public void render(final BasePage<?, ?> page, final Response.ResponseBuilder builder) { if (!BaseRs.this.auth().identity().equals(Identity.ANONYMOUS)) { try { page.append( new JaxbBundle("token", BaseRs.this.user().token()) ); } catch (final IOException ex) { throw new IllegalStateException(ex); } page.link(new Link("user:refresh", "/u/refresh")); } } };
/** * Get entrance page JAX-RS response. * @return The JAX-RS response * @throws Exception If some problem inside */ @GET @Path("/") public Response index() throws Exception { return new PageBuilder() .stylesheet("/xsl/locks.xsl") .build(StPage.class) .init(this) .append( new JaxbBundle( "documentation", IOUtils.toString( this.getClass().getResourceAsStream( "doc-locks.html" ) ) ) ) .append(this.list()) .append(new JaxbBundle("menu", "locks")) .link(new Link("lock", "./lock")) .link(new Link("label", "./label")) .link(new Link("unlock", "./unlock")) .render() .build(); }
return new JaxbBundle("counters").add( return new JaxbBundle("counter") .add("name", name) .up()
new JaxbBundle("identity") .add("urn", identity.urn().toString()) .up()