mengw15 commented on code in PR #8125:
URL: https://github.com/apache/texera/pull/8125#discussion_r3899645091


##########
amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala:
##########
@@ -726,6 +758,41 @@ class WorkflowResource extends LazyLogging {
     workflowDao.update(workflow)
   }
 
+  /**
+    * Set which view a workflow opens in by default (CANVAS or FORM). Only 
this preference lives
+    * in a column; the form's definition travels in workflow.content under 
`formBinding`, so
+    * switching the default never touches it.
+    */
+  @PUT
+  @Consumes(Array(MediaType.APPLICATION_JSON))
+  @RolesAllowed(Array("REGULAR", "ADMIN"))
+  @Path("/set-default-view/{wid}")
+  def setDefaultView(
+      @PathParam("wid") wid: Integer,
+      request: DefaultViewRequest,
+      @Auth user: SessionUser
+  ): Unit = {
+    if (!WorkflowAccessResource.hasWriteAccess(wid, user.getUid)) {
+      throw new ForbiddenException(s"You do not have permission to modify 
workflow $wid")
+    }
+    val view =
+      try DefaultViewEnum.valueOf(request.view)

Review Comment:
   `valueOf(null)` throws NullPointerException, not IllegalArgumentException, 
so a body of `{}` or `{"view": null}` returns a 500 where the previous string 
comparison returned 400. Worth catching NPE (or null-checking `request.view`) 
and adding the null case to the invalid-value test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to