Search in sources :

Example 51 with DataObject

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

the class TestDataObjectAuthorization method testCheckAdminUser.

public void testCheckAdminUser() throws Throwable {
    UserDetails adminUser = this.getUser("admin");
    assertNotNull(adminUser);
    assertEquals("admin", adminUser.getUsername());
    assertEquals(1, adminUser.getAuthorizations().size());
    IDataObjectManager contentManager = (IDataObjectManager) this.getService("DataObjectManager");
    DataObject content = contentManager.loadDataObject("ART111", true);
    boolean check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
    content = contentManager.loadDataObject("EVN25", true);
    check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
    content = contentManager.loadDataObject("EVN41", true);
    check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
}
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 52 with DataObject

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

the class TestDataObjectAuthorization method testCheckNewUser.

/*
     * This test is fully inherited from the original TestAuthorizationManager in jAPS2 (2.0.6)
     */
public void testCheckNewUser() throws Throwable {
    String username = "UserForTest";
    String password = "PasswordForTest";
    this.addUserForTest(username, password);
    UserDetails extractedUser = null;
    try {
        extractedUser = this.getUser(username, password);
        assertEquals(username, extractedUser.getUsername());
        assertNotNull(extractedUser);
        assertEquals(1, extractedUser.getAuthorizations().size());
        Group group = this._groupManager.getGroup("coach");
        boolean checkGroup = this._authorizationManager.isAuth(extractedUser, group);
        assertFalse(checkGroup);
        group = this._groupManager.getGroup(Group.FREE_GROUP_NAME);
        checkGroup = this._authorizationManager.isAuth(extractedUser, group);
        assertTrue(checkGroup);
        boolean checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.SUPERVISOR);
        assertFalse(checkPermission);
        checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.SUPERUSER);
        assertFalse(checkPermission);
        checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.BACKOFFICE);
        assertTrue(checkPermission);
        checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, "editContents");
        assertTrue(checkPermission);
        IDataObjectManager contentManager = (IDataObjectManager) this.getService("DataObjectManager");
        DataObject content = contentManager.loadDataObject("ART111", true);
        boolean checkContent = this._authorizationManager.isAuth(extractedUser, content);
        assertFalse(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);
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != extractedUser) {
            this._userManager.removeUser(extractedUser);
        }
        extractedUser = this._userManager.getUser(username);
        assertNull(extractedUser);
    }
}
Also used : Group(com.agiletec.aps.system.services.group.Group) 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 53 with DataObject

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

the class TestDataObjectDOM method testGetXMLDocument.

public void testGetXMLDocument() throws ApsSystemException {
    DataObject dataObjectTest = this._dataObjectManager.createDataObject("ART");
    assertNotNull(dataObjectTest);
    dataObjectTest.addGroup("tempGroupName");
    String xml = dataObjectTest.getXML();
    int index = xml.indexOf("tempGroupName");
    assertTrue((index != -1));
}
Also used : DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 54 with DataObject

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

the class TestSearchEngineManager method testSearchContentsId_7.

public void testSearchContentsId_7() 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);
        DataObject content_3 = this.createDataObject_3();
        this.dataObjectSearchEngineManager.deleteIndexedEntity(content_3.getId());
        this.dataObjectSearchEngineManager.addEntityToIndex(content_3);
        // San Pietroburgo è una città meravigliosa W3C-WAI
        // 100
        // Il turismo ha incrementato più del 20 per cento nel 2011-2013, quando la Croazia ha aderito all'Unione europea. Consegienda di questo aumento è una serie di modernizzazione di alloggi di recente costruzione, tra cui circa tre dozzine di ostelli.
        // 101
        // La vita è una cosa meravigliosa
        // 103
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        SearchEngineFilter filter1 = new SearchEngineFilter("it", "San meravigliosa", SearchEngineFilter.TextSearchOption.ALL_WORDS);
        SearchEngineFilter[] filters1 = { filter1 };
        List<String> contentsId = sem.searchEntityId(filters1, null, allowedGroup);
        assertNotNull(contentsId);
        assertEquals(1, contentsId.size());
        assertTrue(contentsId.contains(content_1.getId()));
        SearchEngineFilter filter2 = new SearchEngineFilter("it", "San meravigliosa", SearchEngineFilter.TextSearchOption.AT_LEAST_ONE_WORD);
        SearchEngineFilter[] filters2 = { filter2 };
        contentsId = sem.searchEntityId(filters2, null, allowedGroup);
        assertNotNull(contentsId);
        assertEquals(2, contentsId.size());
        assertTrue(contentsId.contains(content_1.getId()));
        assertTrue(contentsId.contains(content_3.getId()));
        SearchEngineFilter filter3 = new SearchEngineFilter("it", "San meravigliosa", SearchEngineFilter.TextSearchOption.EXACT);
        SearchEngineFilter[] filters3 = { filter3 };
        contentsId = sem.searchEntityId(filters3, null, allowedGroup);
        assertNotNull(contentsId);
        assertEquals(0, contentsId.size());
        SearchEngineFilter filter4 = new SearchEngineFilter("it", "una cosa meravigliosa", SearchEngineFilter.TextSearchOption.EXACT);
        SearchEngineFilter[] filters4 = { filter4 };
        contentsId = sem.searchEntityId(filters4, null, allowedGroup);
        assertNotNull(contentsId);
        assertEquals(1, contentsId.size());
        assertTrue(contentsId.contains(content_3.getId()));
    } catch (Throwable t) {
        throw t;
    }
}
Also used : SearchEngineFilter(org.entando.entando.aps.system.services.searchengine.SearchEngineFilter) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 55 with DataObject

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

the class TestSearchEngineManager method createDataObject_2.

private DataObject createDataObject_2() {
    DataObject content = new DataObject();
    content.setId("101");
    content.setMainGroup(Group.FREE_GROUP_NAME);
    content.addGroup("thirdGroup");
    content.setTypeCode("ART");
    TextAttribute text = new TextAttribute();
    text.setName("Articolo");
    text.setType("Text");
    text.setIndexingType(IndexableAttributeInterface.INDEXING_TYPE_TEXT);
    text.setText("Il turismo ha incrementato più del 20 per cento nel 2011-2013, quando la Croazia ha aderito all'Unione europea. Consegienda di questo aumento è una serie di modernizzazione di alloggi di recente costruzione, tra cui circa tre dozzine di ostelli.", "it");
    text.setText("Tourism had shot up more than 20 percent from 2011 to 2013, when Croatia joined the European Union. Accompanying that rise is a raft of modernized and recently built lodgings, including some three dozen hostels.", "en");
    content.addAttribute(text);
    Category category1 = this._categoryManager.getCategory("resCat1");
    Category category2 = this._categoryManager.getCategory("general_cat2");
    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)

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