logger.warn("Attempt to write to read-only content repository {}", site);
throw new WebApplicationException(Status.PRECONDITION_FAILED);
}
WritableContentRepository contentRepository = (WritableContentRepository) getContentRepository(site, true);
ResourceURI workURI = new PageURIImpl(site, null, pageId, Resource.WORK);
// Does the page exist?
Page currentPage = null;
try {
currentPage = (Page) contentRepository.get(workURI);
if (currentPage == null) {
logger.warn("Attempt to update a page without creating a work version first");
throw new WebApplicationException(Status.PRECONDITION_FAILED);
}
workURI.setPath(currentPage.getURI().getPath());
} catch (ContentRepositoryException e) {
logger.warn("Error lookup up page {} from repository: {}", workURI, e.getMessage());
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}