}
}
public void synchronizeWithGoogleDocs(String nodeIdentifier) throws GWTJahiaServiceException {
try {
JCRSessionWrapper session = retrieveCurrentSession();
JCRNodeWrapper node = session.getNodeByIdentifier(nodeIdentifier);
String uri = GoogleDocsEditor.getDocumentUriBeingEdited(getSession());
if (uri == null) {
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=", "&");