baseURL+="&actionAssignToSelect="+role.getId()+"&actionNextStep="+step2.getId()+"&actionCondition=";
testUrl = new URL(baseURL);
IOUtils.toString(testUrl.openStream(),"UTF-8");
List<WorkflowAction> actions1= wapi.findActions(step1, systemUser);
Assert.assertTrue(actions1.size()==1);
WorkflowAction action1 = actions1.get(0);
/*
* Add action to scheme step2
*/
baseURL = "http://"+req.getServerName()+":"+req.getServerPort()+"/DotAjaxDirector/com.dotmarketing.portlets.workflows.business.TestableWfActionAjax?cmd=save&stepId="+step2.getId()+"&schemeId="+UtilMethods.webifyString(ws.getId())+"&actionName=Publish&whoCanUse=";
baseURL+=role.getId()+",&actionIconSelect=workflowIcon&actionAssignable=true&actionCommentable=true&actionRequiresCheckout=false&actionRoleHierarchyForAssign=false";
baseURL+="&actionAssignToSelect="+role.getId()+"&actionNextStep="+step2.getId()+"&actionCondition=";
testUrl = new URL(baseURL);
IOUtils.toString(testUrl.openStream(),"UTF-8");
List<WorkflowAction> actions2= wapi.findActions(step2, systemUser);
Assert.assertTrue(actions2.size()==1);
WorkflowAction action2 = actions2.get(0);
/*
* Create structure and add workflow scheme
*/
Structure st = StructureCache.getStructureByVelocityVarName("Issue5197Structure");
if(!UtilMethods.isSet(st) || !UtilMethods.isSet(st.getInode())){
st = new Structure();
st.setHost(host.getIdentifier());
st.setDescription("Testing issue 5197");
st.setName("Issue5197Structure");
st.setVelocityVarName("Issue5197Structure");
st.setStructureType(Structure.STRUCTURE_TYPE_CONTENT);
st.setFixed(false);
st.setOwner(systemUser.getUserId());
st.setExpireDateVar("");
st.setPublishDateVar("");
StructureFactory.saveStructure(st);
Permission p = new Permission();
p.setInode(st.getPermissionId());
p.setRoleId(roleAPI.loadCMSAnonymousRole().getId());
p.setPermission(PermissionAPI.PERMISSION_READ);
perAPI.save(p, st, systemUser, true);
p = new Permission();
p.setInode(st.getPermissionId());
p.setRoleId(roleAPI.loadCMSAnonymousRole().getId());
p.setPermission(PermissionAPI.PERMISSION_EDIT);
perAPI.save(p, st, systemUser, true);
p = new Permission();
p.setInode(st.getPermissionId());
p.setRoleId(roleAPI.loadCMSAnonymousRole().getId());
p.setPermission(PermissionAPI.PERMISSION_PUBLISH);
perAPI.save(p, st, systemUser, true);
Field title = new Field("Title",Field.FieldType.TEXT,Field.DataType.TEXT,st,true,true,true,1,"", "", "", false, false, true);
title.setVelocityVarName("title");
FieldFactory.saveField(title);
FieldsCache.addField(title);
}
APILocator.getWorkflowAPI().saveSchemeForStruct(st, ws);
/*
* Create test content and set it up in scheme step
*/
Contentlet contentlet1 = new Contentlet();
contentlet1.setStructureInode(st.getInode());
contentlet1.setHost(host.getIdentifier());
contentlet1.setLanguageId(APILocator.getLanguageAPI().getDefaultLanguage().getId());
contentlet1.setStringProperty("title", "test5197-1"+UtilMethods.dateToHTMLDate(new Date(), "MM-dd-yyyy-HHmmss"));
contentlet1.setHost(host.getIdentifier());
contentlet1 = APILocator.getContentletAPI().checkin(contentlet1, systemUser,false);
if(perAPI.doesUserHavePermission(contentlet1, PermissionAPI.PERMISSION_PUBLISH, systemUser))
APILocator.getVersionableAPI().setLive(contentlet1);
/*
* Test that delete is not possible for step2
* while has associated step or content
*/
contentlet1.setStringProperty("wfActionId", action1.getId());
contentlet1.setStringProperty("wfActionComments", "step1");
contentlet1.setStringProperty("wfActionAssign", role.getId());
wapi.fireWorkflowNoCheckin(contentlet1, systemUser);
contentlet1.setStringProperty("wfActionId", action2.getId());
contentlet1.setStringProperty("wfActionComments", "step2");
contentlet1.setStringProperty("wfActionAssign", role.getId());
wapi.fireWorkflowNoCheckin(contentlet1, systemUser);
WorkflowStep currentStep = wapi.findStepByContentlet(contentlet1);