Skip to content

Commit

Permalink
Moved ForbiddenException to the link package
Browse files Browse the repository at this point in the history
  • Loading branch information
egorsivenko committed Apr 19, 2024
1 parent f7b50c6 commit 03d4ada
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.linkurlshorter.urlshortener.security;
package com.linkurlshorter.urlshortener.link;

public class ForbiddenException extends RuntimeException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.linkurlshorter.urlshortener.link;

import com.linkurlshorter.urlshortener.security.ForbiddenException;
import com.linkurlshorter.urlshortener.user.User;
import com.linkurlshorter.urlshortener.user.UserService;
import jakarta.persistence.EntityManager;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.Comparator;
Expand Down Expand Up @@ -135,6 +138,7 @@ public ResponseEntity<LinkModifyingResponse> refreshLink(@RequestParam UUID id)
throw new ForbiddenException(OPERATION_FORBIDDEN_MSG);
}
}

/**
* Retrieves information about a link using its short link.
*
Expand All @@ -153,6 +157,7 @@ public ResponseEntity<LinkInfoResponse> getInfoByShortLink(@RequestParam String
throw new ForbiddenException(OPERATION_FORBIDDEN_MSG);
}
}

/**
* Retrieves information about all links associated with the authenticated user.
*
Expand All @@ -170,6 +175,7 @@ public ResponseEntity<LinkInfoResponse> getAllLinksForUser() {
.toList();
return ResponseEntity.ok(new LinkInfoResponse(linksDto, "ok"));
}

/**
* Retrieves usage statistics for all links associated with the authenticated user.
*
Expand Down

0 comments on commit 03d4ada

Please sign in to comment.