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


##########
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:
   Fixed. Switched the parse to `DefaultViewEnum.lookupLiteral(request.view)`, 
which returns null for both an unknown literal and a null/missing body value, 
so both now map to a 400 rather than a 500 (no more valueOf NPE). Added 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