Changing user editing so that self-editor shows up as an option only if the SelfEditingPolicySetup was configured in the web.xml. NIHVIVO-775
This commit is contained in:
parent
f72b5e099e
commit
ad3c92d66e
3 changed files with 22 additions and 13 deletions
|
@ -129,11 +129,11 @@
|
||||||
<listener-class> edu.cornell.mannlib.vitro.webapp.auth.policy.setup.VivoPolicySetup</listener-class>
|
<listener-class> edu.cornell.mannlib.vitro.webapp.auth.policy.setup.VivoPolicySetup</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
<listener>
|
<!--<listener>
|
||||||
<listener-class>
|
<listener-class>
|
||||||
edu.cornell.mannlib.vitro.webapp.auth.policy.setup.SelfEditingPolicySetup
|
edu.cornell.mannlib.vitro.webapp.auth.policy.setup.SelfEditingPolicySetup
|
||||||
</listener-class>
|
</listener-class>
|
||||||
</listener>
|
</listener> -->
|
||||||
|
|
||||||
<listener>
|
<listener>
|
||||||
<listener-class>
|
<listener-class>
|
||||||
|
|
|
@ -49,6 +49,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
*/
|
*/
|
||||||
public class SelfEditingPolicySetup implements ServletContextListener {
|
public class SelfEditingPolicySetup implements ServletContextListener {
|
||||||
private static final Log log = LogFactory.getLog(SelfEditingPolicySetup.class.getName());
|
private static final Log log = LogFactory.getLog(SelfEditingPolicySetup.class.getName());
|
||||||
|
public static final String SELF_EDITING_POLICY_WAS_SETUP= "selfEditingPolicyWasSetup";
|
||||||
|
|
||||||
public void contextInitialized(ServletContextEvent sce) {
|
public void contextInitialized(ServletContextEvent sce) {
|
||||||
try{
|
try{
|
||||||
|
@ -61,6 +62,8 @@ public class SelfEditingPolicySetup implements ServletContextListener {
|
||||||
SelfEditingIdentifierFactory niif =new SelfEditingIdentifierFactory();
|
SelfEditingIdentifierFactory niif =new SelfEditingIdentifierFactory();
|
||||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), niif);
|
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), niif);
|
||||||
|
|
||||||
|
sce.getServletContext().setAttribute(SELF_EDITING_POLICY_WAS_SETUP, Boolean.TRUE);
|
||||||
|
|
||||||
log.debug( "SelfEditingPolicy has been setup. " );
|
log.debug( "SelfEditingPolicy has been setup. " );
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
log.error("could not run SelfEditingPolicySetup: " + e);
|
log.error("could not run SelfEditingPolicySetup: " + e);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import edu.cornell.mannlib.vedit.forwarder.PageForwarder;
|
||||||
import edu.cornell.mannlib.vedit.forwarder.impl.UrlForwarder;
|
import edu.cornell.mannlib.vedit.forwarder.impl.UrlForwarder;
|
||||||
import edu.cornell.mannlib.vedit.util.FormUtils;
|
import edu.cornell.mannlib.vedit.util.FormUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.JenaNetidPolicy.ContextSetup;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.JenaNetidPolicy.ContextSetup;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.setup.SelfEditingPolicySetup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.User;
|
import edu.cornell.mannlib.vitro.webapp.beans.User;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||||
|
@ -114,11 +115,20 @@ public class UserRetryController extends BaseEditController {
|
||||||
HashMap optionMap = new HashMap();
|
HashMap optionMap = new HashMap();
|
||||||
|
|
||||||
LoginFormBean loginBean = (LoginFormBean) request.getSession().getAttribute("loginHandler");
|
LoginFormBean loginBean = (LoginFormBean) request.getSession().getAttribute("loginHandler");
|
||||||
|
List roleOptionList = new LinkedList();
|
||||||
|
|
||||||
/* has no impact on anything, so don't confuse by showing */
|
|
||||||
/* bdc34: Datastar needs non-backend-editing users for logging in non-Cornell people*/
|
/* bdc34: Datastar needs non-backend-editing users for logging in non-Cornell people*/
|
||||||
|
/* SelfEditingPolicySetup.SELF_EDITING_POLICY_WAS_SETUP is set by the SelfEditingPolicySetup context listener */
|
||||||
|
boolean selfEditing = (Boolean)getServletContext().getAttribute(SelfEditingPolicySetup.SELF_EDITING_POLICY_WAS_SETUP) == Boolean.TRUE;
|
||||||
Option nonEditor = new Option(ROLE_PROTOCOL+loginBean.getNonEditor(), "self editor");
|
Option nonEditor = new Option(ROLE_PROTOCOL+loginBean.getNonEditor(), "self editor");
|
||||||
|
/* self editing should be displayed if we are editing a user account that is already
|
||||||
|
* self-editing even if self editing is off. */
|
||||||
|
if( selfEditing ||
|
||||||
|
( !"insert".equals(action) && userForEditing.getRoleURI().equals(nonEditor.getValue()) )){
|
||||||
nonEditor.setSelected(userForEditing.getRoleURI().equals(nonEditor.getValue()));
|
nonEditor.setSelected(userForEditing.getRoleURI().equals(nonEditor.getValue()));
|
||||||
|
if (nonEditor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getNonEditor()))
|
||||||
|
roleOptionList.add(nonEditor);
|
||||||
|
}
|
||||||
|
|
||||||
Option editor = new Option(ROLE_PROTOCOL+loginBean.getEditor(), "editor");
|
Option editor = new Option(ROLE_PROTOCOL+loginBean.getEditor(), "editor");
|
||||||
editor.setSelected(userForEditing.getRoleURI().equals(editor.getValue()));
|
editor.setSelected(userForEditing.getRoleURI().equals(editor.getValue()));
|
||||||
|
@ -127,10 +137,6 @@ public class UserRetryController extends BaseEditController {
|
||||||
Option administrator = new Option (ROLE_PROTOCOL+loginBean.getDba(), "system administrator");
|
Option administrator = new Option (ROLE_PROTOCOL+loginBean.getDba(), "system administrator");
|
||||||
administrator.setSelected(userForEditing.getRoleURI().equals(administrator.getValue()));
|
administrator.setSelected(userForEditing.getRoleURI().equals(administrator.getValue()));
|
||||||
|
|
||||||
List roleOptionList = new LinkedList();
|
|
||||||
|
|
||||||
if (nonEditor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getNonEditor()))
|
|
||||||
roleOptionList.add(nonEditor);
|
|
||||||
if (editor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getEditor()))
|
if (editor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getEditor()))
|
||||||
roleOptionList.add(editor);
|
roleOptionList.add(editor);
|
||||||
if (curator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getCurator()))
|
if (curator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getCurator()))
|
||||||
|
|
Loading…
Add table
Reference in a new issue