- Added web script to return the status of the GDoc service (see ALF-8684)
  - Refactor of service code to fix some of the issues when configuration details are changed via JMX or Share



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28681 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2011-06-29 05:58:56 +00:00
parent 6600f32e30
commit 4a8f493553
4 changed files with 80 additions and 56 deletions

View File

@@ -35,6 +35,7 @@
<property name="ownableService" ref="OwnableService"/> <property name="ownableService" ref="OwnableService"/>
<property name="authorityService" ref="AuthorityService"/> <property name="authorityService" ref="AuthorityService"/>
<property name="dictionaryService" ref="DictionaryService"/> <property name="dictionaryService" ref="DictionaryService"/>
<property name="enabled" value="${googledocs.googleeditable.enabled}"/>
<property name="url" value="${googledocs.url}"/> <property name="url" value="${googledocs.url}"/>
<property name="downloadUrl" value="${googledocs.downloadurl}"/> <property name="downloadUrl" value="${googledocs.downloadurl}"/>
<property name="username" value="${googledocs.username}"/> <property name="username" value="${googledocs.username}"/>
@@ -54,6 +55,5 @@
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="contentService" ref="ContentService"/> <property name="contentService" ref="ContentService"/>
<property name="dictionaryService" ref="DictionaryService"/> <property name="dictionaryService" ref="DictionaryService"/>
<property name="enabled" value="${googledocs.googleeditable.enabled}"/>
</bean> </bean>
</beans> </beans>

View File

@@ -27,6 +27,12 @@ import org.alfresco.service.cmr.repository.NodeRef;
*/ */
public interface GoogleDocsService public interface GoogleDocsService
{ {
/**
* Indicates whether the GoogleDocs service is enabled or not.
* @return boolean true if enabled, false otherwise
*/
boolean isEnabled();
/** /**
* Initialises the googles doc service, checking the provided credentials are correct. This need * Initialises the googles doc service, checking the provided credentials are correct. This need
* not be called manually since other service calls will initialise the service on demand, but it can * not be called manually since other service calls will initialise the service on demand, but it can

View File

@@ -106,6 +106,9 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
private AuthorityService authorityService; private AuthorityService authorityService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
/** Indicates whether the GDoc integration is enabled or not */
private boolean enabled = false;
/** GoogleDoc base feed url */ /** GoogleDoc base feed url */
private String url = "http://docs.google.com/feeds/default/private/full"; private String url = "http://docs.google.com/feeds/default/private/full";
private String downloadUrl = "https://docs.google.com/feeds/download"; private String downloadUrl = "https://docs.google.com/feeds/download";
@@ -246,6 +249,7 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
public void setUsername(String username) public void setUsername(String username)
{ {
this.username = username; this.username = username;
this.initialised = false;
} }
/** /**
@@ -254,6 +258,7 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
public void setPassword(String password) public void setPassword(String password)
{ {
this.password = password; this.password = password;
this.initialised = false;
} }
/** /**
@@ -264,6 +269,24 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
this.permissionMap = permissionMap; this.permissionMap = permissionMap;
} }
/**
* Set whether the service is enabled or not.
* @param enabled true if enabled, false otherwise
*/
public void setEnabled(boolean enabled)
{
this.enabled = enabled;
this.initialised = false;
}
/**
* @see org.alfresco.repo.googledocs.GoogleDocsService#isEnabled()
*/
public boolean isEnabled()
{
return enabled;
}
/** /**
* Initialise google docs services * Initialise google docs services
*/ */

View File

@@ -57,9 +57,6 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
CheckOutCheckInServicePolicies.OnCheckIn, CheckOutCheckInServicePolicies.OnCheckIn,
NodeServicePolicies.BeforeDeleteNodePolicy NodeServicePolicies.BeforeDeleteNodePolicy
{ {
/** Indicates whether behaviour is enabled or not */
boolean enabled = false;
/** Policy component */ /** Policy component */
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
@@ -75,14 +72,6 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
/** Content service */ /** Content service */
private ContentService contentService; private ContentService contentService;
/**
* @param enabled true if behaviour enabled, false otherwise
*/
public void setEnabled(boolean enabled)
{
this.enabled = enabled;
}
/** /**
* @param policyComponent policy component * @param policyComponent policy component
*/ */
@@ -127,8 +116,6 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
* Initialise method * Initialise method
*/ */
public void init() public void init()
{
if (enabled == true)
{ {
// GoogleEditable resource behaviours // GoogleEditable resource behaviours
policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME, policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME,
@@ -159,14 +146,13 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
GoogleDocsModel.ASPECT_GOOGLERESOURCE, GoogleDocsModel.ASPECT_GOOGLERESOURCE,
new JavaBehaviour(this, "getGoogleResourceCopyCallback")); new JavaBehaviour(this, "getGoogleResourceCopyCallback"));
} }
}
/** /**
* @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) * @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/ */
public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName) public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName)
{ {
if (nodeService.exists(nodeRef) == true) if (googleDocsService.isEnabled() == true && nodeService.exists(nodeRef) == true)
{ {
// Can only make cm:content descendant google editable // Can only make cm:content descendant google editable
QName type = nodeService.getType(nodeRef); QName type = nodeService.getType(nodeRef);
@@ -183,7 +169,7 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
*/ */
public void onCheckOut(NodeRef workingCopy) public void onCheckOut(NodeRef workingCopy)
{ {
if (nodeService.exists(workingCopy) == true && isUpload() == false) if (googleDocsService.isEnabled() == true && nodeService.exists(workingCopy) == true && isUpload() == false)
{ {
// Upload the content of the working copy to google docs // Upload the content of the working copy to google docs
googleDocsService.createGoogleDoc(workingCopy, GoogleDocsPermissionContext.SHARE_WRITE); googleDocsService.createGoogleDoc(workingCopy, GoogleDocsPermissionContext.SHARE_WRITE);
@@ -205,7 +191,8 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
Map<String, Serializable> versionProperties, String contentUrl, Map<String, Serializable> versionProperties, String contentUrl,
boolean keepCheckedOut) boolean keepCheckedOut)
{ {
if (nodeService.exists(workingCopyNodeRef) == true && if (googleDocsService.isEnabled() == true &&
nodeService.exists(workingCopyNodeRef) == true &&
nodeService.hasAspect(workingCopyNodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE) == true && nodeService.hasAspect(workingCopyNodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE) == true &&
isUpload() == false) isUpload() == false)
{ {
@@ -222,12 +209,26 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
} }
} }
/**
* @see org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckIn#onCheckIn(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public void onCheckIn(NodeRef nodeRef)
{
if (googleDocsService.isEnabled() == true && nodeService.exists(nodeRef) == true)
{
nodeService.removeAspect(nodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE);
}
}
/** /**
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef) * @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
*/ */
public void beforeDeleteNode(NodeRef nodeRef) public void beforeDeleteNode(NodeRef nodeRef)
{ {
if (nodeService.exists(nodeRef) == true && isUpload() == false) if (googleDocsService.isEnabled() == true &&
nodeService.exists(nodeRef) == true &&
isUpload() == false)
{ {
// Delete the associated google resource // Delete the associated google resource
googleDocsService.deleteGoogleResource(nodeRef); googleDocsService.deleteGoogleResource(nodeRef);
@@ -271,10 +272,4 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
return Collections.emptyMap(); return Collections.emptyMap();
} }
} }
@Override
public void onCheckIn(NodeRef nodeRef)
{
nodeService.removeAspect(nodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE);
}
} }