private String getProjectIdAllowingForAdminApi( ){ // Get the thread scoped admin context. AdminUserContext adminUserContext = applicationContext.getBean(AdminUserContext.class); if ( adminUserContext != null && adminUserContext.isAllowAdministration() ) { return null; } return userContext.getProjectId(); } }
private void createAdminContext(boolean allowAdministration) { validateAllowAdministration(allowAdministration); AdminUserContext adminUserContext = applicationContext.getBean(AdminUserContext.class); adminUserContext.setAllowAdministration(allowAdministration); }
protected <R extends T> R preSave(T item, Session session){ // Check in preSave that we are allowed to add items with a projectId of null. // This is only allowed for certain types, when api.admin.basedata=true if (!Strings.isNullOrEmpty(userContext.getProjectId())) { return (R)item; } // check is the adminUserContext allowing administration of base data. AdminUserContext adminUserContext = applicationContext.getBean(AdminUserContext.class); if ( adminUserContext != null && adminUserContext.isAllowAdministration() ) { return (R) item; } throw new RuntimeException("Unable to save item - projectId is null"); }
if ( adminUserContext != null && adminUserContext.isAllowAdministration() ) { return (R) item;