if (!StringUtils.isBlank(path)) {
try {
if (!path.startsWith("/"))
path = "/" + path;
WebUrl url = new WebUrlImpl(site, path);
resourceURI = new GeneralResourceURIImpl(site, url.getPath(), uuid);
// Make sure the resource doesn't exist
if (contentRepository.exists(new GeneralResourceURIImpl(site, url.getPath()))) {
logger.warn("Tried to create already existing resource {} in site '{}'", resourceURI, site);
throw new WebApplicationException(Status.CONFLICT);
}
} catch (IllegalArgumentException e) {
logger.warn("Tried to create a resource with an invalid path '{}': {}", path, e.getMessage());
throw new WebApplicationException(Status.BAD_REQUEST);
} catch (ContentRepositoryException e) {
logger.warn("Resource lookup {} failed for site '{}'", resourceURI, site);
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
} else {
resourceURI = new GeneralResourceURIImpl(site, "/" + uuid.replaceAll("-", ""), uuid);
}
URI uri = null;
Resource<?> resource = null;
try {