use of org.craftercms.studio.api.v2.dal.Group in project studio by craftercms.
the class GroupServiceInternalImpl method getAllGroups.
@Override
public List<Group> getAllGroups(long orgId, int offset, int limit, String sort) throws ServiceLayerException {
// Prepare parameters
Map<String, Object> params = new HashMap<>();
params.put(ORG_ID, orgId);
params.put(OFFSET, offset);
params.put(LIMIT, limit);
params.put(SORT, sort);
try {
return groupDao.getAllGroupsForOrganization(params);
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
use of org.craftercms.studio.api.v2.dal.Group in project studio by craftercms.
the class GroupServiceInternalImpl method addGroupMembers.
@Override
public List<User> addGroupMembers(long groupId, List<Long> userIds, List<String> usernames) throws GroupNotFoundException, UserNotFoundException, ServiceLayerException {
if (!groupExists(groupId, StringUtils.EMPTY)) {
throw new GroupNotFoundException("No group found for id '" + groupId + "'");
}
List<User> users = userServiceInternal.getUsersByIdOrUsername(userIds, usernames);
Map<String, Object> params = new HashMap<>();
params.put(USER_IDS, users.stream().map(User::getId).collect(Collectors.toList()));
params.put(GROUP_ID, groupId);
try {
groupDao.addGroupMembers(params);
return users;
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
use of org.craftercms.studio.api.v2.dal.Group in project studio by craftercms.
the class DbVersionProvider method getCurrentVersion.
/**
* {@inheritDoc}
*/
@Override
public String getCurrentVersion() throws UpgradeException {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
logger.debug("Check if _meta table exists.");
int count = jdbcTemplate.queryForObject(SQL_QUERY_META.replace(SCHEMA, studioConfiguration.getProperty(DB_SCHEMA)), Integer.class);
if (count != 0) {
logger.debug("_meta table exists.");
logger.debug("Get version from _meta table.");
return jdbcTemplate.queryForObject(SQL_QUERY_VERSION, String.class);
} else {
logger.debug("Check if group table exists.");
count = jdbcTemplate.queryForObject(SQL_QUERY_GROUP.replace(SCHEMA, studioConfiguration.getProperty(DB_SCHEMA)), Integer.class);
if (count != 0) {
logger.debug("Database version is 3.0.0");
return VERSION_3_0_0;
} else {
throw new UpgradeNotSupportedException("Automated migration from 2.5.x DB is not supported yet.");
}
}
}
Aggregations