List of usage examples for org.apache.shiro SecurityUtils getSubject
public static Subject getSubject()
From source file:au.org.theark.core.web.component.AbstractSubContainerPanel.java
License:Open Source License
public AbstractSubContainerPanel(String id, boolean flag) { super(id);//from ww w .j a v a2 s . c o m setOutputMarkupPlaceholderTag(true); Subject currentUser = SecurityUtils.getSubject(); realm.clearCachedAuthorizationInfo(currentUser.getPrincipals());// TODO(NN) Uncomment after the User management usecase is complete }
From source file:au.org.theark.core.web.component.customfield.CustomFieldContainerPanel.java
License:Open Source License
protected void prerenderContextCheck() { // Get the Study and Module out of context Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); if ((sessionStudyId != null) && (sessionModuleId != null)) { ArkModule arkModule = null;/*from w ww. jav a 2s . co m*/ Study study = null; study = iArkCommonService.getStudy(sessionStudyId); arkModule = iArkCommonService.getArkModuleById(sessionModuleId); if (study != null && arkModule != null) { cpModel.getObject().getCustomField().setStudy(study); // TODO: Maybe check that the primary function supplied is of // the same module? } } }
From source file:au.org.theark.core.web.component.customfield.dataentry.AbstractCustomDataEditorForm.java
License:Open Source License
public void onBeforeRender() { super.onBeforeRender(); visitChildren(formVisitor);/*from ww w. ja v a 2 s.c om*/ SecurityManager securityManager = ThreadContext.getSecurityManager(); Subject currentUser = SecurityUtils.getSubject(); if (ArkPermissionHelper.hasEditPermission(securityManager, currentUser) || //User can UPDATE ArkPermissionHelper.hasNewPermission(securityManager, currentUser) || //User can CREATE ArkPermissionHelper.hasDeletePermission(securityManager, currentUser)) { //User can DELETE dataViewWMC.setOutputMarkupId(true); dataViewWMC.setEnabled(true); this.add(dataViewWMC); } else { dataViewWMC.setOutputMarkupId(true); dataViewWMC.setEnabled(false); //default to View mode this.add(dataViewWMC); } Long arkFunctionId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_FUNCTION_KEY); ArkFunction arkFunction = iArkCommonService.getArkFunctionById(arkFunctionId); if (arkFunction.getName() .equalsIgnoreCase(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_DATA)) { EditModeButtonsPanel buttonPanel = (EditModeButtonsPanel) buttonsPanelWMC.get("buttonsPanel"); if (buttonPanel != null) { ((ArkAjaxButton) buttonPanel.get("cancel")).setVisible(false); } } }
From source file:au.org.theark.core.web.component.customfield.form.DetailForm.java
License:Open Source License
/** * Constructor// ww w . ja v a2s.co m * * @param id * @param cpModel * @param feedBackPanel * @param arkCrudContainerVO */ public DetailForm(String id, CompoundPropertyModel<CustomFieldVO> cpModel, FeedbackPanel feedBackPanel, ArkCrudContainerVO arkCrudContainerVO) { super(id, feedBackPanel, cpModel, arkCrudContainerVO); // Initialise the model to be empty for now cfGroupDdcListModel = new ListModel<CustomFieldGroup>(); refreshEntityFromBackend(); //this.unitTypeDropDownOn=unitTypeDropDownOn; //this.subjectCustomField = subjectCustomField; Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); }
From source file:au.org.theark.core.web.component.customfield.form.DetailForm.java
License:Open Source License
/** * initialize custom field types.//from w ww . j a v a 2s.c o m */ private void initCustomFieldTypeDdc() { Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); arkModule = iArkCommonService.getArkModuleById(sessionModuleId); List<CustomFieldType> customFieldTypeCollection = iArkCommonService.getCustomFieldTypes(arkModule); ChoiceRenderer fieldTypeRenderer = new ChoiceRenderer(Constants.FIELDTYPE_NAME, Constants.FIELDTYPE_ID); customFieldTypeDdc = new DropDownChoice<CustomFieldType>(Constants.FIELDVO_CUSTOMFIELD_CUSTOM_FIELD_TYPE, customFieldTypeCollection, fieldTypeRenderer) { @Override protected void onBeforeRender() { if (!isNew()) { // Disable customfieldType if data exists for the field setEnabled(!cpModel.getObject().getCustomField().getCustomFieldHasData()); } super.onBeforeRender(); } }; customFieldTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { cpModel.getObject().getCustomField().setCustomFieldType(customFieldTypeDdc.getModelObject()); Collection<CustomFieldCategory> customFieldCategoryCollection = getAvailableAllCategoryListInStudyByCustomFieldType(); categoryPanel.remove(customeFieldCategoryDdc); ChoiceRenderer customfieldCategoryRenderer = new ChoiceRenderer(Constants.CUSTOMFIELDCATEGORY_NAME, Constants.CUSTOMFIELDCATEGORY_ID); customeFieldCategoryDdc = new DropDownChoice<CustomFieldCategory>( Constants.FIELDVO_CUSTOMFIELD_CUSTOEMFIELDCATEGORY, (List) customFieldCategoryCollection, customfieldCategoryRenderer); customeFieldCategoryDdc.setOutputMarkupId(true); customeFieldCategoryDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { customFieldCategoryChangeEvent(target); } }); customFieldCategoryChangeEvent(target); categoryPanel.add(customeFieldCategoryDdc); target.add(customeFieldCategoryDdc); target.add(categoryPanel); } }); }
From source file:au.org.theark.core.web.component.customfield.form.SearchForm.java
License:Open Source License
/** * @param id/*from w ww.ja v a 2s . c om*/ */ public SearchForm(String id, CompoundPropertyModel<CustomFieldVO> cpModel, FeedbackPanel feedBackPanel, ArkCrudContainerVO arkCrudContainerVO) { super(id, cpModel, feedBackPanel, arkCrudContainerVO); //this.unitTypeDropDownOn = unitTypeDropDownOn; this.cpModel = cpModel; this.feedbackPanel = feedBackPanel; this.arkCrudContainerVO = arkCrudContainerVO; //this.subjectCustomField = subjectCustomField; initialiseFieldForm(); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); disableSearchForm(sessionStudyId, "There is no study in context. Please select a study"); }
From source file:au.org.theark.core.web.component.customfield.form.SearchForm.java
License:Open Source License
/** * initialize Custom Filed Types.//from www . j av a2s .c om */ private void initCustomFieldTypeDdc() { Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); arkModule = iArkCommonService.getArkModuleById(sessionModuleId); java.util.Collection<CustomFieldType> customFieldTypeCollection = iArkCommonService .getCustomFieldTypes(arkModule); ChoiceRenderer customfieldTypeRenderer = new ChoiceRenderer(Constants.CUSTOM_FIELD_TYPE_NAME, Constants.CUSTOM_FIELD_TYPE_ID); customFieldTypeDdc = new DropDownChoice<CustomFieldType>(Constants.FIELDVO_CUSTOMFIELD_CUSTOM_FIELD_TYPE, (List) customFieldTypeCollection, customfieldTypeRenderer); customFieldTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { cpModel.getObject().getCustomField().setCustomFieldType(customFieldTypeDdc.getModelObject()); Collection<CustomFieldCategory> customFieldCategoryCollection = getCategoriesListInCustomFieldsByCustomFieldType(); categoryPanel.remove(customeFieldCategoryDdc); ChoiceRenderer customfieldCategoryRenderer = new ChoiceRenderer(Constants.CUSTOMFIELDCATEGORY_NAME, Constants.CUSTOMFIELDCATEGORY_ID); customeFieldCategoryDdc = new DropDownChoice<CustomFieldCategory>( Constants.FIELDVO_CUSTOMFIELD_CUSTOEMFIELDCATEGORY, (List) customFieldCategoryCollection, customfieldCategoryRenderer); customeFieldCategoryDdc.setOutputMarkupId(true); customeFieldCategoryDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { customFieldCategoryChangeEvent(target); } }); customFieldCategoryChangeEvent(target); categoryPanel.add(customeFieldCategoryDdc); target.add(customeFieldCategoryDdc); target.add(categoryPanel); } }); }
From source file:au.org.theark.core.web.component.customfield.form.SearchForm.java
License:Open Source License
@Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel);/*from ww w. j a va 2s. c om*/ final Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); // Get a list of all Fields for the Study in context Study study = iArkCommonService.getStudy(sessionStudyId); getModelObject().getCustomField().setStudy(study); long count = iArkCommonService.getCustomFieldCount(getModelObject().getCustomField()); if (count <= 0L) { this.info("No records match the specified criteria."); target.add(feedbackPanel); } arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }
From source file:au.org.theark.core.web.component.customfieldcategory.CustomFieldCategoryContainerPanel.java
License:Open Source License
protected void prerenderContextCheck() { // Get the Study and Module out of context Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); if ((sessionStudyId != null) && (sessionModuleId != null)) { Study study = null;//www . j a v a2 s. c o m study = iArkCommonService.getStudy(sessionStudyId); ArkModule arkModule = iArkCommonService.getArkModuleById(sessionModuleId); if (study != null && arkModule != null) { cpModel.getObject().getCustomFieldCategory().setStudy(study); // TODO: Maybe check that the primary function supplied is of the same module? } } }
From source file:au.org.theark.core.web.component.customfieldcategory.form.DetailForm.java
License:Open Source License
/** * initialize Custom Filed Types.//w w w .java 2 s . c o m */ private void initCustomFieldTypeDdc() { parentPanel = new WebMarkupContainer("parentPanel"); parentPanel.setOutputMarkupId(true); Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = iArkCommonService.getArkModuleById(sessionModuleId); java.util.Collection<CustomFieldType> customFieldTypeCollection = iArkCommonService .getCustomFieldTypes(arkModule); ChoiceRenderer customfieldTypeRenderer = new ChoiceRenderer(Constants.CUSTOM_FIELD_TYPE_NAME, Constants.CUSTOM_FIELD_TYPE_ID); customFieldTypeDdc = new DropDownChoice<CustomFieldType>( Constants.FIELDVO_CUSTOMFIELDCATEGORY_CUSTOM_FIELD_TYPE, (List) customFieldTypeCollection, customfieldTypeRenderer); //if custom field(s) assigned to the categories custom field type can not be edited. //or //if the custom field category has child/ren then you can not changed the type. if (!isNew()) { customFieldTypeDdc.setEnabled( !(iArkCommonService.isCustomFieldCategoryBeingUsed(getModelObject().getCustomFieldCategory()) || iArkCommonService.isThisCustomCategoryWasAParentCategoryOfAnother( getModelObject().getCustomFieldCategory()))); } customFieldTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { cpModel.getObject().getCustomFieldCategory() .setCustomFieldType(customFieldTypeDdc.getModelObject()); Collection<CustomFieldCategory> customFieldCategoryCollection = getAvailableCategoryCollectionFromModel(); parentPanel.remove(parentCategoryDdc); ChoiceRenderer customfieldCategoryRenderer = new ChoiceRenderer(Constants.CUSTOMFIELDCATEGORY_NAME, Constants.CUSTOMFIELDCATEGORY_ID); parentCategoryDdc = new DropDownChoice<CustomFieldCategory>( Constants.FIELDVO_CUSTOMFIELDCATEGORY_PARENTCATEGORY, (List) customFieldCategoryCollection, customfieldCategoryRenderer); parentCategoryDdc.setOutputMarkupId(true); parentPanel.add(parentCategoryDdc); target.add(parentCategoryDdc); target.add(parentPanel); } }); }