[CCM][FEATURE]

- adds import functionalities for core's ResourceType, CcmApplication, Domain and DomainOwnership
- optimizes imports in some core packages

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4987 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
tosmers 2017-09-06 13:45:39 +00:00
parent 15ff6e8f86
commit e3e30cdffe
84 changed files with 1087 additions and 709 deletions

View File

@ -18,32 +18,18 @@
*/
package org.libreccm.categorization;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.core.CcmObject;
import org.libreccm.portation.Portable;
import org.libreccm.security.Relation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import org.libreccm.security.Relation;
import javax.persistence.FetchType;
/**
* Association class describing the association between a category and an
* object. Instances of these class should not created manually. The methods

View File

@ -47,9 +47,8 @@ public class CategorizationIdGenerator extends ObjectIdGenerator<String> {
@Override
public IdKey key(Object key) {
if (key == null) {
if (key == null)
return null;
}
return new IdKey(Categorization.class, Categorization.class, key);
}

View File

@ -28,22 +28,7 @@ import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable;
import org.libreccm.security.RecursivePermissions;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

View File

@ -22,8 +22,6 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
import org.libreccm.cdi.utils.CdiUtil;
import javax.enterprise.context.RequestScoped;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17

View File

@ -18,8 +18,6 @@
*/
package org.libreccm.categorization;
import static org.libreccm.categorization.CategorizationConstants.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.core.CcmObject;
@ -29,19 +27,16 @@ import org.libreccm.security.PermissionChecker;
import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Shiro;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.*;
import static org.libreccm.categorization.CategorizationConstants.PRIVILEGE_MANAGE_CATEGORY;
import static org.libreccm.categorization.CategorizationConstants.PRIVILEGE_MANAGE_CATEGORY_OBJECTS;
/**
* The {@code CategoryManager} provides several helper methods for managing

View File

@ -18,44 +18,28 @@
*/
package org.libreccm.categorization;
import static org.libreccm.categorization.CategorizationConstants.*;
import static org.libreccm.core.CoreConstants.*;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.URL;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable;
import org.libreccm.security.RecursivePermissions;
import org.libreccm.web.CcmApplication;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedSubgraph;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.*;
import javax.validation.constraints.Pattern;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.*;
import static org.libreccm.categorization.CategorizationConstants.CAT_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/**
* A domain is collection of categories designed a specific purpose. This entity
@ -77,6 +61,8 @@ import javax.xml.bind.annotation.XmlRootElement;
query = "SELECT d FROM Domain d WHERE d.domainKey = :key"),
@NamedQuery(name = "Domain.findByUri",
query = "SELECT d FROM Domain d WHERE d.uri = :uri"),
@NamedQuery(name = "Domain.findByUuid",
query = "SELECT d FROM Domain d WHERE d.uuid = :uuid"),
@NamedQuery(name = "Domain.findAll",
query = "SELECT d FROM Domain d ORDER BY d.domainKey"),
@NamedQuery(
@ -110,7 +96,10 @@ import javax.xml.bind.annotation.XmlRootElement;
)
})
@XmlRootElement(name = "domain", namespace = CAT_XML_NS)
public class Domain extends CcmObject implements Serializable {
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = DomainIdResolver.class,
property = "uuid")
public class Domain extends CcmObject implements Serializable, Portable {
private static final long serialVersionUID = 4012590760598188732L;
@ -192,6 +181,7 @@ public class Domain extends CcmObject implements Serializable {
@ManyToOne
@JoinColumn(name = "ROOT_CATEGORY_ID")
@XmlElement(name = "root", namespace = CAT_XML_NS)
@JsonIdentityReference(alwaysAsId = true)
private Category root;
/**
@ -199,6 +189,7 @@ public class Domain extends CcmObject implements Serializable {
*/
@OneToMany(mappedBy = "domain")
@XmlElementWrapper(name = "owners", namespace = CAT_XML_NS)
@JsonIgnore
private List<DomainOwnership> owners;
public Domain() {

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2015 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.categorization;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
import org.libreccm.cdi.utils.CdiUtil;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/2/17
*/
public class DomainIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final DomainRepository domainRepository = cdiUtil
.findBean(DomainRepository.class);
return domainRepository
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Domain with uuid %s in the database.",
id.key.toString())));
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new DomainIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof DomainIdResolver;
}
}

View File

@ -23,14 +23,13 @@ import org.libreccm.security.RequiresPrivilege;
import org.libreccm.web.ApplicationRepository;
import org.libreccm.web.CcmApplication;
import java.util.List;
import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
/**
* Provides several methods when managing the relations between {@link Domain}s

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2015 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.categorization;
import org.libreccm.portation.AbstractMarshaller;
import org.libreccm.portation.Marshals;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/22/17
*/
@RequestScoped
@Marshals(Domain.class)
public class DomainMarshaller extends AbstractMarshaller<Domain> {
@Inject
private DomainRepository domainRepository;
@Override
protected Class<Domain> getObjectClass() {
return Domain.class;
}
@Override
protected void insertIntoDb(Domain portableObject) {
domainRepository.save(portableObject);
}
}

View File

@ -18,23 +18,17 @@
*/
package org.libreccm.categorization;
import static org.libreccm.core.CoreConstants.*;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.core.CcmObject;
import org.libreccm.portation.Portable;
import org.libreccm.web.CcmApplication;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/**
* Association class for the association between a {@link Domain} and a
@ -52,7 +46,9 @@ import javax.persistence.Table;
query = "SELECT o FROM DomainOwnership o "
+ "WHERE o.owner = :owner AND o.domain = :domain")
})
public class DomainOwnership implements Serializable {
@JsonIdentityInfo(generator = DomainOwnershipIdGenerator.class,
property = "customOwnId")
public class DomainOwnership implements Serializable, Portable {
private static final long serialVersionUID = 201504301305L;
@ -64,18 +60,20 @@ public class DomainOwnership implements Serializable {
@GeneratedValue(strategy = GenerationType.AUTO)
private long ownershipId;
/**
* The {@link CcmObject} owning the {@link Domain}.
*/
@ManyToOne(optional = false)
private CcmApplication owner;
/**
* The {@link Domain} owned by the {@link CcmObject}.
*/
@ManyToOne(optional = false)
@JsonIdentityReference(alwaysAsId = true)
private Domain domain;
/**
* The {@link CcmObject} owning the {@link Domain}.
*/
@ManyToOne(optional = false)
@JsonIdentityReference(alwaysAsId = true)
private CcmApplication owner;
/**
* The context for the domain mapping.
*/

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2015 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.categorization;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
*/
public class DomainOwnershipIdGenerator extends ObjectIdGenerator<String> {
@Override
public Class<?> getScope() {
return DomainOwnership.class;
}
@Override
public boolean canUseFor(ObjectIdGenerator<?> objectIdGenerator) {
return objectIdGenerator instanceof DomainOwnershipIdGenerator;
}
@Override
public ObjectIdGenerator<String> forScope(Class<?> aClass) {
return this;
}
@Override
public ObjectIdGenerator<String> newForSerialization(Object o) {
return this;
}
@Override
public IdKey key(Object key) {
if (key == null)
return null;
return new IdKey(DomainOwnership.class, DomainOwnership.class, key);
}
@Override
public String generateId(Object forPojo) {
if (!(forPojo instanceof DomainOwnership)) {
throw new IllegalArgumentException(
"Only DomainOwnerships instances are supported.");
}
final DomainOwnership domainOwnership = (DomainOwnership) forPojo;
return String.format("{%s}{%s}",
domainOwnership.getDomain().getDomainKey(),
domainOwnership.getOwner().getPrimaryUrl());
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 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.categorization;
import org.libreccm.portation.AbstractMarshaller;
import org.libreccm.portation.Marshals;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/23/17
*/
@RequestScoped
@Marshals(DomainOwnership.class)
public class DomainOwnershipMarshaller extends AbstractMarshaller<DomainOwnership> {
@Inject
private EntityManager entityManager;
@Override
protected Class<DomainOwnership> getObjectClass() {
return DomainOwnership.class;
}
@Override
protected void insertIntoDb(DomainOwnership portableObject) {
if (portableObject.getOwnershipId() == 0) {
entityManager.persist(portableObject);
} else {
entityManager.merge(portableObject);
}
}
}

View File

@ -22,19 +22,16 @@ import org.libreccm.core.AbstractEntityRepository;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
import javax.enterprise.context.RequestScoped;
import javax.persistence.EntityGraph;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityGraph;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
/**
* A repository for executing CRUD operations on {@link Domain} objects.
*
@ -47,9 +44,6 @@ import javax.transaction.Transactional;
@RequestScoped
public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
@Inject
private EntityManager entityManager;
@Override
public Class<Domain> getEntityClass() {
return Domain.class;
@ -82,12 +76,12 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
* {@code null} if there is no such {@code Domain}.
*/
public Optional<Domain> findByDomainKey(final String domainKey) {
final TypedQuery<Domain> query = entityManager.createNamedQuery(
"Domain.findByKey", Domain.class);
final TypedQuery<Domain> query = getEntityManager()
.createNamedQuery("Domain.findByKey", Domain.class);
query.setParameter("key", domainKey);
final EntityGraph<?> graph = entityManager.getEntityGraph(
"Domain.allCategories");
final EntityGraph<?> graph = getEntityManager()
.getEntityGraph( "Domain.allCategories");
query.setHint("javax.persistence.fetchgraph", graph);
try {
@ -106,19 +100,38 @@ public class DomainRepository extends AbstractEntityRepository<Long, Domain> {
* if there is so such {@code Domain}.
*/
public Domain findByUri(final URI uri) {
final TypedQuery<Domain> query = entityManager.createNamedQuery(
"Domain.findByUri", Domain.class);
final TypedQuery<Domain> query = getEntityManager()
.createNamedQuery("Domain.findByUri", Domain.class);
query.setParameter("uri", uri);
return query.getSingleResult();
}
/**
* Finds a {@link Domain} by its uuid.
*
* @param uuid The uuid of the item to find
*
* @return An optional either with the found item or empty
*/
public Optional<Domain> findByUuid(final String uuid) {
final TypedQuery<Domain> query = getEntityManager()
.createNamedQuery("Domain.findByUuid", Domain.class);
query.setParameter("uuid", uuid);
try {
return Optional.of(query.getSingleResult());
} catch (NoResultException ex) {
return Optional.empty();
}
}
public List<Domain> search(final String term) {
final TypedQuery<Domain> query = entityManager.createNamedQuery(
"Domain.search", Domain.class);
final TypedQuery<Domain> query = getEntityManager()
.createNamedQuery("Domain.search", Domain.class);
query.setParameter("term", term);
final EntityGraph<?> graph = entityManager.getEntityGraph(
"Domain.withOwners");
final EntityGraph<?> graph = getEntityManager()
.getEntityGraph("Domain.withOwners");
query.setHint("javax.persistence.fetchgraph", graph);
return query.getResultList();

View File

@ -20,9 +20,9 @@
@XmlAccessorType(XmlAccessType.NONE)
package org.libreccm.categorization;
import static org.libreccm.categorization.CategorizationConstants.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
import static org.libreccm.categorization.CategorizationConstants.CAT_XML_NS;

View File

@ -21,12 +21,6 @@ package org.libreccm.core;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import javax.inject.Inject;
import javax.persistence.EntityGraph;
import javax.persistence.EntityManager;
@ -35,6 +29,7 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.transaction.Transactional;
import java.util.*;
/**
* A base class providing common method needed by every repository.

View File

@ -18,36 +18,27 @@
*/
package org.libreccm.core;
import com.arsdigita.ui.admin.applications.AdminApplicationCreator;
import com.arsdigita.ui.admin.AdminServlet;
import com.arsdigita.ui.admin.AdminUiConstants;
import com.arsdigita.ui.admin.applications.AdminApplicationCreator;
import com.arsdigita.ui.admin.applications.AdminApplicationSetup;
import com.arsdigita.ui.login.LoginApplicationCreator;
import com.arsdigita.ui.login.LoginServlet;
import com.arsdigita.ui.login.LoginApplicationSetup;
import com.arsdigita.ui.login.LoginConstants;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.persistence.EntityManager;
import com.arsdigita.ui.login.LoginServlet;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.admin.ui.AdminJsfApplicationCreator;
import org.libreccm.admin.ui.AdminJsfApplicationSetup;
import org.libreccm.modules.CcmModule;
import org.libreccm.modules.InitEvent;
import org.libreccm.modules.InstallEvent;
import org.libreccm.modules.Module;
import org.libreccm.modules.ShutdownEvent;
import org.libreccm.modules.UnInstallEvent;
import org.libreccm.modules.*;
import org.libreccm.security.SystemUsersSetup;
import org.libreccm.web.ApplicationType;
import javax.persistence.EntityManager;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -29,17 +29,7 @@ import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryManager;
import org.libreccm.security.Permission;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;

View File

@ -18,18 +18,17 @@
*/
package org.libreccm.core;
import static org.libreccm.core.CoreConstants.*;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
/**
* An embeddable entity for storing email addresses.

View File

@ -18,29 +18,18 @@
*/
package org.libreccm.core;
import static org.libreccm.core.CoreConstants.*;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.web.CcmApplication;
import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/**
* The {@code Resource} class is a base class for several other classes, for
@ -58,6 +47,13 @@ import javax.persistence.TemporalType;
*/
@Entity
@Table(name = "RESOURCES", schema = DB_SCHEMA)
@NamedQueries({
@NamedQuery(name = "Resource.findByUuid",
query = "SELECT r FROM Resource r WHERE r.uuid = :uuid"),
})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = ResourceIdResolver.class,
property = "uuid")
public class Resource extends CcmObject implements Serializable {
private static final long serialVersionUID = 7345482620613842781L;
@ -87,6 +83,7 @@ public class Resource extends CcmObject implements Serializable {
private LocalizedString description;
@ManyToOne
@JsonIdentityReference(alwaysAsId = true)
private ResourceType resourceType;
/**
@ -100,6 +97,7 @@ public class Resource extends CcmObject implements Serializable {
* The child resources of this resource.
*/
@OneToMany(mappedBy = "parent")
@JsonIgnore
private List<Resource> childs;
/**
@ -107,6 +105,7 @@ public class Resource extends CcmObject implements Serializable {
* the property will be null.
*/
@ManyToOne
@JsonIdentityReference(alwaysAsId = true)
private Resource parent;
public Resource() {

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2015 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.core;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
import org.libreccm.cdi.utils.CdiUtil;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
*/
public class ResourceIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ResourceRepository resourceRepository = cdiUtil.findBean
(ResourceRepository.class);
return resourceRepository
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Resource with uuid %s in the database.",
id.key.toString())));
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new ResourceIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof ResourceIdResolver;
}
}

View File

@ -0,0 +1,74 @@
/*
* Copyright (C) 2015 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.core;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import java.util.Optional;
import java.util.UUID;
/**
* A repository for executing CRUD operations on {@link Resource} objects.
*
* Note: This repository does the permission checks when retrieving
* {@link Resource}s from the database. This is the responsibility of the
* application using the {@link Resource}.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
*/
@RequestScoped
public class ResourceRepository extends AbstractEntityRepository<Long,
Resource> {
@Override
public Class<Resource> getEntityClass() {
return Resource.class;
}
@Override
public boolean isNew(final Resource entity) {
return entity.getObjectId() == 0;
}
@Override
public void initNewEntity(final Resource resource) {
resource.setUuid(UUID.randomUUID().toString());
}
/**
* Finds a {@link Resource} by its uuid.
*
* @param uuid The uuid of the item to find
*
* @return An optional either with the found item or empty
*/
public Optional<Resource> findByUuid(final String uuid) {
final TypedQuery<Resource> query = getEntityManager()
.createNamedQuery("Resource.findByUuid", Resource.class);
query.setParameter("uuid", uuid);
try {
return Optional.of(query.getSingleResult());
} catch (NoResultException ex) {
return Optional.empty();
}
}
}

View File

@ -18,23 +18,16 @@
*/
package org.libreccm.core;
import static org.libreccm.core.CoreConstants.*;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;
import org.libreccm.l10n.LocalizedString;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/**
* This class is a port of the old {@code ResourceType} entity.
@ -52,12 +45,19 @@ import org.libreccm.l10n.LocalizedString;
@Entity
@Table(name = "RESOURCE_TYPES", schema = DB_SCHEMA)
@Inheritance(strategy = InheritanceType.JOINED)
@NamedQueries({
@NamedQuery(name = "ResourceType.findByTitle",
query = "SELECT r FROM ResourceType r WHERE r.title = :title")
})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = ResourceTypeIdResolver.class,
property = "title")
@SuppressWarnings({"PMD.CyclomaticComplexity",
"PMD.StdCyclomaticComplexity",
"PMD.ModifiedCyclomaticComplexity",
"PMD.NPathComplexity",
"PMD.LongVariable"})
public class ResourceType implements Serializable {
public class ResourceType implements Serializable, Portable {
private static final long serialVersionUID = 4563584142251370627L;

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2015 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.core;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
import org.libreccm.cdi.utils.CdiUtil;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
*/
public class ResourceTypeIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ResourceTypeRepository resourceTypeRepository = cdiUtil
.findBean(ResourceTypeRepository.class);
return resourceTypeRepository
.findByTitle(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No ResourceType with title %s in the " +
"database.", id.key.toString())));
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new ResourceTypeIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof ResourceTypeIdResolver;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2015 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.core;
import org.libreccm.portation.AbstractMarshaller;
import org.libreccm.portation.Marshals;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/22/17
*/
@RequestScoped
@Marshals(ResourceType.class)
public class ResourceTypeMarshaller extends AbstractMarshaller<ResourceType> {
@Inject
private ResourceTypeRepository resourceTypeRepository;
@Override
protected Class<ResourceType> getObjectClass() {
return ResourceType.class;
}
@Override
protected void insertIntoDb(ResourceType portableObject) {
resourceTypeRepository.save(portableObject);
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2015 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.core;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import java.util.Optional;
/**
* A repository for executing CRUD operations on {@link ResourceType} objects.
*
* Note: This repository does the permission checks when retrieving
* {@link ResourceType}s from the database. This is the responsibility of the
* application using the {@link ResourceType}.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
*/
@RequestScoped
public class ResourceTypeRepository extends AbstractEntityRepository<Long,
ResourceType> {
@Override
public Class<ResourceType> getEntityClass() {
return ResourceType.class;
}
@Override
public boolean isNew(final ResourceType entity) {
return entity.getTitle() == null;
}
/**
* Finds a {@link ResourceType} by its title.
*
* @param title The title of the item to find
*
* @return An optional either with the found item or empty
*/
public Optional<ResourceType> findByTitle(final String title) {
final TypedQuery<ResourceType> query = getEntityManager()
.createNamedQuery("ResourceType.findByTitle", ResourceType.class);
query.setParameter("title", title);
try {
return Optional.of(query.getSingleResult());
} catch (NoResultException ex) {
return Optional.empty();
}
}
}

View File

@ -25,10 +25,10 @@
@XmlAccessorType(XmlAccessType.NONE)
package org.libreccm.core;
import static org.libreccm.core.CoreConstants.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
import static org.libreccm.core.CoreConstants.CORE_XML_NS;

View File

@ -19,16 +19,14 @@
package org.libreccm.l10n;
import com.arsdigita.kernel.KernelConfig;
import org.libreccm.configuration.ConfigurationManager;
import java.util.Enumeration;
import java.util.Locale;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Enumeration;
import java.util.Locale;
/**
* Provides the locale which has been selected based on the available languages

View File

@ -18,31 +18,19 @@
*/
package org.libreccm.l10n;
import static org.libreccm.l10n.L10NConstants.*;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.Lob;
import javax.persistence.MapKeyColumn;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.*;
import static org.libreccm.l10n.L10NConstants.L10N_XML_NS;
/**
* A helper class for localisable string properties. This class is declared as
* embeddable, so that it can be used in every other entity. The localised

View File

@ -20,10 +20,10 @@
@XmlAccessorType(XmlAccessType.NONE)
package org.libreccm.l10n;
import static org.libreccm.l10n.L10NConstants.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlSchema;
import static org.libreccm.l10n.L10NConstants.L10N_XML_NS;

View File

@ -23,13 +23,12 @@ import org.apache.logging.log4j.Logger;
import org.apache.shiro.subject.Subject;
import org.libreccm.core.CcmObject;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import javax.inject.Inject;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
/**
* A CDI interceptor which can be used to secure methods of CDI beans. To use

View File

@ -18,13 +18,8 @@
*/
package org.libreccm.security;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.interceptor.InterceptorBinding;
import java.lang.annotation.*;
/**
* Use this annotation to secure a method by the

View File

@ -19,19 +19,16 @@
package org.libreccm.security;
import com.arsdigita.kernel.KernelConfig;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.libreccm.configuration.ConfigurationManager;
import java.util.List;
import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
/**
* This bean provides several services for the {@link CcmShiroRealm}. It wraps

View File

@ -23,7 +23,6 @@ import com.arsdigita.mail.Mail;
import com.arsdigita.ui.login.LoginConstants;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
import org.apache.commons.lang.text.StrSubstitutor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -33,16 +32,11 @@ import org.libreccm.core.CoreConstants;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.l10n.LocalizedString;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import static com.arsdigita.ui.login.LoginServlet.*;

View File

@ -23,15 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.portation.Portable;
import javax.persistence.Entity;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedSubgraph;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

View File

@ -20,14 +20,13 @@ package org.libreccm.security;
import org.libreccm.core.CoreConstants;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.List;
/**
* Manager class providing methods for adding and removing members to and from

View File

@ -22,16 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.portation.Portable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

View File

@ -18,17 +18,14 @@
*/
package org.libreccm.security;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.persistence.TypedQuery;
import org.libreccm.core.AbstractEntityRepository;
import org.libreccm.core.CoreConstants;
import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
/**
* Repository for groups.

View File

@ -19,20 +19,6 @@
package org.libreccm.security;
import com.arsdigita.kernel.security.SecurityConfig;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.List;
import org.libreccm.configuration.ConfigurationManager;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.shiro.authc.credential.PasswordMatcher;
import org.apache.shiro.authc.credential.PasswordService;
@ -43,8 +29,19 @@ import org.apache.shiro.crypto.hash.format.HashFormat;
import org.apache.shiro.crypto.hash.format.HashFormatFactory;
import org.apache.shiro.crypto.hash.format.Shiro1CryptFormat;
import org.apache.shiro.util.ByteSource;
import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.CoreConstants;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.List;
/**
* This class manages the generation and delation of {@link OneTimeAuthToken}s.
*

View File

@ -18,26 +18,12 @@
*/
package org.libreccm.security;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import static org.libreccm.core.CoreConstants.*;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/**
* The {@code OneTimeAuthToken} is used as a one time authentication mechanism

View File

@ -22,10 +22,6 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.configuration.ConfigurationManager;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.Singleton;
@ -36,6 +32,9 @@ import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
/**
* This EJB uses the {@link TimerService} to run a cleanup task periodically to

View File

@ -22,24 +22,10 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashSet;

View File

@ -26,19 +26,7 @@ import org.hibernate.search.annotations.IndexedEmbedded;
import org.libreccm.core.CcmObject;
import org.libreccm.portation.Portable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

View File

@ -18,25 +18,20 @@
*/
package org.libreccm.security;
import static org.libreccm.core.CoreConstants.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.subject.Subject;
import org.libreccm.core.CcmObject;
import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Objects;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.Optional;
import static org.libreccm.core.CoreConstants.ACCESS_DENIED;
/**
* An utility class for checking permissions. Uses the current {@link Subject}

View File

@ -20,29 +20,25 @@ package org.libreccm.security;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.libreccm.core.CcmObject;
import org.libreccm.core.CcmObjectRepository;
import org.libreccm.core.CoreConstants;
import org.libreccm.core.UnexpectedErrorException;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.transaction.Transactional;
/**
* Manager class for granting and revoking permissions.
*

View File

@ -19,15 +19,13 @@
package org.libreccm.security;
import com.arsdigita.ui.login.UserNewForm;
import org.apache.logging.log4j.util.Strings;
import org.libreccm.core.CoreConstants;
import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mail.MessagingException;
import java.util.Optional;
/**

View File

@ -20,11 +20,7 @@ package org.libreccm.security;
import org.libreccm.core.CcmObject;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.*;
/**
* This annotation is used together with the {@link AuthorizationRequired}

View File

@ -18,11 +18,7 @@
*/
package org.libreccm.security;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.*;
/**
* This annotation is used together with the {@link AuthorizationRequired}

View File

@ -27,35 +27,10 @@ import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable;
import org.libreccm.workflow.TaskAssignment;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.persistence.*;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;

View File

@ -20,18 +20,17 @@ package org.libreccm.security;
import org.libreccm.core.CoreConstants;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Manager for roles providing methods for assigning the role the {@link Party}

View File

@ -22,16 +22,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.portation.Portable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

View File

@ -18,19 +18,15 @@
*/
package org.libreccm.security;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.persistence.TypedQuery;
import org.libreccm.core.AbstractEntityRepository;
import org.libreccm.core.CcmObject;
import org.libreccm.core.CoreConstants;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import org.libreccm.core.CcmObject;
import java.util.List;
import java.util.Optional;
/**

View File

@ -18,13 +18,13 @@
*/
package org.libreccm.security;
import static org.libreccm.core.CoreConstants.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.core.CcmObject;
import static org.libreccm.core.CoreConstants.ACCESS_DENIED;
/**
* A helper class used by the secured collections provided by this package.
*

View File

@ -18,10 +18,11 @@
*/
package org.libreccm.security;
import org.libreccm.core.CcmObject;
import java.util.Collection;
import java.util.List;
import java.util.ListIterator;
import org.libreccm.core.CcmObject;
/**
* A decorator for {@link List}s of {@link CcmObject}s which checks if the

View File

@ -18,10 +18,10 @@
*/
package org.libreccm.security;
import java.util.ListIterator;
import org.libreccm.core.CcmObject;
import java.util.ListIterator;
/**
* A decorator for {@link ListIterator} which checks if the current subject is
* permitted to access an object from the list the iterator iterates over before

View File

@ -18,9 +18,10 @@
*/
package org.libreccm.security;
import org.libreccm.core.CcmObject;
import java.util.Iterator;
import java.util.NavigableSet;
import org.libreccm.core.CcmObject;
/**
* A decorated for {@link NavigableSet} which checks if the current subject is

View File

@ -18,9 +18,10 @@
*/
package org.libreccm.security;
import java.util.Set;
import org.libreccm.core.CcmObject;
import java.util.Set;
/**
* A decorator for {@link Set} which checks if the current subject is permitted
* to access the objects from the decorated set before returning them.

View File

@ -18,11 +18,11 @@
*/
package org.libreccm.security;
import org.libreccm.core.CcmObject;
import java.util.Comparator;
import java.util.SortedSet;
import org.libreccm.core.CcmObject;
/**
* Decorator for {@link SortedSet} which checks if the current subject is
* permitted to access the objects from the decorated sorted set before

View File

@ -19,17 +19,6 @@
package org.libreccm.security;
import com.arsdigita.kernel.KernelConfig;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.Session;
@ -37,6 +26,14 @@ import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.Subject;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Optional;
/**

View File

@ -25,12 +25,11 @@ import org.libreccm.core.CoreConstants;
import org.libreccm.core.EmailAddress;
import org.libreccm.modules.InstallEvent;
import javax.persistence.EntityManager;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.persistence.EntityManager;
/**
* Class used by {@link CcmCore#install(org.libreccm.modules.InstallEvent)} to
* create the system users.

View File

@ -20,42 +20,15 @@ package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.core.EmailAddress;
import org.libreccm.portation.Portable;
import javax.persistence.AssociationOverride;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedSubgraph;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;

View File

@ -20,13 +20,6 @@ package org.libreccm.security;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.kernel.security.SecurityConfig;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.executable.ValidateOnExecution;
import org.apache.shiro.authc.credential.PasswordMatcher;
import org.apache.shiro.authc.credential.PasswordService;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
@ -41,7 +34,11 @@ import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.CoreConstants;
import org.libreccm.core.EmailAddress;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
import javax.validation.constraints.NotNull;
import javax.validation.executable.ValidateOnExecution;
/**
* Provides various operations for user objects.

View File

@ -21,13 +21,12 @@ package org.libreccm.security;
import org.libreccm.core.AbstractEntityRepository;
import org.libreccm.core.CoreConstants;
import java.util.List;
import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.persistence.EntityGraph;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
/**
* Repository for user objects.

View File

@ -26,12 +26,11 @@ import org.libreccm.modules.InstallEvent;
import org.libreccm.security.ApplicationRoleSetup;
import org.libreccm.security.Role;
import javax.persistence.EntityManager;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.persistence.EntityManager;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -29,14 +29,6 @@ import org.libreccm.modules.Module;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.ServiceLoader;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
@ -45,6 +37,7 @@ import javax.persistence.TypedQuery;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.transaction.Transactional;
import java.util.*;
/**
*

View File

@ -23,13 +23,12 @@ import org.libreccm.core.CoreConstants;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
import java.util.List;
import java.util.Optional;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
/**
*
@ -87,6 +86,26 @@ public class ApplicationRepository
return query.getResultList();
}
/**
* Finds a {@link CcmApplication} by its uuid.
*
* @param uuid The uuid of the item to find
*
* @return An optional either with the found item or empty
*/
public Optional<CcmApplication> findByUuid(final String uuid) {
final TypedQuery<CcmApplication> query = getEntityManager()
.createNamedQuery("CcmApplication.findByUuid",
CcmApplication.class);
query.setParameter("uuid", uuid);
try {
return Optional.of(query.getSingleResult());
} catch (NoResultException ex) {
return Optional.empty();
}
}
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)

View File

@ -23,13 +23,11 @@ import com.arsdigita.ui.admin.applications.AbstractAppSettingsPane;
import com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm;
import com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>

View File

@ -18,34 +18,27 @@
*/
package org.libreccm.web;
import static org.libreccm.web.WebConstants.*;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.categorization.Domain;
import org.libreccm.categorization.DomainManager;
import org.libreccm.categorization.DomainOwnership;
import static org.libreccm.core.CoreConstants.*;
import org.libreccm.core.Resource;
import org.libreccm.portation.Portable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import static org.libreccm.web.WebConstants.WEB_XML_NS;
/**
*
@ -59,7 +52,10 @@ import javax.xml.bind.annotation.XmlRootElement;
+ "WHERE a.primaryUrl = :path"),
@NamedQuery(name = "CcmApplication.findByType",
query = "SELECT A FROM CcmApplication a "
+ "WHERE a.applicationType = :type")
+ "WHERE a.applicationType = :type"),
@NamedQuery(name = "CcmApplication.findByUuid",
query = "SELECT a FROM CcmApplication a "
+ "WHERE a.uuid = :uuid")
})
@NamedEntityGraphs({
@NamedEntityGraph(
@ -69,7 +65,10 @@ import javax.xml.bind.annotation.XmlRootElement;
})
})
@XmlRootElement(name = "application", namespace = WEB_XML_NS)
public class CcmApplication extends Resource implements Serializable {
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = CcmApplicationIdResolver.class,
property = "uuid")
public class CcmApplication extends Resource implements Serializable, Portable {
private static final long serialVersionUID = 9205226362368890784L;
@ -91,6 +90,7 @@ public class CcmApplication extends Resource implements Serializable {
@OneToMany(mappedBy = "owner")
@XmlElementWrapper(name = "domains", namespace = WEB_XML_NS)
@XmlElement(name = "domain", namespace = WEB_XML_NS)
@JsonIgnore
private List<DomainOwnership> domains;
public CcmApplication() {

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2015 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.web;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
import org.libreccm.cdi.utils.CdiUtil;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/10/17
*/
public class CcmApplicationIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey, Object o) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ApplicationRepository applicationRepository = cdiUtil
.findBean(ApplicationRepository.class);
return applicationRepository
.findByUuid(id.key.toString())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No ccmApplications with uuid %s in the " +
"database.", id.key.toString())));
}
@Override
public ObjectIdResolver newForDeserialization(Object o) {
return new CcmApplicationIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver objectIdResolver) {
return objectIdResolver instanceof CcmApplicationIdResolver;
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2015 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.web;
import org.libreccm.portation.AbstractMarshaller;
import org.libreccm.portation.Marshals;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 8/22/17
*/
@RequestScoped
@Marshals(CcmApplication.class)
public class CcmApplicationMarshaller extends AbstractMarshaller<CcmApplication> {
@Inject
private ApplicationRepository applicationRepository;
@Override
protected Class<CcmApplication> getObjectClass() {
return CcmApplication.class;
}
@Override
protected void insertIntoDb(CcmApplication portableObject) {
applicationRepository.save(portableObject);
}
}

View File

@ -18,18 +18,11 @@
*/
package org.libreccm.web;
import static org.libreccm.core.CoreConstants.*;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/**
*

View File

@ -18,15 +18,12 @@
*/
package org.libreccm.web;
import com.arsdigita.web.URL;
import javax.servlet.annotation.WebServlet;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.servlet.annotation.WebServlet;
/**
* Provides the path name of the location of the applications servlet/JSP.
*

View File

@ -24,22 +24,9 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.portation.Portable;
import org.libreccm.security.User;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;

View File

@ -19,24 +19,17 @@
package org.libreccm.workflow;
import org.libreccm.core.CoreConstants;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Role;
import org.libreccm.security.RoleMembership;
import org.libreccm.security.RoleRepository;
import org.libreccm.security.Shiro;
import org.libreccm.security.User;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import org.libreccm.security.*;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/**
*

View File

@ -26,7 +26,6 @@ import org.libreccm.security.User;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

View File

@ -26,25 +26,7 @@ import org.libreccm.core.CcmObject;
import org.libreccm.core.Identifiable;
import org.libreccm.l10n.LocalizedString;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.ArrayList;

View File

@ -23,14 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.portation.Portable;
import org.libreccm.security.Role;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

View File

@ -20,24 +20,14 @@ package org.libreccm.workflow;
import org.hibernate.annotations.Type;
import org.libreccm.core.CoreConstants;
import org.libreccm.core.Identifiable;
import org.libreccm.security.User;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.libreccm.core.Identifiable;
/**
* A comment for a task. Comments are intended for other users, for example to
* inform them about problems etc. with the object.

View File

@ -26,14 +26,13 @@ import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Shiro;
import org.libreccm.security.User;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
/**
* Manager for {@link Task}s. The logic of some of this methods has been taken

View File

@ -26,25 +26,7 @@ import org.libreccm.core.Identifiable;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable;
import javax.persistence.AssociationOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.ArrayList;

View File

@ -19,9 +19,9 @@
package org.libreccm.workflow;
import com.arsdigita.kernel.KernelConfig;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.subject.Subject;
import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.CcmObject;
import org.libreccm.core.CoreConstants;
@ -29,19 +29,7 @@ import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Shiro;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.libreccm.security.User;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
@ -49,11 +37,13 @@ import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.transaction.Transactional;
import org.apache.shiro.subject.Subject;
import org.libreccm.security.User;
import java.util.Optional;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
/**
* Manager for {@link Workflow}s. The logic of some of these classes has been

View File

@ -21,12 +21,11 @@ package org.libreccm.workflow;
import org.libreccm.core.AbstractEntityRepository;
import org.libreccm.core.CcmObject;
import java.util.Optional;
import java.util.UUID;
import javax.enterprise.context.RequestScoped;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import java.util.Optional;
import java.util.UUID;
/**
* Repository for {@link Workflow}s.

View File

@ -20,9 +20,8 @@ package org.libreccm.workflow;
import org.libreccm.core.AbstractEntityRepository;
import java.util.UUID;
import javax.enterprise.context.RequestScoped;
import java.util.UUID;
/**
* A repository for {@link WorkflowTemplate}s.

View File

@ -33,14 +33,11 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.*;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.libreccm.security.Group;
import org.libreccm.security.GroupRepository;
import org.libreccm.tests.categories.IntegrationTest;
import javax.inject.Inject;
import java.util.concurrent.TimeUnit;
import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies;
@ -149,6 +146,11 @@ public class CoreDataImportTest {
Assert.assertFalse(importHelper.importCategories());
Assert.assertFalse(importHelper.importCategorizations());
Assert.assertFalse(importHelper.importResourceTypes());
Assert.assertFalse(importHelper.importCcmApplications());
Assert.assertFalse(importHelper.importDomains());
Assert.assertFalse(importHelper.importDomainOwnerships());
}

View File

@ -18,30 +18,13 @@
*/
package org.libreccm.portation;
import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.CategorizationMarshaller;
import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryMarshaller;
import org.libreccm.security.Group;
import org.libreccm.security.GroupMarshaller;
import org.libreccm.security.GroupMembership;
import org.libreccm.security.GroupMembershipMarshaller;
import org.libreccm.security.Permission;
import org.libreccm.security.PermissionMarshaller;
import org.libreccm.security.Role;
import org.libreccm.security.RoleMarshaller;
import org.libreccm.security.RoleMembership;
import org.libreccm.security.RoleMembershipMarshaller;
import org.libreccm.security.User;
import org.libreccm.security.UserMarshaller;
import org.libreccm.workflow.AssignableTask;
import org.libreccm.workflow.AssignableTaskMarshaller;
import org.libreccm.workflow.TaskAssignment;
import org.libreccm.workflow.TaskAssignmentMarshaller;
import org.libreccm.workflow.Workflow;
import org.libreccm.workflow.WorkflowMarshaller;
import org.libreccm.workflow.WorkflowTemplate;
import org.libreccm.workflow.WorkflowTemplateMarshaller;
import org.libreccm.categorization.*;
import org.libreccm.core.ResourceType;
import org.libreccm.core.ResourceTypeMarshaller;
import org.libreccm.security.*;
import org.libreccm.web.CcmApplication;
import org.libreccm.web.CcmApplicationMarshaller;
import org.libreccm.workflow.*;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
@ -56,17 +39,11 @@ import javax.inject.Inject;
@RequestScoped
class ImportHelper {
//private String repoPath = "/home/jensp/pwi/libreccm/ccm/";
private String repoPath = "/home/tosmers/Svn/libreccm/";
private String projectPath = "ccm_ng/ccm-core/src/test/resources/" +
private final String repoPath = "/home/tosmers/Svn/libreccm/";
private final String projectPath = "ccm_ng/ccm-core/src/test/resources/" +
"portation/trunk-iaw-exports";
private boolean indentation = false;
private final boolean indentation = false;
@Inject
@Marshals(Category.class)
private CategoryMarshaller categoryMarshaller;
@Inject
@Marshals(Categorization.class)
private CategorizationMarshaller categorizationMarshaller;
@Inject
@Marshals(User.class)
private UserMarshaller userMarshaller;
@ -82,6 +59,26 @@ class ImportHelper {
@Inject
@Marshals(RoleMembership.class)
private RoleMembershipMarshaller roleMembershipMarshaller;
@Inject
@Marshals(Category.class)
private CategoryMarshaller categoryMarshaller;
@Inject
@Marshals(Categorization.class)
private CategorizationMarshaller categorizationMarshaller;
@Inject
@Marshals(ResourceType.class)
private ResourceTypeMarshaller resourceTypeMarshaller;
@Inject
@Marshals(CcmApplication.class)
private CcmApplicationMarshaller ccmApplicationMarshaller;
@Inject
@Marshals(Domain.class)
private DomainMarshaller domainMarshaller;
@Inject
@Marshals(DomainOwnership.class)
private DomainOwnershipMarshaller domainOwnershipMarshaller;
@Inject
@Marshals(WorkflowTemplate.class)
private WorkflowTemplateMarshaller workflowTemplateMarshaller;
@ -94,80 +91,153 @@ class ImportHelper {
@Inject
@Marshals(TaskAssignment.class)
private TaskAssignmentMarshaller taskAssignmentMarshaller;
@Inject
@Marshals(Permission.class)
private PermissionMarshaller permissionMarshaller;
boolean importCategories() {
categoryMarshaller.prepare(Format.XML, repoPath + projectPath,
"categories.xml", indentation);
return categoryMarshaller.importFile();
}
boolean importCategorizations() {
categorizationMarshaller.prepare(Format.XML, repoPath + projectPath,
"categorizations.xml", indentation);
return categorizationMarshaller.importFile();
}
boolean importUsers() {
userMarshaller.prepare(Format.XML, repoPath + projectPath,
"users.xml", indentation);
userMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"users.xml",
indentation);
return userMarshaller.importFile();
}
boolean importGroups() {
groupMarshaller.prepare(Format.XML, repoPath + projectPath,
"groups.xml", indentation);
groupMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"groups.xml",
indentation);
return groupMarshaller.importFile();
}
boolean importGroupMemberships() {
groupMembershipMarshaller.prepare(Format.XML, repoPath + projectPath,
"groupMemberships.xml", indentation);
groupMembershipMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"groupMemberships.xml",
indentation);
return groupMembershipMarshaller.importFile();
}
boolean importRoles() {
roleMarshaller.prepare(Format.XML, repoPath + projectPath,
"roles.xml", indentation);
roleMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"roles.xml",
indentation);
return roleMarshaller.importFile();
}
boolean importRoleMemberships() {
roleMembershipMarshaller.prepare(Format.XML, repoPath + projectPath,
"roleMemberships.xml", indentation);
roleMembershipMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"roleMemberships.xml",
indentation);
return roleMembershipMarshaller.importFile();
}
boolean importCategories() {
categoryMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"categories.xml",
indentation);
return categoryMarshaller.importFile();
}
boolean importCategorizations() {
categorizationMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"categorizations.xml",
indentation);
return categorizationMarshaller.importFile();
}
boolean importResourceTypes() {
resourceTypeMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"resourceTypes.xml",
indentation);
return resourceTypeMarshaller.importFile();
}
boolean importCcmApplications() {
ccmApplicationMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"ccmApplications.xml",
indentation);
return ccmApplicationMarshaller.importFile();
}
boolean importDomains() {
domainMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"domains.xml",
indentation);
return domainMarshaller.importFile();
}
boolean importDomainOwnerships() {
domainOwnershipMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"domainOwnerships.xml",
indentation);
return domainOwnershipMarshaller.importFile();
}
boolean importWorkflowTemplates() {
workflowTemplateMarshaller.prepare(Format.XML, repoPath + projectPath,
"workflowTemplates.xml", indentation);
workflowTemplateMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"workflowTemplates.xml",
indentation);
return workflowTemplateMarshaller.importFile();
}
boolean importWorkflows() {
workflowMarshaller.prepare(Format.XML, repoPath + projectPath,
"workflows.xml", indentation);
workflowMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"workflows.xml",
indentation);
return workflowMarshaller.importFile();
}
boolean importAssignableTasks() {
assignableTaskMarshaller.prepare(Format.XML, repoPath + projectPath,
"assignableTasks.xml", indentation);
assignableTaskMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"assignableTasks.xml",
indentation);
return assignableTaskMarshaller.importFile();
}
boolean importTaskAssignments() {
taskAssignmentMarshaller.prepare(Format.XML, repoPath + projectPath,
"taskAssignments.xml", indentation);
taskAssignmentMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"taskAssignments.xml",
indentation);
return taskAssignmentMarshaller.importFile();
}
boolean importPermissions() {
permissionMarshaller.prepare(Format.XML, repoPath + projectPath,
"permissions.xml", indentation);
permissionMarshaller.prepare(
Format.XML,
repoPath + projectPath,
"permissions.xml",
indentation);
return permissionMarshaller.importFile();
}