String uuid = UUID.randomUUID().toString();
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());