CCM NG: ccm-shortcuts module
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4146 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
5015534bea
commit
572db42a15
|
|
@ -41,8 +41,18 @@
|
||||||
<groupId>net.sf.saxon</groupId>
|
<groupId>net.sf.saxon</groupId>
|
||||||
<artifactId>Saxon-HE</artifactId>
|
<artifactId>Saxon-HE</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- CCM modules -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>ccm-shortcuts</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--<dependencies>
|
<!--<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.libreccm</groupId>
|
<groupId>org.libreccm</groupId>
|
||||||
|
|
|
||||||
|
|
@ -1064,8 +1064,8 @@
|
||||||
<reuseForks>true</reuseForks>
|
<reuseForks>true</reuseForks>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
<jboss.home>${project.basedir}/target/wildfly-8.2.0.Final</jboss.home>
|
<!--<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>
|
<module.path>${project.basedir}/target/wildfly-8.2.0.Final/modules</module.path>-->
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
||||||
<groups>
|
<groups>
|
||||||
|
|
@ -1150,8 +1150,8 @@
|
||||||
<reuseForks>true</reuseForks>
|
<reuseForks>true</reuseForks>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
<jboss.home>${project.basedir}/target/wildfly-8.2.0.Final</jboss.home>
|
<!--<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>
|
<module.path>${project.basedir}/target/wildfly-8.2.0.Final/modules</module.path>-->
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
||||||
<groups>
|
<groups>
|
||||||
|
|
|
||||||
|
|
@ -187,8 +187,8 @@ public class ModuleManager {
|
||||||
System.out.printf("Checking status of module %s%n",
|
System.out.printf("Checking status of module %s%n",
|
||||||
node.getModule().getClass().getName());
|
node.getModule().getClass().getName());
|
||||||
final InstalledModule installedModule = entityManager.find(
|
final InstalledModule installedModule = entityManager.find(
|
||||||
InstalledModule.class, node.
|
InstalledModule.class,
|
||||||
getModule().getClass().getName().hashCode());
|
node.getModule().getClass().getName().hashCode());
|
||||||
LOGGER.info("Status of module {} ({}): {}",
|
LOGGER.info("Status of module {} ({}): {}",
|
||||||
node.getModuleInfo().getModuleName(),
|
node.getModuleInfo().getModuleName(),
|
||||||
node.getModule().getClass().getName(),
|
node.getModule().getClass().getName(),
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,7 @@ import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.libreccm.categorization.Categorization;
|
|
||||||
import org.libreccm.jpa.EntityManagerProducer;
|
|
||||||
import org.libreccm.jpa.utils.MimeTypeConverter;
|
|
||||||
import org.libreccm.l10n.LocalizedString;
|
|
||||||
import org.libreccm.security.Permission;
|
|
||||||
import org.libreccm.tests.categories.IntegrationTest;
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
import org.libreccm.testutils.EqualsVerifier;
|
|
||||||
import org.libreccm.web.CcmApplication;
|
|
||||||
import org.libreccm.workflow.Workflow;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ DROP SEQUENCE IF EXISTS hibernate_sequence;
|
||||||
|
|
||||||
CREATE SCHEMA ccm_core;
|
CREATE SCHEMA ccm_core;
|
||||||
|
|
||||||
|
|
||||||
create table CCM_CORE.APPLICATIONS (
|
create table CCM_CORE.APPLICATIONS (
|
||||||
APPLICATION_TYPE varchar(1024) not null,
|
APPLICATION_TYPE varchar(1024) not null,
|
||||||
PRIMARY_URL varchar(1024) not null,
|
PRIMARY_URL varchar(1024) not null,
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,22 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-entitymanager</artifactId>
|
<artifactId>hibernate-entitymanager</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
@ -136,7 +147,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.18.1</version>
|
<version>2.19.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<groups>org.libreccm.tests.categories.UnitTest</groups>
|
<groups>org.libreccm.tests.categories.UnitTest</groups>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
@ -332,4 +343,184 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</reporting>
|
</reporting>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>wildfly-remote-h2-mem</id>
|
||||||
|
<dependencies>
|
||||||
|
<!-- <dependency>
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>ccm-core</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>-->
|
||||||
|
|
||||||
|
<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-wildfly-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-wildfly-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>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,24 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.NamedQueries;
|
||||||
|
import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import org.libreccm.core.CcmObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(schema ="CCM_SHORTCUTS", name = "SHORTCUTS")
|
@Table(schema = "CCM_SHORTCUTS", name = "SHORTCUTS")
|
||||||
|
@NamedQueries({
|
||||||
|
@NamedQuery(
|
||||||
|
name = "Shortcut.findByUrlKey",
|
||||||
|
query = "SELECT s FROM Shortcut s WHERE s.urlKey = :urlKey"),
|
||||||
|
@NamedQuery(
|
||||||
|
name = "Shortcut.findByRedirect",
|
||||||
|
query = "SELECT s FROM Shortcut s WHERE s.redirect = :redirect")
|
||||||
|
})
|
||||||
public class Shortcut implements Serializable {
|
public class Shortcut implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5674633339633714327L;
|
private static final long serialVersionUID = -5674633339633714327L;
|
||||||
|
|
@ -46,7 +55,7 @@ public class Shortcut implements Serializable {
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private long shortcutId;
|
private long shortcutId;
|
||||||
|
|
||||||
@Column(name = "URL_KEY", length = 1024)
|
@Column(name = "URL_KEY", length = 1024, unique = true)
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String urlKey;
|
private String urlKey;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,7 @@ package org.libreccm.shortcuts;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
|
@ -94,8 +93,8 @@ public class ShortcutManager {
|
||||||
/**
|
/**
|
||||||
* checks if the given URL is valid
|
* checks if the given URL is valid
|
||||||
*
|
*
|
||||||
* @param url the Url you want to validate
|
* @param url the URL you want to validate
|
||||||
* @return true if you can succesfully connect to the url, therefore is
|
* @return true if you can successfully connect to the url, therefore is
|
||||||
* valid.
|
* valid.
|
||||||
*/
|
*/
|
||||||
private boolean validateURL(final String url) {
|
private boolean validateURL(final String url) {
|
||||||
|
|
@ -104,44 +103,5 @@ public class ShortcutManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the first shortcut with the specified urlKey.
|
|
||||||
*
|
|
||||||
* @param urlKey the wanted urlKey
|
|
||||||
* @return Shortcut a shortcut with the specified urlKey
|
|
||||||
*/
|
|
||||||
public Shortcut findByUrlKey(final String urlKey) {
|
|
||||||
//get all Shortcuts:
|
|
||||||
List shortcutlist = shortcutRepository.findAll();
|
|
||||||
//search for the right one:
|
|
||||||
Iterator<Shortcut> iterator = shortcutlist.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Shortcut shortcut = iterator.next();
|
|
||||||
if (shortcut.getUrlKey().equals(urlKey)) {
|
|
||||||
return shortcut;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all shortcuts with the specified redirect.
|
|
||||||
*
|
|
||||||
* @param redirect the wanted redirect
|
|
||||||
* @return List<Shortcut> a List of Shortcuts with the specified redirect
|
|
||||||
*/
|
|
||||||
public List<Shortcut> findByRedirect(final String redirect) {
|
|
||||||
//get all Shortcuts:
|
|
||||||
List shortcutlist = shortcutRepository.findAll();
|
|
||||||
//removes all shortcuts that don't fit
|
|
||||||
Iterator<Shortcut> iterator = shortcutlist.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Shortcut shortcut = iterator.next();
|
|
||||||
if (!shortcut.getRedirect().equals(redirect)) {
|
|
||||||
shortcutlist.remove(shortcut);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return shortcutlist;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,18 @@ package org.libreccm.shortcuts;
|
||||||
|
|
||||||
import org.libreccm.core.AbstractEntityRepository;
|
import org.libreccm.core.AbstractEntityRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.persistence.NoResultException;
|
||||||
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="konerman@tzi.de">Alexander Konermann</a>
|
* @author <a href="konerman@tzi.de">Alexander Konermann</a>
|
||||||
*/
|
*/
|
||||||
|
@RequestScoped
|
||||||
public class ShortcutRepository extends AbstractEntityRepository<Long, Shortcut> {
|
public class ShortcutRepository extends AbstractEntityRepository<Long, Shortcut> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -33,7 +41,41 @@ public class ShortcutRepository extends AbstractEntityRepository<Long, Shortcut>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNew(final Shortcut entity) {
|
public boolean isNew(final Shortcut entity) {
|
||||||
return entity.getShortcutId() == 0;
|
return entity.getShortcutId() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the first shortcut with the specified urlKey.
|
||||||
|
*
|
||||||
|
* @param urlKey the wanted urlKey
|
||||||
|
*
|
||||||
|
* @return The shortcut with the specified urlKey if there is any.
|
||||||
|
*/
|
||||||
|
public Optional<Shortcut> findByUrlKey(final String urlKey) {
|
||||||
|
final TypedQuery<Shortcut> query = getEntityManager().createNamedQuery(
|
||||||
|
"Shortcut.findByUrlKey", Shortcut.class);
|
||||||
|
query.setParameter("urlKey", urlKey);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final Shortcut result = query.getSingleResult();
|
||||||
|
return Optional.of(result);
|
||||||
|
} catch (NoResultException ex) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all shortcuts which redirect to the provided target.
|
||||||
|
*
|
||||||
|
* @param redirect the wanted redirect
|
||||||
|
* @return List<Shortcut> a List of Shortcuts with the specified redirect
|
||||||
|
*/
|
||||||
|
public List<Shortcut> findByRedirect(final String redirect) {
|
||||||
|
final TypedQuery<Shortcut> query = getEntityManager().createNamedQuery(
|
||||||
|
"Shortcut.findByRedirect", Shortcut.class);
|
||||||
|
query.setParameter("redirect", redirect);
|
||||||
|
|
||||||
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,34 +18,45 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.shortcuts;
|
package org.libreccm.shortcuts;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import org.libreccm.modules.CcmModule;
|
||||||
import javax.persistence.Table;
|
import org.libreccm.modules.InitEvent;
|
||||||
|
import org.libreccm.modules.InstallEvent;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.modules.Module;
|
||||||
|
import org.libreccm.modules.ShutdownEvent;
|
||||||
|
import org.libreccm.modules.UnInstallEvent;
|
||||||
|
import org.libreccm.web.ApplicationType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Module(applicationTypes = {
|
||||||
@Table(schema ="CCM_SHORTCUTS", name = "SHORTCUTS_APP")
|
@ApplicationType(name = ShortcutsConstants.SHORTCUTS_APP_TYPE,
|
||||||
public class Shortcuts extends CcmApplication {
|
descBundle = "org.libreccm.shortcuts.ShortcutsResources",
|
||||||
private static final long serialVersionUID = -6793265996161649637L;
|
singleton = true,
|
||||||
|
creator = ShortcutsApplicationCreator.class)}
|
||||||
|
)
|
||||||
|
public class Shortcuts implements CcmModule {
|
||||||
|
|
||||||
// private String shortcutAppName;
|
@Override
|
||||||
|
public void install(final InstallEvent event) {
|
||||||
public Shortcuts() {
|
final ShortcutsSetup setup = new ShortcutsSetup(event);
|
||||||
super();
|
setup.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public String getShortcutAppName() {
|
@Override
|
||||||
// return shortcutAppName;
|
public void init(final InitEvent event) {
|
||||||
// }
|
//Nothing
|
||||||
//
|
}
|
||||||
// public void setShortcutAppName(final String shortcutAppName) {
|
|
||||||
// this.shortcutAppName = shortcutAppName;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shutdown(final ShutdownEvent event) {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uninstall(final UnInstallEvent event) {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm.shortcuts;
|
||||||
|
|
||||||
|
import org.libreccm.web.ApplicationCreator;
|
||||||
|
import org.libreccm.web.ApplicationRepository;
|
||||||
|
import org.libreccm.web.ApplicationType;
|
||||||
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class ShortcutsApplicationCreator
|
||||||
|
implements ApplicationCreator<CcmApplication>{
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ApplicationRepository appRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CcmApplication createInstance(final String primaryUrl,
|
||||||
|
final ApplicationType type) {
|
||||||
|
if (!ShortcutsConstants.SHORTCUTS_PRIMARY_URL.equals(primaryUrl)) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Shortcuts is a singleton application which is mounted at "
|
||||||
|
+ "/shortcuts");
|
||||||
|
}
|
||||||
|
|
||||||
|
return appRepository.retrieveApplicationForPath(primaryUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm.shortcuts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public final class ShortcutsConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the shortcuts application type
|
||||||
|
*/
|
||||||
|
public static final String SHORTCUTS_APP_TYPE
|
||||||
|
= "org.libreccm.shortcuts.Shortcuts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary URL of the singleton Shortcuts application instance.
|
||||||
|
*/
|
||||||
|
public static final String SHORTCUTS_PRIMARY_URL = "/shortcuts/";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm.shortcuts;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.libreccm.modules.InstallEvent;
|
||||||
|
import org.libreccm.security.PermissionManager;
|
||||||
|
import org.libreccm.security.Role;
|
||||||
|
import org.libreccm.security.RoleManager;
|
||||||
|
import org.libreccm.security.RoleRepository;
|
||||||
|
import org.libreccm.web.AbstractCcmApplicationSetup;
|
||||||
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ShortcutsSetup extends AbstractCcmApplicationSetup {
|
||||||
|
|
||||||
|
public ShortcutsSetup(final InstallEvent event) {
|
||||||
|
super(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
final CcmApplication shortcuts = new CcmApplication();
|
||||||
|
shortcuts.setUuid(UUID.randomUUID().toString());
|
||||||
|
shortcuts.setApplicationType(ShortcutsConstants.SHORTCUTS_APP_TYPE);
|
||||||
|
shortcuts.setPrimaryUrl(ShortcutsConstants.SHORTCUTS_PRIMARY_URL);
|
||||||
|
getEntityManager().persist(shortcuts);
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final RoleRepository roleRepository = cdiUtil.findBean(
|
||||||
|
RoleRepository.class);
|
||||||
|
final Role shortcutsManager = new Role();
|
||||||
|
shortcutsManager.setName("shortcuts-manager");
|
||||||
|
roleRepository.save(shortcutsManager);
|
||||||
|
|
||||||
|
final PermissionManager permissionManager = cdiUtil.findBean(
|
||||||
|
PermissionManager.class);
|
||||||
|
permissionManager.grantPrivilege("manage_shortcuts", shortcutsManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
org.libreccm.shortcuts.Shortcuts
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
|
|
||||||
create table SHORTCUTS (
|
|
||||||
shortcut_id bigint generated by default as identity,
|
|
||||||
redirect varchar(1024),
|
|
||||||
url_key varchar(1024),
|
|
||||||
primary key (shortcut_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table SHORTCUTS_APP (
|
|
||||||
object_id bigint not null,
|
|
||||||
primary key (object_id)
|
|
||||||
);
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
create table SHORTCUTS (
|
||||||
|
shortcut_id bigint generated by default as identity,
|
||||||
|
redirect varchar(1024),
|
||||||
|
url_key varchar(1024),
|
||||||
|
primary key (shortcut_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
alter table CCM_SHORTCUTS.SHORTCUTS
|
||||||
|
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
|
|
||||||
create table SHORTCUTS (
|
|
||||||
shortcut_id int8 not null,
|
|
||||||
redirect varchar(1024),
|
|
||||||
url_key varchar(1024),
|
|
||||||
primary key (shortcut_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
create table SHORTCUTS_APP (
|
|
||||||
object_id int8 not null,
|
|
||||||
primary key (object_id)
|
|
||||||
);
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
create table SHORTCUTS (
|
||||||
|
shortcut_id int8 not null,
|
||||||
|
redirect varchar(1024),
|
||||||
|
url_key varchar(1024),
|
||||||
|
primary key (shortcut_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
alter table CCM_SHORTCUTS.SHORTCUTS
|
||||||
|
add constraint UK_4otuwtog6qqdbg4e6p8xdpw8h unique (URL_KEY);
|
||||||
|
|
@ -0,0 +1,152 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm.shortcuts;
|
||||||
|
|
||||||
|
import org.jboss.arquillian.container.test.api.Deployment;
|
||||||
|
import org.jboss.arquillian.junit.Arquillian;
|
||||||
|
import org.jboss.arquillian.junit.InSequence;
|
||||||
|
import org.jboss.arquillian.persistence.CreateSchema;
|
||||||
|
import org.jboss.arquillian.persistence.PersistenceTest;
|
||||||
|
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
|
||||||
|
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
||||||
|
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||||
|
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||||
|
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
|
||||||
|
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||||
|
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
|
||||||
|
import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage;
|
||||||
|
import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
|
||||||
|
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependencies;
|
||||||
|
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenDependency;
|
||||||
|
import org.jboss.shrinkwrap.resolver.impl.maven.coordinate.MavenDependencyImpl;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.categories.Category;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@Category(IntegrationTest.class)
|
||||||
|
@RunWith(Arquillian.class)
|
||||||
|
@PersistenceTest
|
||||||
|
@Transactional(TransactionMode.COMMIT)
|
||||||
|
@CreateSchema({"create_ccm_shortcuts_schema.sql"})
|
||||||
|
public class ShortcutRepositoryTest {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ShortcutRepository shortcutRepository;
|
||||||
|
|
||||||
|
@PersistenceContext
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
public ShortcutRepositoryTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpClass() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownClass() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deployment
|
||||||
|
public static EnterpriseArchive createDeployment() {
|
||||||
|
final PomEquippedResolveStage pom = Maven
|
||||||
|
.resolver()
|
||||||
|
.loadPomFromFile("pom.xml");
|
||||||
|
final PomEquippedResolveStage dependencies = pom
|
||||||
|
.importCompileAndRuntimeDependencies();
|
||||||
|
dependencies.addDependency(MavenDependencies.createDependency(
|
||||||
|
"org.libreccm:ccm-core", ScopeType.RUNTIME, false));
|
||||||
|
dependencies.addDependency(MavenDependencies.createDependency(
|
||||||
|
"org.libreccm:ccm-testutils", ScopeType.RUNTIME, false));
|
||||||
|
dependencies.addDependency(MavenDependencies.createDependency(
|
||||||
|
"net.sf.saxon:Saxon-HE", ScopeType.RUNTIME, false));
|
||||||
|
final File[] libs = dependencies.resolve().withTransitivity().asFile();
|
||||||
|
|
||||||
|
for (File lib : libs) {
|
||||||
|
System.err.printf("Adding file '%s' to test archive...%n",
|
||||||
|
lib.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
final WebArchive webArchive = ShrinkWrap.create(
|
||||||
|
WebArchive.class,
|
||||||
|
"LibreCCM-org.libreccm.shortcuts.ShortcutTest-web.war")
|
||||||
|
// .addPackage(org.libreccm.categorization.Categorization.class
|
||||||
|
// .getPackage())
|
||||||
|
// .addPackage(org.libreccm.configuration.Configuration.class
|
||||||
|
// .getPackage())
|
||||||
|
// .addPackage(org.libreccm.core.CcmCore.class.getPackage())
|
||||||
|
// .addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||||
|
// .getPackage())
|
||||||
|
// .addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
||||||
|
// .addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.shortcuts.Shortcuts.class.getPackage())
|
||||||
|
// .addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||||
|
// .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||||
|
.addAsLibraries(libs)
|
||||||
|
.addAsResource("test-persistence.xml",
|
||||||
|
"META-INF/persistence.xml")
|
||||||
|
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||||
|
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||||
|
|
||||||
|
return ShrinkWrap.create(
|
||||||
|
EnterpriseArchive.class,
|
||||||
|
"LibreCCM-org.libreccm.shortcuts.ShortcutRepositoryTest.ear")
|
||||||
|
.addAsModule(webArchive)
|
||||||
|
.addAsResource("application.xml", "application.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@InSequence(1)
|
||||||
|
public void repoIsInjected() {
|
||||||
|
assertThat(shortcutRepository, is(not(nullValue())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@InSequence(2)
|
||||||
|
public void entityManagerIsInjected() {
|
||||||
|
assertThat(entityManager, is(not((nullValue()))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<arquillian xmlns="http://jboss.org/schema/arquillian"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://jboss.org/schema/arquillian
|
||||||
|
http://jboss.org/schema/arquillian/arquillian_1_0.xsd" >
|
||||||
|
|
||||||
|
<engine>
|
||||||
|
<property name="deploymentExportPath">target/deployments</property>
|
||||||
|
</engine>
|
||||||
|
<defaultProtocol type="Servlet 3.0"/>
|
||||||
|
<!--<property name="javaVmArguments">
|
||||||
|
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
|
||||||
|
</property>-->
|
||||||
|
|
||||||
|
<extension qualifier="persistence">
|
||||||
|
<property name="defaultDataSource">java:/comp/env/jdbc/org/libreccm/ccm-shortcuts/h2-mem</property>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Disable automatic cleanup, does not work because of referential
|
||||||
|
integrity constrains.
|
||||||
|
-->
|
||||||
|
<property name="defaultCleanupPhase">NONE</property>
|
||||||
|
|
||||||
|
<property name="dumpData">true</property>
|
||||||
|
<property name="dumpDirectory">target</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
<extension qualifier="persistence-dbunit">
|
||||||
|
<property name="defaultDataSetFormat">json</property>
|
||||||
|
<property name="datatypeFactory">org.dbunit.ext.h2.H2DataTypeFactory</property>
|
||||||
|
<property name="excludePoi">true</property>
|
||||||
|
<property name="qualifiedTableNames">true</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
<extension qualifier="persistence-script">
|
||||||
|
<property name="scriptsToExecuteAfterTest">scripts/h2-cleanup.sql</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
|
||||||
|
</arquillian>
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
author: Jens Pelzetter
|
||||||
|
-->
|
||||||
|
|
||||||
|
<persistence
|
||||||
|
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||||
|
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||||
|
version="2.1">
|
||||||
|
|
||||||
|
<persistence-unit name="LibreCCM" transaction-type="JTA">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Enforce JPA provider
|
||||||
|
Not really necessary here because we don't use any Hibernate
|
||||||
|
specific features, but makes it easier to manage to database
|
||||||
|
creation scripts.
|
||||||
|
-->
|
||||||
|
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||||
|
|
||||||
|
<jta-data-source>java:/comp/env/jdbc/org/libreccm/ccm-shortcuts/h2-mem</jta-data-source>
|
||||||
|
<properties>
|
||||||
|
<property name="hibernate.hbm2ddl.auto" value=""/>
|
||||||
|
<property name="hibernate.show_sql" value="true"/>
|
||||||
|
<property name="hibernate.id.new_generator_mappings" value="true"/>
|
||||||
|
<property name="hibernate.connection.autocommit" value="false" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Properties for Hibernate Envers
|
||||||
|
We are using the ValidityAuditStrategy here because it is faster
|
||||||
|
when querying data than the DefaultStrategy
|
||||||
|
-->
|
||||||
|
<property name="org.hibernate.envers.audit_strategy"
|
||||||
|
value="org.hibernate.envers.strategy.ValidityAuditStrategy"/>
|
||||||
|
</properties>
|
||||||
|
</persistence-unit>
|
||||||
|
|
||||||
|
</persistence>
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<arquillian xmlns="http://jboss.org/schema/arquillian"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://jboss.org/schema/arquillian
|
||||||
|
http://jboss.org/schema/arquillian/arquillian_1_0.xsd" >
|
||||||
|
|
||||||
|
<engine>
|
||||||
|
<property name="deploymentExportPath">target/deployments</property>
|
||||||
|
</engine>
|
||||||
|
|
||||||
|
<extension qualifier="persistence">
|
||||||
|
<property name="defaultDataSource">java:/comp/env/jdbc/org/libreccm/ccm-shortcuts/pgsql</property>
|
||||||
|
<!--<property name="javaVmArguments">
|
||||||
|
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
|
||||||
|
</property>-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Disable automatic cleanup, does not work because of referential
|
||||||
|
integrity constrains.
|
||||||
|
-->
|
||||||
|
<property name="defaultCleanupPhase">NONE</property>
|
||||||
|
|
||||||
|
<property name="dumpData">true</property>
|
||||||
|
<property name="dumpDirectory">target</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
<extension qualifier="persistence-dbunit">
|
||||||
|
<property name="defaultDataSetFormat">json</property>
|
||||||
|
<!--<property name="datatypeFactory">org.dbunit.ext.h2.H2DataTypeFactory</property>-->
|
||||||
|
<property name="excludePoi">true</property>
|
||||||
|
<property name="qualifiedTableNames">true</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
<extension qualifier="persistence-script">
|
||||||
|
<property name="scriptsToExecuteAfterTest">scripts/pgsql-cleanup.sql</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
|
||||||
|
</arquillian>
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
author: Jens Pelzetter
|
||||||
|
-->
|
||||||
|
|
||||||
|
<persistence
|
||||||
|
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||||
|
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||||
|
version="2.1">
|
||||||
|
|
||||||
|
<persistence-unit name="LibreCCM" transaction-type="JTA">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Enforce JPA provider
|
||||||
|
Not really necessary here because we don't use any Hibernate
|
||||||
|
specific features, but makes it easier to manage to database
|
||||||
|
creation scripts.
|
||||||
|
-->
|
||||||
|
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||||
|
|
||||||
|
<jta-data-source>java:/comp/env/jdbc/org/libreccm/ccm-shortcuts/pgsql</jta-data-source>
|
||||||
|
<properties>
|
||||||
|
<property name="hibernate.hbm2ddl.auto" value=""/>
|
||||||
|
<property name="hibernate.show_sql" value="true"/>
|
||||||
|
<property name="hibernate.id.new_generator_mappings" value="true"/>
|
||||||
|
<property name="hibernate.connection.autocommit" value="false" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Properties for Hibernate Envers
|
||||||
|
We are using the ValidityAuditStrategy here because it is faster
|
||||||
|
when querying data than the DefaultStrategy
|
||||||
|
-->
|
||||||
|
<property name="org.hibernate.envers.audit_strategy"
|
||||||
|
value="org.hibernate.envers.strategy.ValidityAuditStrategy"/>
|
||||||
|
</properties>
|
||||||
|
</persistence-unit>
|
||||||
|
|
||||||
|
</persistence>
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<application xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" version="7">
|
||||||
|
<display-name>ccm-bundle-shortcuts-test-wildfly</display-name>
|
||||||
|
<module>
|
||||||
|
<web>
|
||||||
|
<web-uri>LibreCCM-org.libreccm.shortcuts.ShortcutTest-web.war</web-uri>
|
||||||
|
<context-root>/libreccm-shortcuts-test</context-root>
|
||||||
|
</web>
|
||||||
|
</module>
|
||||||
|
<library-directory>lib</library-directory>
|
||||||
|
</application>
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
DELETE FROM ccm_shortcuts.shortcuts;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings_string_list;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings_l10n_str_values;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings_enum_values;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings_enum_values;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.categorizations;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.category_domains;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.categories;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.permissions;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.ccm_objects;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.role_memberships;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.group_memberships;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.groups;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.one_time_auth_tokens;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.users;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.user_email_addresses;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.parties;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.ccm_roles;
|
||||||
|
|
||||||
|
ALTER SEQUENCE hibernate_sequence RESTART WITH 1;
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
DELETE FROM ccm_shortcuts.shortcuts;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings_string_list;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings_l10n_str_values;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings_enum_values;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings_enum_values;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.settings;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.categorizations;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.category_domains;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.categories;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.permissions;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.ccm_objects;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.role_memberships;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.group_memberships;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.groups;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.one_time_auth_tokens;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.users;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.user_email_addresses;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.parties;
|
||||||
|
|
||||||
|
DELETE FROM ccm_core.ccm_roles;
|
||||||
|
|
||||||
|
ALTER SEQUENCE hibernate_sequence RESTART;
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||||
|
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||||
|
version="3.0">
|
||||||
|
|
||||||
|
<display-name>LibreCCM Shortcuts Test</display-name>
|
||||||
|
</web-app>
|
||||||
Loading…
Reference in New Issue