/** * Counts the total number of users which fit the given criteria.<p> * * @param dbc the database context * @param searchParams the user search criteria * * @return the total number of users matching the criteria * * @throws CmsDataAccessException if something goes wrong */ long countUsers(CmsDbContext dbc, CmsUserSearchParameters searchParams) throws CmsDataAccessException { return getUserDriver(dbc).countUsers(dbc, searchParams); }
/** * Searches for users which fit the given criteria.<p> * * @param dbc the database context * @param searchParams the search criteria * * @return the users which fit the search criteria * * @throws CmsDataAccessException if something goes wrong */ public List<CmsUser> searchUsers(CmsDbContext dbc, CmsUserSearchParameters searchParams ) throws CmsDataAccessException { return getUserDriver(dbc).searchUsers(dbc, searchParams); }
/** * Returns all resources of the given organizational unit.<p> * * @param dbc the current db context * @param orgUnit the organizational unit to get all resources for * * @return all <code>{@link CmsResource}</code> objects in the organizational unit * * @throws CmsException if operation was not successful * * @see org.opencms.security.CmsOrgUnitManager#getResourcesForOrganizationalUnit(CmsObject, String) * @see org.opencms.security.CmsOrgUnitManager#getUsers(CmsObject, String, boolean) * @see org.opencms.security.CmsOrgUnitManager#getGroups(CmsObject, String, boolean) */ public List<CmsResource> getResourcesForOrganizationalUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit) throws CmsException { return getUserDriver(dbc).getResourcesForOrganizationalUnit(dbc, orgUnit); }
/** * Returns all direct users of the given organizational unit.<p> * * @param dbc the current db context * @param orgUnit the organizational unit to get all users for * @param recursive if all groups of sub-organizational units should be retrieved too * * @return all <code>{@link CmsUser}</code> objects in the organizational unit * * @throws CmsException if operation was not successful * * @see org.opencms.security.CmsOrgUnitManager#getResourcesForOrganizationalUnit(CmsObject, String) * @see org.opencms.security.CmsOrgUnitManager#getUsers(CmsObject, String, boolean) */ public List<CmsUser> getUsers(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive) throws CmsException { return getUserDriver(dbc).getUsers(dbc, orgUnit, recursive); }
/** * Returns all direct users of the given organizational unit, without their additional info.<p> * * @param dbc the current db context * @param orgUnit the organizational unit to get all users for * @param recursive if all groups of sub-organizational units should be retrieved too * * @return all <code>{@link CmsUser}</code> objects in the organizational unit * * @throws CmsException if operation was not successful * * @see org.opencms.security.CmsOrgUnitManager#getResourcesForOrganizationalUnit(CmsObject, String) * @see org.opencms.security.CmsOrgUnitManager#getUsers(CmsObject, String, boolean) */ public List<CmsUser> getUsersWithoutAdditionalInfo( CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive) throws CmsException { return getUserDriver(dbc).getUsersWithoutAdditionalInfo(dbc, orgUnit, recursive); }
/** * Returns all groups of the given organizational unit.<p> * * @param dbc the current db context * @param orgUnit the organizational unit to get the groups for * @param includeSubOus if all groups of sub-organizational units should be retrieved too * @param readRoles if to read roles or groups * * @return all <code>{@link CmsGroup}</code> objects in the organizational unit * * @throws CmsException if operation was not successful * * @see org.opencms.security.CmsOrgUnitManager#getResourcesForOrganizationalUnit(CmsObject, String) * @see org.opencms.security.CmsOrgUnitManager#getGroups(CmsObject, String, boolean) */ public List<CmsGroup> getGroups( CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean includeSubOus, boolean readRoles) throws CmsException { return getUserDriver(dbc).getGroups(dbc, orgUnit, includeSubOus, readRoles); }
/** * Adds a resource to the given organizational unit.<p> * * @param dbc the current db context * @param orgUnit the organizational unit to add the resource to * @param resource the resource that is to be added to the organizational unit * * @throws CmsException if something goes wrong * * @see org.opencms.security.CmsOrgUnitManager#addResourceToOrgUnit(CmsObject, String, String) * @see org.opencms.security.CmsOrgUnitManager#addResourceToOrgUnit(CmsObject, String, String) */ public void addResourceToOrgUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsResource resource) throws CmsException { m_monitor.flushCache(CmsMemoryMonitor.CacheType.HAS_ROLE, CmsMemoryMonitor.CacheType.ROLE_LIST); getUserDriver(dbc).addResourceToOrganizationalUnit(dbc, orgUnit, resource); }
/** * Removes a resource from the given organizational unit.<p> * * @param dbc the current db context * @param orgUnit the organizational unit to remove the resource from * @param resource the resource that is to be removed from the organizational unit * * @throws CmsException if something goes wrong * * @see org.opencms.security.CmsOrgUnitManager#addResourceToOrgUnit(CmsObject, String, String) * @see org.opencms.security.CmsOrgUnitManager#addResourceToOrgUnit(CmsObject, String, String) */ public void removeResourceFromOrgUnit(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, CmsResource resource) throws CmsException { m_monitor.flushCache(CmsMemoryMonitor.CacheType.HAS_ROLE, CmsMemoryMonitor.CacheType.ROLE_LIST); getUserDriver(dbc).removeResourceFromOrganizationalUnit(dbc, orgUnit, resource); }
/** * Returns a user object if the password for the user is correct.<p> * * If the user/pwd pair is not valid a <code>{@link CmsException}</code> is thrown.<p> * * @param dbc the current database context * @param username the username of the user that is to be read * @param password the password of the user that is to be read * * @return user read * * @throws CmsException if operation was not successful */ public CmsUser readUser(CmsDbContext dbc, String username, String password) throws CmsException { // don't read user from cache here because password may have changed CmsUser user = getUserDriver(dbc).readUser(dbc, username, password, null); m_monitor.cacheUser(user); return user; }
/** * Reads all access control entries.<p> * * @param dbc the current database context * @return all access control entries for the current project (offline/online) * * @throws CmsException if something goes wrong */ public List<CmsAccessControlEntry> getAllAccessControlEntries(CmsDbContext dbc) throws CmsException { I_CmsUserDriver userDriver = getUserDriver(dbc); List<CmsAccessControlEntry> ace = userDriver.readAccessControlEntries( dbc, dbc.currentProject(), CmsAccessControlEntry.PRINCIPAL_READALL_ID, false); return ace; }
/** * Reads an access control entry from the cms.<p> * * The access control entries of a resource are readable by everyone. * * @param dbc the current database context * @param resource the resource * @param principal the id of a group or a user any other entity * @return an access control entry that defines the permissions of the entity for the given resource * @throws CmsException if something goes wrong */ public CmsAccessControlEntry readAccessControlEntry(CmsDbContext dbc, CmsResource resource, CmsUUID principal) throws CmsException { return getUserDriver(dbc).readAccessControlEntry( dbc, dbc.currentProject(), resource.getResourceId(), principal); }
/** * Reads a group based on its name.<p> * * @param dbc the current database context * @param groupname the name of the group that is to be read * * @return the requested group * * @throws CmsDataAccessException if operation was not successful */ public CmsGroup readGroup(CmsDbContext dbc, String groupname) throws CmsDataAccessException { CmsGroup group = null; // try to read group from cache group = m_monitor.getCachedGroup(groupname); if (group == null) { group = getUserDriver(dbc).readGroup(dbc, groupname); m_monitor.cacheGroup(group); } return group; }
/** * Reads an organizational Unit based on its fully qualified name.<p> * * @param dbc the current db context * @param ouFqn the fully qualified name of the organizational Unit to be read * * @return the organizational Unit that with the provided fully qualified name * * @throws CmsException if something goes wrong */ public CmsOrganizationalUnit readOrganizationalUnit(CmsDbContext dbc, String ouFqn) throws CmsException { CmsOrganizationalUnit organizationalUnit = null; // try to read organizational unit from cache organizationalUnit = m_monitor.getCachedOrgUnit(ouFqn); if (organizationalUnit == null) { organizationalUnit = getUserDriver(dbc).readOrganizationalUnit(dbc, ouFqn); m_monitor.cacheOrgUnit(organizationalUnit); } return organizationalUnit; }
/** * Writes a vector of access control entries as new access control entries of a given resource.<p> * * Already existing access control entries of this resource are removed before. * Access is granted, if:<p> * <ul> * <li>the current user has control permission on the resource</li> * </ul> * * @param dbc the current database context * @param resource the resource * @param acEntries a list of <code>{@link CmsAccessControlEntry}</code> objects * * @throws CmsException if something goes wrong */ public void importAccessControlEntries( CmsDbContext dbc, CmsResource resource, List<CmsAccessControlEntry> acEntries) throws CmsException { I_CmsUserDriver userDriver = getUserDriver(dbc); userDriver.removeAccessControlEntries(dbc, dbc.currentProject(), resource.getResourceId()); Iterator<CmsAccessControlEntry> i = acEntries.iterator(); while (i.hasNext()) { userDriver.writeAccessControlEntry(dbc, dbc.currentProject(), i.next()); } m_monitor.clearAccessControlListCache(); }
/** * @see org.opencms.db.I_CmsUserDriver#readChildGroups(org.opencms.db.CmsDbContext, java.lang.String) */ public List<CmsGroup> readChildGroups(CmsDbContext dbc, String parentGroupFqn) throws CmsDataAccessException { List<CmsGroup> children = new ArrayList<CmsGroup>(); try { // get parent group CmsGroup parent = m_driverManager.getUserDriver(dbc).readGroup(dbc, parentGroupFqn); // parent group exists, so get all children if (parent != null) { // create statement Query q = m_sqlManager.createQuery(dbc, C_GROUPS_GET_CHILD_1); q.setParameter(1, parent.getId().toString()); List<CmsDAOGroups> res = q.getResultList(); // create new Cms group objects for (CmsDAOGroups g : res) { children.add(internalCreateGroup(g)); } } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return children; }
/** * Reads a group based on its id.<p> * * @param dbc the current database 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(CmsDbContext dbc, CmsUUID groupId) throws CmsException { CmsGroup group = null; // try to read group from cache group = m_monitor.getCachedGroup(groupId.toString()); if (group == null) { group = getUserDriver(dbc).readGroup(dbc, groupId); m_monitor.cacheGroup(group); } return group; }
/** * Returns a user object.<p> * * @param dbc the current database context * @param username the name of the user that is to be read * * @return user read * * @throws CmsDataAccessException if operation was not successful */ public CmsUser readUser(CmsDbContext dbc, String username) throws CmsDataAccessException { CmsUser user = m_monitor.getCachedUser(username); if (user == null) { user = getUserDriver(dbc).readUser(dbc, username); m_monitor.cacheUser(user); } // important: do not return the cached user object, but a clone to avoid unwanted changes on cached objects return user.clone(); }
/** * Returns a user object based on the id of a user.<p> * * @param dbc the current database context * @param id the id of the user to read * * @return the user read * * @throws CmsException if something goes wrong */ public CmsUser readUser(CmsDbContext dbc, CmsUUID id) throws CmsException { CmsUser user = m_monitor.getCachedUser(id.toString()); if (user == null) { user = getUserDriver(dbc).readUser(dbc, id); m_monitor.cacheUser(user); } // important: do not return the cached user object, but a clone to avoid unwanted changes on cached objects return user.clone(); }
/** * 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 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; }