/** * Checks if this group is a role group.<p> * * @return <code>true</code> if this group is a role group */ public boolean isRole() { return (getFlags() & I_CmsPrincipal.FLAG_GROUP_ROLE) == I_CmsPrincipal.FLAG_GROUP_ROLE; }
/** * Checks if this group is a virtual group, emulating a role.<p> * * @return if this group is a virtual group */ public boolean isVirtual() { return (getFlags() & I_CmsPrincipal.FLAG_GROUP_VIRTUAL) == I_CmsPrincipal.FLAG_GROUP_VIRTUAL; }
/** * Checks if this group is a role group.<p> * * @return <code>true</code> if this group is a role group */ public boolean isRole() { return (getFlags() & I_CmsPrincipal.FLAG_GROUP_ROLE) == I_CmsPrincipal.FLAG_GROUP_ROLE; }
/** * Checks if this group is a virtual group, emulating a role.<p> * * @return if this group is a virtual group */ public boolean isVirtual() { return (getFlags() & I_CmsPrincipal.FLAG_GROUP_VIRTUAL) == I_CmsPrincipal.FLAG_GROUP_VIRTUAL; }
/** * Returns <code>true</code> if this group is enabled as a project user group.<p> * * @return <code>true</code> if this group is enabled as a project user group */ public boolean isProjectCoWorker() { return (getFlags() & I_CmsPrincipal.FLAG_GROUP_PROJECT_USER) == I_CmsPrincipal.FLAG_GROUP_PROJECT_USER; }
/** * Returns <code>true</code> if this group is enabled as a project manager group.<p> * * @return <code>true</code> if this group is enabled as a project manager group */ public boolean isProjectManager() { return (getFlags() & I_CmsPrincipal.FLAG_GROUP_PROJECT_MANAGER) == I_CmsPrincipal.FLAG_GROUP_PROJECT_MANAGER; }
/** * Filters out all groups with flags greater than <code>{@link I_CmsPrincipal#FLAG_CORE_LIMIT}</code>.<p> * * The given parameter list is directly modified, so the returned list is the same object as the input list.<p> * * @param groups a list of <code>{@link CmsGroup}</code> objects * * @return the filtered principal list */ public static List<CmsGroup> filterCoreGroups(List<CmsGroup> groups) { Iterator<CmsGroup> it = groups.iterator(); while (it.hasNext()) { CmsGroup p = it.next(); if (p.getFlags() > I_CmsPrincipal.FLAG_CORE_LIMIT) { it.remove(); } } return groups; }
/** * Sets the project user flag for this group to the given value.<p> * * @param value the value to set */ public void setProjectCoWorker(boolean value) { if (isProjectCoWorker() != value) { setFlags(getFlags() ^ I_CmsPrincipal.FLAG_GROUP_PROJECT_USER); } }
/** * Sets the project manager flag for this group to the given value.<p> * * @param value the value to set */ public void setProjectManager(boolean value) { if (isProjectManager() != value) { setFlags(getFlags() ^ I_CmsPrincipal.FLAG_GROUP_PROJECT_MANAGER); } }
/** * Returns the role for the given group.<p> * * @param group a group to check for role representation * * @return the role for the given group */ public static CmsRole valueOf(CmsGroup group) { // check groups for internal representing the roles if (group.isRole()) { CmsRole role = valueOfGroupName(group.getName()); if (role != null) { return role; } } // check virtual groups mapping a role if (group.isVirtual()) { int index = (group.getFlags() & (I_CmsPrincipal.FLAG_CORE_LIMIT - 1)); index = index / (I_CmsPrincipal.FLAG_GROUP_VIRTUAL * 2); CmsRole role = getSystemRoles().get(index); return role.forOrgUnit(group.getOuFqn()); } return null; }
/** * Returns the role for the given group.<p> * * @param group a group to check for role representation * * @return the role for the given group */ public static CmsRole valueOf(CmsGroup group) { // check groups for internal representing the roles if (group.isRole()) { CmsRole role = valueOfGroupName(group.getName()); if (role != null) { return role; } } // check virtual groups mapping a role if (group.isVirtual()) { int index = (group.getFlags() & (I_CmsPrincipal.FLAG_CORE_LIMIT - 1)); index = index / (I_CmsPrincipal.FLAG_GROUP_VIRTUAL * 2); CmsRole role = (CmsRole)getSystemRoles().get(index); return role.forOrgUnit(group.getOuFqn()); } return null; }
/** * @see org.opencms.db.I_CmsUserDriver#writeGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsDataAccessException { PreparedStatement stmt = null; Connection conn = null; if (group != null) { try { conn = getSqlManager().getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_GROUPS_WRITE_GROUP_4"); stmt.setString(1, m_sqlManager.validateEmpty(group.getDescription())); stmt.setInt(2, group.getFlags()); stmt.setString(3, group.getParentId().toString()); stmt.setString(4, group.getId().toString()); stmt.executeUpdate(); } catch (SQLException e) { throw new CmsDbSqlException( Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, null); } } else { throw new CmsDbEntryNotFoundException( org.opencms.db.Messages.get().container(org.opencms.db.Messages.ERR_UNKNOWN_GROUP_1, "null")); } }
/** * @see org.opencms.db.I_CmsUserDriver#writeGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsDataAccessException { PreparedStatement stmt = null; Connection conn = null; if (group != null) { try { conn = getSqlManager().getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_GROUPS_WRITE_GROUP_4"); stmt.setString(1, m_sqlManager.validateEmpty(group.getDescription())); stmt.setInt(2, group.getFlags()); stmt.setString(3, group.getParentId().toString()); stmt.setString(4, group.getId().toString()); stmt.executeUpdate(); } catch (SQLException e) { throw new CmsDbSqlException(Messages.get().container( Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)), e); } finally { m_sqlManager.closeAll(dbc, conn, stmt, null); } } else { throw new CmsDbEntryNotFoundException(org.opencms.db.Messages.get().container( org.opencms.db.Messages.ERR_UNKNOWN_GROUP_1, "null")); } }
/** * @see org.opencms.db.I_CmsUserDriver#writeGroup(org.opencms.db.CmsDbContext, org.opencms.file.CmsGroup) */ public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsDataAccessException { if (group != null) { try { Query q = m_sqlManager.createQuery(dbc, C_GROUPS_WRITE_GROUP_4); q.setParameter(1, group.getId().toString()); List<CmsDAOGroups> res = q.getResultList(); for (CmsDAOGroups g : res) { g.setGroupDescription(m_sqlManager.validateEmpty(group.getDescription())); g.setGroupFlags(group.getFlags()); g.setParentGroupId(group.getParentId().toString()); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } } else { throw new CmsDbEntryNotFoundException( org.opencms.db.Messages.get().container(org.opencms.db.Messages.ERR_UNKNOWN_GROUP_1, "null")); } }
e.addElement(CmsImportVersion7.N_NAME).addText(group.getSimpleName()); e.addElement(CmsImportVersion7.N_DESCRIPTION).addCDATA(group.getDescription()); e.addElement(CmsImportVersion7.N_FLAGS).addText(Integer.toString(group.getFlags())); e.addElement(CmsImportVersion7.N_PARENTGROUP).addText(parentgroup);
e.addElement(CmsImportVersion10.N_NAME).addText(group.getSimpleName()); e.addElement(CmsImportVersion10.N_DESCRIPTION).addCDATA(group.getDescription()); e.addElement(CmsImportVersion10.N_FLAGS).addText(Integer.toString(group.getFlags())); e.addElement(CmsImportVersion10.N_PARENTGROUP).addText(parentgroup);