/** * For historical reasons the JSON returned for unauthorized exceptions uses a key called "reason", not "message". */ public String getReason() { return getMessage(); } }
/** * Table names must be lowercase ASCII strings. between 1 and 255 characters in length. Whitespace, ISO control * characters and certain punctuation characters that aren't generally allowed in file names or in elasticsearch * index names are excluded (elasticsearch appears to allow: !$%&()+-.:;=@[]^_`{}~). Table names may not begin * with a single underscore to allow URL space for extensions such as "/_table/...". */ public static boolean isLegalTableName(String table) { return com.bazaarvoice.emodb.common.api.Names.isLegalTableName(table); }
/** * Role group names mostly follow the same conventions as role names. The only difference is that the role group * "_" is a reserved null-substitution for the absence of a group. */ public static boolean isLegalRoleGroupName(String group) { return isLegalRoleName(group) && !"_".equals(group); } }
protected UriBuilder getPollUriBuilder(String subscription, Duration claimTtl, int limit) { return _databus.clone() .segment(subscription, "poll") .queryParam("ttl", Ttls.toSeconds(claimTtl, 0, Integer.MAX_VALUE)) .queryParam("limit", limit) .queryParam("partitioned", _partitionSafe); }
/** * Verifies whether the user has a specific permission. If not it throws a standard UnauthorizedException. * @throws UnauthorizedException User did not have the permission */ private void verifyPermission(Subject subject, String permission) throws UnauthorizedException { if (!subject.hasPermission(permission)) { throw new UnauthorizedException(); } }
@SuppressWarnings("ThrowableNotThrown") @Override public Response toResponse(PartitionForwardingException exception) { // To prevent herding advise the caller to retry after 1 to 5 seconds, chosen randomly. return _providers.getExceptionMapper(ServiceUnavailableException.class) .toResponse(new ServiceUnavailableException("Service unavailable, try again later", new Random().nextInt(5) + 1)); } }
private String checkGroup(@Nullable String group) { // Role groups follow the same naming conventions as role names checkArgument(group == null || isLegalRoleGroupName(group), "Group cannot be named %s", group); // Since legal role group names cannot equal "_" if the previous check passed then there cannot be a conflict return group == null ? NO_GROUP_NAME : group; }
@Override public Response toResponse(ServiceUnavailableException exception) { return Response.status(Response.Status.SERVICE_UNAVAILABLE) .header("X-BV-Exception", ServiceUnavailableException.class.getName()) .header("Retry-After", exception.getRetryAfterSeconds()) .entity(exception) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }
@Override public UpdateRequest writeRecords(UUID dataId, Collection<ByteBuffer> records) { if (!records.isEmpty()) { ColumnListMutation<ByteBuffer> row = _mutation.withRow(CF_DEDUP_DATA, dataId); for (ByteBuffer record : records) { row.putColumn(record, EMPTY_BUFFER, Ttls.toSeconds(_eventTtl, 1, null)); } } return this; }
@Override public Response toResponse(AuthenticationException exception) { // AuthenticationException is only used internally to propagate authorization errors. Convert the // exception to the equivalent public-facing exception from the API. UnauthorizedException apiException = new UnauthorizedException(); return _providers.getExceptionMapper(UnauthorizedException.class).toResponse(apiException); } }
private void executeIfAcceptingWrites(Runnable runnable) { _writerPhaser.register(); try { if (_writesAccepted) { runnable.run(); } else { _writesRejectedCounter.inc(); throw new ServiceUnavailableException(); } } finally { _writerPhaser.arriveAndDeregister(); } }
public static boolean isLegalTableName(String table) { return com.bazaarvoice.emodb.common.api.Names.isLegalTableName(table); }
/** * Role group names mostly follow the same conventions as role names. The only difference is that the role group * "_" is a reserved null-substitution for the absence of a group. */ public static boolean isLegalRoleGroupName(String group) { return isLegalRoleName(group) && !"_".equals(group); } }
/** * For historical reasons the JSON returned for unauthorized exceptions uses a key called "reason", not "message". */ public String getReason() { return getMessage(); } }
private String checkGroup(@Nullable String group) { // Role groups follow the same naming conventions as role names checkArgument(group == null || isLegalRoleGroupName(group), "Group cannot be named %s", group); // Since legal role group names cannot equal "_" if the previous check passed then there cannot be a conflict return group == null ? NO_GROUP_NAME : group; }
@Override public UpdateRequest writeRecords(UUID dataId, Collection<ByteBuffer> records) { if (!records.isEmpty()) { ColumnListMutation<ByteBuffer> row = _mutation.withRow(CF_DEDUP_DATA, dataId); for (ByteBuffer record : records) { row.putColumn(record, EMPTY_BUFFER, Ttls.toSeconds(_eventTtl, 1, null)); } } return this; }
@Override public Response toResponse(AuthorizationException exception) { // AuthorizationException is only used internally to propagate authorization errors. Convert the // exception to the equivalent public-facing exception from the API. UnauthorizedException apiException = new UnauthorizedException(); return _providers.getExceptionMapper(UnauthorizedException.class).toResponse(apiException); } }
public static boolean isLegalTableName(String table) { return com.bazaarvoice.emodb.common.api.Names.isLegalTableName(table); }
@Override public UpdateRequest writeSegment(UUID segment, String internalState) { Duration manifestTtl = Duration.ofDays(31); _mutation.withRow(CF_DEDUP_MD, queue) .putColumn(segment, internalState, Ttls.toSeconds(manifestTtl, 1, null)); return this; }
@Override public UpdateRequest writeSegment(UUID segment, String internalState) { Duration manifestTtl = Duration.ofDays(31); _mutation.withRow(CF_DEDUP_MD, queue) .putColumn(segment, internalState, Ttls.toSeconds(manifestTtl, 1, null)); return this; }