Skip to content

Commit

Permalink
Use the proper container for setting and retrieving the audit settings
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-susanh committed Jan 24, 2024
1 parent 8dbf05d commit cee5768
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions audit/src/org/labkey/audit/AuditController.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
Expand Down Expand Up @@ -527,12 +528,14 @@ public static class SaveAuditSettingsAction extends MutatingApiAction<AuditSetti
@Override
public void validateForm(AuditSettingsForm form, Errors errors)
{
if (!getContainer().isAppHomeFolder())
errors.reject(ERROR_GENERIC, "This action is not supported for sub-folders of the application.");
if (form.getRequireUserComments() == null)
errors.reject(ERROR_REQUIRED, "requireUserComments is required to be non-null.");
}

@Override
public Object execute(AuditSettingsForm form, BindException errors) throws Exception
public Object execute(AuditSettingsForm form, BindException errors)
{
ContainerManager.setRequireAuditComments(getContainer(), getUser(), form.getRequireUserComments());
return success();
Expand All @@ -558,9 +561,12 @@ public void setRequireUserComments(Boolean requireUserComments)
public static class GetAuditSettingsAction extends ReadOnlyApiAction<Object>
{
@Override
public Object execute(Object o, BindException errors) throws Exception
public Object execute(Object o, BindException errors)
{
return Map.of(REQUIRE_USER_COMMENTS_PROPERTY_NAME, getContainer().getAuditCommentsRequired());
Container container = getContainer();
if (!container.isAppHomeFolder())
container = container.getProject();
return container == null ? Collections.emptyMap() : Map.of(REQUIRE_USER_COMMENTS_PROPERTY_NAME, container.getAuditCommentsRequired());
}
}
}

0 comments on commit cee5768

Please sign in to comment.