A simple avm submit action. Takes no parameters and submits everything under and

including the actionedNodeRef passed into execute to the corresponding staging area.
Cosmetic change to more or less DOA WCM Submit workflow.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3877 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-21 21:44:09 +00:00
parent 26c799e268
commit dfd1e70dc5
4 changed files with 193 additions and 0 deletions

View File

@@ -394,4 +394,16 @@
</property> </property>
</bean> </bean>
<bean id="simple-avm-submit" class="org.alfresco.repo.avm.actions.SimpleAVMSubmitAction" parent="action-executer">
<property name="avmService">
<ref bean="avmService"/>
</property>
<property name="avmSyncService">
<ref bean="avmSyncService"/>
</property>
<property name="publicAction">
<value>false</value>
</property>
</bean>
</beans> </beans>

View File

@@ -84,3 +84,9 @@ execute-all-rules.description=Execute all rules on the child items.
start-workflow.title=Start Workflow start-workflow.title=Start Workflow
start-workflow.description=This will start a workflow for the matched items. start-workflow.description=This will start a workflow for the matched items.
# WCM Actions
simple-avm-submit.title=Simple Direct Submit
simple-avm-submit.description=This will submit any newer nodes in the matched item to the corresponding staging.

View File

@@ -31,6 +31,8 @@ import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ActionImpl;
import org.alfresco.repo.avm.actions.SimpleAVMSubmitAction;
import org.alfresco.repo.avm.util.BulkLoader; import org.alfresco.repo.avm.util.BulkLoader;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
@@ -59,6 +61,53 @@ import org.alfresco.service.transaction.TransactionService;
*/ */
public class AVMServiceTest extends AVMServiceTestBase public class AVMServiceTest extends AVMServiceTestBase
{ {
/**
* Test the SimpleAVMSubmitAction.
*/
public void testSubmitAction()
{
try
{
fService.createAVMStore("foo-staging");
fService.createDirectory("foo-staging:/", "layer");
fService.createDirectory("foo-staging:/layer", "a");
fService.createDirectory("foo-staging:/layer/a","b");
fService.createDirectory("foo-staging:/layer/a/b", "c");
fService.createFile("foo-staging:/layer/a/b/c", "foo").close();
fService.createFile("foo-staging:/layer/a/b/c", "bar").close();
fService.createAVMStore("area");
fService.setStoreProperty("area", QName.createQName(null, ".website.name"),
new PropertyValue(null, "foo"));
fService.createLayeredDirectory("foo-staging:/layer", "area:/", "layer");
fService.createFile("area:/layer", "figs").close();
fService.getFileOutputStream("area:/layer/a/b/c/foo").close();
fService.removeNode("area:/layer/a/b/c/bar");
List<AVMDifference> diffs =
fSyncService.compare(-1, "area:/layer", -1, "foo-staging:/layer");
assertEquals(3, diffs.size());
final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction)fContext.getBean("simple-avm-submit");
class TxnWork implements TransactionUtil.TransactionWork<Object>
{
public Object doWork() throws Exception
{
action.execute(null, AVMNodeConverter.ToNodeRef(-1, "area:/layer"));
return null;
}
};
TxnWork worker = new TxnWork();
TransactionUtil.executeInUserTransaction((TransactionService)fContext.getBean("transactionComponent"),
worker);
diffs =
fSyncService.compare(-1, "area:/layer", -1, "foo-staging:/layer");
assertEquals(0, diffs.size());
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/** /**
* Test one argument remove. * Test one argument remove.
*/ */

View File

@@ -0,0 +1,126 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm.actions;
import java.util.List;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
/**
* This action submits all the newer changes in the passed in NodeRef
* to its corresponding staging area. It ignores conflicts and older nodes.
* @author britt
*/
public class SimpleAVMSubmitAction extends ActionExecuterAbstractBase
{
private static Logger fgLogger = Logger.getLogger(SimpleAVMSubmitAction.class);
public static String NAME = "simple-avm-submit";
/**
* The AVMService instance.
*/
private AVMService fAVMService;
/**
* The AVMSyncService instance.
*/
private AVMSyncService fAVMSyncService;
/**
* Default constructor.
*/
public SimpleAVMSubmitAction()
{
super();
}
/**
* Set the AVMService.
* @param avmService The instance.
*/
public void setAvmService(AVMService avmService)
{
fAVMService = avmService;
}
/**
* Set the AVMSyncService.
* @param avmSyncService The instance.
*/
public void setAvmSyncService(AVMSyncService avmSyncService)
{
fAVMSyncService = avmSyncService;
}
/**
* Perform the action. The NodeRef must be an AVM NodeRef.
* @param action Don't actually need anything from this here.
* @param actionedUponNodeRef The AVM NodeRef.
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
// Crack the NodeRef.
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
int version = (Integer)avmVersionPath[0];
String path = (String)avmVersionPath[1];
// Get store name and path parts.
String [] storePath = path.split(":");
// Get the .website.name property.
PropertyValue wsProp =
fAVMService.getStoreProperty(storePath[0],
QName.createQName(null, ".website.name"));
if (wsProp == null)
{
fgLogger.warn(".website.name property not found.");
return;
}
// And the actual web-site name.
String websiteName = wsProp.getStringValue();
// Construct the submit destination path.
String avmDest = websiteName + "-staging:" + storePath[1];
// Get the difference between source and destination.
List<AVMDifference> diffs =
fAVMSyncService.compare(version, path, -1, avmDest);
// Do the update.
fAVMSyncService.update(diffs, true, true, false, false);
// Cleanup by flattening the source relative to the destination.
fAVMSyncService.flatten(path, avmDest);
}
/**
* This action takes no parameters.
* @param paramList The List to add nothing to.
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
// No parameters for this action.
}
}