You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "Vincent Devillers (JIRA)" <ji...@apache.org> on 2016/12/26 11:57:58 UTC
[jira] [Commented] (KNOX-815) Add list in Oozie for ClientDSL
[ https://issues.apache.org/jira/browse/KNOX-815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15778207#comment-15778207 ]
Vincent Devillers commented on KNOX-815:
----------------------------------------
Duplicate with KNOX-835
> Add list in Oozie for ClientDSL
> -------------------------------
>
> Key: KNOX-815
> URL: https://issues.apache.org/jira/browse/KNOX-815
> Project: Apache Knox
> Issue Type: Improvement
> Components: ClientDSL
> Affects Versions: 0.7.0
> Reporter: Khanh Maudoux
> Priority: Minor
> Labels: KIP-4
> Fix For: 0.12.0
>
>
> The ClientDSL for Oozie shoud provide the list method.
> It could be easily done with something like that (in a java 8 style):
> {code:xml}
> public static class Request extends AbstractRequest<Status.Response> {
> private List<String> filter = new ArrayList<>();
> private String type;
> Request( Hadoop session ) {
> super( session );
> }
> public Request filter( String filter ) {
> this.filter.add( filter );
> return this;
> }
> public Request type( String type ) {
> this.type = type;
> return this;
> }
> protected Callable<Status.Response> callable() {
> return new Callable<Status.Response>() {
> @Override
> public Status.Response call() throws Exception {
> String comma = URLEncoder.encode(";");
> String filters = Request.this.filter.stream().map(e -> URLEncoder.encode(e)).collect(Collectors.joining(comma));
> URIBuilder uri = null;
> if (StringUtils.isEmpty(filters)) {
> uri = Request.this.uri(new String[]{Workflow.SERVICE_PATH, "/jobs/"});
> } else {
> uri = Request.this.uri(new String[]{Workflow.SERVICE_PATH, "/jobs/", "?filter=" + filters});
> }
> if (StringUtils.isNotEmpty(type)) {
> uri.addParameter("jobtype", type);
> }
> HttpGet request = new HttpGet(uri.build());
> return new Status.Response((Request.this.execute(request)));
> }
> };
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)