in src/main/java/com/google/gcs/sdrs/controller/RetentionRulesController.java [80:118]
public Response get(
@QueryParam("type") String retentionRuleType,
@QueryParam("projectId") String projectId,
@QueryParam("dataStorageName") String dataStorageName) {
try {
Collection<ValidationResult> partialValidations =
validateCompositeKey(retentionRuleType, projectId, dataStorageName);
ValidationResult result = ValidationResult.compose(partialValidations);
if (!result.isValid) {
throw new ValidationException(result);
}
if (retentionRuleType.equalsIgnoreCase(RetentionRuleType.GLOBAL.toString())) {
if (projectId == null) {
projectId = SdrsApplication.getAppConfigProperty("sts.defaultProjectId");
}
if (dataStorageName == null) {
dataStorageName = SdrsApplication.getAppConfigProperty("sts.defaultStorageName");
}
}
RetentionRuleResponse response =
service.getRetentionRuleByBusinessKey(
projectId,
dataStorageName,
RetentionRuleType.valueOf(retentionRuleType.toUpperCase()));
if (response == null) {
throw new ResourceNotFoundException(
String.format(
"Retention rule doesn't exist for projectId: %s, dataStorageName: %s",
projectId, dataStorageName));
}
return successResponse(response);
} catch (Exception exception) {
return errorResponse(exception);
}
}