Follow on for ALF-4748: Provide config flag to control if replicated content is read-only (locked) on target

- flag is now controlled via subsystem named 'Replication'
- property is named replication.transfer.readonly (value of true or false)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22581 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2010-09-16 11:29:31 +00:00
parent 0dba104f26
commit 15bd8754d9
7 changed files with 134 additions and 16 deletions

View File

@@ -3,8 +3,26 @@
<beans>
<!-- Replication Service -->
<!-- Replication global parameters (implemented as a subsystem) -->
<!-- NOTE: the replication service as a whole could be converted to a subsystem in the future) -->
<bean id="Replication" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
<property name="autoStart">
<value>true</value>
</property>
</bean>
<bean id="replicationParams" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Replication" />
</property>
<property name="interfaces">
<list>
<value>org.alfresco.repo.replication.ReplicationParams</value>
</list>
</property>
</bean>
<!-- Replication Service -->
<bean id="ReplicationService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>org.alfresco.service.cmr.replication.ReplicationService</value>
@@ -40,20 +58,19 @@
class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
<!-- Replication Service base bean -->
<bean id="replicationService" class="org.alfresco.repo.replication.ReplicationServiceImpl" >
<bean id="replicationService" class="org.alfresco.repo.replication.ReplicationServiceImpl" >
<property name="actionService" ref="ActionService"/>
<property name="scheduledPersistedActionService" ref="scheduledPersistedActionService" />
<property name="replicationDefinitionPersister" ref="replicationDefinitionPersister" />
</bean>
</bean>
<bean id="replicationDefinitionPersister" class="org.alfresco.repo.replication.ReplicationDefinitionPersisterImpl" >
<property name="runtimeActionService" ref="actionService" />
<property name="nodeService" ref="NodeService" />
</bean>
<bean id="replicationDefinitionPersister" class="org.alfresco.repo.replication.ReplicationDefinitionPersisterImpl" >
<property name="runtimeActionService" ref="actionService" />
<property name="nodeService" ref="NodeService" />
</bean>
<!-- Replication Action executor -->
<bean id="replicationActionExecutor" parent="action-executer"
class="org.alfresco.repo.replication.ReplicationActionExecutor">
<property name="publicAction">
@@ -71,7 +88,7 @@
<property name="actionTrackingService" ref="actionTrackingService" />
<property name="transactionService" ref="transactionService" />
<property name="replicationDefinitionPersister" ref="replicationDefinitionPersister" />
<property name="readOnly" value="true" />
<property name="replicationParams" ref="replicationParams" />
</bean>
<!-- JavaScript API support -->

View File

@@ -0,0 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="replicationParams" class="org.alfresco.repo.replication.ReplicationParamsImpl">
<property name="transferReadOnly">
<value>${replication.transfer.readonly}</value>
</property>
</bean>
</beans>

View File

@@ -0,0 +1 @@
replication.transfer.readonly=true

View File

@@ -69,7 +69,7 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
private ActionTrackingService actionTrackingService;
private TransactionService transactionService;
private ReplicationDefinitionPersisterImpl replicationDefinitionPersister;
private Boolean readOnly;
private ReplicationParams replicationParams;
/**
* By default, we lock for 30 minutes
@@ -136,13 +136,13 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
}
/**
* Sets transfer read only default value
* Sets Replication Parameters
*
* @param readOnly true => mark items in destination repository as read only
* @param replicationParams replication parameters
*/
public void setReadOnly(Boolean readOnly)
public void setReplicationParams(ReplicationParams replicationParams)
{
this.readOnly = readOnly;
this.replicationParams = replicationParams;
}
@Override
@@ -187,7 +187,7 @@ public class ReplicationActionExecutor extends ActionExecuterAbstractBase {
new TransferDefinition();
transferDefinition.setNodes(toTransfer);
transferDefinition.setSync(true);
transferDefinition.setReadOnly(readOnly == null ? true : readOnly);
transferDefinition.setReadOnly(replicationParams.getTransferReadOnly());
// Exclude aspects from transfer
// NOTE: this list of aspects should be synced up with the NodeCrawler in expandPayload to

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.replication;
/**
* An interface for retrieving configurable replication parameters.
*/
public interface ReplicationParams
{
/**
* Lock replicated items in target repository
*
* @return <code>true</code> lock replication items
*/
public boolean getTransferReadOnly();
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.replication;
/**
* Configurable system parameters.
*/
public class ReplicationParamsImpl implements ReplicationParams
{
/** Lock replication items? */
private boolean readOnly = true;
public ReplicationParamsImpl()
{
}
/**
* Sets whether to lock replicated items
*
* @param readOnly <code>true</code> lock replicated items in target repository
*/
public void setTransferReadOnly(boolean readOnly)
{
this.readOnly = readOnly;
}
/*
* (non-Javadoc)
* @see org.alfresco.repo.replication.ReplicationParams#getTransferReadOnly()
*/
public boolean getTransferReadOnly()
{
return this.readOnly;
}
}

View File

@@ -89,6 +89,7 @@ public class ReplicationServiceIntegrationTest extends TestCase
private ReplicationActionExecutor replicationActionExecutor;
private ReplicationService replicationService;
private ReplicationParams replicationParams;
private TransactionService transactionService;
private TransferService2 transferService;
private ContentService contentService;
@@ -129,6 +130,7 @@ public class ReplicationServiceIntegrationTest extends TestCase
{
replicationActionExecutor = (ReplicationActionExecutor) ctx.getBean("replicationActionExecutor");
replicationService = (ReplicationService) ctx.getBean("replicationService");
replicationParams = (ReplicationParams) ctx.getBean("replicationParams");
transactionService = (TransactionService) ctx.getBean("transactionService");
transferService = (TransferService2) ctx.getBean("transferService2");
contentService = (ContentService) ctx.getBean("contentService");
@@ -935,7 +937,7 @@ public class ReplicationServiceIntegrationTest extends TestCase
TransferDefinition td = replicationActionExecutor.buildTransferDefinition(rd, nodes);
assertEquals(true, td.isSync());
assertEquals(true, td.isReadOnly());
assertEquals(replicationParams.getTransferReadOnly(), td.isReadOnly());
assertEquals(2, td.getNodes().size());
assertEquals(true, td.getNodes().contains(folder1));
assertEquals(true, td.getNodes().contains(content1_1));