org.springframework.webflow.engine.Flow.getState()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.springframework.webflow.engine.Flow.getState()方法的一些代码示例,展示了Flow.getState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flow.getState()方法的具体详情如下:
包路径:org.springframework.webflow.engine.Flow
类名称:Flow
方法名:getState

Flow.getState介绍

[英]Returns the number of states defined in this flow.
[中]返回此流中定义的状态数。

代码示例

代码示例来源:origin: org.apereo.cas/cas-server-support-actions-aup-webflow

private void createTransitionStateToAcceptableUsagePolicy(final Flow flow) {
  final ActionState submit = (ActionState) flow.getState(CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
  createTransitionForState(submit, CasWebflowConstants.TRANSITION_ID_SUCCESS, STATE_ID_AUP_CHECK, true);
}

代码示例来源:origin: org.apereo.cas/cas-server-support-reports

Arrays.stream(def.getStateIds()).forEach(st -> {
  val state = (State) def.getState(st);
  val stateMap = new LinkedHashMap<String, Object>();

代码示例来源:origin: spring-projects/spring-webflow

public void testAddStates() {
  Flow flow = new Flow("myFlow");
  new EndState(flow, "myState1");
  new EndState(flow, "myState2");
  assertEquals("Wrong start state:", "myState1", flow.getStartState().getId());
  assertEquals("State count wrong:", 2, flow.getStateCount());
  assertTrue(flow.containsState("myState1"));
  assertTrue(flow.containsState("myState2"));
  State state = flow.getStateInstance("myState1");
  assertEquals("Wrong flow:", flow.getId(), state.getFlow().getId());
  assertEquals("Wrong state:", "myState1", flow.getState("myState1").getId());
  assertEquals("Wrong state:", "myState2", flow.getState("myState2").getId());
}

代码示例来源:origin: org.apereo.cas/cas-server-core-webflow-api

/**
 * Gets state.
 *
 * @param <T>     the type parameter
 * @param flow    the flow
 * @param stateId the state id
 * @param clazz   the clazz
 * @return the state
 */
public <T> T getState(final Flow flow, final String stateId, final Class<T> clazz) {
  if (containsFlowState(flow, stateId)) {
    val state = flow.getState(stateId);
    return clazz.cast(state);
  }
  return null;
}

代码示例来源:origin: spring-projects/spring-webflow

public void testGetStateNoSuchState() {
  try {
    flow.getState("myState3");
    fail("Returned a state that doesn't exist");
  } catch (IllegalArgumentException e) {
    // expected
  }
}

代码示例来源:origin: net.unicon/cas-mfa-java

/**
 * Add on entry action to service check state.
 *
 * @param flow the flow
 */
protected void addOnEntryActionToServiceCheckState(final Flow flow) {
  final DecisionState state = (DecisionState) flow.getState(STATE_DEFINITION_ID_SERVICE_CHECK);
  final EvaluateAction action = createEvaluateAction("removeHostnameServiceInContextAction");
  state.getEntryActionList().add(action);
  LOGGER.debug("Set on-entry action for decision state {}", state.getId());
}
/**

代码示例来源:origin: kawhii/sso

/**
   * 绑定输入信息
   *
   * @param flow
   */
  protected void bindCredential(Flow flow) {
    //重写绑定自定义credential
    createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, UsernamePasswordSysCredential.class);
    //登录页绑定新参数
    final ViewState state = (ViewState) flow.getState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);
    final BinderConfiguration cfg = getViewStateBinderConfiguration(state);
    //由于用户名以及密码已经绑定,所以只需对新加系统参数绑定即可
    cfg.addBinding(new BinderConfiguration.Binding("system", null, false));
  }
}

代码示例来源:origin: net.unicon/cas-mfa-java

/**
 * Add multi factor outcome transitions to submission action state.
 *
 * @param flow the flow
 * @param flowIds the flow ids
 */
protected void addMultiFactorOutcomeTransitionsToSubmissionActionState(final Flow flow, final String[] flowIds) {
  final ActionState actionState = (ActionState) flow.getState(STATE_DEFINITION_ID_REAL_SUBMIT);
  LOGGER.debug("Retrieved action state {}", actionState.getId());
  final Action existingAction = actionState.getActionList().get(0);
  actionState.getActionList().remove(existingAction);
  final EvaluateAction action = createEvaluateAction("initiatingAuthenticationViaFormAction");
  actionState.getActionList().add(action);
  LOGGER.debug("Set action {} for action state {}", actionState.getId());
  for (final String flowId : flowIds) {
    addTransitionToActionState(actionState, flowId, flowId);
  }
}

代码示例来源:origin: kawhii/sso

/**
 * 登录校验流程
 */
private void createLoginValidateValidateFlow() {
  final Flow flow = getLoginFlow();
  if (flow != null) {
    final ActionState state = (ActionState) flow.getState(CasWebflowConstants.TRANSITION_ID_REAL_SUBMIT);
    final List<Action> currentActions = new ArrayList<>();
    state.getActionList().forEach(currentActions::add);
    currentActions.forEach(a -> state.getActionList().remove(a));
    state.getActionList().add(createEvaluateAction("validateLoginCaptchaAction"));
    currentActions.forEach(a -> state.getActionList().add(a));
    state.getTransitionSet().add(createTransition("captchaError", CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
  }
}

代码示例来源:origin: kawhii/sso

/**
   * 发送邮箱前输入验证码流程
   */
  private void createPasswordResetValidateFlow() {
    final Flow flow = getLoginFlow();
    if (flow != null) {
      ViewState accountInfo = (ViewState) flow.getState(CasWebflowConstants.VIEW_ID_SEND_RESET_PASSWORD_ACCT_INFO);
      //提交查找用户后,先校验验证码
      createTransitionForState(accountInfo, "findAccount", VALIDATE_CAPTCHA_ACTION, true);
      //校验图片动作
      ActionState actionState = createActionState(flow, VALIDATE_CAPTCHA_ACTION, createEvaluateAction(VALIDATE_CAPTCHA_ACTION));
      //失败重新是发送页
      createTransitionForState(actionState, CasWebflowConstants.TRANSITION_ID_RESET_PASSWORD,
          CasWebflowConstants.VIEW_ID_SEND_RESET_PASSWORD_ACCT_INFO);
      //发送邮件
      createTransitionForState(actionState, "sendInstructions", "sendInstructions");
    }
  }
}

代码示例来源:origin: net.unicon/cas-mfa-java

/**
 * Create multi factor parent subflow state definitions.
 *
 * @param flow the flow
 * @param id the id
 */
protected void createMultiFactorParentSubflowStateDefinitions(final Flow flow, final String id) {
  final EvaluateAction action = createEvaluateAction("generateMfaCredentialsAction");
  final SubflowState subflowState = createSubflowState(flow, id, id, action);
  final List<DefaultMapping> mappings = new ArrayList<>();
  mappings.add(createMappingToSubflowState("mfaCredentials", "flowScope.mfaCredentials", true,
      MultiFactorCredentials.class));
  mappings.add(createMappingToSubflowState("mfaService", "flowScope.service", true,
      MultiFactorAuthenticationSupportingWebApplicationService.class));
  final Mapper inputMapper = createMapperToSubflowState(mappings);
  final SubflowAttributeMapper subflowMapper = createSubflowAttributeMapper(inputMapper, null);
  subflowState.setAttributeMapper(subflowMapper);
  final ActionState actionState = (ActionState) flow.getState(STATE_DEFINITION_ID_REAL_SUBMIT);
  final String targettedStateId = actionState.getTransition(SUCCESS_EVENT_ID).getTargetStateId();
  subflowState.getTransitionSet().add(createTransition(MFA_SUCCESS_EVENT_ID, targettedStateId));
  subflowState.getTransitionSet().add(createTransition(UNKNOWN_PRINCIPAL_ERROR_EVENT_ID,
      "viewUnknownPrincipalErrorView"));
  subflowState.getTransitionSet().add(createTransition(MFA_UNRECOGNIZED_AUTHN_METHOD_ERROR_EVENT_ID,
      "viewMfaUnrecognizedAuthnMethodErrorView"));
}

代码示例来源:origin: spring-projects/spring-webflow

public void testGetTransitionableState() {
  assertEquals("Wrong state:", "myState1", flow.getTransitionableState("myState1").getId());
  assertEquals("Wrong state:", "myState1", flow.getState("myState1").getId());
}

代码示例来源:origin: org.wicketstuff/spring-webflow-extras

@Override
public boolean isEnabled() {
  boolean transitionExistsForCurrentView = false;
  
  FlowDefinition flowDef = ((FlowExecutorImpl)PageFlowWebApplication.get().getFlowExecutor()).getDefinitionLocator().getFlowDefinition(PageFlowWebApplication.get().getFlowId());
  
  // Retrieve the flow instance for the input view state
  Flow flow = (Flow)flowDef;
  StateDefinition currState = flow.getState(PageFlowSession.get().getFlowState().getCurrentViewStateId());
  TransitionableState transitionState = null;
  if(currState instanceof TransitionableState){
    transitionState = (TransitionableState)currState;
  } else {
    //End states aren't transitional and so none of the links should be enabled
    return false;
  }
  
  if(transitionState.getTransition(getEventId()) != null || flow.getGlobalTransition(getEventId()) != null){
    transitionExistsForCurrentView = true;
  }
  
  return transitionExistsForCurrentView;
}

代码示例来源:origin: spring-projects/spring-webflow

public void testFlowSecuredState() {
  EndStateModel end = new EndStateModel("end");
  end.setSecured(new SecuredModel("ROLE_USER"));
  model.setStates(asList(end));
  Flow flow = getFlow(model);
  SecurityRule rule = (SecurityRule) flow.getState("end").getAttributes()
      .get(SecurityRule.SECURITY_ATTRIBUTE_NAME);
  assertNotNull(rule);
  assertEquals(SecurityRule.COMPARISON_ANY, rule.getComparisonType());
  assertEquals(1, rule.getAttributes().size());
  assertTrue(rule.getAttributes().contains("ROLE_USER"));
}

代码示例来源:origin: spring-projects/spring-webflow

assertSame(flowExecution.getFlowSessions().get(0).getDefinition(), flowDefinition);
assertSame(flowExecution.getFlowSessions().get(0).getDefinition().getState("end"),
    flowDefinition.getState("end"));
assertSame(flowExecution.getFlowSessions().get(1).getDefinition(), locator.child);
assertSame(flowExecution.getFlowSessions().get(1).getDefinition().getState("state"),
    locator.child.getState("state"));

相关文章