Search in sources :

Example 26 with Content

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

the class TestContentAuthorization method testCheckCustomerUser.

public void testCheckCustomerUser() throws Throwable {
    UserDetails extractedUser = this.getUser("pageManagerCustomers");
    assertNotNull(extractedUser);
    assertEquals("pageManagerCustomers", extractedUser.getUsername());
    assertEquals(1, extractedUser.getAuthorizations().size());
    IContentManager contentManager = (IContentManager) this.getService(JacmsSystemConstants.CONTENT_MANAGER);
    Content content = contentManager.loadContent("ART111", true);
    boolean checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertTrue(checkContent);
    content = contentManager.loadContent("EVN25", true);
    checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertTrue(checkContent);
    content = contentManager.loadContent("EVN41", true);
    checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertFalse(checkContent);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) IContentManager(com.agiletec.plugins.jacms.aps.system.services.content.IContentManager) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 27 with Content

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

the class TestContentAuthorization 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);
        IContentManager contentManager = (IContentManager) this.getService(JacmsSystemConstants.CONTENT_MANAGER);
        Content content = contentManager.loadContent("ART111", true);
        boolean checkContent = this._authorizationManager.isAuth(extractedUser, content);
        assertFalse(checkContent);
        content = contentManager.loadContent("EVN25", true);
        checkContent = this._authorizationManager.isAuth(extractedUser, content);
        assertTrue(checkContent);
        content = contentManager.loadContent("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) IContentManager(com.agiletec.plugins.jacms.aps.system.services.content.IContentManager) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 28 with Content

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

the class TestContentAuthorization method testCheckAdminUser.

public void testCheckAdminUser() throws Throwable {
    UserDetails adminUser = this.getUser("admin");
    assertNotNull(adminUser);
    assertEquals("admin", adminUser.getUsername());
    assertEquals(1, adminUser.getAuthorizations().size());
    IContentManager contentManager = (IContentManager) this.getService(JacmsSystemConstants.CONTENT_MANAGER);
    Content content = contentManager.loadContent("ART111", true);
    boolean check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
    content = contentManager.loadContent("EVN25", true);
    check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
    content = contentManager.loadContent("EVN41", true);
    check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) IContentManager(com.agiletec.plugins.jacms.aps.system.services.content.IContentManager) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 29 with Content

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

the class TestPageActionReferences method tearDown.

@Override
protected void tearDown() throws Exception {
    super.tearDown();
    Content content = this.contentManager.loadContent(CONTENT_ID, false);
    this.contentManager.insertOnLineContent(content);
    this._pageManager.deletePage(TEST_PAGE_CODE);
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content)

Example 30 with Content

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

the class ContentManager method loadContent.

@Override
public // @CacheableInfo(groups = "T(com.agiletec.plugins.jacms.aps.system.services.cache.CmsCacheWrapperManager).getContentCacheGroupsCsv(#id)")
Content loadContent(String id, boolean onLine, boolean cacheable) throws ApsSystemException {
    Content content = null;
    try {
        ContentRecordVO contentVo = this.loadContentVO(id);
        content = this.createContent(contentVo, onLine);
    } catch (ApsSystemException e) {
        _logger.error("Error while loading content : id {}", id, e);
        throw new ApsSystemException("Error while loading content : id " + id, e);
    }
    return content;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ContentRecordVO(com.agiletec.plugins.jacms.aps.system.services.content.model.ContentRecordVO) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

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