public boolean allowRemoveTags(TaggableActivity activity) { WizardPageDefinition pageDef = (WizardPageDefinition) activity.getObject(); // Try to get a wizard page sequence WizardPageSequence ps = wizardManager.getWizardPageSeqByDef(pageDef.getId()); boolean authorized = false; if (ps != null) { Wizard wizard = ps.getCategory().getWizard(); /* * If you own the wizard, or if you can delete wizards, or if you * can revise wizards, then you are able to delete page definitions * and can, therefore, remove tags. */ authorized = sessionManager .getCurrentSessionUserId() .equalsIgnoreCase(wizard.getOwner().getId().getValue()) || authzManager.isAuthorized(WizardFunctionConstants.EDIT_WIZARD, wizard.getId()) || authzManager.isAuthorized(WizardFunctionConstants.DELETE_WIZARD, wizard.getId()); } else { ScaffoldingCell cell = matrixManager.getScaffoldingCellByWizardPageDef(pageDef.getId()); /* * If you can create or delete scaffolding, then you are able to * delete scaffolding cells and can, therefore, remove tags. */ authorized = authzManager.isAuthorized( MatrixFunctionConstants.CREATE_SCAFFOLDING, cell.getScaffolding().getId()) || authzManager.isAuthorized( MatrixFunctionConstants.DELETE_SCAFFOLDING_ANY, cell.getScaffolding().getId()) || (authzManager.isAuthorized( MatrixFunctionConstants.DELETE_SCAFFOLDING_OWN, cell.getScaffolding().getId()) && cell.getScaffolding() .getOwner() .getId() .equals(getAuthnManager().getAgent().getId())); } return authorized; }