ResourceIDImpl assumedResourceID = resourceDAO.getResourceID(path, false);
if (assumedResourceID != null && resourceDAO.resourceExists(assumedResourceID)) {
String msg = "Failed to add new Collection " + path + "There already exist " +
"non collection resource.";
log.error(msg);
throw new RegistryException(msg);
}
String parentPath = RegistryUtils.getParentPath(path);
ResourceIDImpl parentResourceID = null;
if (parentPath != null) {
parentResourceID = resourceDAO.getResourceID(parentPath, true);
if (parentResourceID == null || !resourceDAO.resourceExists(parentResourceID)) {
addEmptyCollection(parentPath);
if (parentResourceID == null) {
// since this is a collection there is no much performance hit here
parentResourceID = resourceDAO.getResourceID(parentPath, true);
}
} else if (!AuthorizationUtils.authorize(
parentPath, ActionConstants.PUT)) {
String msg = "Failed to add new resource. User " +
CurrentSession.getUser() + " does not have authorization to " +
"update the collection " + parentPath + ".";
log.error(msg);
throw new RegistryException(msg);
}
} else if (!path.equals(RegistryConstants.ROOT_PATH)) {
return;
}
if (!AuthorizationUtils.authorize(
path, ActionConstants.PUT)) {
String msg = "Failed to add new resource. User " +
CurrentSession.getUser() + " does not have authorization to " +
"add the collection at" + path + ".";
log.error(msg);
throw new RegistryException(msg);
}
CollectionImpl collection = new CollectionImpl();
RegistryContext registryContext = null;