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>
|
||||
|
||||
<listener>
|
||||
<!--<listener>
|
||||
<listener-class>
|
||||
edu.cornell.mannlib.vitro.webapp.auth.policy.setup.SelfEditingPolicySetup
|
||||
</listener-class>
|
||||
</listener>
|
||||
</listener> -->
|
||||
|
||||
<listener>
|
||||
<listener-class>
|
||||
|
|
|
@ -49,7 +49,8 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|||
*/
|
||||
public class SelfEditingPolicySetup implements ServletContextListener {
|
||||
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) {
|
||||
try{
|
||||
log.debug("Setting up SelfEditingPolicy");
|
||||
|
@ -60,7 +61,9 @@ public class SelfEditingPolicySetup implements ServletContextListener {
|
|||
|
||||
SelfEditingIdentifierFactory niif =new SelfEditingIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), niif);
|
||||
|
||||
|
||||
sce.getServletContext().setAttribute(SELF_EDITING_POLICY_WAS_SETUP, Boolean.TRUE);
|
||||
|
||||
log.debug( "SelfEditingPolicy has been setup. " );
|
||||
}catch(Exception 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.util.FormUtils;
|
||||
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.User;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
|
@ -114,23 +115,28 @@ public class UserRetryController extends BaseEditController {
|
|||
HashMap optionMap = new HashMap();
|
||||
|
||||
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");
|
||||
nonEditor.setSelected(userForEditing.getRoleURI().equals(nonEditor.getValue()));
|
||||
/* 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()));
|
||||
if (nonEditor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getNonEditor()))
|
||||
roleOptionList.add(nonEditor);
|
||||
}
|
||||
|
||||
Option editor = new Option(ROLE_PROTOCOL+loginBean.getEditor(), "editor");
|
||||
editor.setSelected(userForEditing.getRoleURI().equals(editor.getValue()));
|
||||
Option curator = new Option(ROLE_PROTOCOL+loginBean.getCurator(), "curator");
|
||||
curator.setSelected(userForEditing.getRoleURI().equals(curator.getValue()));
|
||||
Option administrator = new Option (ROLE_PROTOCOL+loginBean.getDba(), "system administrator");
|
||||
administrator.setSelected(userForEditing.getRoleURI().equals(administrator.getValue()));
|
||||
|
||||
List roleOptionList = new LinkedList();
|
||||
|
||||
if (nonEditor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getNonEditor()))
|
||||
roleOptionList.add(nonEditor);
|
||||
administrator.setSelected(userForEditing.getRoleURI().equals(administrator.getValue()));
|
||||
|
||||
if (editor.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getEditor()))
|
||||
roleOptionList.add(editor);
|
||||
if (curator.getSelected() || (Integer.decode(loginBean.getLoginRole()) >= loginBean.getCurator()))
|
||||
|
|
Loading…
Add table
Reference in a new issue