AMBARI-20247. Show full error while importing the workflow from encrypted file. (Madan Mohan Reddy via gauravn7)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1766ebfc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1766ebfc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1766ebfc Branch: refs/heads/branch-feature-AMBARI-12556 Commit: 1766ebfc4af4d2f5786f6a8e448bb2228201b651 Parents: 1d7498f Author: Gaurav Nagar <[email protected]> Authored: Fri Mar 3 20:58:43 2017 +0530 Committer: Gaurav Nagar <[email protected]> Committed: Fri Mar 3 20:59:47 2017 +0530 ---------------------------------------------------------------------- .../ambari/view/OozieProxyImpersonator.java | 26 ++++++++++--- .../oozie/ambari/view/assets/AssetResource.java | 41 +++++++++++++------- .../ambari/view/exception/WfmWebException.java | 12 +++++- .../WorkflowsManagerResource.java | 11 +++++- 4 files changed, 67 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/1766ebfc/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 c4e5bbd..9bf2f90 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 @@ -120,8 +120,9 @@ public class OozieProxyImpersonator { try { hdfsFileUtils.hdfsCheck(); return Response.ok().build(); - }catch (Exception e){ - throw new WfmWebException(e); + }catch (Exception ex){ + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex); } } @@ -131,8 +132,9 @@ public class OozieProxyImpersonator { try{ hdfsFileUtils.homeDirCheck(); return Response.ok().build(); - }catch (Exception e){ - throw new WfmWebException(e); + }catch (Exception ex){ + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex); } } @@ -203,10 +205,13 @@ public class OozieProxyImpersonator { appPath, ui.getQueryParameters(), jobType); return Response.status(Status.OK).entity(response).build(); } catch (WfmWebException ex) { + LOGGER.error(ex.getMessage(),ex); throw ex; } catch(WfmException ex){ + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex,ex.getErrorCode()); } catch(Exception ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } @@ -241,9 +246,11 @@ public class OozieProxyImpersonator { viewContext.getUsername(), getWorkflowName(postBody)); } } catch (WfmWebException ex) { + LOGGER.error(ex.getMessage(),ex); throw ex; } catch (Exception ex) { - throw new WfmWebException(ex); + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex); } return Response.ok().build(); } @@ -298,8 +305,10 @@ public class OozieProxyImpersonator { } return saveAsset(postBody, uploadPath, overwrite); } catch (WfmWebException ex) { + LOGGER.error(ex.getMessage(),ex); throw ex; } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } @@ -337,6 +346,7 @@ public class OozieProxyImpersonator { }; return Response.ok(streamer).status(200).build(); } catch (IOException ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } @@ -360,6 +370,7 @@ public class OozieProxyImpersonator { }; return Response.ok(streamer).status(200).build(); } catch (IOException ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } @@ -372,6 +383,7 @@ public class OozieProxyImpersonator { workflowFilesService.discardDraft(workflowPath); return Response.ok().build(); } catch (IOException ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } @@ -403,8 +415,10 @@ public class OozieProxyImpersonator { return getWorkflowResponse(filePath, WorkflowFormat.XML.getValue(), false); } } catch (WfmWebException ex) { + LOGGER.error(ex.getMessage(),ex); throw ex; } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } @@ -452,8 +466,10 @@ public class OozieProxyImpersonator { }; return Response.ok(streamer).status(200).build(); } catch (WfmWebException ex) { + LOGGER.error(ex.getMessage(),ex); throw ex; } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/1766ebfc/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/assets/AssetResource.java ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/assets/AssetResource.java b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/assets/AssetResource.java index 3355c85..41b6af0 100644 --- a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/assets/AssetResource.java +++ b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/assets/AssetResource.java @@ -46,7 +46,7 @@ public class AssetResource { private final AssetService assetService; private final ViewContext viewContext; private final HDFSFileUtils hdfsFileUtils; - private OozieUtils oozieUtils = new OozieUtils(); + private final OozieUtils oozieUtils = new OozieUtils(); private final OozieDelegate oozieDelegate; @@ -66,8 +66,9 @@ public class AssetResource { result.getPaging().setTotal(assets != null ? assets.size() : 0L); result.setData(assets); return Response.ok(result).build(); - } catch (Exception e) { - throw new WfmWebException(e); + } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex); } } @@ -81,8 +82,9 @@ public class AssetResource { result.getPaging().setTotal(assets != null ? assets.size() : 0L); result.setData(assets); return Response.ok(result).build(); - } catch (Exception e) { - throw new WfmWebException(e); + } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex); } } @POST @@ -101,8 +103,10 @@ public class AssetResource { result.setStatus(APIResult.Status.SUCCESS); return Response.ok(result).build(); } catch (WfmWebException ex) { + LOGGER.error(ex.getMessage(),ex); throw ex; } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } @@ -120,8 +124,9 @@ public class AssetResource { String tempWfPath = "/tmp" + "/tmpooziewfs/tempwf_" + Math.round(Math.random() * 100000) + ".xml"; try { hdfsFileUtils.writeToFile(tempWfPath, workflowXml, true); - } catch (IOException e) { - throw new WfmWebException(e, ErrorCode.FILE_ACCESS_UNKNOWN_ERROR); + } catch (IOException ex) { + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex, ErrorCode.FILE_ACCESS_UNKNOWN_ERROR); } queryParams.put("oozieparam.action", getAsList("dryrun")); queryParams.put("oozieconfig.rerunOnFailure", getAsList("false")); @@ -132,8 +137,9 @@ public class AssetResource { LOGGER.info(String.format("resp from validating asset=[%s]", dryRunResp)); try { hdfsFileUtils.deleteFile(tempWfPath); - } catch (IOException e) { - throw new WfmWebException(e, ErrorCode.FILE_ACCESS_UNKNOWN_ERROR); + } catch (IOException ex) { + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex, ErrorCode.FILE_ACCESS_UNKNOWN_ERROR); } if (dryRunResp != null && dryRunResp.trim().startsWith("{")) { JsonElement jsonElement = new JsonParser().parse(dryRunResp); @@ -157,8 +163,9 @@ public class AssetResource { try { boolean available = assetService.isAssetNameAvailable(name); return Response.ok(available).build(); - }catch (Exception e){ - throw new WfmWebException(e); + }catch (Exception ex){ + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex); } } @@ -171,8 +178,9 @@ public class AssetResource { result.setStatus(APIResult.Status.SUCCESS); result.setData(assetDefinition); return Response.ok(result).build(); - } catch (Exception e) { - throw new WfmWebException(e); + } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex); } } @@ -185,8 +193,9 @@ public class AssetResource { result.setStatus(APIResult.Status.SUCCESS); result.setData(assetDefinition); return Response.ok(result).build(); - } catch (Exception e) { - throw new WfmWebException(e); + } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); + throw new WfmWebException(ex); } } @@ -206,8 +215,10 @@ public class AssetResource { result.setStatus(APIResult.Status.SUCCESS); return Response.ok(result).build(); } catch (WfmWebException ex) { + LOGGER.error(ex.getMessage(),ex); throw ex; } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/1766ebfc/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/exception/WfmWebException.java ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/exception/WfmWebException.java b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/exception/WfmWebException.java index fd4ce80..2e30a92 100644 --- a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/exception/WfmWebException.java +++ b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/exception/WfmWebException.java @@ -85,7 +85,11 @@ public class WfmWebException extends WebApplicationException { String trace = null; Throwable ex = this.getCause(); if (ex != null) { - trace = ExceptionUtils.getStackTrace(ex); + if (ex.getStackTrace().length<1){ + trace = ExceptionUtils.getStackTrace(this); + }else{ + trace = ExceptionUtils.getStackTrace(ex); + } if (ex instanceof AccessControlException) { errorCode = ErrorCode.FILE_ACCESS_ACL_ERROR; } else if (ex instanceof IOException) { @@ -100,7 +104,11 @@ public class WfmWebException extends WebApplicationException { response.put("errorCode", errorCode.getErrorCode()); response.put("message", errorCode.getDescription()); } else { - response.put("message", this.getMessage()); + if (this.getMessage()!=null){ + response.put("message", this.getMessage()); + }else if (this.getCause()!=null){ + response.put("message", this.getCause().getMessage()); + } } if (this.additionalDetail != null) { response.put("additionalDetail", additionalDetail); http://git-wip-us.apache.org/repos/asf/ambari/blob/1766ebfc/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/workflowmanager/WorkflowsManagerResource.java ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/workflowmanager/WorkflowsManagerResource.java b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/workflowmanager/WorkflowsManagerResource.java index e1a5808..58b944b 100644 --- a/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/workflowmanager/WorkflowsManagerResource.java +++ b/contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/workflowmanager/WorkflowsManagerResource.java @@ -30,8 +30,13 @@ import javax.ws.rs.core.Response; import org.apache.ambari.view.ViewContext; import org.apache.oozie.ambari.view.exception.WfmWebException; +import org.apache.oozie.ambari.view.model.APIResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class WorkflowsManagerResource { + private final static Logger LOGGER = LoggerFactory + .getLogger(WorkflowsManagerResource.class); private final WorkflowManagerService workflowManagerService; private final ViewContext viewContext; public WorkflowsManagerResource(ViewContext viewContext) { @@ -47,6 +52,7 @@ public class WorkflowsManagerResource { result.put("wfprojects", workflowManagerService.getAllWorkflows(viewContext.getUsername())); return Response.ok(result).build(); } catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } } @@ -58,8 +64,11 @@ public class WorkflowsManagerResource { @DefaultValue("false") @QueryParam("deleteDefinition") Boolean deleteDefinition){ try{ workflowManagerService.deleteWorkflow(id,deleteDefinition); - return Response.ok().build(); + APIResult result = new APIResult(); + result.setStatus(APIResult.Status.SUCCESS); + return Response.ok(result).build(); }catch (Exception ex) { + LOGGER.error(ex.getMessage(),ex); throw new WfmWebException(ex); } }
