diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticlePropertiesStep.java b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticlePropertiesStep.java
index 88e470e1b..2f4baf01d 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticlePropertiesStep.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/ArticlePropertiesStep.java
@@ -22,7 +22,6 @@ import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
-
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
@@ -43,7 +42,7 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
* The name of the editing sheet added to this step
*/
public final static String EDIT_SHEET_NAME = "edit";
-
+
private StringParameter selectedLanuageParam;
public ArticlePropertiesStep(final ItemSelectionModel itemModel,
@@ -63,8 +62,10 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
}
@Override
- protected void setDisplayComponent(final ItemSelectionModel itemModel) {
- setDisplayComponent(getArticlePropertySheet(itemModel));
+ protected void setDisplayComponent(
+ final ItemSelectionModel itemModel) {
+ setDisplayComponent(getArticlePropertySheet(itemModel,
+ selectedLanuageParam));
}
/**
@@ -78,11 +79,13 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
* release
*/
public static Component getArticlePropertySheet(
- final ItemSelectionModel itemModel) {
+ final ItemSelectionModel itemModel,
+ final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet
= (DomainObjectPropertySheet) getGenericArticlePropertySheet(
- itemModel);
+ itemModel,
+ selectedLanguageParam);
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.lead",
CmsConstants.CMS_BUNDLE),
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/EventPropertiesStep.java b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/EventPropertiesStep.java
index e37ee7e9b..5f9236a4d 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/EventPropertiesStep.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/EventPropertiesStep.java
@@ -22,7 +22,6 @@ import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.StringParameter;
-
import com.arsdigita.cms.ItemSelectionModel;
import org.librecms.contenttypes.Event;
@@ -92,7 +91,8 @@ public class EventPropertiesStep extends SimpleEditStep {
new WorkflowLockedComponentAccess(editSheet, itemSelectionModel),
editSheet.getSaveCancelSection().getCancelButton());
- setDisplayComponent(getEventPropertySheet(itemSelectionModel));
+ setDisplayComponent(getEventPropertySheet(itemSelectionModel,
+ selectedLanguageParam));
}
/**
@@ -106,10 +106,13 @@ public class EventPropertiesStep extends SimpleEditStep {
*
*/
public static Component getEventPropertySheet(
- final ItemSelectionModel itemSelectionModel) {
+ final ItemSelectionModel itemSelectionModel,
+ final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
- itemSelectionModel);
+ itemSelectionModel,
+ false,
+ selectedLanguageParam);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ConfigurationManager confManager = cdiUtil
@@ -236,8 +239,8 @@ public class EventPropertiesStep extends SimpleEditStep {
try {
result = readMethod.invoke(obj);
} catch (IllegalAccessException
- | IllegalArgumentException
- | InvocationTargetException ex) {
+ | IllegalArgumentException
+ | InvocationTargetException ex) {
throw new UnexpectedErrorException(ex);
}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/GenericArticlePropertiesStep.java b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/GenericArticlePropertiesStep.java
index 0c511bf8c..478ef4e41 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/GenericArticlePropertiesStep.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/GenericArticlePropertiesStep.java
@@ -51,7 +51,7 @@ public class GenericArticlePropertiesStep extends SimpleEditStep {
public static final String EDIT_SHEET_NAME = "edit";
private DomainObjectPropertySheet domainObjectPropertySheet;
-
+
private StringParameter selectedLanguageParam;
public GenericArticlePropertiesStep(
@@ -78,28 +78,34 @@ public class GenericArticlePropertiesStep extends SimpleEditStep {
}
protected void setDisplayComponent(final ItemSelectionModel itemModel) {
- setDisplayComponent(getGenericArticlePropertySheet(itemModel));
+ setDisplayComponent(getGenericArticlePropertySheet(
+ itemModel,
+ selectedLanguageParam));
}
protected StringParameter getSelectedLanguageParam() {
return selectedLanguageParam;
}
-
+
/**
* Returns a component that displays the properties of the Article specified
* by the ItemSelectionModel passed in.
*
- * @param itemModel The ItemSelectionModel to use
+ * @param itemModel The ItemSelectionModel to use
+ * @param selectedLanguageParam
*
* @pre itemModel != null
* @return A component to display the state of the basic properties of the
* release
*/
public static Component getGenericArticlePropertySheet(
- final ItemSelectionModel itemModel) {
-
+ final ItemSelectionModel itemModel,
+ final StringParameter selectedLanguageParam) {
+
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
- itemModel);
+ itemModel,
+ false,
+ selectedLanguageParam);
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.title",
CmsConstants.CMS_BUNDLE),
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/NewsPropertiesStep.java b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/NewsPropertiesStep.java
index 7ccd32d8f..47f6b0daa 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/NewsPropertiesStep.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/NewsPropertiesStep.java
@@ -65,8 +65,8 @@ public class NewsPropertiesStep extends SimpleEditStep {
public static String EDIT_SHEET_NAME = "edit";
public NewsPropertiesStep(final ItemSelectionModel itemModel,
- final AuthoringKitWizard parent,
- final StringParameter selectedLanguageParam) {
+ final AuthoringKitWizard parent,
+ final StringParameter selectedLanguageParam) {
super(itemModel, parent, selectedLanguageParam);
@@ -79,7 +79,9 @@ public class NewsPropertiesStep extends SimpleEditStep {
new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton());
- setDisplayComponent(getNewsDomainObjectPropertySheet(itemModel));
+ setDisplayComponent(getNewsDomainObjectPropertySheet(
+ itemModel,
+ selectedLanguageParam));
}
/**
@@ -94,10 +96,13 @@ public class NewsPropertiesStep extends SimpleEditStep {
*
*/
public static Component getNewsDomainObjectPropertySheet(
- ItemSelectionModel itemModel) {
+ final ItemSelectionModel itemModel,
+ final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
- itemModel);
+ itemModel,
+ false,
+ selectedLanguageParam);
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.title",
CmsConstants.CMS_BUNDLE),
@@ -179,8 +184,8 @@ public class NewsPropertiesStep extends SimpleEditStep {
try {
result = readMethod.invoke(obj);
} catch (IllegalAccessException
- | IllegalArgumentException
- | InvocationTargetException ex) {
+ | IllegalArgumentException
+ | InvocationTargetException ex) {
throw new UnexpectedErrorException(ex);
}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEdit.java b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEdit.java
index 640084b94..ab2122688 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEdit.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/contenttypes/ui/mparticle/MultiPartArticleEdit.java
@@ -73,7 +73,8 @@ public class MultiPartArticleEdit extends SimpleEditStep {
);
setDisplayComponent(getMultiPartArticlePropertiesSheet(
- itemSelectionModel));
+ itemSelectionModel,
+ selectedLanguageParam));
}
protected MultiPartArticleForm getForm(
@@ -83,10 +84,13 @@ public class MultiPartArticleEdit extends SimpleEditStep {
}
public Component getMultiPartArticlePropertiesSheet(
- final ItemSelectionModel itemSelectionModel) {
+ final ItemSelectionModel itemSelectionModel,
+ final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
- itemSelectionModel);
+ itemSelectionModel,
+ false,
+ selectedLanguageParam);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ConfigurationManager confManager = cdiUtil
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java
index d8dc09ede..d59ab875a 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java
@@ -592,16 +592,20 @@ public class ContentItemPage extends CMSPage implements ActionListener {
final ContentItem item) {
final ContentSection section = CMS.getContext().getContentSection();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentSectionManager sectionManager = cdiUtil.findBean(
- ContentSectionManager.class);
- final ItemResolver itemResolver = sectionManager
- .getItemResolver(section);
+// final ContentSectionManager sectionManager = cdiUtil.findBean(
+// ContentSectionManager.class);
+// final ItemResolver itemResolver = sectionManager
+// .getItemResolver(section);
// Pass in the "Live" context since we need it for the preview
- return itemResolver.generateItemURL(state,
- item,
- section,
- CMSDispatcher.PREVIEW);
+// return itemResolver.generateItemURL(state,
+// item,
+// section,
+// CMSDispatcher.PREVIEW);
+ final ContentItemPageController controller = cdiUtil
+ .findBean(ContentItemPageController.class);
+
+ return controller.getDefaultPreviewLink(section, item, state);
}
protected final static GlobalizedMessage gz(final String key) {
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java
index 7f92badad..8d504dd12 100644
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPageController.java
@@ -18,9 +18,16 @@
*/
package com.arsdigita.cms.ui;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.cms.dispatcher.CMSDispatcher;
+
import org.libreccm.l10n.GlobalizationHelper;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemRepository;
+import org.librecms.contentsection.ContentSection;
+import org.librecms.contentsection.ContentSectionManager;
+import org.librecms.contentsection.ContentSectionRepository;
+import org.librecms.dispatcher.ItemResolver;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
@@ -31,27 +38,59 @@ import javax.transaction.Transactional;
* @author Jens Pelzetter
*/
@RequestScoped
-public class ContentItemPageController {
-
+class ContentItemPageController {
+
@Inject
private GlobalizationHelper globalizationHelper;
-
+
+ @Inject
+ private ContentSectionRepository sectionRepo;
+
+ @Inject
+ private ContentSectionManager sectionManager;
@Inject
private ContentItemRepository itemRepo;
-
+
@Transactional(Transactional.TxType.REQUIRED)
- public String getContentTypeLabel(final ContentItem item) {
-
+ protected String getContentTypeLabel(final ContentItem item) {
+
final ContentItem theItem = itemRepo
- .findById(item.getObjectId())
- .orElseThrow(() -> new IllegalArgumentException(String
+ .findById(item.getObjectId())
+ .orElseThrow(() -> new IllegalArgumentException(String
.format("No ContentItem with ID %d in the database.",
item.getObjectId())));
-
+
return theItem
.getContentType()
.getLabel()
.getValue(globalizationHelper.getNegotiatedLocale());
}
-
+
+ @Transactional(Transactional.TxType.REQUIRED)
+ protected String getDefaultPreviewLink(final ContentSection section,
+ final ContentItem item,
+ final PageState state) {
+
+ final ContentSection contentSection = sectionRepo
+ .findById(section.getObjectId())
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format("No ContentSectio with ID %d in the database.",
+ section.getObjectId())));
+
+ final ContentItem contentItem = itemRepo
+ .findById(item.getObjectId())
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format("No ContentItem with ID %d in the database.",
+ item.getObjectId())));
+
+ final ItemResolver itemResolver = sectionManager
+ .getItemResolver(contentSection);
+
+ return itemResolver.generateItemURL(state,
+ contentItem,
+ contentSection,
+ CMSDispatcher.PREVIEW);
+
+ }
+
}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/GenericArticleBody.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/GenericArticleBody.java
index 83dbdf9bf..06d075a91 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/GenericArticleBody.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/GenericArticleBody.java
@@ -21,17 +21,15 @@ package com.arsdigita.cms.ui.authoring;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.LongParameter;
+import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
import org.librecms.contenttypes.Article;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
-import com.arsdigita.util.Assert;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.LocalizedString;
@@ -64,9 +62,10 @@ public class GenericArticleBody extends TextAssetBody {
* listener.
*/
public GenericArticleBody(final ItemSelectionModel itemSelectionModel,
- final AuthoringKitWizard authoringKitWizard) {
+ final AuthoringKitWizard authoringKitWizard,
+ final StringParameter selectedLanguageParam) {
- super(new ItemAssetModel(null));
+ super(new ItemAssetModel(null), selectedLanguageParam);
this.itemSelectionModel = itemSelectionModel;
this.authoringKitWizard = authoringKitWizard;
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/TextAssetBody.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/TextAssetBody.java
index de8d4407f..fb40cdaa6 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/TextAssetBody.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/TextAssetBody.java
@@ -105,6 +105,7 @@ public abstract class TextAssetBody
private static final CMSConfig CMS_CONFIG = CMSConfig.getConfig();
private final StringParameter streamlinedCreationParam;
+ private final StringParameter selectedLanguageParam;
private ItemSelectionModel assetModel;
/**
@@ -112,9 +113,11 @@ public abstract class TextAssetBody
*
* @param assetModel The {@link ItemSelectionModel} which will be
* responsible for maintaining the current asset
+ * @param selectedLanguageParam
*/
- public TextAssetBody(final ItemSelectionModel assetModel) {
- this(assetModel, null);
+ public TextAssetBody(final ItemSelectionModel assetModel,
+ final StringParameter selectedLanguageParam) {
+ this(assetModel, null, selectedLanguageParam);
}
/**
@@ -126,9 +129,11 @@ public abstract class TextAssetBody
* form may use the wizard's methods, such as
* stepForward and stepBack, in its process
* listener.
+ * @param selectedLangugeParam
*/
public TextAssetBody(final ItemSelectionModel assetModel,
- final AuthoringKitWizard authoringKitWizard) {
+ final AuthoringKitWizard authoringKitWizard,
+ final StringParameter selectedLangugeParam) {
super();
this.assetModel = assetModel;
@@ -143,6 +148,8 @@ public abstract class TextAssetBody
.getContentItemClass()
.getName()));
}
+
+ this.selectedLanguageParam = selectedLangugeParam;
if (!CMS_CONFIG.isHideTextAssetUploadFile()) {
final PageFileForm pageFileForm = getPageFileForm();
@@ -182,7 +189,8 @@ public abstract class TextAssetBody
protected DomainObjectPropertySheet getBodyPropertySheet(
final ItemSelectionModel assetModel) {
- return new TextAssetBodyPropertySheet(assetModel);
+ return new TextAssetBodyPropertySheet(assetModel,
+ selectedLanguageParam);
}
/**
@@ -698,7 +706,7 @@ public abstract class TextAssetBody
pageTextForm.add(new Label(new GlobalizedMessage(
"cms.ui.authoring.edit_body_text",
CmsConstants.CMS_BUNDLE)),
- ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH);
+ ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH);
pageTextForm.textWidget = new CMSDHTMLEditor(PageTextForm.TEXT_ENTRY);
pageTextForm.textWidget.setRows(25);
@@ -709,7 +717,8 @@ public abstract class TextAssetBody
pageTextForm.textWidget.setMetaDataAttribute("width", "575");
pageTextForm.textWidget.setMetaDataAttribute("height", "500");
pageTextForm.textWidget.setWrap(CMSDHTMLEditor.SOFT);
- pageTextForm.add(pageTextForm.textWidget, ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH);
+ pageTextForm.add(pageTextForm.textWidget, ColumnPanel.LEFT
+ | ColumnPanel.FULL_WIDTH);
pageTextForm.saveCancelSection = new SaveCancelSection();
pageTextForm.add(pageTextForm.saveCancelSection, ColumnPanel.FULL_WIDTH);
@@ -717,9 +726,10 @@ public abstract class TextAssetBody
// optionally, we clear the text of MSWord tags every time
// the text is submitted/saved
if (CMSConfig.getConfig().isSaveTextCleansWordTags()) {
- pageTextForm.saveCancelSection.getSaveButton().setOnClick("wordClean_"
- + PageTextForm.TEXT_ENTRY
- + "();");
+ pageTextForm.saveCancelSection.getSaveButton().setOnClick(
+ "wordClean_"
+ + PageTextForm.TEXT_ENTRY
+ + "();");
}
pageTextForm.addInitListener(pageTextForm);
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/TextAssetBodyPropertySheet.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/TextAssetBodyPropertySheet.java
index 1727cdf22..78300f2aa 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/TextAssetBodyPropertySheet.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/TextAssetBodyPropertySheet.java
@@ -32,9 +32,9 @@ import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.bebop.Table;
+import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel;
-import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
/**
@@ -49,11 +49,14 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
*
* @param objModel The selection model which feeds domain objects to this
* property sheet.
+ * @param selectedLanguageParam
*
*/
- public TextAssetBodyPropertySheet(final ItemSelectionModel objModel) {
+ public TextAssetBodyPropertySheet(
+ final ItemSelectionModel objModel,
+ final StringParameter selectedLanguageParam) {
- super(objModel);
+ super(objModel, false, selectedLanguageParam);
setModelBuilder(new TMBAdapter(new DomainObjectModelBuilder()));
getColumn(1).setCellRenderer(new TextAssetBodyLabelCellRenderer());
}
@@ -64,7 +67,6 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
// public final static String MIME_TYPE_KEY
// = TextAssetBodyLabelCellRenderer.MIME_TYPE_KEY;
-
private static final String ERROR = "No current property. "
+ "Make sure that nextRow() was "
+ "called at least once.";
@@ -74,7 +76,7 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
private Iterator properties;
private Property currentProperty;
- public TextAssetBodyPropertiesModel(final LocalizedString textAsset,
+ public TextAssetBodyPropertiesModel(final LocalizedString textAsset,
final Iterator properties,
final PageState pageState) {
this.textAsset = textAsset;
@@ -85,7 +87,7 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
@Override
public boolean nextRow() {
-
+
if (properties.hasNext()) {
currentProperty = properties.next();
return true;
@@ -135,10 +137,11 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
implements PropertySheetModelBuilder {
@Override
- public PropertySheetModel makeModel(final PropertySheet sheet,
+ public PropertySheetModel makeModel(final PropertySheet sheet,
final PageState state) {
-
- TextAssetBodyPropertySheet propSheet = (TextAssetBodyPropertySheet) sheet;
+
+ TextAssetBodyPropertySheet propSheet
+ = (TextAssetBodyPropertySheet) sheet;
throw new UnsupportedOperationException("ToDo");
}
@@ -156,7 +159,7 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
}
@Override
- public TableModel makeModel(final Table table,
+ public TableModel makeModel(final Table table,
final PageState state) {
return new TableModelAdapter(
(TextAssetBodyPropertiesModel) modelBuilder.makeModel(
@@ -179,7 +182,7 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
public TableModelAdapter(
final TextAssetBodyPropertiesModel propertiesModel) {
-
+
this.propertiesModel = propertiesModel;
row = -1;
}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/WizardSelectorController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/WizardSelectorController.java
new file mode 100644
index 000000000..0494697aa
--- /dev/null
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/WizardSelectorController.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 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 com.arsdigita.cms.ui.authoring;
+
+import org.librecms.contentsection.ContentItem;
+import org.librecms.contentsection.ContentItemRepository;
+import org.librecms.contentsection.ContentType;
+
+import java.util.Objects;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.transaction.Transactional;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+public class WizardSelectorController {
+
+ @Inject
+ private ContentItemRepository itemRepo;
+
+ @Transactional(Transactional.TxType.REQUIRED)
+ public String getTypeClass(final ContentItem item) {
+
+ Objects.requireNonNull(item);
+
+ final ContentItem contentItem = itemRepo
+ .findById(item.getObjectId())
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format("No ContentItem with ID %d in the database.",
+ item.getObjectId())));
+
+ final ContentType type = contentItem.getContentType();
+
+ return type.getContentItemClass();
+ }
+
+}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/item/ItemWorkflowRequestLocal.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/item/ItemWorkflowRequestLocal.java
index 4fa46ee11..003d717a8 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/item/ItemWorkflowRequestLocal.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/item/ItemWorkflowRequestLocal.java
@@ -25,14 +25,21 @@ import org.librecms.contentsection.ContentItem;
import com.arsdigita.cms.ui.workflow.WorkflowRequestLocal;
+import org.libreccm.cdi.utils.CdiUtil;
public class ItemWorkflowRequestLocal extends WorkflowRequestLocal {
-
@Override
protected final Object initialValue(final PageState state) {
+
final ContentItem item = CMS.getContext().getContentItem();
- return item.getWorkflow();
+// return item.getWorkflow();
+ final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
+ final ItemWorkflowRequestLocalHelper helper = cdiUtil
+ .findBean(ItemWorkflowRequestLocalHelper.class);
+
+ return helper.findWorkflowForContentItem(item);
}
+
}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/item/ItemWorkflowRequestLocalHelper.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/item/ItemWorkflowRequestLocalHelper.java
new file mode 100644
index 000000000..d168305b0
--- /dev/null
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/item/ItemWorkflowRequestLocalHelper.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2017 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 com.arsdigita.cms.ui.item;
+
+import org.hibernate.LazyInitializationException;
+import org.libreccm.workflow.Workflow;
+import org.libreccm.workflow.WorkflowRepository;
+import org.librecms.contentsection.ContentItem;
+import org.librecms.contentsection.ContentItemRepository;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.transaction.Transactional;
+
+/**
+ * Helper class for {@link ItemWorkflowRequestLocal} to avoid a
+ * {@link LazyInitializationException} when accessing the workflow of current
+ * content item.
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+class ItemWorkflowRequestLocalHelper {
+
+ @Inject
+ private ContentItemRepository itemRepo;
+
+ @Inject
+ private WorkflowRepository workflowRepo;
+
+ @Transactional(Transactional.TxType.REQUIRED)
+ protected Workflow findWorkflowForContentItem(final ContentItem item) {
+
+ final ContentItem contentItem = itemRepo
+ .findById(item.getObjectId())
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format("No ContentItem with ID %d in the database.",
+ item.getObjectId())));
+
+ final Workflow workflow = workflowRepo
+ .findById(contentItem.getWorkflow().getWorkflowId())
+ .orElseThrow(() -> new IllegalArgumentException(String
+ .format("No Workflow with ID %d in the database.",
+ contentItem.getWorkflow().getWorkflowId())));
+
+ return workflow;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/AssignedTaskTableModelBuilder.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/AssignedTaskTableModelBuilder.java
index 09c219bd2..e5f86f092 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/AssignedTaskTableModelBuilder.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/workflow/AssignedTaskTableModelBuilder.java
@@ -58,8 +58,7 @@ class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowManager workflowManager = cdiUtil.findBean(
WorkflowManager.class);
- final WorkflowState workflowState = workflowManager
- .getWorkflowState(workflow);
+ final WorkflowState workflowState = workflow.getState();
if (workflowState == WorkflowState.STARTED) {
final AssignedTaskController controller = cdiUtil.findBean(
diff --git a/ccm-cms/src/main/java/org/librecms/dispatcher/MultilingualItemResolver.java b/ccm-cms/src/main/java/org/librecms/dispatcher/MultilingualItemResolver.java
index 5eea66d98..0e913b673 100644
--- a/ccm-cms/src/main/java/org/librecms/dispatcher/MultilingualItemResolver.java
+++ b/ccm-cms/src/main/java/org/librecms/dispatcher/MultilingualItemResolver.java
@@ -461,6 +461,7 @@ public class MultilingualItemResolver implements ItemResolver {
*
* @return generated URL string
*/
+ @Transactional(Transactional.TxType.REQUIRED)
protected String generateDraftURL(final ContentSection section,
final Long itemId) {
if (LOGGER.isDebugEnabled()) {
@@ -504,6 +505,7 @@ public class MultilingualItemResolver implements ItemResolver {
* the given section, which will be presented within
* the given templateContext
*/
+ @Transactional(Transactional.TxType.REQUIRED)
protected String generateLiveURL(final ContentSection section,
final ContentItem item,
final String templateContext) {
@@ -555,6 +557,7 @@ public class MultilingualItemResolver implements ItemResolver {
*
* @return a URL which can be used to preview the given item
*/
+ @Transactional(Transactional.TxType.REQUIRED)
protected String generatePreviewURL(final ContentSection section,
final ContentItem item,
final String templateContext) {
@@ -595,6 +598,7 @@ public class MultilingualItemResolver implements ItemResolver {
* to, or null if no ID has been found in the
* url
*/
+ @Transactional(Transactional.TxType.REQUIRED)
protected ContentItem getItemFromDraftURL(final String url) {
LOGGER.debug("Looking up the item from draft URL ", url);
@@ -640,6 +644,7 @@ public class MultilingualItemResolver implements ItemResolver {
* @return The Content Item instance, it can also be either Bundle or Folder
* objects, depending on URL and file language extension
*/
+ @Transactional(Transactional.TxType.REQUIRED)
protected ContentItem getItemFromLiveURL(final String url,
final Folder parentFolder) {
@@ -693,6 +698,7 @@ public class MultilingualItemResolver implements ItemResolver {
* @return a two-element string array, the first element containing the
* bundle name, and the second element containing the lang string
*/
+ @Transactional(Transactional.TxType.REQUIRED)
protected String[] getNameAndLangFromURLFrag(final String url) {
String name;
String lang = null;
@@ -791,6 +797,7 @@ public class MultilingualItemResolver implements ItemResolver {
*
* @return The negotiated lang instance for the current request.
*/
+ @Transactional(Transactional.TxType.REQUIRED)
protected ContentItem getItemFromLangAndBundle(final String lang,
final ContentItem item) {
return item;
diff --git a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java
index a62fdb746..10bdd04dd 100755
--- a/ccm-core/src/main/java/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java
+++ b/ccm-core/src/main/java/com/arsdigita/toolbox/ui/DomainObjectPropertySheet.java
@@ -129,7 +129,11 @@ public class DomainObjectPropertySheet extends PropertySheet {
this.objectSelectionModel = objectSelectionModel;
properties = new LinkedList<>();
- this.selectedLanguageParam = selectedLanguageParam;
+ if (selectedLanguageParam == null) {
+ this.selectedLanguageParam = new StringParameter("selected_language");
+ } else {
+ this.selectedLanguageParam = selectedLanguageParam;
+ }
toStringFormatter = new SimpleAttributeFormatter();
recursiveFormatter = new RecursiveAttributeFormatter();
@@ -496,8 +500,8 @@ public class DomainObjectPropertySheet extends PropertySheet {
return (String) defaultMsg.localize();
}
- final Optional