return Response.status(Status.BAD_REQUEST).build();
Site site = getSite(request);
WritableContentRepository contentRepository = (WritableContentRepository) getContentRepository(site, true);
ResourceURI livePageURI = new PageURIImpl(site, null, pageId, Resource.LIVE);
ResourceURI workPageURI = new PageURIImpl(site, null, pageId, Resource.WORK);
try {
if (!contentRepository.existsInAnyVersion(livePageURI)) {
logger.warn("Tried to delete non existing page {} in site '{}'", livePageURI, site);
throw new WebApplicationException(Status.NOT_FOUND);
}
} catch (ContentRepositoryException e) {
logger.warn("Page lookup {} failed for site '{}'", livePageURI, site);
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
Page page = null;
try {
page = (Page) contentRepository.get(livePageURI);
if (page != null) {
livePageURI.setPath(page.getURI().getPath());
} else {
page = (Page) contentRepository.get(workPageURI);
workPageURI.setPath(page.getURI().getPath());
}
} catch (ContentRepositoryException e) {
logger.warn("Error lookup up page {} from repository: {}", livePageURI, e.getMessage());
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}