ALF-2703: Incorrect folder sctructure is created in Google Docs

If the transaction within which folders or documents are created within Google Docs fails then the created items will be rolledback as if part of the Alfresco transaction.  This prevents the behaviour reported in this issue.



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20216 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2010-05-13 09:32:35 +00:00
parent 50190d5b64
commit f9b7237eab
3 changed files with 146 additions and 14 deletions

View File

@@ -23,6 +23,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import javax.transaction.UserTransaction;
@@ -51,6 +52,10 @@ import org.alfresco.util.PropertyMap;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import com.google.gdata.client.DocumentQuery;
import com.google.gdata.client.docs.DocsService;
import com.google.gdata.data.docs.DocumentListEntry;
import com.google.gdata.data.docs.DocumentListFeed;
import com.google.gdata.util.ServiceException;
public class GoogleDocumentServiceTest extends TestCase implements GoogleDocsModel
@@ -147,7 +152,7 @@ public class GoogleDocumentServiceTest extends TestCase implements GoogleDocsMod
// Create test documents
nodeRefDoc = createTestDocument("mydoc.docx", "alfresco/subsystems/googledocs/default/test.docx", MimetypeMap.MIMETYPE_WORD);
//nodeRefSpread = createTestDocument("mydoc.xls", "alfresco/subsystems/googledocs/default/testBook.xls", MimetypeMap.MIMETYPE_EXCEL);
nodeRefSpread = createTestDocument("mydoc2.docx", "alfresco/subsystems/googledocs/default/test.docx", MimetypeMap.MIMETYPE_WORD);
nodeRefSpread = createTestDocument("mydoc2.xlsx", "alfresco/subsystems/googledocs/default/test.xlsx", MimetypeMap.MIMETYPE_EXCEL);
// Create an empty content node (simulate creation of a new google doc in UI)
nodeRef2 = fileFolderService.create(folder, "mygoogledoc.doc", ContentModel.TYPE_CONTENT).getNodeRef();
@@ -225,12 +230,24 @@ public class GoogleDocumentServiceTest extends TestCase implements GoogleDocsMod
assertNotNull(nodeService.getProperty(nodeRefDoc, PROP_RESOURCE_ID));
assertNotNull(nodeService.getProperty(nodeRefDoc, PROP_RESOURCE_TYPE));
System.out.println("For node ref " + nodeRefDoc.toString());
System.out.println("Google doc URL: " + nodeService.getProperty(nodeRefDoc, PROP_URL));
System.out.println("Google doc type: " + nodeService.getProperty(nodeRefDoc, PROP_RESOURCE_TYPE));
System.out.println("Google doc id: " + nodeService.getProperty(nodeRefDoc, PROP_RESOURCE_ID));
String downloadFile = downloadFile(googleDocsService.getGoogleDocContent(nodeRefDoc), ".doc");
System.out.println("Download file: " + downloadFile);
DocsService client = new DocsService("Alfresco");
client.setUserCredentials("rwetherall@alfresco.com", "123test123");
URL feedUri = new URL("https://docs.google.com/feeds/default/private/full/");
DocumentQuery query = new DocumentQuery(feedUri);
query.setTitleExact(true);
query.setTitleQuery((String)nodeService.getProperty(nodeRefDoc, ContentModel.PROP_NAME));
DocumentListFeed feed = client.getFeed(query, DocumentListFeed.class);
printDocuments(feed);
googleDocsService.createGoogleDoc(nodeRefSpread, GoogleDocsPermissionContext.SHARE_WRITE);
assertTrue(nodeService.hasAspect(nodeRefSpread, ASPECT_GOOGLERESOURCE));
@@ -241,12 +258,24 @@ public class GoogleDocumentServiceTest extends TestCase implements GoogleDocsMod
System.out.println("Google doc URL: " + nodeService.getProperty(nodeRefSpread, PROP_URL));
System.out.println("Google doc type: " + nodeService.getProperty(nodeRefSpread, PROP_RESOURCE_TYPE));
System.out.println("Google doc id: " + nodeService.getProperty(nodeRefSpread, PROP_RESOURCE_ID));
// // downloadFile = downloadFile(googleDocsService.download(nodeRefSpread), ".xls");
// // System.out.println("Download file: " + downloadFile);
downloadFile = downloadFile(googleDocsService.getGoogleDocContent(nodeRefSpread), ".xls");
System.out.println("Download file: " + downloadFile);
}
}
public void printDocuments(DocumentListFeed feed)
{
for (DocumentListEntry entry : feed.getEntries() )
{
String resourceId = entry.getResourceId();
System.out.println(" -- Document(" + resourceId + "/" + entry.getTitle().getPlainText() + ") ");
}
}
public void testCheckOutCheckIn() throws Exception
{
if (isGoogleServiceAvailable() == true)