use of com.opensymphony.xwork2.Action in project entando-core by entando.
the class TestContentGroupAction method testInsertOnLineContents_1.
public void testInsertOnLineContents_1() throws Throwable {
this.setUserOnSession("admin");
// CONTENUTI FREE
String[] masterContentIds = { "ART111", "EVN20" };
String[] newContentIds = null;
try {
newContentIds = this.addDraftContentsForTest(masterContentIds, false);
for (int i = 0; i < newContentIds.length; i++) {
Content content = this.getContentManager().loadContent(newContentIds[i], false);
assertFalse(content.isOnLine());
}
this.initAction("/do/jacms/Content", "approveContentGroup");
this.addParameter("contentIds", newContentIds);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
for (int i = 0; i < newContentIds.length; i++) {
Content content = this.getContentManager().loadContent(newContentIds[i], false);
assertTrue(content.isOnLine());
}
ActionSupport action = this.getAction();
Collection<String> messages = action.getActionMessages();
assertEquals(1, messages.size());
} catch (Throwable t) {
throw t;
} finally {
this.deleteContents(newContentIds);
}
}
use of com.opensymphony.xwork2.Action in project entando-core by entando.
the class TestIntroNewContentAction method testCreateNewVoid_2.
public void testCreateNewVoid_2() throws Throwable {
this.initAction("/do/jacms/Content", "createNewVoid");
this.setUserOnSession("admin");
String result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
Map<String, List<String>> fieldErros = action.getFieldErrors();
assertEquals(3, fieldErros.size());
}
use of com.opensymphony.xwork2.Action in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionService method internalProcessActions.
protected Field internalProcessActions(Actions actions, Object sourceObject, FieldType targetType) throws AtlasException {
Field processedField = new SimpleField();
processedField.setValue(sourceObject);
processedField.setFieldType(targetType);
if (FieldType.COMPLEX.equals(targetType)) {
return processedField;
}
Object tmpSourceObject = sourceObject;
FieldType sourceType = (sourceObject != null ? getConversionService().fieldTypeFromClass(sourceObject.getClass()) : FieldType.NONE);
if (actions == null || actions.getActions() == null || actions.getActions().isEmpty()) {
if (sourceObject == null) {
return processedField;
}
processedField.setValue(getConversionService().convertType(sourceObject, sourceType, targetType));
processedField.setFieldType(targetType);
return processedField;
}
FieldType currentType = sourceType;
for (Action action : actions.getActions()) {
ActionDetail detail = findActionDetail(action.getDisplayName(), currentType);
if (!detail.getSourceType().equals(currentType) && !FieldType.ANY.equals(detail.getSourceType())) {
tmpSourceObject = getConversionService().convertType(sourceObject, currentType, detail.getSourceType());
}
processedField.setValue(processAction(action, detail, tmpSourceObject));
processedField.setFieldType(detail.getTargetType());
currentType = detail.getTargetType();
}
return processedField;
}
use of com.opensymphony.xwork2.Action in project weicoder by wdcode.
the class StrutsAction method getAction.
/**
* 获得当前Action
* @param <E> 泛型
* @return Action
*/
@SuppressWarnings("unchecked")
public <E extends Action> E getAction() {
// 获得值栈里的对象
Object action = ActionContext.getContext().getValueStack().peek();
// 判断对象是Action类型的
if (action instanceof Action) {
// 返回Action
return (E) action;
}
// 获得Action拦截器
ActionInvocation ai = ActionContext.getContext().getActionInvocation();
// 如果拦截器不为空
if (ai != null) {
return (E) ai.getAction();
}
// 如果都不符合返回null
return null;
}
use of com.opensymphony.xwork2.Action in project entando-core by entando.
the class TestCustomTokenInterceptor method testExecuteValidation_1.
public void testExecuteValidation_1() throws Exception {
ActionInvocation invocation = this.prepareAction();
CustomTokenInterceptor interceptor = new CustomTokenInterceptor();
String result = interceptor.intercept(invocation);
assertEquals(Action.SUCCESS, result);
String newResult = interceptor.intercept(invocation);
assertEquals(CustomTokenInterceptor.INVALID_TOKEN_CODE, newResult);
ActionSupport action = super.getAction();
assertEquals(0, action.getActionErrors().size());
assertEquals(0, action.getActionMessages().size());
}
Aggregations