List of usage examples for org.apache.shiro SecurityUtils getSubject
public static Subject getSubject()
From source file:au.org.theark.lims.web.component.biospecimen.form.ContainerForm.java
License:Open Source License
/** * Returns a list of Studies the user is permitted to access * //from www. ja v a 2s. c o m * @return */ public List<Study> getStudyListForUser() { List<Study> studyList = new ArrayList<Study>(0); try { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = null; //arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); //studyList = iArkCommonService.getStudyListForUserAndModule(arkUserVo, arkModule); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { studyList = iArkCommonService.getParentAndChildStudies(sessionStudyId); getModelObject().setStudyList(studyList); } getModelObject().setStudyList(studyList); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyList; }
From source file:au.org.theark.lims.web.component.biospecimen.form.SearchForm.java
License:Open Source License
private void initStudyDdc() { CompoundPropertyModel<LimsVO> limsCpm = cpmModel; PropertyModel<Study> studyPm = new PropertyModel<Study>(limsCpm, "study"); List<Study> studyListForUser = new ArrayList<Study>(0); try {//from w w w . ja v a 2s. c o m Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); //Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession().getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); //ArkModule arkModule = null; //arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); //studyListForUser = iArkCommonService.getStudyListForUserAndModule(arkUserVo, arkModule); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { studyListForUser = iArkCommonService.getParentAndChildStudies(sessionStudyId); cpmModel.getObject().setStudyList(studyListForUser); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } ChoiceRenderer<Study> studyRenderer = new ChoiceRenderer<Study>(Constants.NAME, Constants.ID); studyDdc = new DropDownChoice<Study>("study", studyPm, (List<Study>) studyListForUser, studyRenderer) { @Override protected void onBeforeRender() { Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(sessionStudyId); cpmModel.getObject().setStudy(study); super.onBeforeRender(); }; }; }
From source file:au.org.theark.lims.web.component.biospecimencustomdata.BiospecimenCustomDataContainerPanel.java
License:Open Source License
protected boolean prerenderContextCheck() { // Get the Study, SubjectUID and ArkModule from Context Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Long sessionBiospecimenId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.lims.web.Constants.BIOSPECIMEN); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); boolean contextLoaded = false; if ((sessionStudyId != null) && (sessionBiospecimenId != null)) { Biospecimen biospecimen = null;/*from www . j a v a 2 s . c o m*/ ArkModule arkModule = null; Study study = null; try { study = iArkCommonService.getStudy(sessionStudyId); cpModel.getObject().getBiospecimen().setStudy(study); biospecimen = iLimsService.getBiospecimen(sessionBiospecimenId); cpModel.getObject().setBiospecimen(biospecimen); arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); // cpModel.getObject().setArkModule(arkModule); if (study != null && biospecimen != null && arkModule != null) { contextLoaded = true; cpModel.getObject().setArkFunction(iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_BIOSPECIMEN)); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } } return contextLoaded; }
From source file:au.org.theark.lims.web.component.biospecimenuidtemplate.BiospecimenUidTemplateContainerPanel.java
License:Open Source License
public BiospecimenUidTemplateContainerPanel(String id, WebMarkupContainer arkContextMarkup) { super(id);// ww w .j a v a 2 s. c o m this.arkContextMarkup = arkContextMarkup; BiospecimenUidTemplate BiospecimenUidTemplate = new BiospecimenUidTemplate(); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SESSION_STUDY_KEY); if (sessionStudyId != null) { Study study = iArkCommonService.getStudy(sessionStudyId); BiospecimenUidTemplate.setStudy(study); } cpModel = new CompoundPropertyModel<BiospecimenUidTemplate>(BiospecimenUidTemplate); arkCrudContainerVO = new ArkCrudContainerVO(); initialisePanel(); }
From source file:au.org.theark.lims.web.component.biospecimenuidtemplate.form.DetailForm.java
License:Open Source License
/** * Returns a list of Studies the user is permitted to access * /* w w w . j a v a 2 s .c om*/ * @return */ private List<Study> getStudyListForUser() { List<Study> studyListForUser = new ArrayList<Study>(0); try { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = null; arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); studyListForUser = iArkCommonService.getStudyListForUserAndModule(arkUserVo, arkModule); // Remove possible Study's already assigned a BiospecimenUidTemplate if (isNew()) { studyListForUser.removeAll(iLimsAdminService.getStudyListAssignedToBiospecimenUidTemplate()); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyListForUser; }
From source file:au.org.theark.lims.web.component.biospecimenupload.BiospecimenUploadContainerPanel.java
License:Open Source License
public BiospecimenUploadContainerPanel(String id, ArkFunction arkFunction) { super(id);/*from w w w . j a v a2 s.c om*/ /* Initialise the CPM */ cpModel = new CompoundPropertyModel<UploadVO>(new UploadVO()); this.arkFunction = arkFunction; /* Bind the CPM to the Form */ containerForm = new ContainerForm("containerForm", cpModel); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = null; if (sessionStudyId != null) { study = iArkCommonService.getStudy(sessionStudyId); } cpModel.getObject().getUpload().setStudy(study); containerForm.add(initialiseFeedBackPanel()); // containerForm.add(initialiseDetailPanel()); containerForm.add(initialiseWizardPanel()); containerForm.add(initialiseSearchResults()); // containerForm.add(initialiseSearchPanel()); containerForm.setMultiPart(true); add(containerForm); }
From source file:au.org.theark.lims.web.component.biospecimenupload.BiospecimenUploadContainerPanel.java
License:Open Source License
protected WebMarkupContainer initialiseSearchResults() { searchResultPanel = new SearchResultListPanel("searchResults", feedBackPanel, containerForm, arkCrudContainerVO);// w w w.j a v a 2s . co m iModel = new LoadableDetachableModel<Object>() { private static final long serialVersionUID = 1L; @Override protected Object load() { // Return all Uploads for the Study in context java.util.Collection<Upload> studyUploads = new ArrayList<Upload>(); if (isActionPermitted()) { Upload studyUpload = new Upload(); List<Study> studyListForUser = new ArrayList<Study>(0); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = null; if (sessionStudyId != null) { study = iArkCommonService.getStudy(sessionStudyId); studyUpload.setStudy(study); studyUpload.setArkFunction(arkFunction); studyListForUser.add(study); studyUploads = iArkCommonService.searchUploadsForBiospecimen(studyUpload, studyListForUser); } } listView.removeAll(); return studyUploads; } }; listView = searchResultPanel.buildPageableListView(iModel); listView.setReuseItems(true); PagingNavigator pageNavigator = new PagingNavigator("navigator", listView); searchResultPanel.add(pageNavigator); searchResultPanel.add(listView); arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultPanel); searchResultPanel.setVisible(true); return arkCrudContainerVO.getSearchResultPanelContainer(); }
From source file:au.org.theark.lims.web.component.biospecimenupload.BiospecimenUploadStep1.java
License:Open Source License
private void initialiseDropDownChoices() { // Initialise Drop Down Choices java.util.Collection<DelimiterType> delimiterTypeCollection = iArkCommonService.getDelimiterTypes(); ChoiceRenderer<DelimiterType> choiceRenderer = new ChoiceRenderer<DelimiterType>(Constants.NAME, Constants.ID);/* w w w . j a v a2s. co m*/ delimiterTypeDdc = new DropDownChoice<DelimiterType>(Constants.UPLOADVO_UPLOAD_DELIMITER_TYPE, (List<DelimiterType>) delimiterTypeCollection, choiceRenderer); // Set to default delimiterType containerForm.getModelObject().getUpload() .setDelimiterType(iArkCommonService.getDelimiterType(new Long(1)));//TODO: This looks hardcoded...please check different types java.util.Collection<UploadType> uploadTypeCollection = iArkCommonService.getUploadTypesForLims(); ChoiceRenderer uploadTypeRenderer = new ChoiceRenderer(Constants.UPLOAD_TYPE_NAME, Constants.UPLOAD_TYPE_ID); uploadTypeDdc = new DropDownChoice<UploadType>(Constants.UPLOADVO_UPLOAD_UPLOAD_TYPE, (List) uploadTypeCollection, uploadTypeRenderer); List<Study> studyListForUser = new ArrayList<Study>(0); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = null; if (sessionStudyId != null) { study = iArkCommonService.getStudy(sessionStudyId); studyListForUser.add(study); } ChoiceRenderer<Study> studyRenderer = new ChoiceRenderer<Study>(Constants.NAME, Constants.ID); PropertyModel<Study> pModel = new PropertyModel<Study>(containerForm.getModelObject(), "upload.study"); studyDdc = new DropDownChoice<Study>(Constants.UPLOADVO_UPLOAD_STUDY, pModel, (List<Study>) studyListForUser, studyRenderer); containerForm.getModelObject().getUpload().setUploadType(iArkCommonService.getDefaultUploadType()); }
From source file:au.org.theark.lims.web.component.biospecimenupload.form.DetailForm.java
License:Open Source License
@Override protected void onSave(Form<UploadVO> containerForm, AjaxRequestTarget target) { // Implement Save/Update if (containerForm.getModelObject().getUpload().getId() == null) { setMultiPart(true); // multipart required for file uploads // Set study in context Long studyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(studyId); // TODO: AJAX-ified and asynchronous and hit database FileUpload fileUpload = fileUploadField.getFileUpload(); Payload payload = iArkCommonService.createPayload(fileUpload.getBytes()); containerForm.getModelObject().getUpload().setPayload(payload); // Set details of Upload object containerForm.getModelObject().getUpload().setStudy(study); byte[] byteArray = fileUpload.getMD5(); String checksum = getHex(byteArray); containerForm.getModelObject().getUpload().setChecksum(checksum); containerForm.getModelObject().getUpload().setFilename(fileUpload.getClientFileName()); // Save/*from ww w . j av a 2 s.co m*/ containerForm.getModelObject().getUpload().setArkFunction(arkFunction); containerForm.getModelObject().getUpload() .setUploadStatus(iArkCommonService.getUploadStatusFor(Constants.UPLOAD_STATUS_COMPLETED)); try { iArkCommonService.createUpload(containerForm.getModelObject().getUpload()); } catch (Exception e) { error("There was a problem during the upload process."); processErrors(target); } this.saveInformation(); //this.info("Subject upload " + containerForm.getModelObject().getUpload().getFilename() + " was created successfully"); processErrors(target); } else { // Update containerForm.getModelObject().getUpload().setArkFunction(arkFunction); iArkCommonService.updateUpload(containerForm.getModelObject().getUpload()); this.updateInformation(); //this.info("Subject upload " + containerForm.getModelObject().getUpload().getFilename() + " was updated successfully"); processErrors(target); } onSavePostProcess(target); /* * TODO:(CE) To handle Business and System Exceptions here */ }
From source file:au.org.theark.lims.web.component.biospecimenupload.form.SearchForm.java
License:Open Source License
public SearchForm(String id, CompoundPropertyModel<UploadVO> model, PageableListView<Upload> listView, FeedbackPanel feedBackPanel, ArkCrudContainerVO arkCrudContainerVO) { super(id, model, feedBackPanel, arkCrudContainerVO); this.cpmModel = model; this.listView = listView; initialiseFieldForm();// www .j a v a 2 s. co m Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); disableSearchForm(sessionStudyId, "There is no study selected. Please select a study."); }