@DaoTransaction public AccessRight getAccessRight( String serviceGridId, String serviceId, String userGridId, String userId) throws DaoException, ServiceNotFoundException, UserNotFoundException { if (!getServiceDao().isServiceExist(serviceGridId, serviceId)) { throw new ServiceNotFoundException(serviceGridId, serviceId); } if (!userGridId.equals("*") && !userId.equals("*")) { if (!getUserDao().isUserExist(userGridId, userId)) { throw new UserNotFoundException(userGridId, userId); } } AccessRightDao dao = getAccessRightDao(); AccessRight r = dao.getAccessRight(userGridId, userId, serviceGridId, serviceId); if (r == null) { r = dao.getGridDefaultAccessRight(userGridId, serviceGridId, serviceId); } if (r == null) { r = dao.getServiceDefaultAccessRight(serviceGridId, serviceId); } if (r != null) { return new AccessRight(userGridId, userId, serviceGridId, serviceId, r.isPermitted()); } else { return null; } }
private void setUser( AccessRight defaultRight, String userGridId, String userId, String serviceGridId, String serviceId, boolean permitted) throws DaoException { AccessRightDao arDao = getAccessRightDao(); if (defaultRight.isPermitted() != permitted) { arDao.setAccessRight(userGridId, userId, serviceGridId, serviceId, permitted); } else { arDao.deleteAccessRight(userGridId, userId, serviceGridId, serviceId); } AccessLimitDao alDao = getAccessLimitDao(); alDao.deleteAccessLimits(userGridId, userId, serviceGridId, serviceId); if (permitted) { for (AccessLimit l : alDao.getServiceDefaultAccessLimits(userGridId, serviceGridId, serviceId)) { alDao.setAccessLimit( userGridId, userId, serviceGridId, serviceId, l.getPeriod(), l.getLimitType(), l.getLimitCount()); } } }
private void setServiceDefault( AccessRight serviceDefaultRight, String serviceGridId, String serviceId, boolean permitted) throws DaoException { AccessRightDao arDao = getAccessRightDao(); if (serviceDefaultRight.isPermitted() == permitted) return; arDao.setServiceDefaultAccessRight(serviceGridId, serviceId, permitted); arDao.adjustGridDefaultRights(serviceGridId, serviceId, permitted); }
private void setGridDefault( AccessRight serviceDefaultRight, AccessRight gridDefaultRight, String userGridId, String serviceGridId, String serviceId, String serviceOwnerUserId, boolean permitted) throws DaoException { AccessRightDao arDao = getAccessRightDao(); if (gridDefaultRight != null) { if (gridDefaultRight.isPermitted() == permitted) return; } else { if (serviceDefaultRight.isPermitted() == permitted) return; } if (serviceDefaultRight.isPermitted() == permitted) { arDao.deleteGridDefaultAccessRight(userGridId, serviceGridId, serviceId); } else { arDao.setGridDefaultAccessRight(userGridId, serviceGridId, serviceId, permitted); } arDao.adjustUserRights(userGridId, serviceGridId, serviceId, serviceOwnerUserId, permitted); /* AccessRightDao arDao = getAccessRightDao(); if(defaultRight.isPermitted() == permitted) return; jp.go.nict.langrid.dao.AccessRightSearchResult res = arDao.searchAccessRightsAccordingToDefaultAndOwner( 0, 10000, userGridId, "", serviceGridId, array(serviceId) , serviceOwnerUserId , array(new jp.go.nict.langrid.dao.Order( "userId" , jp.go.nict.langrid.dao.OrderDirection.ASCENDANT )) ); for(AccessRight ar : res.getElements()){ if(ar.isPermitted() == permitted){ arDao.deleteAccessRight(userGridId, ar.getUserId(), serviceGridId, ar.getServiceId()); } else{ arDao.setAccessRight(userGridId, ar.getUserId(), serviceGridId, ar.getServiceId() , !permitted); } } arDao.setServiceDefaultAccessRight(serviceGridId, serviceId, permitted); */ }