ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [37/50] [abbrv] ambari git commit: AMBARI-19336. User should be prompted to enter valid workflow xml file name while Submit/Validate (Madhan Mohan Reddy via pallavkul)
Date Thu, 05 Jan 2017 00:05:18 GMT
AMBARI-19336. User should be prompted to enter valid workflow xml file name while Submit/Validate
(Madhan Mohan Reddy via pallavkul)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/976e40a6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/976e40a6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/976e40a6

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 976e40a670c2442cf3020de626d5262bd011c5e5
Parents: cab7705
Author: pallavkul <pallav.kul@gmail.com>
Authored: Wed Jan 4 12:11:54 2017 +0530
Committer: pallavkul <pallav.kul@gmail.com>
Committed: Wed Jan 4 12:11:54 2017 +0530

----------------------------------------------------------------------
 .../ambari/view/OozieProxyImpersonator.java     | 12 ++++++------
 .../oozie/ambari/view/WorkflowFilesService.java | 20 +++++++++-----------
 2 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/976e40a6/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/OozieProxyImpersonator.java
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/OozieProxyImpersonator.java
b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/OozieProxyImpersonator.java
index 9dd02d4..df2e3d8 100644
--- a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/OozieProxyImpersonator.java
+++ b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/OozieProxyImpersonator.java
@@ -169,7 +169,7 @@ public class OozieProxyImpersonator {
     if (StringUtils.isEmpty(appPath)) {
       throw new RuntimeException("app path can't be empty.");
     }
-    appPath = appPath.trim();
+    appPath = workflowFilesService.getWorkflowFileName(appPath.trim());
     if (!overwrite) {
       boolean fileExists = hdfsFileUtils.fileExists(appPath);
       if (fileExists) {
@@ -178,7 +178,7 @@ public class OozieProxyImpersonator {
     }
     postBody = utils.formatXml(postBody);
     try {
-      String filePath = workflowFilesService.createWorkflowFile(appPath,
+      String filePath = workflowFilesService.createFile(appPath,
         postBody, overwrite);
       LOGGER.info(String.format(
         "submit workflow job done. filePath=[%s]", filePath));
@@ -210,8 +210,8 @@ public class OozieProxyImpersonator {
     if (StringUtils.isEmpty(appPath)) {
       throw new RuntimeException("app path can't be empty.");
     }
-    appPath = appPath.trim();
-    workflowFilesService.saveDraft(appPath, postBody, overwrite);
+    appPath = workflowFilesService.getWorkflowDrafFileName(appPath.trim());
+    workflowFilesService.createFile(appPath, postBody, overwrite);
     if (PROJ_MANAGER_ENABLED) {
       JobType jobType = StringUtils.isEmpty(jobTypeStr) ? JobType.WORKFLOW : JobType.valueOf(jobTypeStr);
       String name = oozieUtils.deduceWorkflowNameFromJson(postBody);
@@ -303,7 +303,7 @@ public class OozieProxyImpersonator {
     if (StringUtils.isEmpty(appPath)) {
       throw new RuntimeException("app path can't be empty.");
     }
-    appPath = appPath.trim();
+    appPath = workflowFilesService.getWorkflowFileName(appPath.trim());
     if (!overwrite) {
       boolean fileExists = hdfsFileUtils.fileExists(appPath);
       if (fileExists) {
@@ -312,7 +312,7 @@ public class OozieProxyImpersonator {
     }
     postBody = utils.formatXml(postBody);
     try {
-      String filePath = hdfsFileUtils.writeToFile(appPath, postBody,
+      String filePath = workflowFilesService.createFile(appPath, postBody,
         overwrite);
       LOGGER.info(String.format(
         "submit workflow job done. filePath=[%s]", filePath));

http://git-wip-us.apache.org/repos/asf/ambari/blob/976e40a6/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/WorkflowFilesService.java
----------------------------------------------------------------------
diff --git a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/WorkflowFilesService.java
b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/WorkflowFilesService.java
index f98df0d..d8bf9ff 100644
--- a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/WorkflowFilesService.java
+++ b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/WorkflowFilesService.java
@@ -34,9 +34,9 @@ public class WorkflowFilesService {
     this.hdfsFileUtils = hdfsFileUtils;
   }
 
-  public String createWorkflowFile(String appPath, String content,
+  public String createFile(String appPath, String content,
                                    boolean overwrite) throws IOException {
-    return hdfsFileUtils.writeToFile(getWorkflowFileName(appPath), content,
+    return hdfsFileUtils.writeToFile(appPath, content,
       overwrite);
   }
 
@@ -46,12 +46,6 @@ public class WorkflowFilesService {
       overwrite);
   }
 
-  public String saveDraft(String appPath, String content, boolean overwrite)
-    throws IOException {
-    return hdfsFileUtils.writeToFile(getWorkflowDrafFileName(appPath),
-      content, overwrite);
-  }
-
   public InputStream readDraft(String appPath) throws IOException {
     return hdfsFileUtils.read(getWorkflowDrafFileName(appPath));
   }
@@ -60,11 +54,15 @@ public class WorkflowFilesService {
     return hdfsFileUtils.read(getWorkflowFileName(appPath));
   }
 
-  private String getWorkflowDrafFileName(String appPath) {
-    return getWorkflowFileName(appPath).concat(".draft.json");
+  public String getWorkflowDrafFileName(String appPath) {
+    if (appPath.endsWith(".draft.json")){
+      return appPath;
+    }else{
+      return getWorkflowFileName(appPath).concat(".draft.json");
+    }
   }
 
-  private String getWorkflowFileName(String appPath) {
+  public String getWorkflowFileName(String appPath) {
     String workflowFile = null;
     if (appPath.endsWith(".xml")) {
       workflowFile = appPath;


Mime
View raw message