use of net.jforum.dao.GroupSecurityDAO in project jforum2 by rafaelsteil.
the class GenericGroupDAO method delete.
/**
* @see net.jforum.dao.GroupDAO#delete(int)
*/
public void delete(int groupId) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("GroupModel.delete"));
p.setInt(1, groupId);
p.executeUpdate();
GroupSecurityDAO securityDao = DataAccessDriver.getInstance().newGroupSecurityDAO();
securityDao.deleteAllRoles(groupId);
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of net.jforum.dao.GroupSecurityDAO in project jforum2 by rafaelsteil.
the class GroupAction method permissionsSave.
public void permissionsSave() {
int id = this.request.getIntParameter("id");
GroupSecurityDAO gmodel = DataAccessDriver.getInstance().newGroupSecurityDAO();
PermissionControl pc = new PermissionControl();
pc.setSecurityModel(gmodel);
new PermissionProcessHelper(pc, id).processData();
SecurityRepository.clean();
RolesRepository.clear();
ForumRepository.clearModeratorList();
this.list();
}
use of net.jforum.dao.GroupSecurityDAO in project jforum2 by rafaelsteil.
the class SecurityRepository method load.
/**
* Load user's roles.
*
* @param user The <code>User</code> to load
* @param force If <code>true</code>, forces a reload. If <code>false</code>, the call
* will be ignored if the roles are already loaded.
*
* @see SecurityRepository#load(int)
* @see SecurityRepository#load(int, boolean)
* @see SecurityRepository#load(User)
* @return PermissionControl
*/
public static PermissionControl load(User user, boolean force) {
String userId = Integer.toString(user.getId());
if (force || cache.get(FQN, userId) == null) {
PermissionControl pc = new PermissionControl();
// load roles
GroupSecurityDAO dao = DataAccessDriver.getInstance().newGroupSecurityDAO();
pc.setRoles(dao.loadRolesByUserGroups(user));
cache.add(FQN, userId, pc);
return pc;
}
return SecurityRepository.get(user.getId());
}
use of net.jforum.dao.GroupSecurityDAO in project jforum2 by rafaelsteil.
the class GenericForumDAO method delete.
/**
* @see net.jforum.dao.ForumDAO#delete(int)
*/
public void delete(int forumId) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.delete"));
p.setInt(1, forumId);
p.executeUpdate();
GroupSecurityDAO groupSecurity = DataAccessDriver.getInstance().newGroupSecurityDAO();
groupSecurity.deleteForumRoles(forumId);
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of net.jforum.dao.GroupSecurityDAO in project jforum2 by rafaelsteil.
the class CategoryAction method insertSave.
// A new one
public void insertSave() {
Category c = new Category();
c.setName(this.request.getParameter("category_name"));
c.setModerated("1".equals(this.request.getParameter("moderated")));
int categoryId = this.cm.addNew(c);
c.setId(categoryId);
ForumRepository.addCategory(c);
String[] groups = this.request.getParameterValues("groups");
if (groups != null) {
GroupSecurityDAO gmodel = DataAccessDriver.getInstance().newGroupSecurityDAO();
PermissionControl pc = new PermissionControl();
pc.setSecurityModel(gmodel);
Role role = new Role();
role.setName(SecurityConstants.PERM_CATEGORY);
for (int i = 0; i < groups.length; i++) {
int groupId = Integer.parseInt(groups[i]);
RoleValueCollection roleValues = new RoleValueCollection();
RoleValue rv = new RoleValue();
rv.setValue(Integer.toString(categoryId));
roleValues.add(rv);
pc.addRoleValue(groupId, role, roleValues);
}
SecurityRepository.clean();
RolesRepository.clear();
}
this.list();
}
Aggregations