use of com.netflix.metacat.common.server.usermetadata.UserMetadataServiceException in project metacat by Netflix.
the class MysqlUserMetadataService method getDescendantDataUris.
@Override
public List<String> getDescendantDataUris(@Nonnull final String uri) {
List<String> result;
final Connection connection = DBUtil.getReadConnection(poolingDataSource);
try {
final ColumnListHandler<String> handler = new ColumnListHandler<>("uri");
result = new QueryRunner().query(connection, SQL.GET_DESCENDANT_DATA_URIS, handler, uri + "/%");
} catch (SQLException e) {
log.error("Sql exception", e);
throw new UserMetadataServiceException(String.format("Failed to get descendant uris for %s", uri), e);
} finally {
DBUtil.closeReadConnection(connection);
}
return result;
}
use of com.netflix.metacat.common.server.usermetadata.UserMetadataServiceException in project metacat by Netflix.
the class MysqlUserMetadataService method getDescendantDefinitionNames.
@Override
public List<QualifiedName> getDescendantDefinitionNames(@Nonnull final QualifiedName name) {
List<String> result;
final Connection connection = DBUtil.getReadConnection(poolingDataSource);
try {
final ColumnListHandler<String> handler = new ColumnListHandler<>("name");
result = new QueryRunner().query(connection, SQL.GET_DESCENDANT_DEFINITION_NAMES, handler, name.toString() + "/%");
} catch (SQLException e) {
log.error("Sql exception", e);
throw new UserMetadataServiceException(String.format("Failed to get descendant names for %s", name), e);
} finally {
DBUtil.closeReadConnection(connection);
}
return result.stream().map(QualifiedName::fromString).collect(Collectors.toList());
}
use of com.netflix.metacat.common.server.usermetadata.UserMetadataServiceException in project metacat by Netflix.
the class MysqlUserMetadataService method getDeletedDataMetadataUris.
@Override
public List<String> getDeletedDataMetadataUris(final Date deletedPriorTo, final Integer offset, final Integer limit) {
List<String> result;
final Connection connection = DBUtil.getReadConnection(poolingDataSource);
try {
final ColumnListHandler<String> handler = new ColumnListHandler<>("uri");
result = new QueryRunner().query(connection, String.format(SQL.GET_DELETED_DATA_METADATA_URI, offset, limit), handler, deletedPriorTo);
} catch (SQLException e) {
log.error("Sql exception", e);
throw new UserMetadataServiceException(String.format("Failed to get deleted data metadata uris deleted prior to %s", deletedPriorTo), e);
} finally {
DBUtil.closeReadConnection(connection);
}
return result;
}
use of com.netflix.metacat.common.server.usermetadata.UserMetadataServiceException in project metacat by Netflix.
the class MysqlUserMetadataService method deleteDataMetadatasWithBatch.
private void deleteDataMetadatasWithBatch(final List<String> uris, final boolean removeDataMetadata) {
try {
final Connection conn = poolingDataSource.getConnection();
try {
final List<List<String>> subLists = Lists.partition(uris, config.getUserMetadataMaxInClauseItems());
for (List<String> subUris : subLists) {
_deleteDataMetadatas(conn, subUris, removeDataMetadata);
}
conn.commit();
} catch (SQLException e) {
conn.rollback();
throw e;
} finally {
conn.close();
}
} catch (SQLException e) {
log.error("Sql exception", e);
throw new UserMetadataServiceException(String.format("Failed deleting the data metadata for %s", uris), e);
}
}
use of com.netflix.metacat.common.server.usermetadata.UserMetadataServiceException in project metacat by Netflix.
the class MySqlTagService method delete.
@Override
public Void delete(final QualifiedName name, final boolean updateUserMetadata) {
try {
final Connection conn = getDataSource().getConnection();
try {
new QueryRunner().update(conn, SQL_DELETE_TAG_ITEM_TAGS_BY_NAME, name.toString());
new QueryRunner().update(conn, SQL_DELETE_TAG_ITEM, name.toString());
if (updateUserMetadata) {
// Set the tags in user metadata
final Map<String, Set<String>> data = Maps.newHashMap();
data.put(NAME_TAGS, Sets.newHashSet());
userMetadataService.saveDefinitionMetadata(name, "admin", Optional.of(metacatJson.toJsonObject(data)), true);
}
conn.commit();
} catch (SQLException e) {
conn.rollback();
throw e;
} finally {
conn.close();
}
} catch (SQLException e) {
final String message = String.format("Failed to delete all tags for name %s", name);
log.error(message, e);
throw new UserMetadataServiceException(message, e);
}
return null;
}
Aggregations