use of org.springframework.webflow.action.ExternalRedirectAction in project cas by apereo.
the class AbstractCasWebflowConfigurer method createEndState.
@Override
public EndState createEndState(final Flow flow, final String id, final String viewId, final boolean redirect) {
if (!redirect) {
return createEndState(flow, id, viewId);
}
final Expression expression = createExpression(viewId, String.class);
final ActionExecutingViewFactory viewFactory = new ActionExecutingViewFactory(new ExternalRedirectAction(expression));
return createEndState(flow, id, viewFactory);
}
use of org.springframework.webflow.action.ExternalRedirectAction in project cas by apereo.
the class SpringWebflowEndpoint method getStateDetails.
private static Map<String, Object> getStateDetails(final Flow flowDefinition, final String st) {
val state = (State) flowDefinition.getState(st);
val stateMap = new LinkedHashMap<String, Object>();
if (!state.getAttributes().asMap().isEmpty()) {
stateMap.put("attributes", CollectionUtils.wrap(state.getAttributes()));
}
if (StringUtils.isNotBlank(state.getCaption())) {
stateMap.put("caption", state.getCaption());
}
var acts = StreamSupport.stream(state.getEntryActionList().spliterator(), false).map(SpringWebflowEndpoint::convertActionToString).collect(Collectors.toList());
if (!acts.isEmpty()) {
stateMap.put("entryActions", acts);
}
if (state instanceof ActionState) {
acts = StreamSupport.stream(((ActionState) state).getActionList().spliterator(), false).map(SpringWebflowEndpoint::convertActionToString).collect(Collectors.toList());
if (!acts.isEmpty()) {
stateMap.put("actionList", acts);
}
}
if (state instanceof EndState) {
stateMap.put("isEndState", Boolean.TRUE);
}
if (state.isViewState()) {
val viewState = (ViewState) state;
stateMap.put("isViewState", state.isViewState());
stateMap.put("isRedirect", viewState.getRedirect());
acts = StreamSupport.stream(state.getEntryActionList().spliterator(), false).map(Object::toString).collect(Collectors.toList());
if (!acts.isEmpty()) {
stateMap.put("renderActions", viewState.getRenderActionList());
}
acts = Arrays.stream(viewState.getVariables()).map(variable -> variable.getName() + " -> " + variable.getValueFactory().toString()).collect(Collectors.toList());
if (!acts.isEmpty()) {
stateMap.put("viewVariables", acts);
}
val field = ReflectionUtils.findField(viewState.getViewFactory().getClass(), "viewId");
if (field != null) {
ReflectionUtils.makeAccessible(field);
val exp = (Expression) ReflectionUtils.getField(field, viewState.getViewFactory());
stateMap.put("viewId", StringUtils.defaultIfBlank(Objects.requireNonNull(exp).getExpressionString(), exp.getValue(null).toString()));
} else if (viewState.getViewFactory() instanceof ActionExecutingViewFactory) {
val factory = (ActionExecutingViewFactory) viewState.getViewFactory();
if (factory.getAction() instanceof ExternalRedirectAction) {
val redirect = (ExternalRedirectAction) factory.getAction();
val uri = ReflectionUtils.findField(redirect.getClass(), "resourceUri");
ReflectionUtils.makeAccessible(Objects.requireNonNull(uri));
val exp = (Expression) ReflectionUtils.getField(uri, redirect);
stateMap.put("viewId", "externalRedirect -> #{" + Objects.requireNonNull(exp).getExpressionString() + '}');
} else {
stateMap.put("viewId", factory.getAction().toString());
}
} else {
LOGGER.info("Field viewId cannot be located on view state [{}]", state);
}
}
if (state instanceof TransitionableState) {
val stDef = (TransitionableState) state;
acts = StreamSupport.stream(stDef.getExitActionList().spliterator(), false).map(Object::toString).collect(Collectors.toList());
if (!acts.isEmpty()) {
stateMap.put("exitActions", acts);
}
acts = Arrays.stream(stDef.getTransitions()).map(tr -> tr.getId() + " -> " + tr.getTargetStateId()).collect(Collectors.toList());
if (!acts.isEmpty()) {
stateMap.put("transitions", acts);
}
}
return stateMap;
}
use of org.springframework.webflow.action.ExternalRedirectAction in project cas by apereo.
the class AbstractCasWebflowConfigurer method createEndState.
@Override
public EndState createEndState(final Flow flow, final String id, final String viewId, final boolean redirect) {
if (!redirect) {
return createEndState(flow, id, viewId);
}
final Expression expression = createExpression(viewId, String.class);
final ActionExecutingViewFactory viewFactory = new ActionExecutingViewFactory(new ExternalRedirectAction(expression));
return createEndState(flow, id, viewFactory);
}
Aggregations