Function bodies 69 total
com.accountabilityatlas.videoservice.web.VideoController.getVideo method · java · L48-L56 (9 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
public ResponseEntity<VideoDetail> getVideo(UUID id) {
Video video = videoService.getVideo(id);
UUID currentUserId = getCurrentUserIdOrNull();
String trustTier = getCurrentTrustTierOrNull();
if (!videoService.canView(video, currentUserId, trustTier)) {
throw new UnauthorizedException("You do not have permission to view this video");
}
return ResponseEntity.ok(toVideoDetail(video));
}com.accountabilityatlas.videoservice.web.VideoController.listVideos method · java · L63-L100 (38 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
public ResponseEntity<VideoListResponse> listVideos(
com.accountabilityatlas.videoservice.web.model.VideoStatus status,
List<com.accountabilityatlas.videoservice.web.model.Amendment> amendments,
List<com.accountabilityatlas.videoservice.web.model.Participant> participants,
UUID submittedBy,
Integer page,
Integer size,
String sort,
String direction) {
PageRequest pageable =
PageRequest.of(
page != null ? page : 0,
size != null ? size : 20,
Sort.by(
"desc".equalsIgnoreCase(direction) ? Sort.Direction.DESC : Sort.Direction.ASC,
sort != null ? sort : "createdAt"));
VideoStatus domainStatus = status != null ? VideoStatus.valueOf(status.name()) : null;
UUID currentUserId = getCurrentUserIdOrNull();
String trustTier = getCurrentTrustTierOrNull();
boolean isModeratorOrAdmin = "MODERATOR".equals(trustTier) || "ADMIN".equals(trustTier);
if (submcom.accountabilityatlas.videoservice.web.VideoController.getVideosByUser method · java · L104-L121 (18 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
public ResponseEntity<VideoListResponse> getVideosByUser(
UUID userId,
com.accountabilityatlas.videoservice.web.model.VideoStatus status,
Integer page,
Integer size) {
PageRequest pageable = PageRequest.of(page != null ? page : 0, size != null ? size : 20);
UUID currentUserId = getCurrentUserIdOrNull();
boolean isOwner = currentUserId != null && currentUserId.equals(userId);
VideoStatus domainStatus = getDomainStatus(status, isOwner);
if (!isOwner) {
domainStatus = VideoStatus.APPROVED;
}
Page<Video> videos = videoService.listVideosByUser(userId, domainStatus, pageable);
return ResponseEntity.ok(toVideoListResponse(videos));
}com.accountabilityatlas.videoservice.web.VideoController.createVideo method · java · L133-L153 (21 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
public ResponseEntity<VideoDetail> createVideo(CreateVideoRequest request) {
UUID userId = requireCurrentUserId();
UUID locationId = request.getLocationId();
String trustTier = getCurrentTrustTierOrNull();
Video video =
videoService.createVideo(
request.getYoutubeUrl().toString(),
request.getAmendments().stream()
.map(a -> Amendment.valueOf(a.name()))
.collect(Collectors.toSet()),
request.getParticipants().stream()
.map(p -> Participant.valueOf(p.name()))
.collect(Collectors.toSet()),
request.getVideoDate(),
userId,
trustTier != null ? trustTier : "NEW",
List.of(locationId));
return ResponseEntity.status(HttpStatus.CREATED).body(toVideoDetail(video));
}com.accountabilityatlas.videoservice.web.VideoController.updateVideo method · java · L157-L177 (21 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
public ResponseEntity<VideoDetail> updateVideo(UUID id, UpdateVideoRequest request) {
UUID userId = requireCurrentUserId();
Video video =
videoService.updateVideo(
id,
request.getAmendments() != null
? request.getAmendments().stream()
.map(a -> Amendment.valueOf(a.name()))
.collect(Collectors.toSet())
: null,
request.getParticipants() != null
? request.getParticipants().stream()
.map(p -> Participant.valueOf(p.name()))
.collect(Collectors.toSet())
: null,
request.getVideoDate(),
userId);
return ResponseEntity.ok(toVideoDetail(video));
}com.accountabilityatlas.videoservice.web.VideoController.previewVideo method · java · L189-L219 (31 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
public ResponseEntity<VideoPreview> previewVideo(String youtubeUrl) {
String videoId = youTubeService.extractVideoId(youtubeUrl);
YouTubeMetadata metadata = youTubeService.fetchMetadata(videoId);
VideoPreview preview = new VideoPreview();
preview.setYoutubeId(metadata.videoId());
preview.setTitle(metadata.title());
preview.setDescription(metadata.description());
preview.setThumbnailUrl(toUriOrNull(metadata.thumbnailUrl()));
preview.setDurationSeconds(metadata.durationSeconds());
preview.setChannelId(metadata.channelId());
preview.setChannelName(metadata.channelName());
preview.setPublishedAt(
metadata.publishedAt() != null
? metadata.publishedAt().atOffset(java.time.ZoneOffset.UTC)
: null);
videoService
.findByYoutubeId(videoId)
.ifPresentOrElse(
existing -> {
preview.setAlreadyExists(true);
preview.setExistingVideoId(existing.getId());
com.accountabilityatlas.videoservice.web.VideoController.extractVideoMetadata method · java · L223-L231 (9 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
public ResponseEntity<VideoMetadataExtraction> extractVideoMetadata(String youtubeUrl) {
requireCurrentUserId();
String videoId = youTubeService.extractVideoId(youtubeUrl);
YouTubeMetadata metadata = youTubeService.fetchMetadata(videoId);
String publishedAt = metadata.publishedAt() != null ? metadata.publishedAt().toString() : null;
MetadataExtractionService.ExtractionResult result =
metadataExtractionService.extract(metadata.title(), metadata.description(), publishedAt);
return ResponseEntity.ok(toVideoMetadataExtraction(result));
}Repobility · open methodology · https://repobility.com/research/
com.accountabilityatlas.videoservice.web.VideoController.addVideoLocation method · java · L243-L251 (9 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
addVideoLocation(UUID id, AddVideoLocationRequest request) {
UUID userId = requireCurrentUserId();
VideoLocation location =
videoLocationService.addLocation(
id, request.getLocationId(), Boolean.TRUE.equals(request.getIsPrimary()), userId);
return ResponseEntity.status(HttpStatus.CREATED).body(toVideoLocationModel(location));
}com.accountabilityatlas.videoservice.web.VideoController.toVideoDetail method · java · L262-L293 (32 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private VideoDetail toVideoDetail(Video video) {
VideoDetail detail = new VideoDetail();
detail.setId(video.getId());
detail.setYoutubeId(video.getYoutubeId());
detail.setTitle(video.getTitle());
detail.setDescription(video.getDescription());
detail.setThumbnailUrl(toUriOrNull(video.getThumbnailUrl()));
detail.setDurationSeconds(video.getDurationSeconds());
detail.setChannelId(video.getChannelId());
detail.setChannelName(video.getChannelName());
detail.setPublishedAt(
video.getPublishedAt() != null
? video.getPublishedAt().atOffset(java.time.ZoneOffset.UTC)
: null);
detail.setVideoDate(video.getVideoDate());
detail.setAmendments(
video.getAmendments().stream()
.map(a -> com.accountabilityatlas.videoservice.web.model.Amendment.valueOf(a.name()))
.toList());
detail.setParticipants(
video.getParticipants().stream()
.map(p -> com.accountabilityatlas.videcom.accountabilityatlas.videoservice.web.VideoController.toVideoListResponse method · java · L296-L304 (9 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private VideoListResponse toVideoListResponse(Page<Video> page) {
VideoListResponse response = new VideoListResponse();
response.setContent(page.getContent().stream().map(this::toVideoSummary).toList());
response.setPage(page.getNumber());
response.setSize(page.getSize());
response.setTotalElements((int) page.getTotalElements());
response.setTotalPages(page.getTotalPages());
return response;
}com.accountabilityatlas.videoservice.web.VideoController.toVideoSummary method · java · L307-L328 (22 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private VideoSummary toVideoSummary(Video video) {
VideoSummary summary = new VideoSummary();
summary.setId(video.getId());
summary.setYoutubeId(video.getYoutubeId());
summary.setTitle(video.getTitle());
summary.setThumbnailUrl(toUriOrNull(video.getThumbnailUrl()));
summary.setDurationSeconds(video.getDurationSeconds());
summary.setAmendments(
video.getAmendments().stream()
.map(a -> com.accountabilityatlas.videoservice.web.model.Amendment.valueOf(a.name()))
.toList());
summary.setParticipants(
video.getParticipants().stream()
.map(p -> com.accountabilityatlas.videoservice.web.model.Participant.valueOf(p.name()))
.toList());
summary.setStatus(
com.accountabilityatlas.videoservice.web.model.VideoStatus.valueOf(
video.getStatus().name()));
summary.setRejectionReason(video.getRejectionReason());
summary.setCreatedAt(video.getCreatedAt().atOffset(java.time.ZoneOcom.accountabilityatlas.videoservice.web.VideoController.toVideoLocationModel method · java · L331-L345 (15 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private com.accountabilityatlas.videoservice.web.model.VideoLocation toVideoLocationModel(
VideoLocation location) {
var model = new com.accountabilityatlas.videoservice.web.model.VideoLocation();
model.setId(location.getId());
model.setVideoId(location.getVideo().getId());
model.setLocationId(location.getLocationId());
model.setIsPrimary(location.isPrimary());
if (location.getDisplayName() != null) {
LocationSummary locSummary = getLocationSummary(location);
model.setLocation(locSummary);
}
return model;
}com.accountabilityatlas.videoservice.web.VideoController.requireCurrentUserId method · java · L370-L376 (7 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private UUID requireCurrentUserId() {
UUID userId = getCurrentUserIdOrNull();
if (userId == null) {
throw new UnauthorizedException("Missing or invalid authentication token");
}
return userId;
}com.accountabilityatlas.videoservice.web.VideoController.getCurrentUserIdOrNull method · java · L379-L385 (7 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private UUID getCurrentUserIdOrNull() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || !(authentication.getPrincipal() instanceof Jwt jwt)) {
return null;
}
return UUID.fromString(jwt.getSubject());
}com.accountabilityatlas.videoservice.web.VideoController.getCurrentTrustTierOrNull method · java · L388-L394 (7 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private String getCurrentTrustTierOrNull() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || !(authentication.getPrincipal() instanceof Jwt jwt)) {
return null;
}
return jwt.getClaimAsString("trustTier");
}About: code-quality intelligence by Repobility · https://repobility.com
com.accountabilityatlas.videoservice.web.VideoController.toVideoMetadataExtraction method · java · L397-L437 (41 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private VideoMetadataExtraction toVideoMetadataExtraction(
MetadataExtractionService.ExtractionResult result) {
VideoMetadataExtraction extraction = new VideoMetadataExtraction();
extraction.setAmendments(
result.amendments() != null
? result.amendments().stream()
.filter(this::isValidAmendment)
.map(com.accountabilityatlas.videoservice.web.model.Amendment::valueOf)
.toList()
: List.of());
extraction.setParticipants(
result.participants() != null
? result.participants().stream()
.filter(this::isValidParticipant)
.map(com.accountabilityatlas.videoservice.web.model.Participant::valueOf)
.toList()
: List.of());
extraction.setVideoDate(
result.videoDate() != null ? java.time.LocalDate.parse(result.videoDate()) : null);
if (result.location() != null) {
ExtractedLocation loc = new ExtractedLocom.accountabilityatlas.videoservice.web.VideoController.isValidAmendment method · java · L439-L446 (8 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private boolean isValidAmendment(String value) {
try {
com.accountabilityatlas.videoservice.web.model.Amendment.valueOf(value);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}com.accountabilityatlas.videoservice.web.VideoController.isValidParticipant method · java · L448-L455 (8 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private boolean isValidParticipant(String value) {
try {
com.accountabilityatlas.videoservice.web.model.Participant.valueOf(value);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}com.accountabilityatlas.videoservice.web.VideoController.toUriOrNull method · java · L458-L467 (10 LOC)src/main/java/com/accountabilityatlas/videoservice/web/VideoController.java
private URI toUriOrNull(String value) {
if (value == null || value.isBlank()) {
return null;
}
try {
return URI.create(value);
} catch (IllegalArgumentException ex) {
return null;
}
}‹ prevpage 2 / 2