CCM NG/ccm-cms: More work for the FolderBrowser

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4579 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2017-02-16 18:07:31 +00:00
parent 19aaed5baa
commit add1a11eb6
24 changed files with 144 additions and 49 deletions

View File

@ -49,7 +49,11 @@ import org.librecms.contentsection.privileges.TypePrivileges;
import java.util.List;
import java.util.TooManyListenersException;
import java.util.stream.Collectors;
import org.libreccm.l10n.GlobalizationHelper;
import org.librecms.contentsection.ContentTypeManager;
import org.librecms.contenttypes.ContentTypeInfo;
import org.librecms.contenttypes.ContentTypesManager;
/**
* A form element which displays a select box of all content types available
@ -128,24 +132,23 @@ public abstract class NewItemForm extends Form {
NewItemFormController.class);
final ContentTypeRepository typeRepo = cdiUtil.findBean(
ContentTypeRepository.class);
final ContentTypesManager typesManager = cdiUtil.findBean(
ContentTypesManager.class);
final PermissionChecker permissionChecker = cdiUtil
.findBean(PermissionChecker.class);
// if (singleTypeID == null) {
// parentType = null;
// } else {
// parentType = typeRepo.findById(singleTypeID).get();
// }
// typesCollection = section.getContentTypes().stream()
// .filter(type -> permissionChecker.isPermitted(
// TypePrivileges.USE_TYPE,
// type))
// .collect(Collectors.toList());
typesCollection = controller.getContentTypes(section);
typesCollection.forEach(type -> target.addOption(
new Option(Long.toString(type.getObjectId()),
new Text(type.getContentItemClass()))));
for (final ContentType type : typesCollection) {
final ContentTypeInfo typeInfo = typesManager
.getContentTypeInfo(type.getContentItemClass());
final String value = Long.toString(type.getObjectId());
final Label label = new Label(
new GlobalizedMessage(typeInfo.getLabelKey(),
typeInfo.getLabelBundle()));
target.addOption(
new Option(value, label));
}
}
});

View File

@ -24,6 +24,10 @@ import org.librecms.contentsection.ContentSectionCreator;
import org.librecms.contentsection.ContentSectionSetup;
import org.librecms.contentsection.ui.admin.ApplicationInstanceForm;
import org.librecms.contentsection.ui.admin.SettingsPane;
import org.librecms.contenttypes.Article;
import org.librecms.contenttypes.Event;
import org.librecms.contenttypes.MultiPartArticle;
import org.librecms.contenttypes.News;
import java.io.IOException;
import java.io.InputStream;
@ -52,6 +56,7 @@ import java.util.Properties;
)
}
)
@ContentTypes({Article.class, Event.class, MultiPartArticle.class, News.class})
public class Cms implements CcmModule {
private static final Logger LOGGER = LogManager.getLogger(Cms.class);

View File

@ -18,6 +18,9 @@
*/
package org.librecms.contentsection;
import com.arsdigita.globalization.GlobalizedMessage;
import org.libreccm.l10n.GlobalizationHelper;
import org.librecms.contentsection.privileges.TypePrivileges;
import org.libreccm.security.AuthorizationRequired;
@ -26,8 +29,12 @@ import org.libreccm.security.RequiresPrivilege;
import org.libreccm.security.Role;
import org.libreccm.workflow.WorkflowTemplate;
import org.librecms.contentsection.privileges.AdminPrivileges;
import org.librecms.contenttypes.Article;
import org.librecms.lifecycle.LifecycleDefinition;
import java.util.Objects;
import java.util.ResourceBundle;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
@ -46,6 +53,16 @@ public class ContentTypeManager {
@Inject
private PermissionManager permissionManager;
/**
* Converts the class name of a content type to {@link Class} object.
*
* @param className The class name of the content type.
*
* @return The class for the content type.
*
* @throws IllegalArgumentException If the provided class is not a sub class
* of {@link ContentItem}.
*/
@SuppressWarnings("unchecked")
public Class<? extends ContentItem> classNameToClass(final String className) {
final Class<?> clazz;
@ -57,7 +74,7 @@ public class ContentTypeManager {
ex);
}
if (clazz.isAssignableFrom(ContentItem.class)) {
if (ContentItem.class.isAssignableFrom(clazz)) {
return (Class<? extends ContentItem>) clazz;
} else {
throw new IllegalArgumentException(String.format(
@ -65,6 +82,13 @@ public class ContentTypeManager {
}
}
/**
* Sets the default lifecycle to use for new items of a content type.
*
* @param type
* @param definition The {@link LifecycleDefinition} for the lifecycle to
* use for new items of the provided {@code type}.
*/
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public void setDefaultLifecycle(
@ -77,6 +101,13 @@ public class ContentTypeManager {
typeRepo.save(type);
}
/**
* Sets the default workflow to use for new items of a content type.
*
* @param type
* @param template The {@link WorkflowTemplate} for the workflow to use for
* new items of the provided {@code type}.
*/
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public void setDefaultWorkflow(
@ -89,6 +120,13 @@ public class ContentTypeManager {
typeRepo.save(type);
}
/**
* Creates a permission granting the {@link TypePrivileges#USE_TYPE}
* privilege to a role.
*
* @param type The type on which the privilege is granted.
* @param role The role to which the privilege is granted.
*/
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public void grantUsageOfType(
@ -99,6 +137,14 @@ public class ContentTypeManager {
permissionManager.grantPrivilege(TypePrivileges.USE_TYPE, role, type);
}
/**
* Denies usages of the provided content type by revoking any existing
* permissions granting the {@link TypePrivileges#USE_TYPE} privilege to the
* provided role.
*
* @param type The type for which the permission is revoked.
* @param role The role from which the permission is removed.
*/
@Transactional(Transactional.TxType.REQUIRED)
@AuthorizationRequired
public void denyUsageOnType(

View File

@ -42,6 +42,8 @@ import org.librecms.contentsection.ContentItem;
@Entity
@Audited
@Table(name = "ARTICLES", schema = DB_SCHEMA)
@ContentTypeDescription(labelBundle = "org.librecms.contenttypes.Article",
descriptionBundle = "org.librecms.contenttypes.Article")
public class Article extends ContentItem implements Serializable {
private static final long serialVersionUID = 3832010184748095822L;

View File

@ -18,7 +18,6 @@
*/
package org.librecms.contenttypes;
import org.libreccm.modules.CcmModule;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentType;
@ -72,7 +71,8 @@ public class ContentTypesManager {
}
final List<Class<? extends ContentItem>> moduleTypes = Arrays
.stream(annotation.value()).collect(Collectors.toList());
.stream(annotation.value())
.collect(Collectors.toList());
types.addAll(moduleTypes);
}
@ -137,6 +137,7 @@ public class ContentTypesManager {
final AuthoringKit authoringKit = contentTypeClass.getAnnotation(
AuthoringKit.class);
if (authoringKit != null) {
final AuthoringKitInfo authoringKitInfo = new AuthoringKitInfo();
authoringKitInfo.setCreateComponent(authoringKit.createComponent());
@ -147,6 +148,7 @@ public class ContentTypesManager {
authoringKitInfo.setAuthoringSteps(steps);
steps.sort((step1, step2) -> Integer.compare(step1.getOrder(),
step2.getOrder()));
}
return contentTypeInfo;
}
@ -252,7 +254,7 @@ public class ContentTypesManager {
ex);
}
if (!clazz.isAssignableFrom(ContentItem.class)) {
if (!ContentItem.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(String.format(
"Class \"%s\" is not a subclass of \"%s\".",
contentTypeClass,

View File

@ -48,6 +48,8 @@ import static org.librecms.CmsConstants.*;
@Entity
@Audited
@Table(name = "EVENTS", schema = DB_SCHEMA)
@ContentTypeDescription(labelBundle = "org.librecms.contenttypes.Event",
descriptionBundle = "org.librecms.contenttypes.Event")
public class Event extends ContentItem implements Serializable {
private static final long serialVersionUID = -9104886733503414635L;

View File

@ -45,6 +45,8 @@ import static org.librecms.CmsConstants.*;
@Entity
@Audited
@Table(name = "MULTIPART_ARTICLES", schema = DB_SCHEMA)
@ContentTypeDescription(labelBundle = "org.librecms.contenttypes.MultiPartArticle",
descriptionBundle = "org.librecms.contenttypes.MultiPartArticle")
public class MultiPartArticle extends ContentItem implements Serializable {
private static final long serialVersionUID = -587374085831420868L;

View File

@ -46,6 +46,8 @@ import static org.librecms.CmsConstants.*;
@Entity
@Audited
@Table(name = "NEWS", schema = DB_SCHEMA)
@ContentTypeDescription(labelBundle = "org.librecms.contenttypes.News",
descriptionBundle = "org.librecms.contenttypes.News")
public class News extends ContentItem implements Serializable {
private static final long serialVersionUID = -4939565845920227974L;

View File

@ -115,3 +115,5 @@ cms.ui.authoring.no_types_registered=No types registered
cms.ui.contents_of=Contents of
cms.ui.new_folder=Create new folder
cms.ui.edit_folder=Rename the current folder
cms.ui.authoring.create_new=Create new
cms.ui.authoring.go=Go

View File

@ -114,3 +114,5 @@ cms.ui.authoring.no_types_registered=Keine Typen registiert
cms.ui.contents_of=Inhalt von
cms.ui.new_folder=Neuen Ordner erstellen
cms.ui.edit_folder=Aktuellen Ordner umbenennen
cms.ui.authoring.create_new=Neuer Inhalt
cms.ui.authoring.go=Anlegen

View File

@ -83,3 +83,5 @@ cms.ui.authoring.no_types_registered=No types registered
cms.ui.contents_of=Contents of
cms.ui.new_folder=Create new folder
cms.ui.edit_folder=Rename the current folder
cms.ui.authoring.create_new=Create new
cms.ui.authoring.go=Go

View File

@ -0,0 +1,2 @@
label = Article
description = An simple Article

View File

@ -0,0 +1,2 @@
label = Artikel
description = Ein einfacher Artikel

View File

@ -24,3 +24,5 @@ cms.contenttypes.event.type_label=Event
cms.contenttypes.event_type_not_registered=Type not registered
cms.contenttypes.ui.event.lead_hint=A short description of the focus of the event and its main topic. Should be no longer than 2-3 sentences. The lead text will be displayed in the detail view of the event as well as in listings of events.
cms.contenttypes.ui.event.end_date_hint=Optionally enter an end date. It is displayed on the detail view as well as in listings of other short references.
label=Event
description=An event

View File

@ -25,3 +25,5 @@ cms.contenttypes.event.type_label=Veranstaltung
cms.contenttypes.event_type_not_registered=Typ nicht registriert
cms.contenttypes.ui.event.lead_hint=Kurze Beschreibung der Veranstaltung und ihres zentralen Themas. Die L\u00e4nge sollte maximal 2-3 S\u00e4tze betragen. Die Zusammenfassung wird sowohl in der Vollansicht der Veranstaltung als auch in allen Teilsichten und Listen angezeigt.
cms.contenttypes.ui.event.end_date_hint=Ein optionales Enddatum; es wird sowohl in der Vollansicht als auch in allen Listen und sonstigen Referencen angezeigt.
label=Veranstaltung
description=Veranstaltung

View File

@ -25,3 +25,5 @@ cms.contenttypes.ui.event.there_are_no_events=Il n'y a aucun \u00e9venement
cms.contenttypes.event.type_label=Event
cms.contenttypes.ui.event.lead_hint=A short description of the focus of the event and its main topic. Should be no longer than 2-3 sentences. The lead text will be displayed in the detail view of the event as well as in listings of events.
cms.contenttypes.ui.event.end_date_hint=Optionally enter an end date. It is displayed on the detail view as well as in listings of other short references.
label=Event
description=An event

View File

@ -32,4 +32,5 @@ cms.contenttypes.ui.mparticle.section.create_break=Create page break after this
cms.contenttypes.ui.mparticle.image.delete_button=Delete Image
cms.contenttypes.ui.mparticle.section_table.link_move_below=move belowe here
cms.contenttypes.ui.mparticle.section_table.link_not_defined=(No action possible)
cms.contenttypes.multipartarticle.type_label=Multipart Article
label=Multipart Article
description=A long article which is divided in several sections

View File

@ -32,4 +32,5 @@ cms.contenttypes.ui.mparticle.section.create_break=Seitenumbruch nach diesem Abs
cms.contenttypes.ui.mparticle.image.delete_button=Bild Entfernen
cms.contenttypes.ui.mparticle.section_table.link_move_below=unterhalb verschieben
cms.contenttypes.ui.mparticle.section_table.link_not_defined=(Keine Aktion m\u00f6glich)
cms.contenttypes.multipartarticle.type_label=Mehrteiliger Artikel
label=Mehrteiliger Artikel
description=Ein l\u00e4ngerer Artikel, der in mehrere Abschnitte unterteilt ist.

View File

@ -32,4 +32,5 @@ cms.contenttypes.ui.mparticle.section.create_break=Create page break
cms.contenttypes.ui.mparticle.image.delete_button=Delete Image
cms.contenttypes.ui.mparticle.section_table.link_move_below=move belowe here
cms.contenttypes.ui.mparticle.section_table.link_not_defined=(No action possible)
cms.contenttypes.multipartarticle.type_label=Multipart Article
label=Multipart Article
description=A long article which is divided in several sections

View File

@ -8,4 +8,5 @@ cms.contenttypes.ui.newsitem.news_date=Date
cms.contenttypes.ui.newsitem.unknown=unknown
cms.contenttypes.ui.newsitem.yes=Yes
cms.contenttypes.ui.newsitem.no=No
cms.contenttypes.newsitem.type_label=News Item
label=News Item
description=News Item

View File

@ -16,4 +16,5 @@ cms.contenttypes.ui.newsitem.news_date=Erscheinungsdatum:
cms.contenttypes.ui.newsitem.unknown=unbekannt
cms.contenttypes.ui.newsitem.yes=Ja
cms.contenttypes.ui.newsitem.no=Nein
cms.contenttypes.newsitem.type_label=Neuigkeiten
label=Neuigkeiten
description=Was gibt es neues?

View File

@ -14,4 +14,5 @@ cms.contenttypes.ui.newsitem.news_date=Erscheinungsdatum:
cms.contenttypes.ui.newsitem.unknown=unknown
cms.contenttypes.ui.newsitem.yes=Yes
cms.contenttypes.ui.newsitem.no=No
cms.contenttypes.newsitem.type_label=News Item
label=News Item
description=News Item

View File

@ -292,10 +292,12 @@ public class GlobalizedMessage {
getBundleName(),
locale,
rbControl);
} catch (MissingResourceException e) {
} catch (MissingResourceException ex) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"ResourceBundle " + getBundleName() + " was not found.");
"ResourceBundle {} was not found.",
getBundleName());
LOGGER.debug(ex);
}
}

View File

@ -18,6 +18,8 @@
*/
package org.libreccm.security;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.libreccm.portation.AbstractMarshaller;
import org.libreccm.portation.Marshals;
@ -34,6 +36,8 @@ import javax.transaction.Transactional;
@Marshals(RoleMembership.class)
public class RoleMembershipMarshaller extends AbstractMarshaller<RoleMembership> {
private static final Logger LOGGER = LogManager.getLogger(RoleMembershipMarshaller.class);
@Inject
private EntityManager entityManager;
@ -51,6 +55,9 @@ public class RoleMembershipMarshaller extends AbstractMarshaller<RoleMembership>
portableObject.setMembershipId(portableObject.getMembershipId() * -1);
// entityManager.persist(portableObject);
entityManager.merge(portableObject);
entityManager.flush();
LOGGER.debug("Saved RoleMembership with id {}.",
portableObject.getMembershipId());
// } else {
// entityManager.merge(portableObject);
// }