Search in sources :

Example 56 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentAction method testValidate_3.

public void testValidate_3() throws Throwable {
    // Description maxlength
    String contentTypeCode = "ART";
    String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
    String marker = "__DESCR_TEST__";
    String insertedDescr = marker;
    while (insertedDescr.length() < 300) {
        insertedDescr += marker;
    }
    try {
        String result = this.executeCreateNewVoid(contentTypeCode, "descr", Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        assertEquals(Action.SUCCESS, result);
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("descr", insertedDescr);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErros = action.getFieldErrors();
        assertEquals(2, fieldErros.size());
        List<String> descrFieldsErrors = fieldErros.get("descr");
        assertEquals(1, descrFieldsErrors.size());
        List<String> titleFieldsErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleFieldsErrors.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 57 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentAction method testValidate_5.

public void testValidate_5() throws Throwable {
    String contentTypeCode = "RAH";
    String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
    String insertedDescr = "XXX Prova Validazione XXX";
    String shortTitle = "short";
    String longTitle = "Titolo che supera la lunghezza massima di cento caratteri; " + "Ripeto, Titolo che supera la lunghezza massima di cento caratteri";
    try {
        String result = this.executeCreateNewVoid(contentTypeCode, "descr", Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        assertEquals(Action.SUCCESS, result);
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", shortTitle);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        List<String> titleItFieldErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleItFieldErrors.size());
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", longTitle);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        action = this.getAction();
        fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        titleItFieldErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleItFieldErrors.size());
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", "Right Title length");
        this.addParameter("Text:en_Titolo", longTitle);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        action = this.getAction();
        fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        titleItFieldErrors = fieldErros.get("Text:en_Titolo");
        assertEquals(1, titleItFieldErrors.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 58 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentAction method testSaveNewContent.

public void testSaveNewContent() throws Throwable {
    String contentId = "ART1";
    Content master = this.getContentManager().loadContent(contentId, false);
    String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(master, ApsAdminSystemConstants.ADD);
    master.setId(null);
    String descr = "Contenuto di prova per testSave";
    try {
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, master);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("Text:it_Titolo", "");
        this.addParameter("descr", "");
        String result = this.executeAction();
        assertEquals(Action.INPUT, result);
        Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
        assertEquals(2, fieldErrors.size());
        assertEquals(1, fieldErrors.get("descr").size());
        assertEquals(1, fieldErrors.get("Text:it_Titolo").size());
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.addParameter("Text:it_Titolo", descr);
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(descr);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) List(java.util.List)

Example 59 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentAction method testSaveContentWithPageReference.

public void testSaveContentWithPageReference() throws Throwable {
    String contentId = "ART111";
    this.executeEdit(contentId, "admin");
    Content master = this.getContentManager().loadContent(contentId, false);
    String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(master, ApsAdminSystemConstants.EDIT);
    String groupToRemove = "customers";
    try {
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        assertEquals(2, contentOnSession.getGroups().size());
        assertTrue(contentOnSession.getGroups().contains(groupToRemove));
        this.initContentAction("/do/jacms/Content", "removeGroup", contentOnSessionMarker);
        this.addParameter("extraGroupName", groupToRemove);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        assertEquals(1, contentOnSession.getGroups().size());
        assertFalse(contentOnSession.getGroups().contains(groupToRemove));
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.addParameter("descr", master.getDescription());
        this.addParameter("mainGroup", master.getMainGroup());
        this.addParameter("descr", master.getDescription());
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErrors = action.getFieldErrors();
        assertEquals(1, fieldErrors.size());
        List<String> mainGroupFieldErrors = (List<String>) fieldErrors.get("mainGroup");
        assertEquals(2, mainGroupFieldErrors.size());
    } catch (Throwable t) {
        this.getContentManager().saveContent(master);
        throw t;
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 60 with Content

use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.

the class TestContentGroupAction method testSuspendContents_2.

public void testSuspendContents_2() throws Throwable {
    this.setUserOnSession("supervisorCoach");
    // 2 CONTENUTI FREE, 1 Customers e 1 Coach
    String[] masterContentIds = { "ART180", "EVN20", "ART104", "ART102" };
    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);
        int suspendedContents = 0;
        for (int i = 0; i < newContentIds.length; i++) {
            Content content = this.getContentManager().loadContent(newContentIds[i], false);
            if (!Group.FREE_GROUP_NAME.equals(content.getMainGroup())) {
                assertFalse(content.isOnLine());
                ++suspendedContents;
            } else {
                assertTrue(content.isOnLine());
            }
        }
        assertEquals(2, suspendedContents);
        ActionSupport action = this.getAction();
        Collection<String> messages = action.getActionMessages();
        assertEquals(1, messages.size());
        Collection<String> errors = action.getActionErrors();
        assertEquals(2, errors.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.deleteContents(newContentIds);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport)

Aggregations

Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)227 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)35 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)29 ArrayList (java.util.ArrayList)26 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 ActionSupport (com.opensymphony.xwork2.ActionSupport)14 List (java.util.List)14 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)13 HttpSession (javax.servlet.http.HttpSession)13 UserDetails (com.agiletec.aps.system.services.user.UserDetails)12 IPage (com.agiletec.aps.system.services.page.IPage)10 Date (java.util.Date)8 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)7 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)7 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)7 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)7 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)6 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6