/** * Reads the group of a project.<p> * * @param context the current request context * @param project the project to read from * * @return the group of a resource */ public CmsGroup readGroup(CmsRequestContext context, CmsProject project) { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsGroup result = null; try { result = m_driverManager.readGroup(dbc, project); } finally { dbc.clear(); } return result; }
/** * Reads the group of a project.<p> * * @param context the current request context * @param project the project to read from * * @return the group of a resource */ public CmsGroup readGroup(CmsRequestContext context, CmsProject project) { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsGroup result = null; try { result = m_driverManager.readGroup(dbc, project); } finally { dbc.clear(); } return result; }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }
/** * Sets a new parent group for an already existing group.<p> * * @param dbc the current database context * @param groupName the name of the group that should be written * @param parentGroupName the name of the parent group to set, * or <code>null</code> if the parent * group should be deleted. * * @throws CmsException if operation was not successful * @throws CmsDataAccessException if the group with <code>groupName</code> could not be read from VFS */ public void setParentGroup(CmsDbContext dbc, String groupName, String parentGroupName) throws CmsException, CmsDataAccessException { CmsGroup group = readGroup(dbc, groupName); CmsUUID parentGroupId = CmsUUID.getNullUUID(); // if the group exists, use its id, else set to unknown. if (parentGroupName != null) { parentGroupId = readGroup(dbc, parentGroupName).getId(); } group.setParentId(parentGroupId); // write the changes to the cms writeGroup(dbc, group); }
/** * Sets a new parent group for an already existing group.<p> * * @param dbc the current database context * @param groupName the name of the group that should be written * @param parentGroupName the name of the parent group to set, * or <code>null</code> if the parent * group should be deleted. * * @throws CmsException if operation was not successful * @throws CmsDataAccessException if the group with <code>groupName</code> could not be read from VFS */ public void setParentGroup(CmsDbContext dbc, String groupName, String parentGroupName) throws CmsException, CmsDataAccessException { CmsGroup group = readGroup(dbc, groupName); CmsUUID parentGroupId = CmsUUID.getNullUUID(); // if the group exists, use its id, else set to unknown. if (parentGroupName != null) { parentGroupId = readGroup(dbc, parentGroupName).getId(); } group.setParentId(parentGroupId); // write the changes to the cms writeGroup(dbc, group); }
/** * Reads the group of a project.<p> * * @param dbc the current database context * @param project the project to read from * * @return the group of a resource */ public CmsGroup readGroup(CmsDbContext dbc, CmsProject project) { try { return readGroup(dbc, project.getGroupId()); } catch (CmsException exc) { return new CmsGroup( CmsUUID.getNullUUID(), CmsUUID.getNullUUID(), project.getGroupId() + "", "deleted group", 0); } }
/** * Reads the group of a project.<p> * * @param dbc the current database context * @param project the project to read from * * @return the group of a resource */ public CmsGroup readGroup(CmsDbContext dbc, CmsProject project) { try { return readGroup(dbc, project.getGroupId()); } catch (CmsException exc) { return new CmsGroup( CmsUUID.getNullUUID(), CmsUUID.getNullUUID(), project.getGroupId() + "", "deleted group", 0); } }
/** * Writes an already existing group.<p> * * The group id has to be a valid OpenCms group id.<br> * * The group with the given id will be completely overridden * by the given data.<p> * * @param dbc the current database context * @param group the group that should be written * * @throws CmsException if operation was not successful */ public void writeGroup(CmsDbContext dbc, CmsGroup group) throws CmsException { CmsGroup oldGroup = readGroup(dbc, group.getName()); m_monitor.uncacheGroup(oldGroup); getUserDriver(dbc).writeGroup(dbc, group); m_monitor.cacheGroup(group); if (!dbc.getProjectId().isNullUUID()) { // group modified event is not needed return; } // fire group modified event Map<String, Object> eventData = new HashMap<String, Object>(); eventData.put(I_CmsEventListener.KEY_GROUP_ID, group.getId().toString()); eventData.put(I_CmsEventListener.KEY_GROUP_NAME, oldGroup.getName()); eventData.put(I_CmsEventListener.KEY_USER_ACTION, I_CmsEventListener.VALUE_GROUP_MODIFIED_ACTION_WRITE); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_GROUP_MODIFIED, eventData)); }
/** * Reads the manager group of a project.<p> * * @param dbc the current database context * @param project the project to read from * * @return the group of a resource */ public CmsGroup readManagerGroup(CmsDbContext dbc, CmsProject project) { try { return readGroup(dbc, project.getManagerGroupId()); } catch (CmsException exc) { // the group does not exist any more - return a dummy-group return new CmsGroup( CmsUUID.getNullUUID(), CmsUUID.getNullUUID(), project.getManagerGroupId() + "", "deleted group", 0); } }
/** * Reads the manager group of a project.<p> * * @param dbc the current database context * @param project the project to read from * * @return the group of a resource */ public CmsGroup readManagerGroup(CmsDbContext dbc, CmsProject project) { try { return readGroup(dbc, project.getManagerGroupId()); } catch (CmsException exc) { // the group does not exist any more - return a dummy-group return new CmsGroup( CmsUUID.getNullUUID(), CmsUUID.getNullUUID(), project.getManagerGroupId() + "", "deleted group", 0); } }
/** * Reads a group based on its name.<p> * * @param context the current request context * @param groupname the name of the group that is to be read * * @return the requested group * * @throws CmsException if operation was not successful */ public CmsGroup readGroup(CmsRequestContext context, String groupname) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsGroup result = null; try { result = m_driverManager.readGroup(dbc, CmsOrganizationalUnit.removeLeadingSeparator(groupname)); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_READ_GROUP_FOR_NAME_1, groupname), e); } finally { dbc.clear(); } return result; }
/** * Reads a group based on its id.<p> * * @param context the current request context * @param groupId the id of the group that is to be read * * @return the requested group * * @throws CmsException if operation was not successful */ public CmsGroup readGroup(CmsRequestContext context, CmsUUID groupId) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsGroup result = null; try { result = m_driverManager.readGroup(dbc, groupId); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_READ_GROUP_FOR_ID_1, groupId.toString()), e); } finally { dbc.clear(); } return result; }
/** * Reads a group based on its id.<p> * * @param context the current request context * @param groupId the id of the group that is to be read * * @return the requested group * * @throws CmsException if operation was not successful */ public CmsGroup readGroup(CmsRequestContext context, CmsUUID groupId) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsGroup result = null; try { result = m_driverManager.readGroup(dbc, groupId); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_READ_GROUP_FOR_ID_1, groupId.toString()), e); } finally { dbc.clear(); } return result; }
/** * Reads a group based on its name.<p> * * @param context the current request context * @param groupname the name of the group that is to be read * * @return the requested group * * @throws CmsException if operation was not successful */ public CmsGroup readGroup(CmsRequestContext context, String groupname) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); CmsGroup result = null; try { result = m_driverManager.readGroup(dbc, CmsOrganizationalUnit.removeLeadingSeparator(groupname)); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_READ_GROUP_FOR_NAME_1, groupname), e); } finally { dbc.clear(); } return result; }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }
/** * Returns all child groups of a group.<p> * * This method also returns all sub-child groups of the current group.<p> * * @param context the current request context * @param groupname the name of the group * @param includeSubChildren if set also returns all sub-child groups of the given group * * @return a list of all child <code>{@link CmsGroup}</code> objects or <code>null</code> * * @throws CmsException if operation was not successful */ public List<CmsGroup> getChildren(CmsRequestContext context, String groupname, boolean includeSubChildren) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); List<CmsGroup> result = null; try { result = m_driverManager.getChildren( dbc, m_driverManager.readGroup(dbc, CmsOrganizationalUnit.removeLeadingSeparator(groupname)), includeSubChildren); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_GET_CHILD_GROUPS_TRANSITIVE_1, groupname), e); } finally { dbc.clear(); } return result; }
/** * Returns all child groups of a group.<p> * * This method also returns all sub-child groups of the current group.<p> * * @param context the current request context * @param groupname the name of the group * @param includeSubChildren if set also returns all sub-child groups of the given group * * @return a list of all child <code>{@link CmsGroup}</code> objects or <code>null</code> * * @throws CmsException if operation was not successful */ public List getChildren(CmsRequestContext context, String groupname, boolean includeSubChildren) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); List result = null; try { result = m_driverManager.getChildren(dbc, m_driverManager.readGroup( dbc, CmsOrganizationalUnit.removeLeadingSeparator(groupname)), includeSubChildren); } catch (Exception e) { dbc.report(null, Messages.get().container(Messages.ERR_GET_CHILD_GROUPS_TRANSITIVE_1, groupname), e); } finally { dbc.clear(); } return result; }
/** * 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; }