}
@Override
public void handle(Request request, Response response) {
String fileKey = request.mandatoryParam(PARAM_KEY);
UserSession userSession = UserSession.get();
JsonWriter json = response.newJsonWriter();
json.beginObject();
DbSession session = dbClient.openSession(false);
try {
ComponentDto component = dbClient.componentDao().getNullableByKey(session, fileKey);
if (component == null) {
throw new NotFoundException(String.format("Component '%s' does not exist", fileKey));
}
userSession.checkComponentPermission(UserRole.USER, fileKey);
List<Period> periodList = periods(component.projectUuid(), session);
Integer periodIndex = request.paramAsInt(PARAM_PERIOD);
Date periodDate = periodDate(periodIndex, periodList);