throw new GWTJahiaServiceException(
JahiaResourceBundle.getJahiaInternalResource("message.googleDocs.synchronize.documentNotFound",
getLocale(), "No document currently being edited in Google Docs can be found."));
}
try {
GoogleDocsService googleDocsService =
googleDocsServiceFactory.getDocsService(getRequest(), getResponse());
InputStream content = googleDocsService.downloadFile(uri);
try {
JCRNodeWrapper parent = node.getParent();
session.checkout(parent);
parent.uploadFile(node.getName(), content, node.getFileContent().getContentType());
session.save();
} finally {
IOUtils.closeQuietly(content);
String docId = null;
if (uri.contains("docId=")) {
docId = StringUtils.substringBetween(uri, "docId=", "&");
} else if (uri.contains("key=")) {
docId = StringUtils.substringBetween(uri, "key=", "&");
} else if (uri.contains("id=")) {
docId = StringUtils.substringBetween(uri, "id=", "&");
}
if (docId != null) {
try {
googleDocsService.delete(docId);
} catch (Exception e) {
logger.warn("Unable to delete document '" + docId + "' from Google Docs", e);
}
} else {
logger.warn("Unable to retrieve document ID from the URI: " + uri);