com.opensymphony.xwork2.ActionSupport Java Examples

The following examples show how to use com.opensymphony.xwork2.ActionSupport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageSettingsActionAspect.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
private boolean checkPath(String alternativePath, ActionSupport action) {
    File file = new File(alternativePath);
    if (file.exists()) {
        if (!file.canRead() || !file.canWrite()) {
            action.addFieldError(PARAM_ROBOT_ALTERNATIVE_PATH_CODE,
                    action.getText("jpseo.error.robotFilePath.file.requiredAuth", new String[]{alternativePath}));
            return false;
        }
    } else {
        File directory = file.getParentFile();
        if (!directory.exists()) {
            action.addFieldError(PARAM_ROBOT_ALTERNATIVE_PATH_CODE,
                    action.getText("jpseo.error.robotFilePath.directory.notExists", new String[]{directory.getAbsolutePath()}));
            return false;
        } else if (!directory.canRead() || !directory.canWrite()) {
            action.addFieldError(PARAM_ROBOT_ALTERNATIVE_PATH_CODE,
                    action.getText("jpseo.error.robotFilePath.directory.requiredAuth", new String[]{directory.getAbsolutePath()}));
            return false;
        }
    }
    return true;
}
 
Example #2
Source File: TestPageModelAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testValidate_1() throws Throwable {
    String testPageModelCode = "test_pagemodel";
    assertNull(this._pageModelManager.getPageModel(testPageModelCode));
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/PageModel", "save");
        super.addParameter("code", testPageModelCode);
        super.addParameter("strutsAction", ApsAdminSystemConstants.ADD);
        String result = this.executeAction();
        ActionSupport action = super.getAction();
        assertEquals(Action.INPUT, result);
        assertEquals(3, action.getFieldErrors().size());
        assertNotNull(action.getFieldErrors().get("description"));
        assertNotNull(action.getFieldErrors().get("template"));
        assertNotNull(action.getFieldErrors().get("xmlConfiguration"));
    } catch (Exception e) {
        this._pageModelManager.deletePageModel(testPageModelCode);
        assertNull(this._pageModelManager.getPageModel(testPageModelCode));
        throw e;
    }
}
 
Example #3
Source File: TestPageModelAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testValidate_2() throws Throwable {
    String testPageModelCode = "internal";
    PageModel model = this._pageModelManager.getPageModel(testPageModelCode);
    assertNotNull(model);
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/PageModel", "save");
        super.addParameter("code", testPageModelCode);
        super.addParameter("description", "Description");
        super.addParameter("strutsAction", ApsAdminSystemConstants.ADD);
        String result = this.executeAction();
        ActionSupport action = super.getAction();
        assertEquals(Action.INPUT, result);
        assertEquals(3, action.getFieldErrors().size());
        assertNotNull(action.getFieldErrors().get("code"));
        assertNotNull(action.getFieldErrors().get("template"));
        assertNotNull(action.getFieldErrors().get("xmlConfiguration"));
    } catch (Exception e) {
        this._pageModelManager.updatePageModel(model);
        throw e;
    }
}
 
Example #4
Source File: ContentActionHelperAspect.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void checkFriendlyCodes(IApsEntity entity, ActionSupport action) {
	if (null == entity) {
		_logger.error("Invocazione di scansione/salvataggio contenuto nullo");
		return;
	}
	AttributeInterface attribute = entity.getAttributeByRole(JpseoSystemConstants.ATTRIBUTE_ROLE_FRIENDLY_CODE);
	if (null != attribute && attribute instanceof ITextAttribute) {
		String contentId = entity.getId();
		String msgPrefix = action.getText("EntityAttribute.singleAttribute.errorMessage.prefix", new String[] { attribute.getName() });
		ITextAttribute textAttr = (ITextAttribute) attribute;
		if (attribute.isMultilingual()) {
			String attributeName = attribute.getName();
			Iterator<Lang> langs = this.getLangManager().getLangs().iterator();
			while (langs.hasNext()) {
				Lang currentLang = langs.next();
				this.checkFriendlyCode(textAttr.getTextForLang(currentLang.getCode()), currentLang, attributeName, msgPrefix, contentId, action);
			}
		} else {
			this.checkFriendlyCode(textAttr.getText(), null, attribute.getName(), msgPrefix, contentId, action);
		}
	}
}
 
Example #5
Source File: TestWidgetTypeAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureTrashType_2() throws Throwable {
    String widgetTypeCode = "test_widgetType_trash2";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    try {
        WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
        type.setLocked(true);
        this._widgetTypeManager.addWidgetType(type);
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        String result = this.executeTrash(widgetTypeCode, "admin");
        assertEquals("inputWidgetTypes", result);
        ActionSupport action = this.getAction();
        assertEquals(1, action.getActionErrors().size());
        assertNotNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
            this._mockWidgetTypeDAO.deleteWidgetType(widgetTypeCode);
        }
        ((IManager) this._widgetTypeManager).refresh();
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    }
}
 
Example #6
Source File: TestNavigatorWidgetConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureAddExpression_1() throws Throwable {
	Map<String, String> params = new HashMap<String, String>();
	params.put("pageCode", "pagina_2");
	params.put("frame", "3");
	params.put("widgetTypeCode", "leftmenu");
	params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
	String result = this.executeAddExpression("admin", params);
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErrors = action.getFieldErrors();
	assertEquals(1, fieldErrors.size());
	assertEquals(1, fieldErrors.get("specId").size());

	NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
	Widget widget = navAction.getWidget();
	assertNotNull(widget);
	ApsProperties props = widget.getConfig();
	assertEquals(0, props.size());
	assertEquals("parent.subtree(2)+abs(1).subtree(2)+current", navAction.getNavSpec());
	assertEquals(3, navAction.getExpressions().size());
}
 
Example #7
Source File: TestNavigatorWidgetConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureAddExpression_2() throws Throwable {
	Map<String, String> params = new HashMap<String, String>();
	params.put("pageCode", "pagina_2");
	params.put("frame", "3");
	params.put("widgetTypeCode", "leftmenu");
	params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
	params.put("specId", "3");
	params.put("specSuperLevel", "-2");
	String result = this.executeAddExpression("admin", params);
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	assertEquals(1, action.getActionErrors().size());

	NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
	Widget widget = navAction.getWidget();
	assertNotNull(widget);
	ApsProperties props = widget.getConfig();
	assertEquals(0, props.size());
	assertEquals("parent.subtree(2)+abs(1).subtree(2)+current", navAction.getNavSpec());
	assertEquals(3, navAction.getExpressions().size());
}
 
Example #8
Source File: TestNavigatorWidgetConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureAddExpression_3() throws Throwable {
	Map<String, String> params = new HashMap<String, String>();
	params.put("pageCode", "pagina_2");
	params.put("frame", "3");
	params.put("widgetTypeCode", "leftmenu");
	params.put("navSpec", "parent.subtree(2)+current");
	params.put("specId", "4");
	params.put("specAbsLevel", "-1");
	String result = this.executeAddExpression("admin", params);
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	assertEquals(1, action.getActionErrors().size());

	NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
	Widget widget = navAction.getWidget();
	assertNotNull(widget);
	ApsProperties props = widget.getConfig();
	assertEquals(0, props.size());
	assertEquals("parent.subtree(2)+current", navAction.getNavSpec());
	assertEquals(2, navAction.getExpressions().size());
}
 
Example #9
Source File: ContentActionHelperAspect.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void checkFriendlyCode(String text, Lang currentLang, String attributeName, String msgPrefix, String contentId, ActionSupport action) {
	String friendlyCode = FriendlyCodeGenerator.generateFriendlyCode(text);
	if (null != friendlyCode) {
		FriendlyCodeVO fcVO = this.getSeoMappingManager().getReference(friendlyCode);
		if (null != fcVO && (contentId==null || !contentId.equals(fcVO.getContentId()))) {
			String errorMsg = null;
			if (currentLang == null) {
				errorMsg = action.getText("jpseo.error.content.friendlyCode.alreadyInUse", new String[] { friendlyCode });
			} else {
				errorMsg = action.getText("jpseo.error.content.friendlyCodeForLang.alreadyInUse", new String[] { friendlyCode, currentLang.getDescr() });
			}
			String fcUtilizer = null;
			if (fcVO.getPageCode() != null) {
				fcUtilizer = action.getText("jpseo.error.content.friendlyCode.utilizer.page", new String[] { fcVO.getPageCode() });
			} else {
				fcUtilizer = action.getText("jpseo.error.content.friendlyCode.utilizer.content", new String[] { fcVO.getContentId() });
			}
			action.addFieldError(attributeName, msgPrefix + " " + errorMsg + " " + fcUtilizer);
		}
	}
}
 
Example #10
Source File: LinkAttributeManager.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    String errorCode = attributeFieldError.getErrorCode();
    String messageKey = null;
    if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_PAGE)) {
        messageKey = "LinkAttribute.fieldError.linkToPage";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.VOID_PAGE)) {
        messageKey = "LinkAttribute.fieldError.linkToPage.voidPage";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_CONTENT)) {
        messageKey = "LinkAttribute.fieldError.linkToContent";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_PAGE_GROUPS)) {
        messageKey = "LinkAttribute.fieldError.linkToPage.wrongGroups";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS)) {
        messageKey = "LinkAttribute.fieldError.linkToContent.wrongGroups";
    }
    if (null != messageKey) {
        return action.getText(messageKey);
    } else {
        return super.getCustomAttributeErrorMessage(attributeFieldError, action);
    }
}
 
Example #11
Source File: TestMultipleResourceAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSaveNewResource_2() throws Throwable {
    String insertedDescr = "Description ";
    while (insertedDescr.length() < 300) {
        insertedDescr += insertedDescr;
    }
    this.setUserOnSession("admin");
    this.initAction("/do/jacms/Resource", "save");
    this.addParameter("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
    this.addParameter("descr_0", insertedDescr);
    this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
    String result = this.executeAction();
    assertEquals(Action.INPUT, result);
    ActionSupport action = this.getAction();
    Map<String, List<String>> actionFieldErrors = action.getFieldErrors();
    assertEquals(5, actionFieldErrors.size());
    assertEquals(1, actionFieldErrors.get("resourceTypeCode").size());

}
 
Example #12
Source File: HypertextAttributeManager.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    String errorCode = attributeFieldError.getErrorCode();
    String messageKey = null;
    if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_PAGE)) {
        messageKey = "HypertextAttribute.fieldError.linkToPage";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.VOID_PAGE)) {
        messageKey = "HypertextAttribute.fieldError.linkToPage.voidPage";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_CONTENT)) {
        messageKey = "HypertextAttribute.fieldError.linkToContent";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_PAGE_GROUPS)) {
        messageKey = "HypertextAttribute.fieldError.linkToPage.wrongGroups";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS)) {
        messageKey = "HypertextAttribute.fieldError.linkToContent.wrongGroups";
    }
    if (null != messageKey) {
        String[] args = {attributeFieldError.getTracer().getLang().getDescr()};
        return action.getText(messageKey, args);
    } else {
        return super.getCustomAttributeErrorMessage(attributeFieldError, action);
    }
}
 
Example #13
Source File: TestIntroNewContentAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testCreateNewVoid_5() throws Throwable {
	this.setUserOnSession("editorCustomers");
	this.initAction("/do/jacms/Content", "createNewVoid");
	this.addParameter("contentTypeCode", "ART");
	this.addParameter("contentDescription", "Description");
	this.addParameter("contentMainGroup", Group.FREE_GROUP_NAME);
	String result = this.executeAction();
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErros = action.getFieldErrors();
	assertEquals(1, fieldErros.size());
	assertEquals(1, fieldErros.get("contentMainGroup").size());

	this.initAction("/do/jacms/Content", "createNewVoid");
	this.addParameter("contentTypeCode", "ART");
	this.addParameter("contentDescription", "Description");
	this.addParameter("contentMainGroup", "customers");
	result = this.executeAction();
	assertEquals(Action.SUCCESS, result);
}
 
Example #14
Source File: TestContentGroupAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testDeleteContents_1() throws Throwable {
	this.setUserOnSession("admin");
	String[] masterContentIds = {"ART111", "EVN20"};//CONTENUTO FREE
	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", "deleteContentGroup");
		this.addParameter("contentIds", newContentIds);
		String result = this.executeAction();
		assertEquals(Action.SUCCESS, result);
		ActionSupport action = this.getAction();
		Collection<String> messages = action.getActionMessages();
		assertEquals(1, messages.size());
		Collection<String> errors = action.getActionErrors();
		assertEquals(0, errors.size());
	} catch (Throwable t) {
		throw t;
	} finally {
		this.deleteContents(newContentIds);
	}
}
 
Example #15
Source File: TestContentGroupAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSuspendContents_1() throws Throwable {
	this.setUserOnSession("admin");
	String[] masterContentIds = {"ART111", "EVN20"};//CONTENUTO FREE
	String[] newContentIds = null;
	try {
		newContentIds = this.addDraftContentsForTest(masterContentIds, true);
		for (int i=0; i<newContentIds.length; i++) {
			Content content = this.getContentManager().loadContent(newContentIds[i], false);
			assertTrue(content.isOnLine());
		}
		this.initAction("/do/jacms/Content", "suspendContentGroup");
		this.addParameter("contentIds", newContentIds);
		String result = this.executeAction();
		assertEquals(Action.SUCCESS, result);
		ActionSupport action = this.getAction();
		Collection<String> messages = action.getActionMessages();
		assertEquals(1, messages.size());
		Collection<String> errors = action.getActionErrors();
		assertEquals(0, errors.size());
	} catch (Throwable t) {
		throw t;
	} finally {
		this.deleteContents(newContentIds);
	}
}
 
Example #16
Source File: TestContentGroupAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testInsertOnLineContents_3() throws Throwable {
	this.setUserOnSession("admin");
	String[] masterContentIds = {"ART179"};//CONTENUTO FREE con errori di validazione
	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);
		ActionSupport action = this.getAction();
		Collection<String> messages = action.getActionMessages();
		assertEquals(0, messages.size());
		Collection<String> errors = action.getActionErrors();
		assertEquals(1, errors.size());
	} catch (Throwable t) {
		throw t;
	} finally {
		this.deleteContents(newContentIds);
	}
}
 
Example #17
Source File: TestPageAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSavePage() throws Throwable {
    String pageCode = "customer_subpage_2";
    IPage page = this.pageManager.getDraftPage(pageCode);
    assertNotNull(page);
    try {
        this.prepareTestSaveEditPage(page, "management", "");
        String result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        assertEquals(3, action.getFieldErrors().size());
        assertEquals(1, action.getFieldErrors().get("group").size());
        assertEquals(1, action.getFieldErrors().get("langit").size());
        assertEquals(1, action.getFieldErrors().get("extraGroups").size());
    } catch (Throwable t) {
        this.pageManager.updatePage(page);
        throw t;
    }
}
 
Example #18
Source File: TestContentViewerWidgetAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void testSave_2(String contentId, String pageCode, int frame, String expectedResult) throws Throwable {
	try {
		this.intSaveViewerConfig(contentId, pageCode, frame);
		String result = this.executeAction();
		assertEquals(expectedResult, result);
		if (expectedResult.equals(Action.INPUT)) {
			ActionSupport action = this.getAction();
			assertEquals(1, action.getFieldErrors().size());
			assertEquals(1, action.getFieldErrors().get("contentId").size());
		}
	} catch (Throwable t) {
		throw t;
	} finally {
		IPage page = this._pageManager.getDraftPage(pageCode);
		page.getWidgets()[frame] = null;
		this._pageManager.updatePage(page);
	}
}
 
Example #19
Source File: TestTextAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureAddTextFilter() throws Throwable {
	Map<String, String> params = this.getBaseParams("NEW");
	params.put("filterKey", "Title");
	params.put("attributeFilter", "true");
	params.put("filterTypeId", String.valueOf(IContentListFilterAction.TEXT_ATTRIBUTE_FILTER_TYPE));//Tipo Stringa
	params.put("filterOptionId", String.valueOf(IContentListFilterAction.VALUE_FILTER_OPTION));//Opzione "Value"
	params.put("stringValue", "");
	String result = this.executeAddFilter("admin", params, "saveTextFilter");
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> stringValueErrors = fieldsErrors.get("stringValue");
	assertEquals(1, stringValueErrors.size());
}
 
Example #20
Source File: TestMultipleResourceAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSaveNewResourceMultipleResourceValidation() throws Throwable {
    this.setUserOnSession("admin");
    this.initAction("/do/jacms/Resource", "save");
    this.addParameter("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
    this.addParameter("resourceTypeCode", "Image");
    this.addParameter("mainGroup", "test");
    this.addParameter("descr_0", "test");
    String result = this.executeAction();
    ActionSupport action = this.getAction();
    Map<String, List<String>> actionFieldErrors = action.getFieldErrors();
    assertEquals(Action.INPUT, result);
    assertEquals(3, actionFieldErrors.size());
    assertEquals(1, actionFieldErrors.get("fileUploadId_0").size());	        
    assertEquals(1, actionFieldErrors.get("fileUploadName_0").size());
    assertEquals(1, actionFieldErrors.get("fileUploadContentType_0").size());        
}
 
Example #21
Source File: TestContentViewerWidgetAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureJoinContent_1() throws Throwable {
	String result = this.executeJoinContent("admin", "pagina_11", "1", null);//ID Nullo
	assertEquals(Action.INPUT, result);

	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErrors = action.getFieldErrors();
	assertEquals(1, fieldErrors.size());
	List<String> contentIdFieldErrors = fieldErrors.get("contentId");
	assertEquals(1, contentIdFieldErrors.size());
}
 
Example #22
Source File: TestContentAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testValidate_2() throws Throwable {
    String insertedDescr = "XXX Prova Validazione XXX";
    try {
        Content contentForTest = this.getContentManager().loadContent("EVN191", true);
        String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(contentForTest, ApsAdminSystemConstants.EDIT);
        contentForTest.setId(null);
        contentForTest.setDescription(insertedDescr);
        contentForTest.setMainGroup("coach");//Valorizzo il gruppo proprietario

        contentForTest.getGroups().add("customers");

        //AGGIUNGO LINK SU PAGINA COACH
        MonoListAttribute linksCorrelati = (MonoListAttribute) contentForTest.getAttribute("LinkCorrelati");
        LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
        linkAttribute.setText("Descrizione link", "it");
        SymbolicLink symbolicLink = new SymbolicLink();
        symbolicLink.setDestinationToContent("EVN103");//Contenuto di coach
        linkAttribute.setSymbolicLink(symbolicLink);

        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, contentForTest);

        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        String result = this.executeAction();
        assertEquals(Action.INPUT, result);

        ActionSupport action = this.getAction();
        assertEquals(1, action.getFieldErrors().size());
        assertEquals(1, action.getFieldErrors().get("Monolist:Link:LinkCorrelati_0").size());

    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
 
Example #23
Source File: AbstractAttributeManager.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String getErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    try {
        String errorCode = attributeFieldError.getErrorCode();
        if (errorCode.equals(FieldError.MANDATORY)) {
            return action.getText(this.getRequiredAttributeMessage());
        } else if (errorCode.equals(AttributeFieldError.OGNL_VALIDATION)) {
            String message = attributeFieldError.getMessage();
            if (null != message && message.trim().length() > 0) {
                return message;
            }
            String label = null;
            String labelKey = attributeFieldError.getMessageKey();
            if (null != labelKey && labelKey.trim().length() > 0) {
                Lang currentLang = this.getLangManager().getDefaultLang();
                if (action instanceof BaseAction) {
                    currentLang = ((BaseAction) action).getCurrentLang();
                }
                label = this.getI18nManager().getLabel(labelKey, currentLang.getCode());
            }
            if (label != null) {
                return label;
            } else return this.getCustomAttributeErrorMessage(attributeFieldError, action);
        } else {
            return this.getCustomAttributeErrorMessage(attributeFieldError, action);
        }
    } catch (Throwable t) {
    	_logger.error("Error creating Error Message", t);
        throw new RuntimeException("Error creating Error Message", t);
    }
}
 
Example #24
Source File: TestContentViewerWidgetAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureJoinContent_3() throws Throwable {
	String result = this.executeJoinContent("admin", "pagina_11", "1", "ART122");//ID di contenuto non autorizzato
	assertEquals(Action.INPUT, result);

	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErrors = action.getFieldErrors();
	assertEquals(1, fieldErrors.size());
	List<String> contentIdFieldErrors = (List<String>) fieldErrors.get("contentId");
	assertEquals(1, contentIdFieldErrors.size());
}
 
Example #25
Source File: TestContentViewerWidgetAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureJoinContent_2() throws Throwable {
	String result = this.executeJoinContent("admin", "pagina_11", "1", "ART179");//ID di contenuto non pubblico
	assertEquals(Action.INPUT, result);

	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErrors = action.getFieldErrors();
	assertEquals(1, fieldErrors.size());
	List<String> contentIdFieldErrors = (List<String>) fieldErrors.get("contentId");
	assertEquals(1, contentIdFieldErrors.size());
}
 
Example #26
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddRangeDateFilter_1() throws Throwable {
	String result = this.executeSaveRangeDateFilter(IContentListFilterAction.INSERTED_DATE_FILTER, "", //Data Start inserita
			IContentListFilterAction.INSERTED_DATE_FILTER, "25/09/1972");// Data End Inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateStart");
	assertEquals(1, dateValueErrors.size());//required dateStart
}
 
Example #27
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddDateValueFilter_1() throws Throwable {
	String result = this.executeSaveValueDateFilter(IContentListFilterAction.NO_DATE_FILTER, "");//Opzione nessuna Data inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateValueType");
	assertEquals(1, dateValueErrors.size());
}
 
Example #28
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddDateValueFilter_2() throws Throwable {
	String result = this.executeSaveValueDateFilter(IContentListFilterAction.INSERTED_DATE_FILTER, "");//Opzione Data inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateValue");
	assertEquals(1, dateValueErrors.size());
}
 
Example #29
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddDateValueFilter_3() throws Throwable {
	String result = this.executeSaveValueDateFilter(IContentListFilterAction.INSERTED_DATE_FILTER, "wrongFormat");//Opzione Data inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateValue");
	assertEquals(2, dateValueErrors.size());//Errore in conversione e messaggio campo obbligatorio
}
 
Example #30
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddRangeDateFilter_3() throws Throwable {
	String result = this.executeSaveRangeDateFilter(IContentListFilterAction.INSERTED_DATE_FILTER, "25/09/1972", //Data Start inserita
			IContentListFilterAction.INSERTED_DATE_FILTER, "wrongFormat");// Data End Inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateEnd");
	assertEquals(2, dateValueErrors.size());//dateEnd Wrong Format and dateEnd required
}