CCM NG/ccm-cms: Several changes, especially to handle the new localisation model for content items

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4824 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-06-29 14:32:00 +00:00
parent 3b42241dbb
commit 4a29a3446a
13 changed files with 287 additions and 186 deletions

View File

@ -9,3 +9,7 @@ ccmRealm.credentialsMatcher = $passwordMatcher
securityManager.realms = $ccmRealm
securityManager.rememberMeManager.cipherKey = p5h/Aphy0gfV+XThbEPqSG4iQNh2fTNH9ZEkSBAt/Ok=
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $cacheManager

View File

@ -30,6 +30,7 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.CreationComponent;
import com.arsdigita.cms.ui.authoring.CreationSelector;
import com.arsdigita.cms.ui.authoring.LanguageWidget;
@ -44,6 +45,8 @@ import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.Folder;
import org.librecms.contenttypes.MultiPartArticle;
import java.util.Locale;
/**
* A form which will create a MultiPartArticle or one of its subclasses.
*
@ -135,16 +138,20 @@ public class MultiPartArticleCreateForm
}
@Override
public void process(final FormSectionEvent e) throws FormProcessException {
final FormData data = e.getFormData();
final PageState state = e.getPageState();
public void process(final FormSectionEvent event) throws FormProcessException {
final FormData data = event.getFormData();
final PageState state = event.getPageState();
final ContentSection section = creationSelector.getContentSection(state);
final Folder folder = creationSelector.getFolder(state);
final Locale locale = new Locale((String) data
.get(BasicItemForm.LANGUAGE));
final MultiPartArticle article = createArticle(state,
(String) data.get(NAME),
section,
folder);
folder,
locale);
article.getTitle().addValue(KernelConfig.getConfig().getDefaultLocale(),
(String) data.get(TITLE));
if (!CMSConfig.getConfig().isHideLaunchDate()) {

View File

@ -301,6 +301,7 @@ public abstract class MultiPartArticleForm
* @param name
* @param section
* @param folder
* @param locale Initial locale of the article.
*
* @return the new content item (or a proper subclass)
* @throws com.arsdigita.bebop.FormProcessException
@ -308,7 +309,8 @@ public abstract class MultiPartArticleForm
public MultiPartArticle createArticle(final PageState state,
final String name,
final ContentSection section,
final Folder folder)
final Folder folder,
final Locale locale)
throws FormProcessException {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
@ -319,7 +321,8 @@ public abstract class MultiPartArticleForm
.createContentItem(name,
section,
folder,
MultiPartArticle.class);
MultiPartArticle.class,
locale);
if (itemSelectionModel.getSelectedKey(state) == null) {
itemSelectionModel.setSelectedKey(state, article.getObjectId());

View File

@ -19,6 +19,7 @@
package com.arsdigita.cms.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentItem;
@ -26,10 +27,15 @@ import org.librecms.contentsection.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.PageLocations;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contentsection.ContentItemL10NManager;
import java.util.List;
import java.util.Locale;
/**
* <p>
@ -41,11 +47,14 @@ import java.util.List;
class ContentItemContextBar extends ContentSectionContextBar {
private final ItemSelectionModel itemSelectionModel;
private final StringParameter selectedLanguageParam;
ContentItemContextBar(final ItemSelectionModel itemSelectionModel) {
ContentItemContextBar(final ItemSelectionModel itemSelectionModel,
final StringParameter selectedLanguageParam) {
super();
this.itemSelectionModel = itemSelectionModel;
this.selectedLanguageParam = selectedLanguageParam;
}
@Override
@ -63,12 +72,33 @@ class ContentItemContextBar extends ContentSectionContextBar {
title.append(localize("cms.ui.content_item"));
title.append(": ")
.append(item.getDisplayName());
// final String language = item.getLanguage();
// if (language != null) {
// title.append(" (")
// .append(language)
// .append(")");
// }
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentItemL10NManager l10nManager = cdiUtil
.findBean(ContentItemL10NManager.class);
final String selectedLanguage = (String) state
.getValue(selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage == null
|| selectedLanguage.isEmpty()) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
}
final String language;
if (l10nManager.hasLanguage(item, selectedLocale)) {
language = selectedLanguage;
} else {
state.setValue(selectedLanguageParam,
KernelConfig.getConfig().getDefaultLanguage());
language = KernelConfig.getConfig().getDefaultLanguage();
}
if (language != null) {
title.append(" (")
.append(language)
.append(")");
}
entries.add(new Entry(title.toString(), url));

View File

@ -29,6 +29,7 @@ import com.arsdigita.bebop.Resettable;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.bebop.TabbedPane;
import com.arsdigita.bebop.Text;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.FormSectionEvent;
@ -66,6 +67,7 @@ import org.arsdigita.cms.CMSConfig;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemL10NManager;
import org.librecms.contentsection.ContentItemRepository;
import org.librecms.contentsection.ContentItemVersion;
import org.librecms.contentsection.ContentSection;
@ -74,6 +76,7 @@ import org.librecms.contentsection.ContentType;
import org.librecms.dispatcher.ItemResolver;
import java.io.IOException;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
@ -145,9 +148,9 @@ public class ContentItemPage extends CMSPage implements ActionListener {
private final TabbedPane tabbedPane;
private final StringParameter returnUrlParameter;
private final ItemSelectionModel itemModel;
private final ItemSelectionModel itemSelectionModel;
private final SingleSelectionModel<String> selectedLanguageModel;
private final ACSObjectSelectionModel typeModel;
private final ACSObjectSelectionModel typeSelectionModel;
private final ContentItemRequestLocal itemRequestLocal;
private final Summary summaryPane;
private final ItemWorkflowAdminPane workflowPane;
@ -156,9 +159,9 @@ public class ContentItemPage extends CMSPage implements ActionListener {
private final ItemLanguages languagesPane;
private final ItemRevisionAdminPane revisionsPane;
private final ItemTemplates templatesPane;
private final Link m_previewLink;
private final GlobalNavigation m_globalNavigation;
private final ContentItemContextBar m_contextBar;
private final Link previewLink;
private final GlobalNavigation globalNavigation;
private final ContentItemContextBar contextBar;
private final StringParameter selectedLanguageParam;
@ -175,11 +178,44 @@ public class ContentItemPage extends CMSPage implements ActionListener {
@Override
public final void prepare(final PrintEvent event) {
final PageState state = event.getPageState();
final Label label = (Label) event.getTarget();
final ContentItem item = itemRequestLocal.getContentItem(event.
getPageState());
label.setLabel(item.getDisplayName());
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentItemL10NManager l10nManager = cdiUtil
.findBean(ContentItemL10NManager.class);
final String selectedLanguage = (String) state
.getValue(selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage == null
|| selectedLanguage.isEmpty()) {
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
} else {
selectedLocale = new Locale(selectedLanguage);
}
final String language;
if (l10nManager.hasLanguage(item, selectedLocale)) {
language = selectedLanguage;
} else {
state.setValue(selectedLanguageParam,
KernelConfig.getConfig().getDefaultLanguage());
language = KernelConfig.getConfig().getDefaultLanguage();
}
final StringBuffer title = new StringBuffer(item.getDisplayName());
if (language != null) {
title
.append(" (")
.append(language)
.append(")");
}
label.setLabel(title.toString());
}
}
@ -199,14 +235,13 @@ public class ContentItemPage extends CMSPage implements ActionListener {
final LongParameter itemId = new LongParameter(ITEM_ID);
itemId.addParameterListener(new NotNullValidationListener(ITEM_ID));
addGlobalStateParam(itemId);
itemModel = new ItemSelectionModel(itemId);
itemSelectionModel = new ItemSelectionModel(itemId);
// Add the selected item language as parameter
selectedLanguageParam = new StringParameter(
SELECTED_LANGUAGE);
selectedLanguageParam.addParameterListener(
new NotNullValidationListener(
SELECTED_LANGUAGE));
new NotNullValidationListener(SELECTED_LANGUAGE));
addGlobalStateParam(selectedLanguageParam);
selectedLanguageModel = new ParameterSingleSelectionModel<>(
selectedLanguageParam);
@ -222,8 +257,10 @@ public class ContentItemPage extends CMSPage implements ActionListener {
STREAMLINED_CREATION);
addGlobalStateParam(streamlinedCreation);
typeModel = new ACSObjectSelectionModel(ContentType.class.getName(),
ContentType.class.getName(),
typeSelectionModel = new ACSObjectSelectionModel(ContentType.class
.getName(),
ContentType.class
.getName(),
contentType);
// Validate the item ID parameter (caches the validation).
@ -234,20 +271,22 @@ public class ContentItemPage extends CMSPage implements ActionListener {
returnUrlParameter = new StringParameter(RETURN_URL);
addGlobalStateParam(returnUrlParameter);
m_globalNavigation = new GlobalNavigation();
add(m_globalNavigation);
globalNavigation = new GlobalNavigation();
add(globalNavigation);
m_contextBar = new ContentItemContextBar(itemModel);
add(m_contextBar);
contextBar = new ContentItemContextBar(itemSelectionModel,
selectedLanguageParam);
add(contextBar);
// Create panels.
summaryPane = new Summary(itemModel);
wizardPane = new WizardSelector(itemModel, typeModel);
languagesPane = new ItemLanguages(itemModel, selectedLanguageModel);
summaryPane = new Summary(itemSelectionModel);
wizardPane = new WizardSelector(itemSelectionModel, typeSelectionModel);
languagesPane = new ItemLanguages(itemSelectionModel,
selectedLanguageModel);
workflowPane = new ItemWorkflowAdminPane(itemId); // Make this use m_item XXX
lifecyclePane = new ItemLifecycleAdminPane(itemRequestLocal);
revisionsPane = new ItemRevisionAdminPane(itemRequestLocal);
templatesPane = new ItemTemplates(itemModel);
templatesPane = new ItemTemplates(itemSelectionModel);
// Create tabbed pane.
tabbedPane = new TabbedPane();
@ -285,7 +324,7 @@ public class ContentItemPage extends CMSPage implements ActionListener {
});
// Build the preview link.
m_previewLink = new Link(new Label(gz("cms.ui.preview")),
previewLink = new Link(new Label(gz("cms.ui.preview")),
new PrintListener() {
@Override
@ -298,8 +337,8 @@ public class ContentItemPage extends CMSPage implements ActionListener {
}
});
m_previewLink.setIdAttr("preview_link");
add(m_previewLink);
previewLink.setIdAttr("preview_link");
add(previewLink);
addActionListener(this);
@ -374,7 +413,7 @@ public class ContentItemPage extends CMSPage implements ActionListener {
*/
@Override
public ContentItem getContentItem(final PageState state) {
return (ContentItem) itemModel.getSelectedObject(state);
return (ContentItem) itemSelectionModel.getSelectedObject(state);
}
/**

View File

@ -38,6 +38,7 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.parameters.LongParameter;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.CMS;
import org.librecms.contentsection.ContentSection;
@ -106,6 +107,7 @@ public class FlatItemList extends SegmentedPanel implements FormProcessListener,
private final Label contentLabel;
private final FolderPath folderPath;
private final Label chooseLabel;
private final StringParameter selectedLanguageParam;
/**
* Construct a new item listing pane. The provided folder selection model is
@ -178,6 +180,8 @@ public class FlatItemList extends SegmentedPanel implements FormProcessListener,
permissionsSegment.addHeader(new Label(new GlobalizedMessage(
"cms.ui.permissions", CmsConstants.CMS_BUNDLE)));
selectedLanguageParam = new StringParameter(ContentItemPage.SELECTED_LANGUAGE);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final PermissionManager permissionManager = cdiUtil.findBean(
PermissionManager.class);
@ -198,7 +202,8 @@ public class FlatItemList extends SegmentedPanel implements FormProcessListener,
typeSelectionModel.addChangeListener(this);
creationSelector = new CreationSelector(typeSelectionModel,
folderSelectionModel);
folderSelectionModel,
selectedLanguageParam);
newItemSegment.add(creationSelector);
//m_newItemSeg.add(new Label("<br/>", false));
@ -234,6 +239,7 @@ public class FlatItemList extends SegmentedPanel implements FormProcessListener,
page.addComponentStateParam(this,
typeSelectionModel.getStateParameter());
page.addGlobalStateParam(selectedLanguageParam);
page.addActionListener(new ActionListener() {

View File

@ -272,6 +272,7 @@ public abstract class BasicPageForm extends BasicItemForm {
* @param section
* @param folder
* @param initializer
* @param locale
*
* @return the new content item (or a proper subclass thereof)
*
@ -282,47 +283,16 @@ public abstract class BasicPageForm extends BasicItemForm {
final String name,
final ContentSection section,
final Folder folder,
final ContentItemInitializer<T> initializer) throws FormProcessException {
final ContentItemInitializer<T> initializer,
final Locale locale) throws FormProcessException {
// final ItemSelectionModel selectionModel = getItemSelectionModel();
// final ContentType contentType = selectionModel.getContentType();
//
// final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final ContentItemManager itemManager = cdiUtil
// .findBean(ContentItemManager.class);
//
// // Create new item
// final ContentItem item;
// try {
// @SuppressWarnings("unchecked")
// final Class<? extends ContentItem> clazz
// = (Class<? extends ContentItem>) Class
// .forName(contentType.getContentItemClass());
// item = itemManager.createContentItem(name,
// section,
// folder,
// clazz,
// initializer);
// } catch (ClassNotFoundException ex) {
// throw new FormProcessException(
// "Couldn't create contentpage",
// new GlobalizedMessage(
// "cms.ui.authoring.couldnt_create_contentpage",
// CmsConstants.CMS_BUNDLE),
// ex);
// }
//
// // Create new item
// // Make sure the item will be remembered across requests
// selectionModel.setSelectedKey(state, item.getObjectId());
//
// return item;
return createContentItemPage(state,
name,
section,
folder,
null,
initializer);
initializer,
locale);
}
public <T extends ContentItem> T createContentItemPage(
@ -331,15 +301,14 @@ public abstract class BasicPageForm extends BasicItemForm {
final ContentSection section,
final Folder folder,
final WorkflowTemplate workflowTemplate,
final ContentItemInitializer<T> initializer) throws FormProcessException {
final ContentItemInitializer<T> initializer,
final Locale locale) throws FormProcessException {
final ItemSelectionModel selectionModel = getItemSelectionModel();
final ContentType contentType = selectionModel.getContentType();
// Create new item
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
// final ContentItemManager itemManager = cdiUtil
// .findBean(ContentItemManager.class);
final BasicPageFormController controller = cdiUtil
.findBean(BasicPageFormController.class);
@ -349,33 +318,22 @@ public abstract class BasicPageForm extends BasicItemForm {
final Class<T> clazz = (Class<T>) Class
.forName(contentType.getContentItemClass());
// @SuppressWarnings("unchecked")
// final Class<? extends ContentItem> clazz
// = (Class<? extends ContentItem>) Class
// .forName(contentType.getContentItemClass());
//
if (workflowTemplate == null) {
// item = itemManager.createContentItem(name,
// section,
// folder,
// clazz,
// initializer);
item = controller
.createContentItem(name, section, folder, clazz,
initializer);
.createContentItem(name,
section,
folder,
clazz,
initializer,
locale);
} else {
// item = itemManager.createContentItem(name,
// section,
// folder,
// workflowTemplate,
// clazz,
// initializer);
item = controller.createContentItem(name,
section,
folder,
workflowTemplate,
clazz,
initializer);
initializer,
locale);
}
} catch (ClassNotFoundException ex) {
throw new FormProcessException(

View File

@ -29,6 +29,8 @@ import org.librecms.contentsection.ContentSectionRepository;
import org.librecms.contentsection.Folder;
import org.librecms.contentsection.FolderRepository;
import java.util.Locale;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.transaction.Transactional;
@ -61,9 +63,16 @@ class BasicPageFormController {
final ContentSection section,
final Folder folder,
final Class<T> clazz,
final ContentItemInitializer<T> initializer) {
final ContentItemInitializer<T> initializer,
final Locale locale) {
return createContentItem(name, section, folder, null, clazz, initializer);
return createContentItem(name,
section,
folder,
null,
clazz,
initializer,
locale);
}
@Transactional(Transactional.TxType.REQUIRED)
@ -73,7 +82,8 @@ class BasicPageFormController {
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Class<T> clazz,
final ContentItemInitializer<T> initializer) {
final ContentItemInitializer<T> initializer,
final Locale locale) {
final ContentSection contentSection = sectionRepo
.findById(section.getObjectId())
@ -94,7 +104,8 @@ class BasicPageFormController {
contentSection,
itemFolder,
clazz,
initializer);
initializer,
locale);
} else {
final WorkflowTemplate itemWorkflowTemplate = workflowTemplateRepo
@ -108,7 +119,8 @@ class BasicPageFormController {
itemFolder,
itemWorkflowTemplate,
clazz,
initializer);
initializer,
locale);
}
return item;

View File

@ -28,6 +28,7 @@ import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.bebop.form.FormErrorDisplay;
import com.arsdigita.bebop.parameters.LongParameter;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.ContentItemPage;
import com.arsdigita.cms.ui.folder.FolderSelectionModel;
@ -91,10 +92,12 @@ public class CreationSelector extends MetaForm {
private final FolderSelectionModel folderSelectionModel;
private final SingleSelectionModel<Long> typeSelectionModel;
private final StringParameter selectedLanguageParam;
private static final Class[] ARGUMENTS = new Class[]{
ItemSelectionModel.class,
CreationSelector.class
CreationSelector.class,
StringParameter.class
};
private Object[] values;
@ -115,14 +118,17 @@ public class CreationSelector extends MetaForm {
* @param folderSelectionModel the {@link FolderSelectionModel} containing
* the folder in which new items are to be
* created
* @param selectedLanguageParam
*/
public CreationSelector(final SingleSelectionModel<Long> typeSelectionModel,
final FolderSelectionModel folderSelectionModel) {
final FolderSelectionModel folderSelectionModel,
final StringParameter selectedLanguageParam) {
super("pageCreate");
this.typeSelectionModel = typeSelectionModel;
this.folderSelectionModel = folderSelectionModel;
this.selectedLanguageParam = selectedLanguageParam;
itemIdParameter = new LongParameter(ITEM_ID);
itemSelectionModel = new ItemSelectionModel(itemIdParameter);
@ -200,7 +206,9 @@ public class CreationSelector extends MetaForm {
final ItemSelectionModel itemSelectionModel
= new ItemSelectionModel(
type, itemIdParameter);
vals = new Object[]{itemSelectionModel, this};
vals = new Object[]{itemSelectionModel,
this,
selectedLanguageParam};
final Constructor<? extends FormSection> constructor = createClass
.getConstructor(ARGUMENTS);

View File

@ -44,6 +44,7 @@ import org.libreccm.workflow.WorkflowTemplateRepository;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemInitializer;
import org.librecms.contentsection.ContentItemRepository;
import org.librecms.contenttypes.ContentTypeInfo;
import org.librecms.contenttypes.ContentTypesManager;
@ -68,14 +69,15 @@ public class PageCreateForm
extends BasicPageForm
implements FormSubmissionListener, CreationComponent {
private final CreationSelector creationSelector;
private ApplyWorkflowFormSection workflowSection;
/**
* The state parameter which specifies the content section
*/
public static final String SECTION_ID = "sid";
private final CreationSelector creationSelector;
private ApplyWorkflowFormSection workflowSection;
private final StringParameter selectedLanguageParam;
/**
* Construct a new PageCreationForm
*
@ -95,6 +97,7 @@ public class PageCreateForm
super("PageCreate", itemModel, selectedLanguageParam);
this.creationSelector = creationSelector;
this.selectedLanguageParam = selectedLanguageParam;
workflowSection.setCreationSelector(creationSelector);
addSubmissionListener(this);
@ -223,16 +226,19 @@ public class PageCreateForm
final Long selectedWorkflowTemplateId = workflowSection
.getSelectedWorkflowTemplateId(state);
final Locale locale = new Locale((String) data.get(LANGUAGE));
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentItem item;
if (selectedWorkflowTemplateId == null) {
item = createContentPage(state,
(String) data.get(NAME),
section,
folder,
getItemInitializer(data, state));
getItemInitializer(data, state),
locale);
} else {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowTemplateRepository workflowTemplateRepo = cdiUtil
.findBean(WorkflowTemplateRepository.class);
final WorkflowTemplate workflowTemplate = workflowTemplateRepo
@ -246,14 +252,19 @@ public class PageCreateForm
section,
folder,
workflowTemplate,
getItemInitializer(data, state));
getItemInitializer(data, state),
locale);
}
final Locale locale = new Locale((String) data.get(LANGUAGE));
item.getName().addValue(locale, (String) data.get(NAME));
// item.getName().addValue(locale, (String) data.get(NAME));
item.getTitle().addValue(locale, (String) data.get(TITLE));
// workflowSection.applyWorkflow(state, item);
final ContentItemRepository itemRepo = cdiUtil
.findBean(ContentItemRepository.class);
itemRepo.save(item);
state.setValue(selectedLanguageParam, locale.toString());
creationSelector.editItem(state, item);
}

View File

@ -372,18 +372,24 @@ public class FolderBrowserController {
final FolderBrowserTableRow row = new FolderBrowserTableRow();
final Locale negotiatedLocale = globalizationHelper
.getNegotiatedLocale();
row.setObjectId(item.getObjectId());
row.setObjectUuid(item.getItemUuid());
if (item.getName().hasValue(negotiatedLocale)) {
row.setName(item.getName().getValue(negotiatedLocale));
} else {
row.setName(item.getName().getValue(defaultLocale));
}
final List<Locale> languages = new ArrayList<>(itemL10NManager
.availableLanguages(item));
languages.sort((lang1, lang2) -> lang1.toString().compareTo(
lang2.toString()));
row.setLanguages(languages);
if (item.getTitle().hasValue(globalizationHelper
.getNegotiatedLocale())) {
row.setTitle(item.getTitle().getValue(globalizationHelper
.getNegotiatedLocale()));
if (item.getTitle().hasValue(negotiatedLocale)) {
row.setTitle(item.getTitle().getValue(negotiatedLocale));
} else {
row.setTitle(item.getTitle().getValue(defaultLocale));
}
@ -573,7 +579,8 @@ public class FolderBrowserController {
CmsConstants.CATEGORIZATION_TYPE_FOLDER),
builder.equal(fromItem.get("version"),
ContentItemVersion.DRAFT),
builder.like(builder.lower(fromItem.get("displayName")),
builder.like(builder.lower(fromItem.get(
"displayName")),
filterTerm)
)
)

View File

@ -132,6 +132,7 @@ public class ContentItemManager {
* @param section The content section in which the item is generated.
* @param folder The folder in which in the item is stored.
* @param type The type of the new content item.
* @param locale Initial locale of the new item
*
* @return The new content item.
*/
@ -142,14 +143,16 @@ public class ContentItemManager {
final ContentSection section,
@RequiresPrivilege(ItemPrivileges.CREATE_NEW)
final Folder folder,
final Class<T> type) {
final Class<T> type,
final Locale locale) {
return createContentItem(name,
section,
folder,
type,
item -> {
});
},
locale);
}
@ -168,6 +171,7 @@ public class ContentItemManager {
* @param type The type of the new content item.
* @param initalizer A {@link ContentItemInitializer} for setting mandatory
* values
* @param locale Initial locale of the new item
*
* @return The new content item.
*/
@ -179,7 +183,8 @@ public class ContentItemManager {
@RequiresPrivilege(ItemPrivileges.CREATE_NEW)
final Folder folder,
final Class<T> type,
final ContentItemInitializer<T> initalizer) {
final ContentItemInitializer<T> initalizer,
final Locale locale) {
final Optional<ContentType> contentType = typeRepo
.findByContentSectionAndClass(section, type);
@ -196,7 +201,8 @@ public class ContentItemManager {
folder,
contentType.get().getDefaultWorkflow(),
type,
initalizer);
initalizer,
locale);
}
/**
@ -219,6 +225,7 @@ public class ContentItemManager {
* @param workflowTemplate The template for the workflow to apply to the new
* item.
* @param type The type of the new content item.
* @param locale
*
* @return The new content item.
*/
@ -230,7 +237,8 @@ public class ContentItemManager {
@RequiresPrivilege(ItemPrivileges.CREATE_NEW)
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Class<T> type) {
final Class<T> type,
final Locale locale) {
return createContentItem(name,
section,
@ -238,7 +246,8 @@ public class ContentItemManager {
workflowTemplate,
type,
item -> {
});
},
locale);
}
@ -264,6 +273,7 @@ public class ContentItemManager {
* @param type The type of the new content item.
* @param initializer Initialiser implementation for setting mandatory
* properties of the new item.
* @param locale Initial locale of the new item
*
* @return The new content item.
*/
@ -276,7 +286,8 @@ public class ContentItemManager {
final Folder folder,
final WorkflowTemplate workflowTemplate,
final Class<T> type,
final ContentItemInitializer<T> initializer) {
final ContentItemInitializer<T> initializer,
final Locale locale) {
final Optional<ContentType> contentType = typeRepo
.findByContentSectionAndClass(section, type);
@ -312,7 +323,7 @@ public class ContentItemManager {
KernelConfig.class);
item.setDisplayName(name);
item.getName().addValue(kernelConfig.getDefaultLocale(),
item.getName().addValue(locale,
name);
item.setVersion(ContentItemVersion.DRAFT);

View File

@ -130,7 +130,8 @@ public class DomainObjectPropertySheet extends PropertySheet {
this.objectSelectionModel = objectSelectionModel;
properties = new LinkedList<>();
if (selectedLanguageParam == null) {
this.selectedLanguageParam = new StringParameter("selected_language");
this.selectedLanguageParam
= new StringParameter("selected_language");
} else {
this.selectedLanguageParam = selectedLanguageParam;
}
@ -609,11 +610,15 @@ public class DomainObjectPropertySheet extends PropertySheet {
if (tmp instanceof LocalizedString) {
final LocalizedString localizedString
= (LocalizedString) tmp;
final Locale selectedLocale = new Locale(
(String) state.getValue(selectedLanguageParam));
final Locale defaultLocale = KernelConfig
.getConfig()
.getDefaultLocale();
final Object selectedLanguage = state.getValue(
selectedLanguageParam);
final Locale selectedLocale;
if (selectedLanguage instanceof Locale) {
selectedLocale = (Locale) selectedLanguage;
} else {
selectedLocale = new Locale((String) selectedLanguage);
}
if (localizedString.hasValue(selectedLocale)) {
value = localizedString.getValue(selectedLocale);
} else {