org.takes.rs.xe.XeSource Java Examples
The following examples show how to use
org.takes.rs.xe.XeSource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TkDomains.java From jare with MIT License | 6 votes |
/** * Convert event to Xembly. * @param domain The event * @return Xembly * @throws IOException If fails */ private static XeSource source(final Domain domain) throws IOException { final String name = domain.name(); final Usage usage = domain.usage(); return new XeDirectives( new Directives() .add("domain") .add("name").set(name).up() .add("usage").set(usage.total()).up() .append( new XeLink( "delete", new Href("/delete").with("name", name) ).toXembly() ) .up() ); }
Example #2
Source File: XeGoogleLink.java From takes with MIT License | 6 votes |
/** * Ctor. * @param req Request * @param app Google application ID * @param rel Related * @param redir Redirect URI * @return Source * @throws IOException If fails * @since 0.14 * @checkstyle ParameterNumberCheck (4 lines) */ private static XeSource make(final Request req, final CharSequence app, final CharSequence rel, final CharSequence redir) throws IOException { return new XeLink( rel, new Href("https://accounts.google.com/o/oauth2/auth") .with("client_id", app) .with("redirect_uri", redir) .with("response_type", "code") .with("state", new RqHref.Base(req).href()) .with( "scope", "https://www.googleapis.com/auth/userinfo.profile" ) ); }
Example #3
Source File: XeIdentity.java From takes with MIT License | 6 votes |
/** * Ctor. * @param req Request */ public XeIdentity(final Request req) { super( new XeSource() { @Override public Iterable<Directive> toXembly() throws IOException { final Identity identity = new RqAuth(req).identity(); final Directives dirs = new Directives(); if (!identity.equals(Identity.ANONYMOUS)) { dirs.add("identity") .add("urn").set(identity.urn()).up(); for (final Map.Entry<String, String> prop : identity.properties().entrySet()) { dirs.add(prop.getKey()).set(prop.getValue()).up(); } } return dirs; } } ); }
Example #4
Source File: RsPage.java From jpeek with MIT License | 5 votes |
/** * Make it. * @param req Request * @param xsl XSL stylesheet * @param src Sources * @return Response */ @SuppressWarnings("PMD.AvoidDuplicateLiterals") private static Response make(final Request req, final String xsl, final Scalar<Iterable<XeSource>> src) { final Response raw = new RsXembly( new XeChain( new XeStylesheet( String.format("/org/jpeek/web/%s.xsl", xsl) ), new XeAppend( "page", new XeChain( new XeMillis(), new XeDirectives(new Header()), new XeChain(src), new XeMillis(true) ) ) ) ); return new RsFork( req, new FkTypes( "text/html", new RsXslt(new RsWithType(raw, "text/html")) ), new FkTypes( "application/vnd.jpeek+xml", new RsPrettyXml(new RsWithType(raw, "text/xml")) ), new FkTypes("*/*", raw) ); }
Example #5
Source File: TkIndex.java From jare with MIT License | 5 votes |
/** * Convert event to Xembly. * @param domain The event * @return Xembly * @throws IOException If fails */ private static XeSource source(final Domain domain) throws IOException { return new XeDirectives( new Directives() .add("domain") .add("name").set(domain.name()).up() .add("owner").set(domain.owner()).up() .add("usage").set(domain.usage().total()).up() .up() ); }
Example #6
Source File: XeFacebookLink.java From takes with MIT License | 5 votes |
/** * Ctor. * @param req Request * @param app Github application ID * @param rel Related * @param flag Flag to add * @return Source * @throws IOException If fails * @checkstyle ParameterNumberCheck (4 lines) */ private static XeSource make(final Request req, final CharSequence app, final CharSequence rel, final CharSequence flag) throws IOException { return new XeLink( rel, new Href("https://www.facebook.com/dialog/oauth") .with("client_id", app) .with( "redirect_uri", new RqHref.Base(req).href() .with(flag, PsFacebook.class.getSimpleName()) ) ); }
Example #7
Source File: XeGithubLink.java From takes with MIT License | 5 votes |
/** * Ctor. * @param req Request * @param app Github application ID * @param rel Related * @param flag Flag to add * @return Source * @throws IOException If fails * @checkstyle ParameterNumberCheck (4 lines) */ private static XeSource make(final Request req, final CharSequence app, final CharSequence rel, final CharSequence flag) throws IOException { return new XeLink( rel, new Href("https://github.com/login/oauth/authorize") .with("client_id", app) .with( "redirect_uri", new RqHref.Base(req).href() .with(flag, PsGithub.class.getSimpleName()) ) ); }
Example #8
Source File: RsPage.java From takes with MIT License | 5 votes |
/** * Ctor. * @param xsl XSL stylesheet name * @param source Xembly source */ RsPage(final String xsl, final XeSource source) { this.origin = new RsXslt( new RsXembly( new XeStylesheet(xsl), new XeAppend( "page", new XeMillis(false), source, new XeMillis(true) ) ) ); }
Example #9
Source File: Items.java From takes with MIT License | 5 votes |
@Override @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") public Iterable<Directive> toXembly() throws IOException { final Collection<XeSource> items = new LinkedList<>(); final File[] files = this.home.listFiles(); if (files != null) { for (final File file : files) { items.add(new Item(file)); } } return new Directives().add("files").append( new XeChain(items).toXembly() ); }
Example #10
Source File: RsPage.java From jare with MIT License | 4 votes |
/** * Make it. * @param xsl XSL * @param req Request * @param src Source * @return Response * @throws IOException If fails */ private static Response make(final String xsl, final Request req, final Iterable<XeSource> src) throws IOException { final Response raw = new RsXembly( new XeStylesheet(xsl), new XeAppend( "page", new XeMillis(false), new XeChain(src), new XeLinkHome(req), new XeLinkSelf(req), new XeMillis(true), new XeDate(), new XeSla(), new XeLocalhost(), new XeFlash(req), new XeWhen( new RqAuth(req).identity().equals(Identity.ANONYMOUS), new XeChain( new XeGithubLink(req, Manifests.read("Jare-GithubId")) ) ), new XeWhen( !new RqAuth(req).identity().equals(Identity.ANONYMOUS), new XeChain( new XeIdentity(req), new XeLogoutLink(req), new XeLink("domains", "/domains") ) ), new XeAppend( "version", new XeAppend("name", Manifests.read("Jare-Version")), new XeAppend("revision", Manifests.read("Jare-Revision")), new XeAppend("date", Manifests.read("Jare-Date")), new XeAppend("heroku", RsPage.heroku()) ) ) ); return new RsFork( req, new FkTypes( "application/xml,text/xml", new RsPrettyXml(new RsWithType(raw, "text/xml")) ), new FkTypes( "*/*", new RsXslt(new RsWithType(raw, "text/html")) ) ); }
Example #11
Source File: RsPage.java From jpeek with MIT License | 2 votes |
/** * Ctor. * @param req Request * @param xsl XSL stylesheet * @param src Sources */ RsPage(final Request req, final String xsl, final Scalar<Iterable<XeSource>> src) { super(RsPage.make(req, xsl, src)); }
Example #12
Source File: RsPage.java From jare with MIT License | 2 votes |
/** * Ctor. * @param xsl XSL * @param req Request * @param src Source * @throws IOException If fails */ public RsPage(final String xsl, final Request req, final XeSource... src) throws IOException { this(xsl, req, Arrays.asList(src)); }
Example #13
Source File: RsPage.java From jare with MIT License | 2 votes |
/** * Ctor. * @param xsl XSL * @param req Request * @param src Source * @throws IOException If fails */ public RsPage(final String xsl, final Request req, final Iterable<XeSource> src) throws IOException { super(RsPage.make(xsl, req, src)); }