Khanh Maudoux created KNOX-815:
----------------------------------

             Summary: 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


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)

Reply via email to