CCM NG: ContentSectionManager
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4201 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
92a8f8cc58
commit
c780d6e43b
175
ccm-cms/pom.xml
175
ccm-cms/pom.xml
|
|
@ -346,4 +346,179 @@
|
|||
</reporting>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>wildfly-remote-h2-mem</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<artifactId>wildfly-arquillian-container-remote</artifactId>
|
||||
<!--<version>8.2.1.Final</version>-->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>org.jacoco.core</artifactId>
|
||||
<!--<version>0.7.5.201505241946</version>-->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-jacoco</artifactId>
|
||||
<version>1.0.0.Alpha8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
<artifactId>Saxon-HE</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>src/test/resources-wildfly8-remote-h2-mem</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>${project.build.directory}/generated-resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>de.jpdigital</groupId>
|
||||
<artifactId>hibernate5-ddl-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<dialects>
|
||||
<param>h2</param>
|
||||
<param>postgresql9</param>
|
||||
</dialects>
|
||||
<packages>
|
||||
<param>org.libreccm</param>
|
||||
</packages>
|
||||
<useEnvers>true</useEnvers>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>gen-ddl</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
<configuration>
|
||||
<forkMode>always</forkMode>
|
||||
<forkCount>999</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<systemPropertyVariables>
|
||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<!--<jboss.home>${project.basedir}/target/wildfly-8.2.0.Final</jboss.home>
|
||||
<module.path>${project.basedir}/target/wildfly-8.2.0.Final/modules</module.path>-->
|
||||
</systemPropertyVariables>
|
||||
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
||||
<groups>
|
||||
org.libreccm.tests.categories.UnitTest,
|
||||
org.libreccm.tests.categories.IntegrationTest
|
||||
</groups>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>wildfly-remote-pgsql</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<artifactId>wildfly-arquillian-container-remote</artifactId>
|
||||
<!--<version>8.2.1.Final</version>-->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>org.jacoco.core</artifactId>
|
||||
<!--<version>0.7.5.201505241946</version>-->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-jacoco</artifactId>
|
||||
<version>1.0.0.Alpha8</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>net.sf.saxon</groupId>
|
||||
<artifactId>Saxon-HE</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>src/test/resources-wildfly8-remote-pgsql</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>${project.build.directory}/generated-resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>de.jpdigital</groupId>
|
||||
<artifactId>hibernate5-ddl-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<dialects>
|
||||
<param>h2</param>
|
||||
<param>postgresql9</param>
|
||||
</dialects>
|
||||
<packages>
|
||||
<param>org.libreccm</param>
|
||||
</packages>
|
||||
<useEnvers>true</useEnvers>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>gen-ddl</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
<configuration>
|
||||
<forkMode>always</forkMode>
|
||||
<forkCount>999</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<systemPropertyVariables>
|
||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<!--<jboss.home>${project.basedir}/target/wildfly-8.2.0.Final</jboss.home>
|
||||
<module.path>${project.basedir}/target/wildfly-8.2.0.Final/modules</module.path>-->
|
||||
</systemPropertyVariables>
|
||||
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
||||
<groups>
|
||||
org.libreccm.tests.categories.UnitTest,
|
||||
org.libreccm.tests.categories.IntegrationTest
|
||||
</groups>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -35,8 +35,12 @@ import javax.persistence.JoinTable;
|
|||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.libreccm.web.ApplicationType;
|
||||
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
|
|
@ -45,12 +49,17 @@ import static org.librecms.CmsConstants.*;
|
|||
*/
|
||||
@Entity
|
||||
@Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA)
|
||||
@NamedQueries(
|
||||
@NamedQuery(
|
||||
name = "ContentSection.findByLabel",
|
||||
query = "SELECT s FROM ContentSection s WHERE c.label = :label")
|
||||
)
|
||||
@ApplicationType(
|
||||
name = CONTENT_SECTION_APP_TYPE,
|
||||
descBundle = "org.librecms.contentsection.ContentSectionResources",
|
||||
singleton = false,
|
||||
creator = ContentSectionCreator.class,
|
||||
servlet = ContentSectionServlet.class)
|
||||
name = CONTENT_SECTION_APP_TYPE,
|
||||
descBundle = "org.librecms.contentsection.ContentSectionResources",
|
||||
singleton = false,
|
||||
creator = ContentSectionCreator.class,
|
||||
servlet = ContentSectionServlet.class)
|
||||
public class ContentSection extends CcmApplication implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -671718122153931727L;
|
||||
|
|
@ -247,23 +256,23 @@ public class ContentSection extends CcmApplication implements Serializable {
|
|||
@Override
|
||||
public String toString(final String data) {
|
||||
return super.toString(String.format(
|
||||
", label = \"%s\", "
|
||||
+ "rootDocumentsFolder = \"%s\", "
|
||||
+ "rootAssetsFolder = \"%s\", "
|
||||
+ "pageResolverClass = \"%s\", "
|
||||
+ "itemResolverClass = \"%s\", "
|
||||
+ "templateResolverClass = \"%s\", "
|
||||
+ "xmlGeneratorClass = \"%s\", "
|
||||
+ "defaultLocale = \"%s\"%s",
|
||||
label,
|
||||
Objects.toString(rootDocumentsFolder),
|
||||
Objects.toString(rootAssetsFolder),
|
||||
pageResolverClass,
|
||||
itemResolverClass,
|
||||
templateResolverClass,
|
||||
xmlGeneratorClass,
|
||||
Objects.toString(defaultLocale),
|
||||
data));
|
||||
", label = \"%s\", "
|
||||
+ "rootDocumentsFolder = \"%s\", "
|
||||
+ "rootAssetsFolder = \"%s\", "
|
||||
+ "pageResolverClass = \"%s\", "
|
||||
+ "itemResolverClass = \"%s\", "
|
||||
+ "templateResolverClass = \"%s\", "
|
||||
+ "xmlGeneratorClass = \"%s\", "
|
||||
+ "defaultLocale = \"%s\"%s",
|
||||
label,
|
||||
Objects.toString(rootDocumentsFolder),
|
||||
Objects.toString(rootAssetsFolder),
|
||||
pageResolverClass,
|
||||
itemResolverClass,
|
||||
templateResolverClass,
|
||||
xmlGeneratorClass,
|
||||
Objects.toString(defaultLocale),
|
||||
data));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ public class ContentSectionManager {
|
|||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.ADMIN_PRIVILEGE)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public void removeTypeToSection(final ContentType type,
|
||||
public void removeTypeFromSection(final ContentType type,
|
||||
final ContentSection section) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.libreccm.security.AuthorizationRequired;
|
|||
import org.libreccm.security.RequiresPrivilege;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
|
|
@ -34,6 +35,20 @@ import javax.transaction.Transactional;
|
|||
public class ContentSectionRepository
|
||||
extends AbstractEntityRepository<Long, ContentSection> {
|
||||
|
||||
public ContentSection findByLabel(final String label) {
|
||||
if (label == null || label.isEmpty()) {
|
||||
throw new IllegalArgumentException(
|
||||
"The label of a ContentSection can't be empty.");
|
||||
}
|
||||
|
||||
final TypedQuery<ContentSection> query = getEntityManager()
|
||||
.createNamedQuery("ContentSection.findByLabel",
|
||||
ContentSection.class);
|
||||
query.setParameter("label", label);
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ContentSection> getEntityClass() {
|
||||
return ContentSection.class;
|
||||
|
|
|
|||
|
|
@ -39,12 +39,16 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.libreccm.security.Role;
|
||||
import org.libreccm.security.RoleRepository;
|
||||
import org.libreccm.tests.categories.IntegrationTest;
|
||||
import org.librecms.Cms;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -57,6 +61,15 @@ import static org.junit.Assert.*;
|
|||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||
public class ContentSectionManagerTest {
|
||||
|
||||
@Inject
|
||||
private ContentSectionRepository repository;
|
||||
|
||||
@Inject
|
||||
private ContentSectionManager manager;
|
||||
|
||||
@Inject
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
public ContentSectionManagerTest() {
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +124,7 @@ public class ContentSectionManagerTest {
|
|||
excludeColumns = {"section_id"})
|
||||
@InSequence(100)
|
||||
public void createSection() {
|
||||
manager.createContentSection("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -122,7 +136,9 @@ public class ContentSectionManagerTest {
|
|||
excludeColumns = {"section_id"})
|
||||
@InSequence(200)
|
||||
public void renameSection() {
|
||||
//Rename main to content
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
|
||||
manager.renameContentSection(section, "content");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -134,7 +150,13 @@ public class ContentSectionManagerTest {
|
|||
excludeColumns = {"section_id"})
|
||||
@InSequence(300)
|
||||
public void addRole() {
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
|
||||
manager.addRoleToContentSection(section,
|
||||
"reviewer",
|
||||
PRIVILEGE_ITEMS_VIEW_PUBLISHED,
|
||||
PRIVILEGE_ITEMS_PREVIEW,
|
||||
PRIVILEGE_ITEMS_APPROVE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -146,7 +168,10 @@ public class ContentSectionManagerTest {
|
|||
excludeColumns = {"section_id"})
|
||||
@InSequence(300)
|
||||
public void removeRole() {
|
||||
final ContentSection section = repository.findByLabel("info");
|
||||
final Role role = roleRepository.findByName("info_publisher");
|
||||
|
||||
manager.removeRoleFromContentSection(section, role);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue