class PageDesignerController extends AbstractRepositoryController {

	@PutMapping("/designer/pages/{pageId}/model")
	public ResponseEntity<Map<String, Object>> updatePageModel(
			Principal principal, 
			@PathVariable Integer pageId, 
			@RequestBody PageModel model ) {
		// ensure user login
		if(principal == null) {
			throw new NoAuthorizationException();
		}

		RepositoryResource page = repositoryResourceService.findById(pageId).orElseThrow(ResourceNotFoundException::new);
		if(!(page.isPage())) {
			throw new ResourceNotFoundException();
		}
		Repository project = repositoryService.findById(page.getRepositoryId()).orElseThrow(ResourceNotFoundException::new);
		repositoryPermissionService.canWrite(principal, project).orElseThrow(NoAuthorizationException::new);
		
		repositoryResourceService.updatePageModel(project, page, model);
		
		return ResponseEntity.noContent().build();
	}

}