Search in sources :

Example 26 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class TestValidateDataObject method testValidate_4.

public void testValidate_4() throws Throwable {
    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 {
        DataObject content = this.createNewVoid("RAH", "descr", DataObject.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        ITextAttribute textAttribute = (ITextAttribute) content.getAttribute("Titolo");
        textAttribute.setText(shortTitle, "it");
        List<FieldError> errors = content.validate(this._groupManager);
        assertEquals(1, errors.size());
        FieldError error = errors.get(0);
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.INVALID_MIN_LENGTH, error.getErrorCode());
        textAttribute.setText(longTitle, "it");
        errors = content.validate(this._groupManager);
        assertEquals(1, errors.size());
        error = errors.get(0);
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.INVALID_MAX_LENGTH, error.getErrorCode());
        textAttribute.setText(shortTitle, "en");
        errors = content.validate(this._groupManager);
        assertEquals(2, errors.size());
        error = errors.get(0);
        assertEquals("Text:it_Titolo", error.getFieldCode());
        assertEquals(FieldError.INVALID_MAX_LENGTH, error.getErrorCode());
        error = errors.get(1);
        assertEquals("Text:en_Titolo", error.getFieldCode());
        assertEquals(FieldError.INVALID_MIN_LENGTH, error.getErrorCode());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) FieldError(com.agiletec.aps.system.common.entity.model.FieldError)

Example 27 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class TestDataObjectAuthorization method testCheckCustomerUser.

public void testCheckCustomerUser() throws Throwable {
    UserDetails extractedUser = this.getUser("pageManagerCustomers");
    assertNotNull(extractedUser);
    assertEquals("pageManagerCustomers", extractedUser.getUsername());
    assertEquals(1, extractedUser.getAuthorizations().size());
    IDataObjectManager contentManager = (IDataObjectManager) this.getService("DataObjectManager");
    DataObject content = contentManager.loadDataObject("ART111", true);
    boolean checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertTrue(checkContent);
    content = contentManager.loadDataObject("EVN25", true);
    checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertTrue(checkContent);
    content = contentManager.loadDataObject("EVN41", true);
    checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertFalse(checkContent);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) IDataObjectManager(org.entando.entando.aps.system.services.dataobject.IDataObjectManager)

Example 28 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class TestDataObjectDispenser method testGetRenderedContent_3.

public void testGetRenderedContent_3() throws Throwable {
    DataObject dataobject = this._dataObjectManager.loadDataObject("ART120", true);
    dataobject.setId(null);
    try {
        RequestContext reqCtx = this.getRequestContext();
        this.setUserOnSession("admin");
        this._dataObjectManager.insertDataObject(dataobject);
        DataObjectRenderizationInfo outputInfo = this._dataObjectDispenser.getRenderizationInfo(dataobject.getId(), 2, "it", reqCtx);
        assertNotNull(outputInfo);
        // assertNotNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_CACHE_PREFIX+dataobject.getId()));
        // assertNotNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_AUTH_INFO_CACHE_PREFIX+dataobject.getId()));
        this._dataObjectManager.insertDataObject(dataobject);
        this.waitNotifyingThread();
    // assertNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_CACHE_PREFIX+dataobject.getId()));
    // assertNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_AUTH_INFO_CACHE_PREFIX+dataobject.getId()));
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != dataobject.getId()) {
            this._dataObjectManager.deleteDataObject(dataobject);
        }
    }
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) RequestContext(com.agiletec.aps.system.RequestContext)

Example 29 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class TestSearchEngineManager method createDataObject_1.

private DataObject createDataObject_1() {
    DataObject content = new DataObject();
    content.setId("100");
    content.setMainGroup(Group.FREE_GROUP_NAME);
    content.addGroup("secondaryGroup");
    content.setTypeCode("ART");
    TextAttribute text = new TextAttribute();
    text.setName("Articolo");
    text.setType("Text");
    text.setIndexingType(IndexableAttributeInterface.INDEXING_TYPE_TEXT);
    text.setText("San Pietroburgo è una città meravigliosa W3C-WAI", "it");
    text.setText("St. Petersburg is a wonderful city", "en");
    content.addAttribute(text);
    Category category1 = this._categoryManager.getCategory("resCat2");
    Category category2 = this._categoryManager.getCategory("general_cat3");
    content.addCategory(category1);
    content.addCategory(category2);
    return content;
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) Category(com.agiletec.aps.system.services.category.Category) TextAttribute(com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)

Example 30 with DataObject

use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_1.

public void testSearchContentsId_1() throws Throwable {
    try {
        DataObject content_1 = this.createDataObject_1();
        this.dataObjectSearchEngineManager.deleteIndexedEntity(content_1.getId());
        this.dataObjectSearchEngineManager.addEntityToIndex(content_1);
        DataObject content_2 = this.createDataObject_2();
        this.dataObjectSearchEngineManager.deleteIndexedEntity(content_2.getId());
        this.dataObjectSearchEngineManager.addEntityToIndex(content_2);
        List<String> contentsId = this.dataObjectSearchEngineManager.searchEntityId("it", "San meravigliosa", null);
        assertNotNull(contentsId);
        assertTrue(contentsId.contains(content_1.getId()));
        contentsId = this.dataObjectSearchEngineManager.searchEntityId("en", "Petersburg wonderful", null);
        assertNotNull(contentsId);
        assertTrue(contentsId.contains(content_1.getId()));
        contentsId = this.dataObjectSearchEngineManager.searchEntityId("en", "meravigliosa", null);
        assertNotNull(contentsId);
        assertFalse(contentsId.contains(content_1.getId()));
    } catch (Throwable t) {
        throw t;
    }
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Aggregations

DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)72 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)10 UserDetails (com.agiletec.aps.system.services.user.UserDetails)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)7 JAXBDataObject (org.entando.entando.aps.system.services.dataobject.api.model.JAXBDataObject)7 Test (org.junit.Test)7 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6 ArrayList (java.util.ArrayList)5 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)4 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)4 Category (com.agiletec.aps.system.services.category.Category)4 Date (java.util.Date)4 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)3 FieldError (com.agiletec.aps.system.common.entity.model.FieldError)3 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)3 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)3 Group (com.agiletec.aps.system.services.group.Group)3 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)3 IDataObjectManager (org.entando.entando.aps.system.services.dataobject.IDataObjectManager)3