/** * Returns the parent group of a group.<p> * * @param dbc the current database context * @param groupname the name of the group * * @return group the parent group or <code>null</code> * * @throws CmsException if operation was not successful */ public CmsGroup getParent(CmsDbContext dbc, String groupname) throws CmsException { CmsGroup group = readGroup(dbc, groupname); if (group.getParentId().isNullUUID()) { return null; } // try to read from cache CmsGroup parent = m_monitor.getCachedGroup(group.getParentId().toString()); if (parent == null) { parent = m_userDriver.readGroup(dbc, group.getParentId()); m_monitor.cacheGroup(parent); } return parent; }
/** * Returns the parent group of a group.<p> * * @param dbc the current database context * @param groupname the name of the group * * @return group the parent group or <code>null</code> * * @throws CmsException if operation was not successful */ public CmsGroup getParent(CmsDbContext dbc, String groupname) throws CmsException { CmsGroup group = readGroup(dbc, groupname); if (group.getParentId().isNullUUID()) { return null; } // try to read from cache CmsGroup parent = m_monitor.getCachedGroup(group.getParentId().toString()); if (parent == null) { parent = getUserDriver(dbc).readGroup(dbc, group.getParentId()); m_monitor.cacheGroup(parent); } return parent; }
CmsGroup parent = getCms().readGroup(getCms().readGroup(groupName).getParentId()); html.append(parent.getName()); } else if (detailId.equals(LIST_DETAIL_SET_PERM)) {
/** * Initializes the group object.<p> */ protected void initGroupObject() { try { // edit an existing group, get the group object from db m_group = getCms().readGroup(new CmsUUID(getParamGroupid())); setParentGroup(getCms().readGroup(m_group.getParentId()).getName()); } catch (CmsException e) { // should never happen } }
/** * @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.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { List<CmsListItem> ret = new ArrayList<CmsListItem>(); // get content List<CmsGroup> groups = getGroups(); Set<String> selGroups = new HashSet<String>( CmsStringUtil.splitAsList(getParamGroupid(), CmsHtmlList.ITEM_SEPARATOR, true)); Iterator<CmsGroup> itGroups = groups.iterator(); while (itGroups.hasNext()) { CmsGroup group = itGroups.next(); if (selGroups.contains(group.getId().toString())) { continue; } CmsListItem item = getList().newItem(group.getId().toString()); item.set(LIST_COLUMN_NAME, group.getName()); item.set(LIST_COLUMN_DISPLAY, OpenCms.getWorkplaceManager().translateGroupName(group.getName(), true)); item.set(LIST_COLUMN_DESCRIPTION, group.getDescription(getLocale())); try { item.set(LIST_COLUMN_PARENT, getCms().readGroup(group.getParentId()).getName()); } catch (Exception e) { // ignore } ret.add(item); } return ret; }
if ((group.getParentId() == null) || group.getParentId().isNullUUID()) { parentgroup = ""; } else {
if ((m_group.getParentId() != null) && !m_group.getParentId().isNullUUID()) { setParentGroup(getCms().getParent(m_group.getName()).getName());
if ((group.getParentId() == null) || group.getParentId().isNullUUID()) { parentgroup = ""; } else {
/** * @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")); } }
CmsUUID parentId = group.getParentId(); if (parentId == null) { parentId = CmsUUID.getNullUUID();
CmsUUID parentId = group.getParentId(); if (parentId == null) { parentId = CmsUUID.getNullUUID();