diff --git a/config/alfresco/replication-services-context.xml b/config/alfresco/replication-services-context.xml index 5a332d646a..73a9ce3b55 100644 --- a/config/alfresco/replication-services-context.xml +++ b/config/alfresco/replication-services-context.xml @@ -3,8 +3,26 @@ - + + + + + true + + + + + + + + + org.alfresco.repo.replication.ReplicationParams + + + + + org.alfresco.service.cmr.replication.ReplicationService @@ -40,20 +58,19 @@ class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" /> - + - + - - - - + + + + - @@ -71,7 +88,7 @@ - + diff --git a/config/alfresco/subsystems/Replication/default/replication-context.xml b/config/alfresco/subsystems/Replication/default/replication-context.xml new file mode 100644 index 0000000000..5056a4a369 --- /dev/null +++ b/config/alfresco/subsystems/Replication/default/replication-context.xml @@ -0,0 +1,12 @@ + + + + + + + + ${replication.transfer.readonly} + + + + diff --git a/config/alfresco/subsystems/Replication/default/replication.properties b/config/alfresco/subsystems/Replication/default/replication.properties new file mode 100644 index 0000000000..2609979fc7 --- /dev/null +++ b/config/alfresco/subsystems/Replication/default/replication.properties @@ -0,0 +1 @@ +replication.transfer.readonly=true diff --git a/source/java/org/alfresco/repo/replication/ReplicationActionExecutor.java b/source/java/org/alfresco/repo/replication/ReplicationActionExecutor.java index aa2d233b2a..8ecdcf7da3 100644 --- a/source/java/org/alfresco/repo/replication/ReplicationActionExecutor.java +++ b/source/java/org/alfresco/repo/replication/ReplicationActionExecutor.java @@ -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 diff --git a/source/java/org/alfresco/repo/replication/ReplicationParams.java b/source/java/org/alfresco/repo/replication/ReplicationParams.java new file mode 100644 index 0000000000..2a9dfcb40d --- /dev/null +++ b/source/java/org/alfresco/repo/replication/ReplicationParams.java @@ -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 . + */ +package org.alfresco.repo.replication; + + +/** + * An interface for retrieving configurable replication parameters. + */ +public interface ReplicationParams +{ + + /** + * Lock replicated items in target repository + * + * @return true lock replication items + */ + public boolean getTransferReadOnly(); +} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/replication/ReplicationParamsImpl.java b/source/java/org/alfresco/repo/replication/ReplicationParamsImpl.java new file mode 100644 index 0000000000..83c9b139fd --- /dev/null +++ b/source/java/org/alfresco/repo/replication/ReplicationParamsImpl.java @@ -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 . + */ +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 true 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; + } +} diff --git a/source/java/org/alfresco/repo/replication/ReplicationServiceIntegrationTest.java b/source/java/org/alfresco/repo/replication/ReplicationServiceIntegrationTest.java index 952462aab4..75b75d717e 100644 --- a/source/java/org/alfresco/repo/replication/ReplicationServiceIntegrationTest.java +++ b/source/java/org/alfresco/repo/replication/ReplicationServiceIntegrationTest.java @@ -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));