Merged V4.1-BUG-FIX to HEAD

42902: Merged DEV to V4.1-BUG-FIX
      42519: ALF-13588: Google Doc failed to authenticate after incorrect password being entered for google account 
         Add ability to unregister class behaviours.
         Unregister googledocs behaviours when subsystem stops.
   42903: Merged V3.4-BUG-FIX to V4.1-BUG-FIX
      42901: Merged DEV to V3.4-BUG-FIX
         42837: ALF-12833: Issues installing Alfresco on WebSphere when the server doesn't have internet access
            Create servlet-resources.jar(the same as servlet.jar but only with "resources") and add it into alfresco.war


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42905 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2012-10-21 18:11:58 +00:00
parent b58125d078
commit 8640f47cb1
6 changed files with 82 additions and 16 deletions

View File

@@ -21,7 +21,9 @@ package org.alfresco.repo.googledocs;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
@@ -35,6 +37,8 @@ import org.alfresco.repo.copy.DefaultCopyBehaviourCallback;
import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy; import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy; import org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy;
import org.alfresco.repo.policy.BehaviourDefinition;
import org.alfresco.repo.policy.ClassBehaviourBinding;
import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
@@ -46,6 +50,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.springframework.beans.factory.DisposableBean;
/** /**
* Behaviour associated with google editable documents * Behaviour associated with google editable documents
@@ -55,7 +60,8 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
CheckOutCheckInServicePolicies.OnCheckOut, CheckOutCheckInServicePolicies.OnCheckOut,
CheckOutCheckInServicePolicies.BeforeCheckIn, CheckOutCheckInServicePolicies.BeforeCheckIn,
CheckOutCheckInServicePolicies.OnCheckIn, CheckOutCheckInServicePolicies.OnCheckIn,
NodeServicePolicies.BeforeDeleteNodePolicy NodeServicePolicies.BeforeDeleteNodePolicy,
DisposableBean
{ {
/** Policy component */ /** Policy component */
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
@@ -72,6 +78,9 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
/** Content service */ /** Content service */
private ContentService contentService; private ContentService contentService;
/** binded behaviours definitions*/
private Set<BehaviourDefinition<ClassBehaviourBinding>> behaviours;
/** /**
* @param policyComponent policy component * @param policyComponent policy component
*/ */
@@ -117,34 +126,35 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
*/ */
public void init() public void init()
{ {
behaviours = new HashSet<BehaviourDefinition<ClassBehaviourBinding>>();
// GoogleEditable resource behaviours // GoogleEditable resource behaviours
policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME, behaviours.add(policyComponent.bindClassBehaviour(OnAddAspectPolicy.QNAME,
GoogleDocsModel.ASPECT_GOOGLEEDITABLE , GoogleDocsModel.ASPECT_GOOGLEEDITABLE ,
new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT)); new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT)));
policyComponent.bindClassBehaviour(OnCheckOut.QNAME, behaviours.add(policyComponent.bindClassBehaviour(OnCheckOut.QNAME,
GoogleDocsModel.ASPECT_GOOGLEEDITABLE, GoogleDocsModel.ASPECT_GOOGLEEDITABLE,
new JavaBehaviour(this, "onCheckOut", NotificationFrequency.FIRST_EVENT)); new JavaBehaviour(this, "onCheckOut", NotificationFrequency.FIRST_EVENT)));
// Google resource behaviours // Google resource behaviours
policyComponent.bindClassBehaviour(BeforeCheckIn.QNAME, behaviours.add(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, behaviours.add(policyComponent.bindClassBehaviour(OnCheckIn.QNAME,
GoogleDocsModel.ASPECT_GOOGLERESOURCE, GoogleDocsModel.ASPECT_GOOGLERESOURCE,
new JavaBehaviour(this, "onCheckIn", NotificationFrequency.FIRST_EVENT)); new JavaBehaviour(this, "onCheckIn", NotificationFrequency.FIRST_EVENT)));
policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME, behaviours.add(policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME,
GoogleDocsModel.ASPECT_GOOGLERESOURCE, GoogleDocsModel.ASPECT_GOOGLERESOURCE,
new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT)); new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT)));
// Copy behaviours // Copy behaviours
this.policyComponent.bindClassBehaviour( behaviours.add(policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
GoogleDocsModel.ASPECT_GOOGLEEDITABLE, GoogleDocsModel.ASPECT_GOOGLEEDITABLE,
new JavaBehaviour(this, "getGoogleEditableCopyCallback")); new JavaBehaviour(this, "getGoogleEditableCopyCallback")));
this.policyComponent.bindClassBehaviour( behaviours.add(policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
GoogleDocsModel.ASPECT_GOOGLERESOURCE, GoogleDocsModel.ASPECT_GOOGLERESOURCE,
new JavaBehaviour(this, "getGoogleResourceCopyCallback")); new JavaBehaviour(this, "getGoogleResourceCopyCallback")));
} }
/** /**
@@ -272,4 +282,13 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
return Collections.emptyMap(); return Collections.emptyMap();
} }
} }
@Override
public void destroy() throws Exception
{
for(BehaviourDefinition<ClassBehaviourBinding> definition : behaviours)
{
policyComponent.removeClassDefinition(definition);
}
}
} }

View File

@@ -82,6 +82,23 @@ import java.util.Map;
} }
/**
* Remove behavior from map
*
* @param behaviourDefinition
*/
public void remove(BehaviourDefinition<B> behaviourDefinition)
{
B binding = behaviourDefinition.getBinding();
List<BehaviourDefinition<B>> existing = index.get(binding);
if (existing != null && existing.contains(behaviourDefinition))
{
existing.remove(behaviourDefinition);
size--;
}
}
/** /**
* Gets a Behaviour from the Map * Gets a Behaviour from the Map

View File

@@ -30,7 +30,7 @@ import org.alfresco.service.namespace.QName;
* @author David Caruana * @author David Caruana
* *
*/ */
/*package*/ class ClassBehaviourBinding implements BehaviourBinding public class ClassBehaviourBinding implements BehaviourBinding
{ {
// The dictionary service // The dictionary service
private DictionaryService dictionary; private DictionaryService dictionary;

View File

@@ -213,4 +213,22 @@ import org.alfresco.service.namespace.QName;
} }
} }
/**
* Remove class behaviour
*
* @param behaviour
*/
public void removeClassBehaviour(BehaviourDefinition<B> behaviour)
{
lock.writeLock().lock();
try
{
classMap.remove(behaviour);
}
finally
{
lock.writeLock().unlock();
}
}
} }

View File

@@ -206,6 +206,13 @@ public interface PolicyComponent
*/ */
public BehaviourDefinition<ServiceBehaviourBinding> bindAssociationBehaviour(QName policy, Object service, Behaviour behaviour); public BehaviourDefinition<ServiceBehaviourBinding> bindAssociationBehaviour(QName policy, Object service, Behaviour behaviour);
/**
* Unbind behaviour
*
* @param definition
*/
public void removeClassDefinition(BehaviourDefinition<ClassBehaviourBinding> definition);
} }

View File

@@ -137,6 +137,11 @@ public class PolicyComponentImpl implements PolicyComponent
return delegate; return delegate;
} }
@Override
public void removeClassDefinition(BehaviourDefinition<ClassBehaviourBinding> definition)
{
getClassBehaviourIndex(definition.getPolicy()).removeClassBehaviour(definition);
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.alfresco.repo.policy.PolicyComponent#registerPropertyPolicy(java.lang.Class) * @see org.alfresco.repo.policy.PolicyComponent#registerPropertyPolicy(java.lang.Class)