CCM NG: Several small changes
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3832 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
3be60416f8
commit
34907dfe89
|
|
@ -29,6 +29,8 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
|
import javax.enterprise.inject.spi.CDI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
|
@ -50,12 +52,14 @@ public final class UIConfig {
|
||||||
private String userRedirectUrl = "/permissions/";
|
private String userRedirectUrl = "/permissions/";
|
||||||
|
|
||||||
@Setting
|
@Setting
|
||||||
private String workspaceUrl = "pvt/";
|
private String workspaceUrl = "/pvt/";
|
||||||
|
|
||||||
public static UIConfig getConfig() {
|
public static UIConfig getConfig() {
|
||||||
final CdiUtil cdiUtil = new CdiUtil();
|
// final CdiUtil cdiUtil = new CdiUtil();
|
||||||
final ConfigurationManager confManager = cdiUtil.findBean(
|
// final ConfigurationManager confManager = cdiUtil.findBean(
|
||||||
ConfigurationManager.class);
|
// ConfigurationManager.class);
|
||||||
|
final ConfigurationManager confManager = CDI.current().select(
|
||||||
|
ConfigurationManager.class).get();
|
||||||
return confManager.findConfiguration(UIConfig.class);
|
return confManager.findConfiguration(UIConfig.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.ui.admin;
|
package com.arsdigita.ui.admin;
|
||||||
|
|
||||||
|
import org.libreccm.modules.InstallEvent;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
import org.libreccm.web.AbstractCcmApplicationSetup;
|
import org.libreccm.web.AbstractCcmApplicationSetup;
|
||||||
|
|
||||||
|
|
@ -31,8 +32,8 @@ public class AdminApplicationSetup extends AbstractCcmApplicationSetup {
|
||||||
|
|
||||||
public static final String ADMIN_APP_NAME = "CcmAdmin";
|
public static final String ADMIN_APP_NAME = "CcmAdmin";
|
||||||
|
|
||||||
public AdminApplicationSetup(final EntityManager entityManager) {
|
public AdminApplicationSetup(final InstallEvent event) {
|
||||||
super(entityManager);
|
super(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -547,10 +547,8 @@ class GroupAdministrationTab extends LayoutPanel implements AdminConstants,
|
||||||
//
|
//
|
||||||
// });
|
// });
|
||||||
// body.add(deleteLink);
|
// body.add(deleteLink);
|
||||||
// return main.addSegment(GROUP_EXTREME_ACTIONS_HEADER,
|
return main.addSegment(GROUP_EXTREME_ACTIONS_HEADER,
|
||||||
// body);
|
body);
|
||||||
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.ui.login;
|
package com.arsdigita.ui.login;
|
||||||
|
|
||||||
|
import org.libreccm.modules.InstallEvent;
|
||||||
import org.libreccm.web.AbstractCcmApplicationSetup;
|
import org.libreccm.web.AbstractCcmApplicationSetup;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -31,8 +31,8 @@ public class LoginApplicationSetup extends AbstractCcmApplicationSetup {
|
||||||
|
|
||||||
public static final String LOGIN_APP_NAME = "Login";
|
public static final String LOGIN_APP_NAME = "Login";
|
||||||
|
|
||||||
public LoginApplicationSetup(final EntityManager entityManager) {
|
public LoginApplicationSetup(final InstallEvent event) {
|
||||||
super(entityManager);
|
super(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,16 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
import org.libreccm.web.ApplicationManager;
|
import org.libreccm.web.ApplicationManager;
|
||||||
|
import org.libreccm.web.ApplicationType;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.enterprise.context.spi.CreationalContext;
|
||||||
|
import javax.enterprise.inject.spi.Bean;
|
||||||
|
import javax.enterprise.inject.spi.BeanManager;
|
||||||
|
import javax.enterprise.inject.spi.CDI;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -138,10 +148,10 @@ public class CCMDispatcherServlet extends BaseServlet {
|
||||||
|
|
||||||
if (subject.isAuthenticated()) {
|
if (subject.isAuthenticated()) {
|
||||||
// User is logged in, redirect to user redirect page
|
// User is logged in, redirect to user redirect page
|
||||||
throw new RedirectSignal(URL.there(request,
|
throw new RedirectSignal(
|
||||||
UI
|
URL.there(request,
|
||||||
.getUserRedirectURL(request)),
|
UI.getUserRedirectURL(request)),
|
||||||
false);
|
false);
|
||||||
} else {
|
} else {
|
||||||
// User is *not* logged in, display public front page
|
// User is *not* logged in, display public front page
|
||||||
throw new RedirectSignal(URL.there(request,
|
throw new RedirectSignal(URL.there(request,
|
||||||
|
|
@ -206,7 +216,9 @@ public class CCMDispatcherServlet extends BaseServlet {
|
||||||
BaseApplicationServlet.APPLICATION_ID_ATTRIBUTE,
|
BaseApplicationServlet.APPLICATION_ID_ATTRIBUTE,
|
||||||
spec.getAppID());
|
spec.getAppID());
|
||||||
request.setAttribute(DISPATCHED_ATTRIBUTE, Boolean.TRUE);
|
request.setAttribute(DISPATCHED_ATTRIBUTE, Boolean.TRUE);
|
||||||
forward(spec.getTypeContextPath(), spec.target(path), request,
|
forward(spec.getTypeContextPath(),
|
||||||
|
spec.target(path),
|
||||||
|
request,
|
||||||
response);
|
response);
|
||||||
// return true;
|
// return true;
|
||||||
}
|
}
|
||||||
|
|
@ -266,7 +278,7 @@ public class CCMDispatcherServlet extends BaseServlet {
|
||||||
LOGGER.debug("forwarding from context \"{}\" to context \"{}\"...",
|
LOGGER.debug("forwarding from context \"{}\" to context \"{}\"...",
|
||||||
getServletContext(), context);
|
getServletContext(), context);
|
||||||
|
|
||||||
forward(context.getRequestDispatcher(target),
|
forward(getServletContext().getRequestDispatcher(target),
|
||||||
request,
|
request,
|
||||||
response);
|
response);
|
||||||
}
|
}
|
||||||
|
|
@ -304,8 +316,6 @@ public class CCMDispatcherServlet extends BaseServlet {
|
||||||
path);
|
path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// final CcmApplication application = appRepository
|
|
||||||
// .retrieveApplicationForPath(path);
|
|
||||||
final CcmApplication application = appManager
|
final CcmApplication application = appManager
|
||||||
.findApplicationByPath(path);
|
.findApplicationByPath(path);
|
||||||
|
|
||||||
|
|
@ -313,7 +323,7 @@ public class CCMDispatcherServlet extends BaseServlet {
|
||||||
LOGGER.warn("No application found for path \"{}\".", path);
|
LOGGER.warn("No application found for path \"{}\".", path);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return new ApplicationSpec(application);
|
return new ApplicationSpec(application, appManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,12 +348,16 @@ public class CCMDispatcherServlet extends BaseServlet {
|
||||||
private final String m_instanceURI;
|
private final String m_instanceURI;
|
||||||
private final String m_typeURI;
|
private final String m_typeURI;
|
||||||
private final String m_typeContextPath;
|
private final String m_typeContextPath;
|
||||||
|
private final ApplicationManager appManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param app
|
* @param app
|
||||||
*/
|
*/
|
||||||
ApplicationSpec(CcmApplication app) {
|
ApplicationSpec(final CcmApplication app,
|
||||||
|
final ApplicationManager appManager) {
|
||||||
|
this.appManager = appManager;
|
||||||
|
|
||||||
if (app == null) {
|
if (app == null) {
|
||||||
throw new NullPointerException("app");
|
throw new NullPointerException("app");
|
||||||
}
|
}
|
||||||
|
|
@ -356,7 +370,54 @@ public class CCMDispatcherServlet extends BaseServlet {
|
||||||
.getAnnotation(ServletPath.class)
|
.getAnnotation(ServletPath.class)
|
||||||
.value();
|
.value();
|
||||||
} else {
|
} else {
|
||||||
m_typeURI = URL.SERVLET_DIR + "/legacy-adapter";
|
// final ApplicationManager appManager = CDI.current().select(
|
||||||
|
// ApplicationManager.class).get();
|
||||||
|
// final BeanManager beanManager = CDI.current().getBeanManager();
|
||||||
|
// final Set<Bean<?>> beans = beanManager.getBeans(
|
||||||
|
// ApplicationManager.class);
|
||||||
|
// final Iterator<Bean<?>> iterator = beans.iterator();
|
||||||
|
// final ApplicationManager appManager;
|
||||||
|
// if (iterator.hasNext()) {
|
||||||
|
// @SuppressWarnings("unchecked")
|
||||||
|
// final Bean<ApplicationManager> bean
|
||||||
|
// = (Bean<ApplicationManager>) iterator
|
||||||
|
// .next();
|
||||||
|
// final CreationalContext<ApplicationManager> ctx
|
||||||
|
// = beanManager
|
||||||
|
// .createCreationalContext(bean);
|
||||||
|
//
|
||||||
|
// appManager = (ApplicationManager) beanManager.getReference(
|
||||||
|
// bean, ApplicationManager.class, ctx);
|
||||||
|
// } else {
|
||||||
|
// LOGGER.error("Failed to find {}.",
|
||||||
|
// ApplicationManager.class.getName());
|
||||||
|
// throw new IllegalArgumentException(String.format(
|
||||||
|
// "Failed to find %s",
|
||||||
|
// ApplicationManager.class.getName()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
final ApplicationType appType = appManager.getApplicationTypes()
|
||||||
|
.get(app.getApplicationType());
|
||||||
|
final Class<? extends HttpServlet> appServletClass = appType
|
||||||
|
.servlet();
|
||||||
|
final WebServlet servletAnnotation = appServletClass
|
||||||
|
.getAnnotation(WebServlet.class);
|
||||||
|
if (servletAnnotation != null
|
||||||
|
&& servletAnnotation.urlPatterns() != null
|
||||||
|
&& servletAnnotation.urlPatterns().length > 0) {
|
||||||
|
if (servletAnnotation.urlPatterns()[0].endsWith("*")) {
|
||||||
|
m_typeURI = servletAnnotation
|
||||||
|
.urlPatterns()[0]
|
||||||
|
.substring(0,
|
||||||
|
servletAnnotation
|
||||||
|
.urlPatterns()[0]
|
||||||
|
.length() - 1);
|
||||||
|
} else {
|
||||||
|
m_typeURI = servletAnnotation.urlPatterns()[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_typeURI = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_typeContextPath = "";
|
m_typeContextPath = "";
|
||||||
|
|
|
||||||
|
|
@ -84,14 +84,11 @@ public class CategoryRepository extends AbstractEntityRepository<Long, Category>
|
||||||
+ "Valid path format: domainKey:path");
|
+ "Valid path format: domainKey:path");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Domain domain;
|
final Domain domain = domainRepo.findByDomainKey(tokens[0]);
|
||||||
try {
|
if (domain == null) {
|
||||||
domain = domainRepo.findByDomainKey(tokens[0]);
|
|
||||||
} catch (NoResultException ex) {
|
|
||||||
throw new InvalidCategoryPathException(String.format(
|
throw new InvalidCategoryPathException(String.format(
|
||||||
"No domain identified by the key '%s' found.",
|
"No domain identified by the key '%s' found.",
|
||||||
tokens[0]),
|
tokens[0]));
|
||||||
ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return findByPath(domain, tokens[1]);
|
return findByPath(domain, tokens[1]);
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,11 @@ import static org.libreccm.core.CoreConstants.*;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
import org.hibernate.validator.constraints.NotBlank;
|
||||||
import org.hibernate.validator.constraints.URL;
|
import org.hibernate.validator.constraints.URL;
|
||||||
import org.libreccm.core.CcmObject;
|
import org.libreccm.core.CcmObject;
|
||||||
import org.libreccm.jpa.utils.UriConverter;
|
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
import org.omg.CORBA.DomainManager;
|
import org.omg.CORBA.DomainManager;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -39,14 +37,17 @@ import java.util.Objects;
|
||||||
|
|
||||||
import javax.persistence.AssociationOverride;
|
import javax.persistence.AssociationOverride;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Convert;
|
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.NamedAttributeNode;
|
||||||
|
import javax.persistence.NamedEntityGraph;
|
||||||
|
import javax.persistence.NamedEntityGraphs;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
|
import javax.persistence.NamedSubgraph;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
|
|
@ -72,11 +73,24 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "CATEGORY_DOMAINS", schema = DB_SCHEMA)
|
@Table(name = "CATEGORY_DOMAINS", schema = DB_SCHEMA)
|
||||||
@NamedQueries({
|
@NamedQueries({
|
||||||
@NamedQuery(name="Domain.findByKey",
|
@NamedQuery(name = "Domain.findByKey",
|
||||||
query = "SELECT d FROM Domain d WHERE d.domainKey = :key"),
|
query = "SELECT d FROM Domain d WHERE d.domainKey = :key"),
|
||||||
@NamedQuery(name="Domain.findByUri",
|
@NamedQuery(name = "Domain.findByUri",
|
||||||
query = "SELECT d FROM Domain d WHERE d.uri = :uri")
|
query = "SELECT d FROM Domain d WHERE d.uri = :uri")
|
||||||
})
|
})
|
||||||
|
@NamedEntityGraphs({
|
||||||
|
@NamedEntityGraph(
|
||||||
|
name = "Domain.allCategories",
|
||||||
|
attributeNodes = {
|
||||||
|
@NamedAttributeNode(value = "root",
|
||||||
|
subgraph = "subCategories")},
|
||||||
|
subgraphs = {
|
||||||
|
@NamedSubgraph(
|
||||||
|
name = "subCategories",
|
||||||
|
attributeNodes = {
|
||||||
|
@NamedAttributeNode("subCategories")
|
||||||
|
})})
|
||||||
|
})
|
||||||
@XmlRootElement(name = "domain", namespace = CAT_XML_NS)
|
@XmlRootElement(name = "domain", namespace = CAT_XML_NS)
|
||||||
public class Domain extends CcmObject implements Serializable {
|
public class Domain extends CcmObject implements Serializable {
|
||||||
|
|
||||||
|
|
@ -106,10 +120,9 @@ public class Domain extends CcmObject implements Serializable {
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@Column(name = "URI", nullable = true, unique = true, length = 1024)
|
@Column(name = "URI", nullable = true, unique = true, length = 1024)
|
||||||
@Convert(converter = UriConverter.class)
|
|
||||||
@URL
|
@URL
|
||||||
@XmlElement(name = "uri", namespace = CAT_XML_NS)
|
@XmlElement(name = "uri", namespace = CAT_XML_NS)
|
||||||
private URI uri;
|
private String uri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A human readable title for the {@code Domain}. The title can be
|
* A human readable title for the {@code Domain}. The title can be
|
||||||
|
|
@ -184,11 +197,11 @@ public class Domain extends CcmObject implements Serializable {
|
||||||
this.domainKey = domainKey;
|
this.domainKey = domainKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public URI getUri() {
|
public String getUri() {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUri(final URI uri) {
|
public void setUri(final String uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,18 +40,49 @@ public class DomainManager {
|
||||||
@Inject
|
@Inject
|
||||||
private DomainRepository domainRepo;
|
private DomainRepository domainRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private CategoryRepository categoryRepo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new domain with the provided key (name) and a root category
|
||||||
|
* with the provided name. The domain and the root category can be further
|
||||||
|
* customised after the creation.
|
||||||
|
*
|
||||||
|
* @param domainKey The key (name) of the new domain.
|
||||||
|
* @param rootCategoryName The name of the root category of the new domain.
|
||||||
|
* @return The new domain.
|
||||||
|
*/
|
||||||
|
public Domain createDomain(final String domainKey,
|
||||||
|
final String rootCategoryName) {
|
||||||
|
final Domain domain = new Domain();
|
||||||
|
domain.setDomainKey(domainKey);
|
||||||
|
domain.setVersion("1.0");
|
||||||
|
domain.setDisplayName(domainKey);
|
||||||
|
|
||||||
|
final Category root = new Category();
|
||||||
|
root.setName(rootCategoryName);
|
||||||
|
root.setDisplayName(rootCategoryName);
|
||||||
|
|
||||||
|
domain.setRoot(root);
|
||||||
|
|
||||||
|
categoryRepo.save(root);
|
||||||
|
domainRepo.save(domain);
|
||||||
|
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a {@code CcmApplication} to the owners of a {@link Domain}. If the
|
* Adds a {@code CcmApplication} to the owners of a {@link Domain}. If the
|
||||||
* provided {@code CcmApplication} is already an owner of the provided
|
* provided {@code CcmApplication} is already an owner of the provided
|
||||||
* {@code Domain} the method does nothing.
|
* {@code Domain} the method does nothing.
|
||||||
*
|
*
|
||||||
* @param application The {@code CcmApplication} to add to the owners of the
|
* @param application The {@code CcmApplication} to add to the owners of the
|
||||||
* {@code Domain}.
|
* {@code Domain}.
|
||||||
* @param domain The {@code Domain} to which owners the
|
* @param domain The {@code Domain} to which owners the
|
||||||
* {@code CcmApplication is added}.
|
* {@code CcmApplication is added}.
|
||||||
*/
|
*/
|
||||||
public void addDomainOwner(final CcmApplication application,
|
public void addDomainOwner(final CcmApplication application,
|
||||||
final Domain domain) {
|
final Domain domain) {
|
||||||
|
|
@ -70,14 +101,14 @@ public class DomainManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a {@code CcmApplication} from the owners of a {@code Domain}. If the
|
* Removes a {@code CcmApplication} from the owners of a {@code Domain}. If
|
||||||
* provided {@code CcmApplication} is not an owner of the provided
|
* the provided {@code CcmApplication} is not an owner of the provided
|
||||||
* {@code Domain} the method does nothing.
|
* {@code Domain} the method does nothing.
|
||||||
*
|
*
|
||||||
* @param application The {@code CcmApplication} to remove from the owners of
|
* @param application The {@code CcmApplication} to remove from the owners
|
||||||
* the provided {@code Domain}.
|
* of the provided {@code Domain}.
|
||||||
* @param domain The {@code Domain} from which owners the provided
|
* @param domain The {@code Domain} from which owners the provided
|
||||||
* {@code CcmApplication} should be removed.
|
* {@code CcmApplication} should be removed.
|
||||||
*/
|
*/
|
||||||
public void removeDomainOwner(final CcmApplication application,
|
public void removeDomainOwner(final CcmApplication application,
|
||||||
final Domain domain) {
|
final Domain domain) {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import java.net.URI;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.persistence.EntityGraph;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.NoResultException;
|
import javax.persistence.NoResultException;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
|
@ -62,6 +63,10 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
|
||||||
"Domain.findByKey", Domain.class);
|
"Domain.findByKey", Domain.class);
|
||||||
query.setParameter("key", domainKey);
|
query.setParameter("key", domainKey);
|
||||||
|
|
||||||
|
final EntityGraph<?> graph = entityManager.getEntityGraph(
|
||||||
|
"Domain.allCategories");
|
||||||
|
query.setHint("javax.persistence.fetchgraph", graph);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return query.getSingleResult();
|
return query.getSingleResult();
|
||||||
} catch (NoResultException ex) {
|
} catch (NoResultException ex) {
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,6 @@ public class ConfigurationManager {
|
||||||
// "No setting type for value type \"%s\".", valueTypeName));
|
// "No setting type for value type \"%s\".", valueTypeName));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a value on a setting in the registry.
|
* Sets a value on a setting in the registry.
|
||||||
*
|
*
|
||||||
|
|
@ -348,8 +347,7 @@ public class ConfigurationManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Domain registry = domainRepo
|
final Domain registry = domainRepo.findByDomainKey(REGISTRY_DOMAIN);
|
||||||
.findByDomainKey(REGISTRY_DOMAIN);
|
|
||||||
if (categoryRepo.findByPath(registry, confName) == null) {
|
if (categoryRepo.findByPath(registry, confName) == null) {
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import com.arsdigita.ui.login.LoginApplicationCreator;
|
||||||
import com.arsdigita.ui.login.LoginServlet;
|
import com.arsdigita.ui.login.LoginServlet;
|
||||||
import com.arsdigita.ui.login.LoginApplicationSetup;
|
import com.arsdigita.ui.login.LoginApplicationSetup;
|
||||||
|
|
||||||
|
import org.libreccm.categorization.RegistrySetup;
|
||||||
import org.libreccm.modules.CcmModule;
|
import org.libreccm.modules.CcmModule;
|
||||||
import org.libreccm.modules.InitEvent;
|
import org.libreccm.modules.InitEvent;
|
||||||
import org.libreccm.modules.InstallEvent;
|
import org.libreccm.modules.InstallEvent;
|
||||||
|
|
@ -33,7 +34,6 @@ import org.libreccm.modules.ShutdownEvent;
|
||||||
import org.libreccm.modules.UnInstallEvent;
|
import org.libreccm.modules.UnInstallEvent;
|
||||||
import org.libreccm.security.SystemUsersSetup;
|
import org.libreccm.security.SystemUsersSetup;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
|
|
||||||
import org.libreccm.web.ApplicationType;
|
import org.libreccm.web.ApplicationType;
|
||||||
|
|
||||||
|
|
@ -98,16 +98,19 @@ public class CcmCore implements CcmModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void install(final InstallEvent event) {
|
public void install(final InstallEvent event) {
|
||||||
final EntityManager entityManager = event.getEntityManager();
|
// final EntityManager entityManager = event.getEntityManager();
|
||||||
|
|
||||||
final SystemUsersSetup systemUsersSetup = new SystemUsersSetup(
|
final SystemUsersSetup systemUsersSetup = new SystemUsersSetup(
|
||||||
entityManager);
|
event);
|
||||||
systemUsersSetup.setupSystemUsers();
|
systemUsersSetup.setupSystemUsers();
|
||||||
|
|
||||||
final AdminApplicationSetup adminSetup = new AdminApplicationSetup(entityManager);
|
final RegistrySetup registrySetup = new RegistrySetup(event);
|
||||||
|
registrySetup.setup();
|
||||||
|
|
||||||
|
final AdminApplicationSetup adminSetup = new AdminApplicationSetup(event);
|
||||||
adminSetup.setup();
|
adminSetup.setup();
|
||||||
|
|
||||||
final LoginApplicationSetup loginSetup = new LoginApplicationSetup(entityManager);
|
final LoginApplicationSetup loginSetup = new LoginApplicationSetup(event);
|
||||||
loginSetup.setup();
|
loginSetup.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.libreccm.core.CcmCore;
|
import org.libreccm.core.CcmCore;
|
||||||
import org.libreccm.core.EmailAddress;
|
import org.libreccm.core.EmailAddress;
|
||||||
|
import org.libreccm.modules.InstallEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
@ -45,8 +46,8 @@ public class SystemUsersSetup {
|
||||||
|
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
public SystemUsersSetup(final EntityManager entityManager) {
|
public SystemUsersSetup(final InstallEvent event) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = event.getEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupSystemUsers() {
|
public void setupSystemUsers() {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.web;
|
package org.libreccm.web;
|
||||||
|
|
||||||
|
import org.libreccm.modules.InstallEvent;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -28,8 +30,8 @@ public abstract class AbstractCcmApplicationSetup {
|
||||||
|
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
public AbstractCcmApplicationSetup(final EntityManager entityManager) {
|
public AbstractCcmApplicationSetup(final InstallEvent event) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = event.getEntityManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntityManager getEntityManager() {
|
protected EntityManager getEntityManager() {
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,6 @@ import java.math.BigDecimal;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
|
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
|
||||||
import org.libreccm.categorization.Category;
|
|
||||||
|
|
||||||
import javax.persistence.TypedQuery;
|
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,12 @@ public class DatasetsTest extends DatasetsVerifier {
|
||||||
return Arrays.asList(new String[]{
|
return Arrays.asList(new String[]{
|
||||||
"/datasets/org/libreccm/configuration/ConfigurationManagerTest/after-save-changed.yml",
|
"/datasets/org/libreccm/configuration/ConfigurationManagerTest/after-save-changed.yml",
|
||||||
"/datasets/org/libreccm/configuration/ConfigurationManagerTest/after-save-new.yml",
|
"/datasets/org/libreccm/configuration/ConfigurationManagerTest/after-save-new.yml",
|
||||||
"/datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml"});
|
"/datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetsTest(final String datasetPath) {
|
public DatasetsTest(final String datasetPath) {
|
||||||
super(datasetPath);;
|
super(datasetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -44,12 +44,6 @@
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.libreccm</groupId>
|
|
||||||
<artifactId>ccm-testutils</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ package org.libreccm.testutils;
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
public enum DatasetType {
|
public enum DatasetType {
|
||||||
|
FLAT_XML,
|
||||||
JSON,
|
JSON,
|
||||||
YAML
|
YAML
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
import static org.libreccm.testutils.DatasetType.*;
|
import static org.libreccm.testutils.DatasetType.*;
|
||||||
|
|
||||||
|
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
|
||||||
import org.jboss.arquillian.persistence.dbunit.dataset.yaml.YamlDataSet;
|
import org.jboss.arquillian.persistence.dbunit.dataset.yaml.YamlDataSet;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
@ -124,6 +125,11 @@ public class DatasetsVerifier {
|
||||||
//Get dataset to test
|
//Get dataset to test
|
||||||
final IDataSet dataSet;
|
final IDataSet dataSet;
|
||||||
switch(getDatasetType()) {
|
switch(getDatasetType()) {
|
||||||
|
case FLAT_XML:
|
||||||
|
final FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
|
||||||
|
dataSet = builder.build(getClass().getResourceAsStream(
|
||||||
|
datasetPath));
|
||||||
|
break;
|
||||||
case JSON:
|
case JSON:
|
||||||
dataSet = new JsonDataSet(getClass()
|
dataSet = new JsonDataSet(getClass()
|
||||||
.getResourceAsStream(datasetPath));
|
.getResourceAsStream(datasetPath));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue