class PageDesignerController extends AbstractRepositoryController {

	@GetMapping("/designer/pages/{pageId}/model")
	public ResponseEntity<PageModel> getPageModel(
			Principal principal, 
			@PathVariable Integer pageId) {
		RepositoryResource page = repositoryResourceService.findById(pageId).orElseThrow(ResourceNotFoundException::new);
		if(!page.isPage()) {
			throw new ResourceNotFoundException();
		}
		
		Repository repository = repositoryService.findById(page.getRepositoryId()).orElseThrow(ResourceNotFoundException::new);
		repositoryPermissionService.canRead(principal, repository).orElseThrow(NoAuthorizationException::new);
		
		PageModel result = repositoryResourceService.getPageModel(page);
		return ResponseEntity.ok(result);
	}

}