JCRNodeWrapper parent;
try {
parent = currentUserSession.getNode(parentPath);
} catch (RepositoryException e) {
logger.error(e.toString(), e);
throw new GWTJahiaServiceException(new StringBuilder(parentPath).append(" could not be accessed :\n").append(e.toString()).toString());
}
if (parent.hasPermission("jcr:addChildNodes") && !parent.isLocked()) {
for (JCRNodeWrapper nodeToUnzip : nodesToUnzip) {
try {
if (!unzipFile(nodeToUnzip, parent, currentUserSession)) {
missedPaths.add(nodeToUnzip.getName());
} else if (removeArchive) {
try {
nodeToUnzip.remove();
} catch (RepositoryException e) {
logger.error("Issue when trying to delete original archive " + nodeToUnzip.getPath(), e);
}
}
} catch (RepositoryException e) {
missedPaths.add(nodeToUnzip.getName());
logger.error(e.getMessage(), e);
}
}
} else {
throw new GWTJahiaServiceException("Directory " + parent.getPath() + " is not writable.");
}
try {
parent.saveSession();
} catch (RepositoryException e) {
logger.error("Could not save changes in " + parent.getPath(), e);
}
}
if (missedPaths.size() > 0) {
StringBuilder errors = new StringBuilder("The following files could not be unzipped:");
for (String err : missedPaths) {
errors.append("\n").append(err);
}
throw new GWTJahiaServiceException(errors.toString());
}
}