package org.labkey.webutils.api.action;

import org.labkey.api.action.HasPageConfig;
import org.labkey.api.action.HasViewContext;
import org.labkey.api.action.PermissionCheckable;
import org.labkey.api.view.UnauthorizedException;
import org.labkey.api.view.ViewContext;
import org.labkey.api.view.template.PageConfig;
import org.springframework.web.servlet.mvc.Controller;

/**
 * A base action to base other actions off of.
 *
 * Created by jon on 3/9/17.
 */
public abstract class SimpleAction implements Controller, HasViewContext, HasPageConfig, PermissionCheckable {
    // The SpringActionController populates a pageConfig for actions that implement HasPageConfig
    PageConfig _pageConfig;
    @Override public void setPageConfig(PageConfig page) { _pageConfig = page; }
    @Override public PageConfig getPageConfig()          { return _pageConfig; }

    // The SpringActionController populates a viewContext for actions that implement it.
    ViewContext _viewContext;
    @Override public void setViewContext(ViewContext context) { _viewContext = context; }
    @Override public ViewContext getViewContext()             { return _viewContext; }

    // The SpringActionController uses this method (part of PermissionCheckable) to check for permission to access
    // the specified page.
    @Override public void checkPermissions() throws UnauthorizedException {
        /*
         * TODO: re-implement permission checking.

        try {
            BaseViewAction.checkActionPermissions(this.getClass(), getViewContext(), null);
        }
        catch (UnauthorizedException e) {
            e.setUseBasicAuthentication(false);
            throw e;
        }
        */
    }
}

@@ -67,309 +67,57 @@
 ion.
-HasPageConfig;%0Aimport org.labkey.api.action.HasViewContext;%0Aimport org.labkey.api.action.PermissionCheckable;%0Aimport org.labkey.api.view.UnauthorizedException;%0Aimport org.labkey.api.view.ViewContext;%0Aimport org.labkey.api.view.template.PageConfig;%0Aimport org.springframework.web.servlet.mvc.Controller
+*;%0Aimport org.labkey.api.view.template.PageConfig
 ;%0A%0A/
@@ -241,81 +241,66 @@
 ion 
-implements Controller, HasViewContext, HasPageConfig, PermissionCheckable
+extends PermissionCheckableAction implements HasPageConfig
  %7B%0A 
@@ -589,840 +589,7 @@
 g; %7D
-%0A%0A    // The SpringActionController populates a viewContext for actions that implement it.%0A    ViewContext _viewContext;%0A    @Override public void setViewContext(ViewContext context) %7B _viewContext = context; %7D%0A    @Override public ViewContext getViewContext()             %7B return _viewContext; %7D%0A%0A    // The SpringActionController uses this method (part of PermissionCheckable) to check for permission to access%0A    // the specified page.%0A    @Override public void checkPermissions() throws UnauthorizedException %7B%0A        /*%0A         * TODO: re-implement permission checking.%0A%0A        try %7B%0A            BaseViewAction.checkActionPermissions(this.getClass(), getViewContext(), null);%0A        %7D%0A        catch (UnauthorizedException e) %7B%0A            e.setUseBasicAuthentication(false);%0A            throw e;%0A        %7D%0A        */%0A    %7D
 %0A%7D%0A

Fix #1