private void save(PropertiesMapper mapper, String key, @Nullable Integer userId, @Nullable Long componentId, @Nullable String value) { checkKey(key); long now = system2.now(); mapper.delete(key, userId, componentId); if (isEmpty(value)) { mapper.insertAsEmpty(key, userId, componentId, now); } else if (mustBeStoredInClob(value)) { mapper.insertAsClob(key, userId, componentId, value, now); } else { mapper.insertAsText(key, userId, componentId, value, now); } }
/** * Delete either global, user, component or component per user properties. * <p>Behaves in exactly the same way as {@link #selectByQuery(PropertyQuery, DbSession)} but deletes rather than * selects</p> * * Used by Governance. */ public int deleteByQuery(DbSession dbSession, PropertyQuery query) { return getMapper(dbSession).deleteByQuery(query); }
public void deleteGlobalProperty(String key, DbSession session) { getMapper(session).deleteGlobalProperty(key); }
public void renamePropertyKey(String oldKey, String newKey) { checkArgument(!Strings.isNullOrEmpty(oldKey), "Old property key must not be empty"); checkArgument(!Strings.isNullOrEmpty(newKey), "New property key must not be empty"); if (!newKey.equals(oldKey)) { try (DbSession session = mybatis.openSession(false)) { getMapper(session).renamePropertyKey(oldKey, newKey); session.commit(); } } }
public int delete(DbSession dbSession, PropertyDto dto) { return getMapper(dbSession).delete(dto.getKey(), dto.getUserId(), dto.getResourceId()); }
public void deleteProjectProperty(String key, Long projectId, DbSession session) { getMapper(session).deleteProjectProperty(key, projectId); }
/** * Returns the logins of users who have subscribed to the given notification dispatcher with the given notification channel. * If a resource ID is passed, the search is made on users who have specifically subscribed for the given resource. * * Note that {@link UserRole#USER} permission is not checked here, filter the results with * {@link org.sonar.db.permission.AuthorizationDao#keepAuthorizedLoginsOnProject} * * @return the list of Subscriber (maybe be empty - obviously) */ public Set<Subscriber> findUsersForNotification(String notificationDispatcherKey, String notificationChannelKey, @Nullable String projectKey) { try (DbSession session = mybatis.openSession(false)) { return getMapper(session).findUsersForNotification(NOTIFICATION_PREFIX + notificationDispatcherKey + "." + notificationChannelKey, projectKey); } }
public void deleteProjectProperties(String key, String value, DbSession session) { getMapper(session).deleteProjectProperties(key, value); }
public void renamePropertyKey(String oldKey, String newKey) { checkArgument(!Strings.isNullOrEmpty(oldKey), "Old property key must not be empty"); checkArgument(!Strings.isNullOrEmpty(newKey), "New property key must not be empty"); if (!newKey.equals(oldKey)) { try (DbSession session = mybatis.openSession(false)) { getMapper(session).renamePropertyKey(oldKey, newKey); session.commit(); } } }
public int delete(DbSession dbSession, PropertyDto dto) { return getMapper(dbSession).delete(dto.getKey(), dto.getUserId(), dto.getResourceId()); }
public void deleteProjectProperty(String key, Long projectId, DbSession session) { getMapper(session).deleteProjectProperty(key, projectId); }
/** * Returns the logins of users who have subscribed to the given notification dispatcher with the given notification channel. * If a resource ID is passed, the search is made on users who have specifically subscribed for the given resource. * * @return the list of logins (maybe be empty - obviously) */ public List<String> selectUsersForNotification(String notificationDispatcherKey, String notificationChannelKey, @Nullable String projectUuid) { try (DbSession session = mybatis.openSession(false)) { return getMapper(session).findUsersForNotification(NOTIFICATION_PREFIX + notificationDispatcherKey + "." + notificationChannelKey, projectUuid); } }
public void deleteProjectProperties(String key, String value, DbSession session) { getMapper(session).deleteProjectProperties(key, value); }
private void save(PropertiesMapper mapper, String key, @Nullable Long userId, @Nullable Long componentId, @Nullable String value) { checkKey(key); long now = system2.now(); mapper.delete(key, userId, componentId); if (isEmpty(value)) { mapper.insertAsEmpty(key, userId, componentId, now); } else if (mustBeStoredInClob(value)) { mapper.insertAsClob(key, userId, componentId, value, now); } else { mapper.insertAsText(key, userId, componentId, value, now); } }
public void saveGlobalProperties(Map<String, String> properties) { try (DbSession session = mybatis.openSession(false)) { PropertiesMapper mapper = getMapper(session); properties.entrySet().forEach(entry -> { mapper.deleteGlobalProperty(entry.getKey()); save(mapper, entry.getKey(), null, null, entry.getValue()); }); session.commit(); } }
/** * Delete either global, user, component or component per user properties. * <p>Behaves in exactly the same way as {@link #selectByQuery(PropertyQuery, DbSession)} but deletes rather than * selects</p> * * Used by Governance. */ public int deleteByQuery(DbSession dbSession, PropertyQuery query) { return getMapper(dbSession).deleteByQuery(query); }
public void deleteGlobalProperty(String key, DbSession session) { getMapper(session).deleteGlobalProperty(key); }
public void saveGlobalProperties(Map<String, String> properties) { try (DbSession session = mybatis.openSession(false)) { PropertiesMapper mapper = getMapper(session); properties.entrySet().forEach(entry -> { mapper.deleteGlobalProperty(entry.getKey()); save(mapper, entry.getKey(), null, null, entry.getValue()); }); session.commit(); } }