CCM NG: Several bugfixes
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5151 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
8cb19db371
commit
bbf0eb9bdd
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.librecms.contentsection;
|
||||
|
||||
import com.arsdigita.kernel.KernelConfig;
|
||||
|
||||
import org.apache.shiro.subject.Subject;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -27,6 +29,7 @@ import org.libreccm.categorization.Categorization;
|
|||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryManager;
|
||||
import org.libreccm.categorization.ObjectNotAssignedToCategoryException;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.CcmObjectRepository;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
|
|
@ -65,9 +68,17 @@ import javax.transaction.Transactional;
|
|||
public class ContentItemRepository
|
||||
extends AbstractAuditedEntityRepository<Long, ContentItem> {
|
||||
|
||||
private static final long serialVersionUID = -145167586339461600L;
|
||||
|
||||
@Inject
|
||||
private CategoryManager categoryManager;
|
||||
|
||||
@Inject
|
||||
private CcmObjectRepository ccmObjectRepo;
|
||||
|
||||
@Inject
|
||||
private ConfigurationManager confManager;
|
||||
|
||||
@Inject
|
||||
private FolderRepository folderRepo;
|
||||
|
||||
|
|
@ -75,28 +86,25 @@ public class ContentItemRepository
|
|||
private ContentItemManager itemManager;
|
||||
|
||||
@Inject
|
||||
private CategoryManager categoryManager;
|
||||
|
||||
@Inject
|
||||
private Shiro shiro;
|
||||
|
||||
@Inject
|
||||
private UserRepository userRepository;
|
||||
private PermissionChecker permissionChecker;
|
||||
|
||||
@Inject
|
||||
private RoleManager roleManager;
|
||||
|
||||
@Inject
|
||||
private WorkflowRepository workflowRepo;
|
||||
|
||||
@Inject
|
||||
private TaskRepository taskRepo;
|
||||
private Shiro shiro;
|
||||
|
||||
@Inject
|
||||
private TaskManager taskManager;
|
||||
|
||||
@Inject
|
||||
private PermissionChecker permissionChecker;
|
||||
private TaskRepository taskRepo;
|
||||
|
||||
@Inject
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Inject
|
||||
private WorkflowRepository workflowRepo;
|
||||
|
||||
@Override
|
||||
public Long getEntityId(final ContentItem item) {
|
||||
|
|
@ -440,7 +448,6 @@ public class ContentItemRepository
|
|||
final Class<? extends ContentItem> type,
|
||||
final String name) {
|
||||
|
||||
|
||||
final TypedQuery<ContentItem> query = getEntityManager()
|
||||
.createNamedQuery("ContentItem.filterByFolderAndTypeAndName",
|
||||
ContentItem.class);
|
||||
|
|
@ -637,8 +644,25 @@ public class ContentItemRepository
|
|||
roles = roleManager.findAllRolesForUser(theUser);
|
||||
} else {
|
||||
|
||||
final Optional<User> publicUser;
|
||||
|
||||
final KernelConfig kernelConfig = confManager
|
||||
.findConfiguration(KernelConfig.class);
|
||||
final String principal = (String) shiro
|
||||
.getPublicUser()
|
||||
.getPrincipal();
|
||||
if (kernelConfig.emailIsPrimaryIdentifier()) {
|
||||
publicUser = userRepository.findByEmailAddress(principal);
|
||||
} else {
|
||||
publicUser = userRepository.findByName(principal);
|
||||
}
|
||||
|
||||
if (publicUser.isPresent()) {
|
||||
roles = roleManager.findAllRolesForUser(publicUser.get());
|
||||
} else {
|
||||
roles = Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
final boolean isSystemUser = shiro.isSystemUser();
|
||||
final boolean isAdmin = permissionChecker.isPermitted("*");
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import java.util.Optional;
|
|||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
|
||||
import static org.librecms.pages.PagesConstants.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import static org.librecms.pages.PagesConstants.*;
|
||||
|
||||
import org.libreccm.pagemodel.RendersComponent;
|
||||
import org.librecms.contentsection.ContentItemVersion;
|
||||
|
||||
/**
|
||||
* Renderer for the {@link ItemListComponent}.
|
||||
|
|
@ -166,7 +167,12 @@ public class ItemListComponentRenderer
|
|||
final Join<? extends ContentItem, Categorization> catJoin = from
|
||||
.join("categories");
|
||||
|
||||
criteriaQuery.where(catJoin.get("category").in(categories));
|
||||
criteriaQuery.where(criteriaBuilder
|
||||
.and(catJoin.get("category").in(categories),
|
||||
criteriaBuilder.equal(catJoin.get("indexObject"), false),
|
||||
criteriaBuilder.equal(catJoin.get("type"), ""),
|
||||
criteriaBuilder.equal(from.get("version"),
|
||||
ContentItemVersion.LIVE)));
|
||||
// criteriaQuery
|
||||
// .where(criteriaBuilder
|
||||
// .and(catJoin.get("category").in(categories),
|
||||
|
|
|
|||
|
|
@ -28,22 +28,26 @@ import org.librecms.contentsection.ItemAttachment;
|
|||
import org.librecms.contentsection.rs.ContentItems;
|
||||
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Base class for the renderers for {@link ContentItems}.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public abstract class AbstractContentItemRenderer {
|
||||
public abstract class AbstractContentItemRenderer implements Serializable {
|
||||
|
||||
@Inject
|
||||
private AssetRenderers assetRenderers;
|
||||
private static final long serialVersionUID = 1290408390406469580L;
|
||||
|
||||
private final AssetRenderers assetRenderers;
|
||||
|
||||
public AbstractContentItemRenderer(final AssetRenderers assetRenderers) {
|
||||
this.assetRenderers = assetRenderers;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be called to render a {@link ContentItem}. The method
|
||||
|
|
@ -97,6 +101,7 @@ public abstract class AbstractContentItemRenderer {
|
|||
result.put("contentType", renderContentType(item.getContentType(),
|
||||
language));
|
||||
result.put("description", item.getDescription().getValue(language));
|
||||
result.put("version", item.getVersion().toString());
|
||||
result.put("creationDate", item.getCreationDate());
|
||||
result.put("lastModified", item.getLastModified());
|
||||
result.put("creationUserName", item.getCreationUserName());
|
||||
|
|
|
|||
|
|
@ -20,11 +20,13 @@ package org.librecms.pagemodel.contentitems;
|
|||
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contenttypes.Article;
|
||||
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Renderer for {@link Article} items.
|
||||
|
|
@ -35,6 +37,13 @@ import javax.enterprise.context.RequestScoped;
|
|||
@RequestScoped
|
||||
public class ArticleRenderer extends AbstractContentItemRenderer {
|
||||
|
||||
private static final long serialVersionUID = 8355183377902033759L;
|
||||
|
||||
@Inject
|
||||
public ArticleRenderer(final AssetRenderers assetRenderers) {
|
||||
super(assetRenderers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the provided {@link Article}. The following values are put into
|
||||
* the map:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.librecms.pagemodel.contentitems;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
|
@ -43,6 +44,9 @@ public class ContentItemRenderers {
|
|||
private static final Logger LOGGER = LogManager
|
||||
.getLogger(ContentItemRenderers.class);
|
||||
|
||||
@Inject
|
||||
private AssetRenderers assetRenderers;
|
||||
|
||||
@Inject
|
||||
private Instance<AbstractContentItemRenderer> renderers;
|
||||
|
||||
|
|
@ -94,7 +98,10 @@ public class ContentItemRenderers {
|
|||
LOGGER.warn("No renderer for item type \"{}\" and mode "
|
||||
+ "\"--DEFAULT--\". Returning default renderer.",
|
||||
itemType.getName());
|
||||
return new AbstractContentItemRenderer() {
|
||||
return new AbstractContentItemRenderer(assetRenderers) {
|
||||
|
||||
private static final long serialVersionUID
|
||||
= -4679445070846896396L;
|
||||
|
||||
@Override
|
||||
public void renderItem(final ContentItem item,
|
||||
|
|
|
|||
|
|
@ -20,10 +20,13 @@ package org.librecms.pagemodel.contentitems;
|
|||
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contenttypes.Event;
|
||||
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Renderer for {@link Event} items.
|
||||
*
|
||||
|
|
@ -32,6 +35,13 @@ import java.util.Map;
|
|||
@ContentItemRenderer(renders = Event.class)
|
||||
public class EventRenderer extends AbstractContentItemRenderer {
|
||||
|
||||
private static final long serialVersionUID = -3517404651544429745L;
|
||||
|
||||
@Inject
|
||||
public EventRenderer(final AssetRenderers assetRenderers) {
|
||||
super(assetRenderers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the provided {@link Event}. The following values are put into
|
||||
* {@code result}:
|
||||
|
|
|
|||
|
|
@ -21,12 +21,15 @@ package org.librecms.pagemodel.contentitems;
|
|||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contenttypes.MultiPartArticle;
|
||||
import org.librecms.contenttypes.MultiPartArticleSection;
|
||||
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Renderer for {@link MultiPartArticle} items.
|
||||
*
|
||||
|
|
@ -35,6 +38,13 @@ import java.util.stream.Collectors;
|
|||
@ContentItemRenderer(renders = MultiPartArticle.class)
|
||||
public class MultiPartArticleRenderer extends AbstractContentItemRenderer {
|
||||
|
||||
private static final long serialVersionUID = -4298383182795585868L;
|
||||
|
||||
@Inject
|
||||
public MultiPartArticleRenderer(final AssetRenderers assetRenderers) {
|
||||
super(assetRenderers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the provided {@link MultiPartArticle}. The following values are
|
||||
* put into {@code result}:
|
||||
|
|
|
|||
|
|
@ -20,11 +20,13 @@ package org.librecms.pagemodel.contentitems;
|
|||
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contenttypes.News;
|
||||
import org.librecms.pagemodel.assets.AssetRenderers;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Renderer for {@link News} items.
|
||||
|
|
@ -35,8 +37,16 @@ import javax.enterprise.context.RequestScoped;
|
|||
@RequestScoped
|
||||
public class NewsRenderer extends AbstractContentItemRenderer {
|
||||
|
||||
private static final long serialVersionUID = -493301428054148505L;
|
||||
|
||||
@Inject
|
||||
public NewsRenderer(final AssetRenderers assetRenderers) {
|
||||
super(assetRenderers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the provided {@link News} item. The following values are put into {@code result}:
|
||||
* Renders the provided {@link News} item. The following values are put into
|
||||
* {@code result}:
|
||||
*
|
||||
* <pre>
|
||||
* {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import java.util.Objects;
|
|||
|
||||
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
|
@ -36,6 +38,7 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
|
|
@ -77,13 +80,13 @@ import javax.persistence.Table;
|
|||
name = "Categorization.findIndexObject",
|
||||
query = "SELECT c.categorizedObject FROM Categorization c "
|
||||
+ "WHERE c.category = :category "
|
||||
+ "AND c.index = TRUE")
|
||||
+ "AND c.indexObject = TRUE")
|
||||
,
|
||||
@NamedQuery(
|
||||
name = "Categorization.findIndexObjectCategorization",
|
||||
query = "SELECT c FROM Categorization c "
|
||||
+ "WHERE c.category = :category "
|
||||
+ "AND c.index = TRUE"
|
||||
+ "AND c.indexObject = TRUE"
|
||||
)
|
||||
,
|
||||
@NamedQuery(
|
||||
|
|
@ -92,7 +95,7 @@ import javax.persistence.Table;
|
|||
+ "ELSE false END) "
|
||||
+ "FROM Categorization c "
|
||||
+ "WHERE c.category = :category "
|
||||
+ "AND c.index = TRUE")
|
||||
+ "AND c.indexObject = TRUE")
|
||||
})
|
||||
@JsonIdentityInfo(generator = CategorizationIdGenerator.class,
|
||||
property = "customCatId")
|
||||
|
|
@ -125,11 +128,11 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
private CcmObject categorizedObject;
|
||||
|
||||
/**
|
||||
* If the categorised object is the index object of the category this
|
||||
* property is set to {@code true}.
|
||||
* If the categorised object is the indexObject object of the category this
|
||||
property is set to {@code true}.
|
||||
*/
|
||||
@Column(name = "CATEGORY_INDEX")
|
||||
private boolean index;
|
||||
private boolean indexObject;
|
||||
|
||||
/**
|
||||
* Defines the order in which the categories assigned the the categorised
|
||||
|
|
@ -153,7 +156,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
private String type;
|
||||
|
||||
public Categorization() {
|
||||
index = false;
|
||||
indexObject = false;
|
||||
categoryOrder = 0;
|
||||
objectOrder = 0;
|
||||
}
|
||||
|
|
@ -192,12 +195,16 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
this.categorizedObject = categorizedObject;
|
||||
}
|
||||
|
||||
public boolean isIndex() {
|
||||
return index;
|
||||
// public boolean getIndex() {
|
||||
// return indexObject;
|
||||
// }
|
||||
|
||||
public boolean isIndexObject() {
|
||||
return indexObject;
|
||||
}
|
||||
|
||||
public void setIndex(final boolean index) {
|
||||
this.index = index;
|
||||
public void setIndexObject(final boolean indexObject) {
|
||||
this.indexObject = indexObject;
|
||||
}
|
||||
|
||||
public long getCategoryOrder() {
|
||||
|
|
@ -231,7 +238,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
= 89 * hash + (int) (categorizationId ^ (categorizationId >>> 32));
|
||||
hash = 89 * hash + Objects.hashCode(category);
|
||||
hash = 89 * hash + Objects.hashCode(categorizedObject);
|
||||
hash = 89 * hash + (index ? 1 : 0);
|
||||
hash = 89 * hash + (indexObject ? 1 : 0);
|
||||
hash = 89 * hash + (int) (categoryOrder ^ (categoryOrder >>> 32));
|
||||
hash = 89 * hash + (int) (objectOrder ^ (objectOrder >>> 32));
|
||||
hash = 89 * hash + Objects.hashCode(type);
|
||||
|
|
@ -263,7 +270,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (index != other.isIndex()) {
|
||||
if (indexObject != other.isIndexObject()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +308,7 @@ public class Categorization implements Serializable, Relation, Portable {
|
|||
categorizationId,
|
||||
Objects.toString(category),
|
||||
Objects.toString(categorizedObject),
|
||||
index,
|
||||
indexObject,
|
||||
categoryOrder,
|
||||
objectOrder,
|
||||
type,
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class CategoryManager {
|
|||
final long objectCount = countObjects(assignedCategory);
|
||||
categorization.setObjectOrder(objectCount + 1);
|
||||
categorization.setType(type);
|
||||
categorization.setIndex(false);
|
||||
categorization.setIndexObject(false);
|
||||
|
||||
object.addCategory(categorization);
|
||||
assignedCategory.addObject(categorization);
|
||||
|
|
@ -992,7 +992,7 @@ public class CategoryManager {
|
|||
ex);
|
||||
}
|
||||
|
||||
categorization.setIndex(true);
|
||||
categorization.setIndexObject(true);
|
||||
entityManager.merge(categorization);
|
||||
}
|
||||
|
||||
|
|
@ -1013,7 +1013,7 @@ public class CategoryManager {
|
|||
query.setParameter("category", category);
|
||||
|
||||
final List<Categorization> result = query.getResultList();
|
||||
result.forEach(categorization -> categorization.setIndex(false));
|
||||
result.forEach(categorization -> categorization.setIndexObject(false));
|
||||
result.forEach(categorization -> entityManager.merge(categorization));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
|||
} catch (IOException e) {
|
||||
LOGGER.error("Unable to read objects "
|
||||
+ "from XML line:\n \"{}\"", line);
|
||||
LOGGER.error(e);
|
||||
LOGGER.error("Exception: ", e);
|
||||
error = true;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ import java.util.Optional;
|
|||
@RequestScoped
|
||||
public class UserRepository extends AbstractEntityRepository<Long, User> {
|
||||
|
||||
private static final long serialVersionUID = 5787091134411376455L;
|
||||
|
||||
@Override
|
||||
public Class<User> getEntityClass() {
|
||||
return User.class;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public class CoreDataImportTest {
|
|||
|
||||
Assert.assertFalse(importHelper.importWorkflows());
|
||||
Assert.assertFalse(importHelper.importTaskComments());
|
||||
//Assert.assertFalse(importHelper.importAssignableTasks());
|
||||
Assert.assertFalse(importHelper.importAssignableTasks());
|
||||
// Assert.assertFalse(importHelper.importTaskAssignments());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue