@SuppressWarnings("unchecked") @Test public void deleteDashboardTest() throws Exception { RDBMS db = Mockito.mock(RDBMS.class); when(db.update(Mockito.anyString(), Matchers.anyMap())) .thenReturn(1); when(db.delete(Mockito.anyString(), Matchers.eq(ImmutableMap.of("name",uttestdashbaord1)))) .thenReturn(1); DashboardService dashboardService = new DashboardService(); BaseDBService<?> ds=(BaseDBService<?>)ReflectFieldUtil.getField(dashboardService, "dashboardService"); BaseDBService<?> rs=(BaseDBService<?>)ReflectFieldUtil.getField(dashboardService, "rightGroupService"); ReflectFieldUtil.setField(BaseDBService.class,ds, "db", db); ReflectFieldUtil.setField(BaseDBService.class,rs, "db", db); long id = dashboardService.deleteDashboard(uttestdashbaord1); Assert.assertTrue(id > 0); dashboardService.deleteDashboards(Lists.newArrayList( uttestdashbaord1)); Assert.assertTrue(id > 0); }
@PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE','SYS_MANAGE_DASHBOARD')") public int deleteDashboard(String dashboardName) { checkNotNull(dashboardName); rightGroupService.deleteRightsFromGroupByPrefix(dashboardName+"_"); DBDashboard dashboardCondition = new DBDashboard(); dashboardCondition.setName(dashboardName); int i= dashboardService.deleteBatch(dashboardCondition); PermissionControlCache.getInstance().expireSessionsAll(); return i; }
DashboardService { @PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE','SYS_MANAGE_DASHBOARD')") public int deleteDashboard(String dashboardName) { checkNotNull(dashboardName); rightGroupService.deleteRightsFromGroupByPrefix(dashboardName+"_"); DBDashboard dashboardCondition = new DBDashboard(); dashboardCondition.setName(dashboardName); int i= dashboardService.deleteBatch(dashboardCondition); PermissionControlCache.getInstance().expireSessionsAll(); return i; } }
DashboardService { @PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE','SYS_MANAGE_DASHBOARD')") public int deleteDashboard(String dashboardName) { checkNotNull(dashboardName); rightGroupService.deleteRightsFromGroupByPrefix(dashboardName+"_"); DBDashboard dashboardCondition = new DBDashboard(); dashboardCondition.setName(dashboardName); int i= dashboardService.deleteBatch(dashboardCondition); PermissionControlCache.getInstance().expireSessionsAll(); return i; } DashboardService(); }
DashboardService { @PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE','SYS_MANAGE_DASHBOARD')") public int deleteDashboard(String dashboardName) { checkNotNull(dashboardName); rightGroupService.deleteRightsFromGroupByPrefix(dashboardName+"_"); DBDashboard dashboardCondition = new DBDashboard(); dashboardCondition.setName(dashboardName); int i= dashboardService.deleteBatch(dashboardCondition); PermissionControlCache.getInstance().expireSessionsAll(); return i; } DashboardService(); String getManagePermission(String dashboardName); String getViewPermission(String dashboardName); @PreAuthorize("hasAuthority('ADD_DASHBOARD')") long addDashboard(DBDashboard dashboard); @PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE','SYS_MANAGE_DASHBOARD')") int deleteDashboard(String dashboardName); @PreFilter("hasAuthority(filterObject+'_MANAGE') or hasAuthority('SYS_MANAGE_DASHBOARD')") int deleteDashboards(List<String> dashboardNames); @PreAuthorize("hasAuthority(#dashboardName+'_MANAGE') or hasAuthority('SYS_MANAGE_DASHBOARD')") int updateDashboard(String dashboardName, String displayname, String newConfig); @PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE',#dashboardName+'_VIEW','SYS_MANAGE_DASHBOARD','SYS_VIEW_DASHBOARD')") DBDashboard getDashboardByName(String dashboardName); List<String> getAllDashboardsForOwner(String userName); @PreFilter("hasAuthority(filterObject+'_MANAGE') or hasAuthority(filterObject+'_VIEW') or hasAuthority('SYS_MANAGE_DASHBOARD') or hasAuthority('SYS_VIEW_DASHBOARD')") List<DBDashboard> getDashboardByNames(List<String> names); @PostFilter("hasAuthority(filterObject.name+'_MANAGE') or hasAuthority(filterObject.name+'_VIEW') or hasAuthority('SYS_MANAGE_DASHBOARD') or hasAuthority('SYS_VIEW_DASHBOARD')") List<DBDashboard> getUserViewedDashboard(); @PostFilter("hasAuthority(filterObject.name+'_MANAGE') or hasAuthority('SYS_MANAGE_DASHBOARD')") List<DBDashboard> getAllUserManagedDashboard(); }
DashboardService { @PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE','SYS_MANAGE_DASHBOARD')") public int deleteDashboard(String dashboardName) { checkNotNull(dashboardName); rightGroupService.deleteRightsFromGroupByPrefix(dashboardName+"_"); DBDashboard dashboardCondition = new DBDashboard(); dashboardCondition.setName(dashboardName); int i= dashboardService.deleteBatch(dashboardCondition); PermissionControlCache.getInstance().expireSessionsAll(); return i; } DashboardService(); String getManagePermission(String dashboardName); String getViewPermission(String dashboardName); @PreAuthorize("hasAuthority('ADD_DASHBOARD')") long addDashboard(DBDashboard dashboard); @PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE','SYS_MANAGE_DASHBOARD')") int deleteDashboard(String dashboardName); @PreFilter("hasAuthority(filterObject+'_MANAGE') or hasAuthority('SYS_MANAGE_DASHBOARD')") int deleteDashboards(List<String> dashboardNames); @PreAuthorize("hasAuthority(#dashboardName+'_MANAGE') or hasAuthority('SYS_MANAGE_DASHBOARD')") int updateDashboard(String dashboardName, String displayname, String newConfig); @PreAuthorize("hasAnyAuthority(#dashboardName+'_MANAGE',#dashboardName+'_VIEW','SYS_MANAGE_DASHBOARD','SYS_VIEW_DASHBOARD')") DBDashboard getDashboardByName(String dashboardName); List<String> getAllDashboardsForOwner(String userName); @PreFilter("hasAuthority(filterObject+'_MANAGE') or hasAuthority(filterObject+'_VIEW') or hasAuthority('SYS_MANAGE_DASHBOARD') or hasAuthority('SYS_VIEW_DASHBOARD')") List<DBDashboard> getDashboardByNames(List<String> names); @PostFilter("hasAuthority(filterObject.name+'_MANAGE') or hasAuthority(filterObject.name+'_VIEW') or hasAuthority('SYS_MANAGE_DASHBOARD') or hasAuthority('SYS_VIEW_DASHBOARD')") List<DBDashboard> getUserViewedDashboard(); @PostFilter("hasAuthority(filterObject.name+'_MANAGE') or hasAuthority('SYS_MANAGE_DASHBOARD')") List<DBDashboard> getAllUserManagedDashboard();  }