You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/12/30 12:51:12 UTC
ambari git commit: AMBARI-8950. Views: Pig,
add autocomplete for path inputs. (alexantonenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 10a9c63e8 -> d40a2e5f1
AMBARI-8950. Views: Pig, add autocomplete for path inputs. (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d40a2e5f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d40a2e5f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d40a2e5f
Branch: refs/heads/trunk
Commit: d40a2e5f1b8256aa2c510c3535cb5f95bbf90df9
Parents: 10a9c63
Author: Alex Antonenko <hi...@gmail.com>
Authored: Tue Dec 30 12:52:47 2014 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Tue Dec 30 13:50:54 2014 +0200
----------------------------------------------------------------------
.../view/pig/resources/files/FileService.java | 19 +-
.../view/pig/templeton/client/Request.java | 261 ------------------
.../pig/templeton/client/RequestWrapper.java | 271 +++++++++++++++++++
.../pig/templeton/client/TempletonRequest.java | 2 +-
.../ui/pig-web/app/components/pathInput.js | 50 ++++
.../main/resources/ui/pig-web/app/initialize.js | 1 +
.../app/templates/modal/createScript.hbs | 4 +-
.../pig-web/app/templates/modal/createUdf.hbs | 8 +-
.../src/main/resources/ui/pig-web/bower.json | 3 +-
.../apache/ambari/view/pig/test/FileTest.java | 16 +-
10 files changed, 356 insertions(+), 279 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/resources/files/FileService.java
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/resources/files/FileService.java b/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/resources/files/FileService.java
index aaf877c..6a2628d 100644
--- a/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/resources/files/FileService.java
+++ b/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/resources/files/FileService.java
@@ -25,6 +25,7 @@ import org.apache.ambari.view.pig.services.BaseService;
import org.apache.ambari.view.pig.utils.*;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileAlreadyExistsException;
+import org.apache.hadoop.fs.FileStatus;
import org.json.simple.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,6 +35,8 @@ import javax.ws.rs.*;
import javax.ws.rs.core.*;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
/**
* File access resource
@@ -60,9 +63,21 @@ public class FileService extends BaseService {
@GET
@Path("{filePath:.*}")
@Produces(MediaType.APPLICATION_JSON)
- public Response getFile(@PathParam("filePath") String filePath, @QueryParam("page") Long page) throws IOException, InterruptedException {
- LOG.debug("Reading file " + filePath);
+ public Response getFile(@PathParam("filePath") String filePath,
+ @QueryParam("page") Long page,
+ @QueryParam("action") String action) throws IOException, InterruptedException {
try {
+ if (action != null && action.equals("ls")) {
+ LOG.debug("List directory " + filePath);
+ List<String> ls = new LinkedList<String>();
+ for (FileStatus fs : getHdfsApi().listdir(filePath)) {
+ ls.add(fs.getPath().toString());
+ }
+ JSONObject object = new JSONObject();
+ object.put("ls", ls);
+ return Response.ok(object).status(200).build();
+ }
+ LOG.debug("Reading file " + filePath);
FilePaginator paginator = new FilePaginator(filePath, context);
if (page == null)
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/Request.java
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/Request.java b/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/Request.java
deleted file mode 100644
index 521bfad..0000000
--- a/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/Request.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.view.pig.templeton.client;
-
-import com.google.gson.Gson;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-import org.apache.ambari.view.ViewContext;
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.core.UriBuilder;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Request handler, supports GET, POST, PUT, DELETE methods
- * @param <RESPONSE> data type to deserialize response from JSON
- */
-public class Request<RESPONSE> {
- protected final Class<RESPONSE> responseClass;
- protected final ViewContext context;
- protected final WebResource resource;
-
- protected final Gson gson = new Gson();
-
- protected final static Logger LOG =
- LoggerFactory.getLogger(Request.class);
-
- /**
- * Constructor
- * @param resource object that represents resource
- * @param responseClass model class
- * @param context View Context instance
- */
- public Request(WebResource resource, Class<RESPONSE> responseClass, ViewContext context) {
- this.resource = resource;
- this.responseClass = responseClass;
- this.context = context;
- }
-
- /**
- * Main implementation of GET request
- * @param resource resource
- * @return unmarshalled response data
- */
- public RESPONSE get(WebResource resource) throws IOException {
- LOG.debug("GET " + resource.toString());
-
- InputStream inputStream = context.getURLStreamProvider().readFrom(resource.toString(), "GET",
- null, new HashMap<String, String>());
-
- LOG.info(String.format("curl \"" + resource.toString() + "\""));
- String responseJson = IOUtils.toString(inputStream);
- LOG.debug(String.format("RESPONSE => %s", responseJson));
- return gson.fromJson(responseJson, responseClass);
- }
-
- /**
- * Make GET request
- * @see #get(WebResource)
- */
- public RESPONSE get() throws IOException {
- return get(this.resource);
- }
-
- /**
- * Make GET request
- * @see #get(WebResource)
- */
- public RESPONSE get(MultivaluedMapImpl params) throws IOException {
- return get(this.resource.queryParams(params));
- }
-
- /**
- * Main implementation of POST request
- * @param resource resource
- * @param data post body
- * @return unmarshalled response data
- */
- public RESPONSE post(WebResource resource, MultivaluedMapImpl data) throws IOException {
- LOG.debug("POST " + resource.toString());
- LOG.debug("data: " + data.toString());
-
- StringBuilder curlBuilder = new StringBuilder();
-
- UriBuilder builder = UriBuilder.fromPath("host/");
- for(String key : data.keySet()) {
- for(String value : data.get(key)) {
- builder.queryParam(key, value);
- curlBuilder.append(String.format("-d %s=\"%s\"", key, value.replace("\"", "\\\"")));
- }
- }
-
- if (data != null)
- LOG.debug("... data: " + builder.build().getRawQuery());
-
- Map<String, String> headers = new HashMap<String, String>();
- headers.put("Content-Type", "application/x-www-form-urlencoded");
-
- LOG.info(String.format("curl " + curlBuilder.toString() + " \"" + resource.toString() + "\""));
- InputStream inputStream = context.getURLStreamProvider().readFrom(resource.toString(),
- "POST", builder.build().getRawQuery(), headers);
- String responseJson = IOUtils.toString(inputStream);
-
- LOG.debug(String.format("RESPONSE => %s", responseJson));
- return gson.fromJson(responseJson, responseClass);
- }
-
- /**
- * @see #post(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE post(MultivaluedMapImpl data) throws IOException {
- return post(resource, data);
- }
-
- /**
- * @see #post(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE post() throws IOException {
- return post(resource, new MultivaluedMapImpl());
- }
-
- /**
- * @see #post(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE post(MultivaluedMapImpl params, MultivaluedMapImpl data) throws IOException {
- return post(resource.queryParams(params), data);
- }
-
- /**
- * Main implementation of PUT request
- * @param resource resource
- * @param data put body
- * @return unmarshalled response data
- */
- public RESPONSE put(WebResource resource, MultivaluedMapImpl data) throws IOException {
- LOG.debug("PUT " + resource.toString());
-
- StringBuilder curlBuilder = new StringBuilder();
-
- UriBuilder builder = UriBuilder.fromPath("host/");
- for(String key : data.keySet()) {
- for(String value : data.get(key)) {
- builder.queryParam(key, value);
- curlBuilder.append(String.format("-d %s=\"%s\"", key, value.replace("\"", "\\\"")));
- }
- }
-
- if (data != null)
- LOG.debug("... data: " + builder.build().getRawQuery());
-
- Map<String, String> headers = new HashMap<String, String>();
- headers.put("Content-Type", "application/x-www-form-urlencoded");
-
- LOG.info(String.format("curl -X PUT " + curlBuilder.toString() + " \"" + resource.toString() + "\""));
-
- InputStream inputStream = context.getURLStreamProvider().readFrom(resource.toString(),
- "PUT", builder.build().getRawQuery(), headers);
- String responseJson = IOUtils.toString(inputStream);
-
- LOG.debug(String.format("RESPONSE => %s", responseJson));
- return gson.fromJson(responseJson, responseClass);
- }
-
- /**
- * @see #put(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE put(MultivaluedMapImpl data) throws IOException {
- return put(resource, data);
- }
-
- /**
- * @see #put(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE put() throws IOException {
- return put(resource, new MultivaluedMapImpl());
- }
-
- /**
- * @see #put(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE put(MultivaluedMapImpl params, MultivaluedMapImpl data) throws IOException {
- return put(resource.queryParams(params), data);
- }
-
- /**
- * Main implementation of DELETE request
- * @param resource resource
- * @param data delete body
- * @return unmarshalled response data
- */
- public RESPONSE delete(WebResource resource, MultivaluedMapImpl data) throws IOException {
- LOG.debug("DELETE " + resource.toString());
-
- StringBuilder curlBuilder = new StringBuilder();
-
- UriBuilder builder = UriBuilder.fromPath("host/");
- for(String key : data.keySet()) {
- for(String value : data.get(key)) {
- builder.queryParam(key, value);
- curlBuilder.append(String.format("-d %s=\"%s\"", key, value.replace("\"", "\\\"")));
- }
- }
-
- if (data != null)
- LOG.debug("... data: " + builder.build().getRawQuery());
-
- Map<String, String> headers = new HashMap<String, String>();
- headers.put("Content-Type", "application/x-www-form-urlencoded");
-
- LOG.info(String.format("curl -X DELETE " + curlBuilder.toString() + " \"" + resource.toString() + "\""));
-
- InputStream inputStream = context.getURLStreamProvider().readFrom(resource.toString(),
- "DELETE", builder.build().getRawQuery(), headers);
- String responseJson = IOUtils.toString(inputStream);
-
- LOG.debug(String.format("RESPONSE => %s", responseJson));
- return gson.fromJson(responseJson, responseClass);
- }
-
- /**
- * @see #delete(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE delete(MultivaluedMapImpl data) throws IOException {
- return delete(resource, data);
- }
-
- /**
- * @see #delete(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE delete() throws IOException {
- return delete(resource, new MultivaluedMapImpl());
- }
-
- /**
- * @see #delete(WebResource, MultivaluedMapImpl)
- */
- public RESPONSE delete(MultivaluedMapImpl params, MultivaluedMapImpl data) throws IOException {
- return delete(resource.queryParams(params), data);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/RequestWrapper.java
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/RequestWrapper.java b/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/RequestWrapper.java
new file mode 100644
index 0000000..efd2074
--- /dev/null
+++ b/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/RequestWrapper.java
@@ -0,0 +1,271 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.view.pig.templeton.client;
+
+import com.google.gson.Gson;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.ambari.view.ViewContext;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.UriBuilder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Request handler, supports GET, POST, PUT, DELETE methods
+ * @param <RESPONSE> data type to deserialize response from JSON
+ */
+public class RequestWrapper<RESPONSE> {
+ protected final Class<RESPONSE> responseClass;
+ protected final ViewContext context;
+ protected final WebResource resource;
+
+ protected final Gson gson = new Gson();
+
+ protected final static Logger LOG =
+ LoggerFactory.getLogger(RequestWrapper.class);
+
+ /**
+ * Constructor
+ * @param resource object that represents resource
+ * @param responseClass model class
+ * @param context View Context instance
+ */
+ public RequestWrapper(WebResource resource, Class<RESPONSE> responseClass, ViewContext context) {
+ this.resource = resource;
+ this.responseClass = responseClass;
+ this.context = context;
+ }
+
+ /**
+ * Main implementation of GET request
+ * @param resource resource
+ * @return unmarshalled response data
+ */
+ public RESPONSE get(WebResource resource) throws IOException {
+ LOG.debug("GET " + resource.toString());
+
+ InputStream inputStream = context.getURLStreamProvider().readFrom(resource.toString(), "GET",
+ null, new HashMap<String, String>());
+
+ recordLastCurlCommand(String.format("curl \"" + resource.toString() + "\""));
+ String responseJson = IOUtils.toString(inputStream);
+ LOG.debug(String.format("RESPONSE => %s", responseJson));
+ return gson.fromJson(responseJson, responseClass);
+ }
+
+ /**
+ * Make GET request
+ * @see #get(WebResource)
+ */
+ public RESPONSE get() throws IOException {
+ return get(this.resource);
+ }
+
+ /**
+ * Make GET request
+ * @see #get(WebResource)
+ */
+ public RESPONSE get(MultivaluedMapImpl params) throws IOException {
+ return get(this.resource.queryParams(params));
+ }
+
+ /**
+ * Main implementation of POST request
+ * @param resource resource
+ * @param data post body
+ * @return unmarshalled response data
+ */
+ public RESPONSE post(WebResource resource, MultivaluedMapImpl data) throws IOException {
+ LOG.debug("POST " + resource.toString());
+ LOG.debug("data: " + data.toString());
+
+ StringBuilder curlBuilder = new StringBuilder();
+
+ UriBuilder builder = UriBuilder.fromPath("host/");
+ for(String key : data.keySet()) {
+ for(String value : data.get(key)) {
+ builder.queryParam(key, value);
+ curlBuilder.append(String.format("-d %s=\"%s\"", key, value.replace("\"", "\\\"")));
+ }
+ }
+
+ if (data != null)
+ LOG.debug("... data: " + builder.build().getRawQuery());
+
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put("Content-Type", "application/x-www-form-urlencoded");
+
+ recordLastCurlCommand(String.format("curl " + curlBuilder.toString() + " \"" + resource.toString() + "\""));
+ InputStream inputStream = context.getURLStreamProvider().readFrom(resource.toString(),
+ "POST", builder.build().getRawQuery(), headers);
+ String responseJson = IOUtils.toString(inputStream);
+
+ LOG.debug(String.format("RESPONSE => %s", responseJson));
+ return gson.fromJson(responseJson, responseClass);
+ }
+
+ /**
+ * @see #post(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE post(MultivaluedMapImpl data) throws IOException {
+ return post(resource, data);
+ }
+
+ /**
+ * @see #post(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE post() throws IOException {
+ return post(resource, new MultivaluedMapImpl());
+ }
+
+ /**
+ * @see #post(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE post(MultivaluedMapImpl params, MultivaluedMapImpl data) throws IOException {
+ return post(resource.queryParams(params), data);
+ }
+
+ /**
+ * Main implementation of PUT request
+ * @param resource resource
+ * @param data put body
+ * @return unmarshalled response data
+ */
+ public RESPONSE put(WebResource resource, MultivaluedMapImpl data) throws IOException {
+ LOG.debug("PUT " + resource.toString());
+
+ StringBuilder curlBuilder = new StringBuilder();
+
+ UriBuilder builder = UriBuilder.fromPath("host/");
+ for(String key : data.keySet()) {
+ for(String value : data.get(key)) {
+ builder.queryParam(key, value);
+ curlBuilder.append(String.format("-d %s=\"%s\"", key, value.replace("\"", "\\\"")));
+ }
+ }
+
+ if (data != null)
+ LOG.debug("... data: " + builder.build().getRawQuery());
+
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put("Content-Type", "application/x-www-form-urlencoded");
+
+ recordLastCurlCommand(String.format("curl -X PUT " + curlBuilder.toString() + " \"" + resource.toString() + "\""));
+
+ InputStream inputStream = context.getURLStreamProvider().readFrom(resource.toString(),
+ "PUT", builder.build().getRawQuery(), headers);
+ String responseJson = IOUtils.toString(inputStream);
+
+ LOG.debug(String.format("RESPONSE => %s", responseJson));
+ return gson.fromJson(responseJson, responseClass);
+ }
+
+ /**
+ * @see #put(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE put(MultivaluedMapImpl data) throws IOException {
+ return put(resource, data);
+ }
+
+ /**
+ * @see #put(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE put() throws IOException {
+ return put(resource, new MultivaluedMapImpl());
+ }
+
+ /**
+ * @see #put(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE put(MultivaluedMapImpl params, MultivaluedMapImpl data) throws IOException {
+ return put(resource.queryParams(params), data);
+ }
+
+ /**
+ * Main implementation of DELETE request
+ * @param resource resource
+ * @param data delete body
+ * @return unmarshalled response data
+ */
+ public RESPONSE delete(WebResource resource, MultivaluedMapImpl data) throws IOException {
+ LOG.debug("DELETE " + resource.toString());
+
+ StringBuilder curlBuilder = new StringBuilder();
+
+ UriBuilder builder = UriBuilder.fromPath("host/");
+ for(String key : data.keySet()) {
+ for(String value : data.get(key)) {
+ builder.queryParam(key, value);
+ curlBuilder.append(String.format("-d %s=\"%s\"", key, value.replace("\"", "\\\"")));
+ }
+ }
+
+ if (data != null)
+ LOG.debug("... data: " + builder.build().getRawQuery());
+
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put("Content-Type", "application/x-www-form-urlencoded");
+
+ recordLastCurlCommand(String.format("curl -X DELETE " + curlBuilder.toString() + " \"" + resource.toString() + "\""));
+
+ InputStream inputStream = context.getURLStreamProvider().readFrom(resource.toString(),
+ "DELETE", builder.build().getRawQuery(), headers);
+ String responseJson = IOUtils.toString(inputStream);
+
+ LOG.debug(String.format("RESPONSE => %s", responseJson));
+ return gson.fromJson(responseJson, responseClass);
+ }
+
+ /**
+ * @see #delete(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE delete(MultivaluedMapImpl data) throws IOException {
+ return delete(resource, data);
+ }
+
+ /**
+ * @see #delete(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE delete() throws IOException {
+ return delete(resource, new MultivaluedMapImpl());
+ }
+
+ /**
+ * @see #delete(WebResource, MultivaluedMapImpl)
+ */
+ public RESPONSE delete(MultivaluedMapImpl params, MultivaluedMapImpl data) throws IOException {
+ return delete(resource.queryParams(params), data);
+ }
+
+ private static String lastCurlCommand = null;
+ private static void recordLastCurlCommand(String curl) {
+ LOG.info(curl);
+ lastCurlCommand = curl;
+ }
+
+ public static String getLastCurlCommand() {
+ return lastCurlCommand;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/TempletonRequest.java
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/TempletonRequest.java b/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/TempletonRequest.java
index 8b8b89e..10cfdd5 100644
--- a/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/TempletonRequest.java
+++ b/contrib/views/pig/src/main/java/org/apache/ambari/view/pig/templeton/client/TempletonRequest.java
@@ -31,7 +31,7 @@ import java.io.IOException;
* GET parameters to every request
* @param <RESPONSE> data type to deserialize response from JSON
*/
-public class TempletonRequest<RESPONSE> extends Request<RESPONSE> {
+public class TempletonRequest<RESPONSE> extends RequestWrapper<RESPONSE> {
private String username;
private String doAs;
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/resources/ui/pig-web/app/components/pathInput.js
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/components/pathInput.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/components/pathInput.js
new file mode 100644
index 0000000..e796406
--- /dev/null
+++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/components/pathInput.js
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.PathInputComponent = Em.TextField.extend({
+
+ typeaheadInit:function () {
+ this.$().typeahead({
+ source:Em.run.bind(this,this.typeaheadSource)
+ });
+ }.on('didInsertElement'),
+
+ typeaheadSource:function (query,process) {
+
+ var adapter = this.store.adapterFor(App.File),
+ url = adapter.buildURL(true, query.replace(/[^/]+$/,''));
+
+ adapter.ajax(url, 'GET', {data:{action:'ls'}}).then(function (data) {
+
+ var ls = data.ls.map(function(item){
+ var parser = document.createElement('a');
+ parser.href = item.replace(/.*?:/, "");
+ return decodeURI(parser.pathname);
+ });
+
+ process(ls);
+ });
+ },
+
+ typeaheadClear:function () {
+ this.$().typeahead('destroy');
+ }.on('willClearRender')
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js
index f4fca05..8adf505 100644
--- a/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js
+++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/initialize.js
@@ -170,3 +170,4 @@ require("components/jobProgress");
require("components/pigHelper");
require("components/scriptListRow");
require("components/tabControl");
+require("components/pathInput");
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs
index 50fef58..b80473e 100644
--- a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs
+++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createScript.hbs
@@ -30,8 +30,8 @@
<div {{bind-attr class=":alert :alert-danger titleErrorMessage::hide"}}>{{titleErrorMessage}}</div>
{{/if}}
<div class="form-group">
- <label for="exampleInputPassword1">{{t 'scripts.path'}}</label>
- {{input class="form-control" placeholderTranslation="scripts.modal.file_path_placeholder" valueBinding="filePath"}}
+ <label>{{t 'scripts.path'}}</label>
+ {{path-input class="form-control" placeholderTranslation="scripts.modal.file_path_placeholder" valueBinding="filePath" storeBinding="content.store"}}
<small class="pull-right help-block">{{t 'scripts.modal.file_path_hint'}}</small>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs
index c080728..a72c66a 100644
--- a/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs
+++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/templates/modal/createUdf.hbs
@@ -23,12 +23,12 @@
</div>
<div class="modal-body">
<div class="form-group">
- <label for="exampleInputEmail1">{{t 'common.name'}}</label>
+ <label>{{t 'common.name'}}</label>
{{input class="form-control" placeholderTranslation="udfs.modal.udf_name" valueBinding="content.name"}}
</div>
- <div class="form-group">
- <label for="exampleInputPassword1">{{t 'common.path'}}</label>
- {{input class="form-control" placeholderTranslation="udfs.modal.hdfs_path" valueBinding="content.path"}}
+ <div class="form-group has-feedback">
+ <label>{{t 'common.path'}}</label>
+ {{path-input class="form-control isLoading" placeholderTranslation="udfs.modal.hdfs_path" valueBinding="content.path" storeBinding="content.store"}}
</div>
</div>
<div class="modal-footer">
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/main/resources/ui/pig-web/bower.json
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/bower.json b/contrib/views/pig/src/main/resources/ui/pig-web/bower.json
index bd31a7a..91d8402 100644
--- a/contrib/views/pig/src/main/resources/ui/pig-web/bower.json
+++ b/contrib/views/pig/src/main/resources/ui/pig-web/bower.json
@@ -11,7 +11,8 @@
"moment": "~2.8.1",
"ember-i18n": "~1.6.0",
"font-awesome": "4.2",
- "file-saver": "*"
+ "file-saver": "*",
+ "bootstrap3-typeahead": "~3.0.3"
},
"overrides": {
"codemirror":{
http://git-wip-us.apache.org/repos/asf/ambari/blob/d40a2e5f/contrib/views/pig/src/test/java/org/apache/ambari/view/pig/test/FileTest.java
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/test/java/org/apache/ambari/view/pig/test/FileTest.java b/contrib/views/pig/src/test/java/org/apache/ambari/view/pig/test/FileTest.java
index ba04599..ac26b93 100644
--- a/contrib/views/pig/src/test/java/org/apache/ambari/view/pig/test/FileTest.java
+++ b/contrib/views/pig/src/test/java/org/apache/ambari/view/pig/test/FileTest.java
@@ -125,7 +125,7 @@ public class FileTest extends HDFSTest {
Response response = fileService.updateFile(request, filePath);
Assert.assertEquals(204, response.getStatus());
- Response response2 = fileService.getFile(filePath, 0L);
+ Response response2 = fileService.getFile(filePath, 0L, null);
Assert.assertEquals(200, response2.getStatus());
JSONObject obj = ((JSONObject) response2.getEntity());
@@ -140,7 +140,7 @@ public class FileTest extends HDFSTest {
doCreateFile(name, "1234567890");
- Response response = fileService.getFile(filePath, 0L);
+ Response response = fileService.getFile(filePath, 0L, null);
Assert.assertEquals(200, response.getStatus());
JSONObject obj = ((JSONObject) response.getEntity());
@@ -151,7 +151,7 @@ public class FileTest extends HDFSTest {
Assert.assertTrue(((FileResource) obj.get("file")).isHasNext());
Assert.assertEquals(filePath, ((FileResource) obj.get("file")).getFilePath());
- response = fileService.getFile(filePath, 1L);
+ response = fileService.getFile(filePath, 1L, null);
Assert.assertEquals(200, response.getStatus());
obj = ((JSONObject) response.getEntity());
@@ -159,7 +159,7 @@ public class FileTest extends HDFSTest {
Assert.assertEquals(1, ((FileResource) obj.get("file")).getPage());
Assert.assertTrue(((FileResource) obj.get("file")).isHasNext());
- response = fileService.getFile(filePath, 2L);
+ response = fileService.getFile(filePath, 2L, null);
Assert.assertEquals(200, response.getStatus());
obj = ((JSONObject) response.getEntity());
@@ -168,7 +168,7 @@ public class FileTest extends HDFSTest {
Assert.assertFalse(((FileResource) obj.get("file")).isHasNext());
thrown.expect(BadRequestFormattedException.class);
- fileService.getFile(filePath, 3L);
+ fileService.getFile(filePath, 3L, null);
}
@Test
@@ -178,7 +178,7 @@ public class FileTest extends HDFSTest {
doCreateFile(name, "");
- Response response = fileService.getFile(filePath, 0L);
+ Response response = fileService.getFile(filePath, 0L, null);
Assert.assertEquals(200, response.getStatus());
JSONObject obj = ((JSONObject) response.getEntity());
Assert.assertEquals("", ((FileResource) obj.get("file")).getFileContent());
@@ -189,7 +189,7 @@ public class FileTest extends HDFSTest {
@Test
public void testFileNotFound() throws IOException, InterruptedException {
thrown.expect(NotFoundFormattedException.class);
- fileService.getFile("/tmp/notExistentFile", 2L);
+ fileService.getFile("/tmp/notExistentFile", 2L, null);
}
@Test
@@ -202,6 +202,6 @@ public class FileTest extends HDFSTest {
Assert.assertEquals(204, response.getStatus());
thrown.expect(NotFoundFormattedException.class);
- fileService.getFile(filePath, 0L);
+ fileService.getFile(filePath, 0L, null);
}
}