class PageService extends BasicService implements OwnerAPISupport<Page> {

	@PUT
	@Path("/pages/{pageId}")
	@Produces(MediaType.APPLICATION_JSON)
	public Page updatePage(@PathParam("pageId") long pageId, Page pageData) {
		Page existingPage = getExistingPage(pageId, true);

		sanitizePageData(pageData);
		if (StringUtils.isEmpty(pageData.getName())) {
			throwBadRequest();
		}

		File file = existingPage.getAutoScreenshot();

		existingPage.setDescription(pageData.getDescription());
		existingPage.setFile(pageData.getFile());
		existingPage.setGridX(pageData.getGridX());
		existingPage.setGridY(pageData.getGridY());
		existingPage.setGridRatio(pageData.getGridRatio());
		existingPage.setListPublicly(pageData.isListPublicly());
		existingPage.setMediasharePrivate(pageData.isMediasharePrivate());
		existingPage.setName(pageData.getName());
		existingPage.setPage(pageData.getPage());
		existingPage.setPageType(pageData.getPageType());
		existingPage.setReloadInterval(pageData.getReloadInterval());
		existingPage.setText(pageData.getText());
		existingPage.setTitle(pageData.getTitle());
		existingPage.setUrl(pageData.getUrl());
		existingPage.setAutoScreenshot(null);

		existingPage = PageDAO.save(existingPage);
		if (file != null) {
			new FileDAO().deleteById(file.getId());
		}

		return existingPage;
	}

}