You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by db...@apache.org on 2016/05/03 19:53:56 UTC
ambari git commit: AMBARI-16116. Not able to edit Pig script tab.
(Gaurav Nagar via dipayanb)
Repository: ambari
Updated Branches:
refs/heads/trunk 4342a6b7e -> 15a7ea3d5
AMBARI-16116. Not able to edit Pig script tab. (Gaurav Nagar via dipayanb)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/15a7ea3d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/15a7ea3d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/15a7ea3d
Branch: refs/heads/trunk
Commit: 15a7ea3d5f5aa3843dd44cd8032003ef3854e25c
Parents: 4342a6b
Author: Dipayan Bhowmick <di...@gmail.com>
Authored: Tue May 3 23:23:44 2016 +0530
Committer: Dipayan Bhowmick <di...@gmail.com>
Committed: Tue May 3 23:23:44 2016 +0530
----------------------------------------------------------------------
.../ambari/view/hive/resources/files/FileService.java | 14 ++++++++++----
.../ambari/view/pig/resources/files/FileService.java | 13 +++++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/15a7ea3d/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/files/FileService.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/files/FileService.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/files/FileService.java
index 3eac2b7..ab2b933 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/files/FileService.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/files/FileService.java
@@ -99,10 +99,7 @@ public class FileService extends BaseService {
fillFakeFileObject(filePath, file, content);
} else {
- if (!filePath.startsWith("/") && !filePath.startsWith(".")) {
- filePath = "/" + filePath; // some servers strip double slashes in URL
- }
-
+ filePath = sanitizeFilePath(filePath);
FilePaginator paginator = new FilePaginator(filePath, getSharedObjectsFactory().getHdfsApi());
fillRealFileObject(filePath, page, file, paginator);
@@ -158,6 +155,7 @@ public class FileService extends BaseService {
@Path("{filePath:.*}")
public Response deleteFile(@PathParam("filePath") String filePath) throws IOException, InterruptedException {
try {
+ filePath = sanitizeFilePath(filePath);
LOG.debug("Deleting file " + filePath);
if (getSharedObjectsFactory().getHdfsApi().delete(filePath, false)) {
return Response.status(204).build();
@@ -179,6 +177,7 @@ public class FileService extends BaseService {
public Response updateFile(FileResourceRequest request,
@PathParam("filePath") String filePath) throws IOException, InterruptedException {
try {
+ filePath = sanitizeFilePath(filePath);
LOG.debug("Rewriting file " + filePath);
FSDataOutputStream output = getSharedObjectsFactory().getHdfsApi().create(filePath, true);
output.writeBytes(request.file.getFileContent());
@@ -241,4 +240,11 @@ public class FileService extends BaseService {
public static class FileResourceRequest {
public FileResource file;
}
+
+ private String sanitizeFilePath(String filePath){
+ if (!filePath.startsWith("/") && !filePath.startsWith(".")) {
+ filePath = "/" + filePath; // some servers strip double slashes in URL
+ }
+ return filePath;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/15a7ea3d/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 6697160..40bc9a7 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
@@ -69,6 +69,8 @@ public class FileService extends BaseService {
@QueryParam("page") Long page,
@QueryParam("action") String action) throws IOException, InterruptedException {
try {
+
+ filePath = sanitizeFilePath(filePath);
if (action != null && action.equals("ls")) {
LOG.debug("List directory " + filePath);
List<String> ls = new LinkedList<String>();
@@ -113,6 +115,9 @@ public class FileService extends BaseService {
@Path("{filePath:.*}")
public Response deleteFile(@PathParam("filePath") String filePath) throws IOException, InterruptedException {
try {
+
+ filePath = sanitizeFilePath(filePath);
+
LOG.debug("Deleting file " + filePath);
if (getHdfsApi().delete(filePath, false)) {
return Response.status(204).build();
@@ -134,6 +139,7 @@ public class FileService extends BaseService {
public Response updateFile(FileResourceRequest request,
@PathParam("filePath") String filePath) throws IOException, InterruptedException {
try {
+ filePath = sanitizeFilePath(filePath);
LOG.debug("Rewriting file " + filePath);
FSDataOutputStream output = getHdfsApi().create(filePath, true);
output.writeBytes(request.file.getFileContent());
@@ -196,4 +202,11 @@ public class FileService extends BaseService {
public static class FileResourceRequest {
public FileResource file;
}
+
+ private String sanitizeFilePath(String filePath){
+ if (!filePath.startsWith("/") && !filePath.startsWith(".")) {
+ filePath = "/" + filePath; // some servers strip double slashes in URL
+ }
+ return filePath;
+ }
}