Package com.dotmarketing.portlets.workflows.model

Examples of com.dotmarketing.portlets.workflows.model.WorkflowAction


  }

  public WorkflowAction findAction(String id, User user) throws DotDataException, DotSecurityException {

    WorkflowAction action = wfac.findAction(id);
    if (!APILocator.getPermissionAPI().doesUserHavePermission(action, PermissionAPI.PERMISSION_USE, user, true)) {
      throw new DotSecurityException("User " + user + " cannot read action " + action.getName());
    }
    return action;
  }
View Full Code Here


  }

  public void reorderActionClass(WorkflowActionClass actionClass, int order) throws DotDataException {

    try {
      WorkflowAction baseAction = findAction(actionClass.getActionId(), APILocator.getUserAPI().getSystemUser());
      List<WorkflowActionClass> actionClasses = null;
      try {
        actionClasses = findActionClasses(baseAction);
      } catch (Exception e) {
        throw new DotDataException(e.getLocalizedMessage());
View Full Code Here

        entryStep = wfStep;
      if(wfStep.getMyOrder() < entryStep.getMyOrder())
        entryStep = wfStep;
    }

    WorkflowAction entryAction = null;
    List<WorkflowAction> wfActions = findActions(entryStep, user);

    for(WorkflowAction wfAction : wfActions){
      if(!UtilMethods.isSet(entryAction))
        entryAction = wfAction;
      if(wfAction.getOrder() < entryAction.getOrder())
        entryAction = wfAction;
    }

    if (!APILocator.getPermissionAPI().doesUserHavePermission(entryAction, PermissionAPI.PERMISSION_USE, user, true)) {
      throw new DotSecurityException("User " + user + " cannot read action " + entryAction.getName());
    }
    return entryAction;
  }
View Full Code Here

    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);
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.workflows.model.WorkflowAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.