mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Google Docs:
- Documents that have been previously checked out to Google Docs can now be deleted - Test updated - More logging added to service implementation git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22675 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -341,13 +341,11 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
{
|
{
|
||||||
// Get the entry
|
// Get the entry
|
||||||
DocumentListEntry entry = getDocumentListEntry(nodeRef);
|
DocumentListEntry entry = getDocumentListEntry(nodeRef);
|
||||||
if (entry == null)
|
if (entry != null)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Unable to find google resource to delete for node " + nodeRef.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark the resource for deletion upon completion of the transaction
|
// Mark the resource for deletion upon completion of the transaction
|
||||||
markResource(KEY_MARKED_DELETE, entry.getResourceId());
|
markResource(KEY_MARKED_DELETE, entry.getResourceId());
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the aspect from the node
|
// Remove the aspect from the node
|
||||||
nodeService.removeAspect(nodeRef, ASPECT_GOOGLERESOURCE);
|
nodeService.removeAspect(nodeRef, ASPECT_GOOGLERESOURCE);
|
||||||
@@ -644,9 +642,14 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
*/
|
*/
|
||||||
private DocumentListEntry getDocumentListEntry(NodeRef docNodeRef)
|
private DocumentListEntry getDocumentListEntry(NodeRef docNodeRef)
|
||||||
{
|
{
|
||||||
|
DocumentListEntry result = null;
|
||||||
String docType = (String)nodeService.getProperty(docNodeRef, PROP_RESOURCE_TYPE);
|
String docType = (String)nodeService.getProperty(docNodeRef, PROP_RESOURCE_TYPE);
|
||||||
String docId = (String)nodeService.getProperty(docNodeRef, PROP_RESOURCE_ID);
|
String docId = (String)nodeService.getProperty(docNodeRef, PROP_RESOURCE_ID);
|
||||||
return getDocumentListEntry(docType + ":" + docId);
|
if (docType != null && docId != null)
|
||||||
|
{
|
||||||
|
result = getDocumentListEntry(docType + ":" + docId);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -708,12 +711,21 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug("Creating media content object for mimetype " + mimetype);
|
||||||
|
}
|
||||||
|
|
||||||
// Create the media content object
|
// Create the media content object
|
||||||
MediaContent mediaContent = new MediaContent();
|
MediaContent mediaContent = new MediaContent();
|
||||||
mediaContent.setMimeType(new ContentType(mimetype));
|
mediaContent.setMimeType(new ContentType(mimetype));
|
||||||
|
|
||||||
if (is != null)
|
if (is != null)
|
||||||
{
|
{
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug(" ... input stream has been set");
|
||||||
|
}
|
||||||
mediaContent.setMediaSource(new MediaStreamSource(is, mimetype));
|
mediaContent.setMediaSource(new MediaStreamSource(is, mimetype));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,6 +734,10 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
if (parentFolder != null)
|
if (parentFolder != null)
|
||||||
{
|
{
|
||||||
parentFolderUrl = ((MediaContent)parentFolder.getContent()).getUri();
|
parentFolderUrl = ((MediaContent)parentFolder.getContent()).getUri();
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug(" ... parent folder URL is " + parentFolderUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the document entry object
|
// Create the document entry object
|
||||||
@@ -730,19 +746,35 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
MediaType.XLSX.getMimeType().equals(mimetype) == true ||
|
MediaType.XLSX.getMimeType().equals(mimetype) == true ||
|
||||||
MediaType.ODS.getMimeType().equals(mimetype) == true)
|
MediaType.ODS.getMimeType().equals(mimetype) == true)
|
||||||
{
|
{
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug("Creating SpreadsheetEntry for mimetype " + mimetype);
|
||||||
|
}
|
||||||
docEntry = new SpreadsheetEntry();
|
docEntry = new SpreadsheetEntry();
|
||||||
}
|
}
|
||||||
else if (MediaType.PPS.getMimeType().equals(mimetype) == true ||
|
else if (MediaType.PPS.getMimeType().equals(mimetype) == true ||
|
||||||
MediaType.PPT.getMimeType().equals(mimetype) == true)
|
MediaType.PPT.getMimeType().equals(mimetype) == true)
|
||||||
{
|
{
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug("Creating PresentationEntry for mimetype " + mimetype);
|
||||||
|
}
|
||||||
docEntry = new PresentationEntry();
|
docEntry = new PresentationEntry();
|
||||||
}
|
}
|
||||||
else if (MediaType.PDF.getMimeType().equals(mimetype) == true)
|
else if (MediaType.PDF.getMimeType().equals(mimetype) == true)
|
||||||
{
|
{
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug("Creating PdfEntry for mimetype " + mimetype);
|
||||||
|
}
|
||||||
docEntry = new PdfEntry();
|
docEntry = new PdfEntry();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (logger.isDebugEnabled() == true)
|
||||||
|
{
|
||||||
|
logger.debug("Creating DocumentEntry for mimetype " + mimetype);
|
||||||
|
}
|
||||||
docEntry = new DocumentEntry();
|
docEntry = new DocumentEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,8 +84,6 @@ public class GoogleDocumentServiceSystemTest extends TestCase implements GoogleD
|
|||||||
private static final String USER_SIX = "GoogleDocUserSix";
|
private static final String USER_SIX = "GoogleDocUserSix";
|
||||||
private static final String USER_SEVEN = "GoogleDocUserSeven";
|
private static final String USER_SEVEN = "GoogleDocUserSeven";
|
||||||
|
|
||||||
//private static final String EMAIL_DOMAIN = "@alfresco.com";
|
|
||||||
|
|
||||||
private NodeRef folder = null;
|
private NodeRef folder = null;
|
||||||
private NodeRef nodeRefDoc = null;
|
private NodeRef nodeRefDoc = null;
|
||||||
private NodeRef nodeRefSpread = null;
|
private NodeRef nodeRefSpread = null;
|
||||||
@@ -166,9 +164,6 @@ public class GoogleDocumentServiceSystemTest extends TestCase implements GoogleD
|
|||||||
contentWriter.setEncoding("UTF-8");
|
contentWriter.setEncoding("UTF-8");
|
||||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_EXCEL);
|
contentWriter.setMimetype(MimetypeMap.MIMETYPE_EXCEL);
|
||||||
contentWriter.putContent("");
|
contentWriter.putContent("");
|
||||||
|
|
||||||
ContentData contentData = (ContentData)nodeService.getProperty(nodeRef2, ContentModel.PROP_CONTENT);
|
|
||||||
System.out.println(" ********** Content data = " + contentData.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private NodeRef createTestDocument(String name, String contentPath, String mimetype)
|
private NodeRef createTestDocument(String name, String contentPath, String mimetype)
|
||||||
@@ -271,9 +266,6 @@ public class GoogleDocumentServiceSystemTest extends TestCase implements GoogleD
|
|||||||
{
|
{
|
||||||
if (isGoogleServiceAvailable() == true)
|
if (isGoogleServiceAvailable() == true)
|
||||||
{
|
{
|
||||||
ContentReader contentReader = contentService.getReader(nodeRef2, ContentModel.PROP_CONTENT);
|
|
||||||
//assertNull(contentReader);
|
|
||||||
|
|
||||||
// Check out the empty google document
|
// Check out the empty google document
|
||||||
NodeRef workingCopy = checkOutCheckInService.checkout(nodeRef2);
|
NodeRef workingCopy = checkOutCheckInService.checkout(nodeRef2);
|
||||||
|
|
||||||
@@ -288,9 +280,12 @@ public class GoogleDocumentServiceSystemTest extends TestCase implements GoogleD
|
|||||||
|
|
||||||
checkOutCheckInService.checkin(workingCopy, null);
|
checkOutCheckInService.checkin(workingCopy, null);
|
||||||
|
|
||||||
assertFalse(nodeService.hasAspect(nodeRefDoc, ASPECT_GOOGLERESOURCE));
|
assertFalse(nodeService.hasAspect(nodeRef2, ASPECT_GOOGLERESOURCE));
|
||||||
contentReader = contentService.getReader(nodeRef2, ContentModel.PROP_CONTENT);
|
ContentReader contentReader = contentService.getReader(nodeRef2, ContentModel.PROP_CONTENT);
|
||||||
assertNotNull(contentReader);
|
assertNotNull(contentReader);
|
||||||
|
|
||||||
|
// Lets try and delete the checked in node reference
|
||||||
|
nodeService.deleteNode(nodeRef2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies;
|
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies;
|
||||||
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.BeforeCheckIn;
|
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.BeforeCheckIn;
|
||||||
|
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckIn;
|
||||||
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckOut;
|
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckOut;
|
||||||
import org.alfresco.repo.copy.CopyBehaviourCallback;
|
import org.alfresco.repo.copy.CopyBehaviourCallback;
|
||||||
import org.alfresco.repo.copy.CopyDetails;
|
import org.alfresco.repo.copy.CopyDetails;
|
||||||
@@ -53,6 +54,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPolicy,
|
public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPolicy,
|
||||||
CheckOutCheckInServicePolicies.OnCheckOut,
|
CheckOutCheckInServicePolicies.OnCheckOut,
|
||||||
CheckOutCheckInServicePolicies.BeforeCheckIn,
|
CheckOutCheckInServicePolicies.BeforeCheckIn,
|
||||||
|
CheckOutCheckInServicePolicies.OnCheckIn,
|
||||||
NodeServicePolicies.BeforeDeleteNodePolicy
|
NodeServicePolicies.BeforeDeleteNodePolicy
|
||||||
{
|
{
|
||||||
/** Indicates whether behaviour is enabled or not */
|
/** Indicates whether behaviour is enabled or not */
|
||||||
@@ -140,6 +142,9 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
|
|||||||
policyComponent.bindClassBehaviour(BeforeCheckIn.QNAME,
|
policyComponent.bindClassBehaviour(BeforeCheckIn.QNAME,
|
||||||
GoogleDocsModel.ASPECT_GOOGLERESOURCE,
|
GoogleDocsModel.ASPECT_GOOGLERESOURCE,
|
||||||
new JavaBehaviour(this, "beforeCheckIn", NotificationFrequency.FIRST_EVENT));
|
new JavaBehaviour(this, "beforeCheckIn", NotificationFrequency.FIRST_EVENT));
|
||||||
|
policyComponent.bindClassBehaviour(OnCheckIn.QNAME,
|
||||||
|
GoogleDocsModel.ASPECT_GOOGLERESOURCE,
|
||||||
|
new JavaBehaviour(this, "onCheckIn", NotificationFrequency.FIRST_EVENT));
|
||||||
policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME,
|
policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME,
|
||||||
GoogleDocsModel.ASPECT_GOOGLERESOURCE,
|
GoogleDocsModel.ASPECT_GOOGLERESOURCE,
|
||||||
new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT));
|
new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT));
|
||||||
@@ -266,4 +271,10 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
|
|||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckIn(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
nodeService.removeAspect(nodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user