More bugfixes for ContentItemPage and related classes (ContentItemPage is now displayed)

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4787 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-06-19 13:07:23 +00:00
parent 08a8a03db7
commit 77ac9d7aaa
17 changed files with 295 additions and 93 deletions

View File

@ -22,7 +22,6 @@ import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
@ -63,8 +62,10 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
} }
@Override @Override
protected void setDisplayComponent(final ItemSelectionModel itemModel) { protected void setDisplayComponent(
setDisplayComponent(getArticlePropertySheet(itemModel)); final ItemSelectionModel itemModel) {
setDisplayComponent(getArticlePropertySheet(itemModel,
selectedLanuageParam));
} }
/** /**
@ -78,11 +79,13 @@ public class ArticlePropertiesStep extends GenericArticlePropertiesStep {
* release * release
*/ */
public static Component getArticlePropertySheet( public static Component getArticlePropertySheet(
final ItemSelectionModel itemModel) { final ItemSelectionModel itemModel,
final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet final DomainObjectPropertySheet sheet
= (DomainObjectPropertySheet) getGenericArticlePropertySheet( = (DomainObjectPropertySheet) getGenericArticlePropertySheet(
itemModel); itemModel,
selectedLanguageParam);
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.lead", sheet.add(new GlobalizedMessage("cms.contenttypes.ui.lead",
CmsConstants.CMS_BUNDLE), CmsConstants.CMS_BUNDLE),

View File

@ -22,7 +22,6 @@ import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import org.librecms.contenttypes.Event; import org.librecms.contenttypes.Event;
@ -92,7 +91,8 @@ public class EventPropertiesStep extends SimpleEditStep {
new WorkflowLockedComponentAccess(editSheet, itemSelectionModel), new WorkflowLockedComponentAccess(editSheet, itemSelectionModel),
editSheet.getSaveCancelSection().getCancelButton()); editSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getEventPropertySheet(itemSelectionModel)); setDisplayComponent(getEventPropertySheet(itemSelectionModel,
selectedLanguageParam));
} }
/** /**
@ -106,10 +106,13 @@ public class EventPropertiesStep extends SimpleEditStep {
* *
*/ */
public static Component getEventPropertySheet( public static Component getEventPropertySheet(
final ItemSelectionModel itemSelectionModel) { final ItemSelectionModel itemSelectionModel,
final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemSelectionModel); itemSelectionModel,
false,
selectedLanguageParam);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ConfigurationManager confManager = cdiUtil final ConfigurationManager confManager = cdiUtil

View File

@ -78,7 +78,9 @@ public class GenericArticlePropertiesStep extends SimpleEditStep {
} }
protected void setDisplayComponent(final ItemSelectionModel itemModel) { protected void setDisplayComponent(final ItemSelectionModel itemModel) {
setDisplayComponent(getGenericArticlePropertySheet(itemModel)); setDisplayComponent(getGenericArticlePropertySheet(
itemModel,
selectedLanguageParam));
} }
protected StringParameter getSelectedLanguageParam() { protected StringParameter getSelectedLanguageParam() {
@ -90,16 +92,20 @@ public class GenericArticlePropertiesStep extends SimpleEditStep {
* by the ItemSelectionModel passed in. * by the ItemSelectionModel passed in.
* *
* @param itemModel The ItemSelectionModel to use * @param itemModel The ItemSelectionModel to use
* @param selectedLanguageParam
* *
* @pre itemModel != null * @pre itemModel != null
* @return A component to display the state of the basic properties of the * @return A component to display the state of the basic properties of the
* release * release
*/ */
public static Component getGenericArticlePropertySheet( public static Component getGenericArticlePropertySheet(
final ItemSelectionModel itemModel) { final ItemSelectionModel itemModel,
final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemModel); itemModel,
false,
selectedLanguageParam);
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.title", sheet.add(new GlobalizedMessage("cms.contenttypes.ui.title",
CmsConstants.CMS_BUNDLE), CmsConstants.CMS_BUNDLE),

View File

@ -79,7 +79,9 @@ public class NewsPropertiesStep extends SimpleEditStep {
new WorkflowLockedComponentAccess(editSheet, itemModel), new WorkflowLockedComponentAccess(editSheet, itemModel),
editSheet.getSaveCancelSection().getCancelButton()); editSheet.getSaveCancelSection().getCancelButton());
setDisplayComponent(getNewsDomainObjectPropertySheet(itemModel)); setDisplayComponent(getNewsDomainObjectPropertySheet(
itemModel,
selectedLanguageParam));
} }
/** /**
@ -94,10 +96,13 @@ public class NewsPropertiesStep extends SimpleEditStep {
* *
*/ */
public static Component getNewsDomainObjectPropertySheet( public static Component getNewsDomainObjectPropertySheet(
ItemSelectionModel itemModel) { final ItemSelectionModel itemModel,
final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemModel); itemModel,
false,
selectedLanguageParam);
sheet.add(new GlobalizedMessage("cms.contenttypes.ui.title", sheet.add(new GlobalizedMessage("cms.contenttypes.ui.title",
CmsConstants.CMS_BUNDLE), CmsConstants.CMS_BUNDLE),

View File

@ -73,7 +73,8 @@ public class MultiPartArticleEdit extends SimpleEditStep {
); );
setDisplayComponent(getMultiPartArticlePropertiesSheet( setDisplayComponent(getMultiPartArticlePropertiesSheet(
itemSelectionModel)); itemSelectionModel,
selectedLanguageParam));
} }
protected MultiPartArticleForm getForm( protected MultiPartArticleForm getForm(
@ -83,10 +84,13 @@ public class MultiPartArticleEdit extends SimpleEditStep {
} }
public Component getMultiPartArticlePropertiesSheet( public Component getMultiPartArticlePropertiesSheet(
final ItemSelectionModel itemSelectionModel) { final ItemSelectionModel itemSelectionModel,
final StringParameter selectedLanguageParam) {
final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
itemSelectionModel); itemSelectionModel,
false,
selectedLanguageParam);
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ConfigurationManager confManager = cdiUtil final ConfigurationManager confManager = cdiUtil

View File

@ -592,16 +592,20 @@ public class ContentItemPage extends CMSPage implements ActionListener {
final ContentItem item) { final ContentItem item) {
final ContentSection section = CMS.getContext().getContentSection(); final ContentSection section = CMS.getContext().getContentSection();
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentSectionManager sectionManager = cdiUtil.findBean( // final ContentSectionManager sectionManager = cdiUtil.findBean(
ContentSectionManager.class); // ContentSectionManager.class);
final ItemResolver itemResolver = sectionManager // final ItemResolver itemResolver = sectionManager
.getItemResolver(section); // .getItemResolver(section);
// Pass in the "Live" context since we need it for the preview // Pass in the "Live" context since we need it for the preview
return itemResolver.generateItemURL(state, // return itemResolver.generateItemURL(state,
item, // item,
section, // section,
CMSDispatcher.PREVIEW); // CMSDispatcher.PREVIEW);
final ContentItemPageController controller = cdiUtil
.findBean(ContentItemPageController.class);
return controller.getDefaultPreviewLink(section, item, state);
} }
protected final static GlobalizedMessage gz(final String key) { protected final static GlobalizedMessage gz(final String key) {

View File

@ -18,9 +18,16 @@
*/ */
package com.arsdigita.cms.ui; package com.arsdigita.cms.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.dispatcher.CMSDispatcher;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemRepository; 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.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
@ -31,16 +38,21 @@ import javax.transaction.Transactional;
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@RequestScoped @RequestScoped
public class ContentItemPageController { class ContentItemPageController {
@Inject @Inject
private GlobalizationHelper globalizationHelper; private GlobalizationHelper globalizationHelper;
@Inject
private ContentSectionRepository sectionRepo;
@Inject
private ContentSectionManager sectionManager;
@Inject @Inject
private ContentItemRepository itemRepo; private ContentItemRepository itemRepo;
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String getContentTypeLabel(final ContentItem item) { protected String getContentTypeLabel(final ContentItem item) {
final ContentItem theItem = itemRepo final ContentItem theItem = itemRepo
.findById(item.getObjectId()) .findById(item.getObjectId())
@ -54,4 +66,31 @@ public class ContentItemPageController {
.getValue(globalizationHelper.getNegotiatedLocale()); .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);
}
} }

View File

@ -21,17 +21,15 @@ package com.arsdigita.cms.ui.authoring;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal; 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.Option;
import com.arsdigita.bebop.form.SingleSelect; import com.arsdigita.bebop.form.SingleSelect;
import com.arsdigita.bebop.parameters.LongParameter; import com.arsdigita.bebop.parameters.LongParameter;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import org.librecms.contenttypes.Article; import org.librecms.contenttypes.Article;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
import com.arsdigita.util.Assert;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
@ -64,9 +62,10 @@ public class GenericArticleBody extends TextAssetBody {
* listener. * listener.
*/ */
public GenericArticleBody(final ItemSelectionModel itemSelectionModel, 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.itemSelectionModel = itemSelectionModel;
this.authoringKitWizard = authoringKitWizard; this.authoringKitWizard = authoringKitWizard;

View File

@ -105,6 +105,7 @@ public abstract class TextAssetBody
private static final CMSConfig CMS_CONFIG = CMSConfig.getConfig(); private static final CMSConfig CMS_CONFIG = CMSConfig.getConfig();
private final StringParameter streamlinedCreationParam; private final StringParameter streamlinedCreationParam;
private final StringParameter selectedLanguageParam;
private ItemSelectionModel assetModel; private ItemSelectionModel assetModel;
/** /**
@ -112,9 +113,11 @@ public abstract class TextAssetBody
* *
* @param assetModel The {@link ItemSelectionModel} which will be * @param assetModel The {@link ItemSelectionModel} which will be
* responsible for maintaining the current asset * responsible for maintaining the current asset
* @param selectedLanguageParam
*/ */
public TextAssetBody(final ItemSelectionModel assetModel) { public TextAssetBody(final ItemSelectionModel assetModel,
this(assetModel, null); final StringParameter selectedLanguageParam) {
this(assetModel, null, selectedLanguageParam);
} }
/** /**
@ -126,9 +129,11 @@ public abstract class TextAssetBody
* form may use the wizard's methods, such as * form may use the wizard's methods, such as
* stepForward and stepBack, in its process * stepForward and stepBack, in its process
* listener. * listener.
* @param selectedLangugeParam
*/ */
public TextAssetBody(final ItemSelectionModel assetModel, public TextAssetBody(final ItemSelectionModel assetModel,
final AuthoringKitWizard authoringKitWizard) { final AuthoringKitWizard authoringKitWizard,
final StringParameter selectedLangugeParam) {
super(); super();
this.assetModel = assetModel; this.assetModel = assetModel;
@ -144,6 +149,8 @@ public abstract class TextAssetBody
.getName())); .getName()));
} }
this.selectedLanguageParam = selectedLangugeParam;
if (!CMS_CONFIG.isHideTextAssetUploadFile()) { if (!CMS_CONFIG.isHideTextAssetUploadFile()) {
final PageFileForm pageFileForm = getPageFileForm(); final PageFileForm pageFileForm = getPageFileForm();
addFileWidgets(pageFileForm); addFileWidgets(pageFileForm);
@ -182,7 +189,8 @@ public abstract class TextAssetBody
protected DomainObjectPropertySheet getBodyPropertySheet( protected DomainObjectPropertySheet getBodyPropertySheet(
final ItemSelectionModel assetModel) { final ItemSelectionModel assetModel) {
return new TextAssetBodyPropertySheet(assetModel); return new TextAssetBodyPropertySheet(assetModel,
selectedLanguageParam);
} }
/** /**
@ -709,7 +717,8 @@ public abstract class TextAssetBody
pageTextForm.textWidget.setMetaDataAttribute("width", "575"); pageTextForm.textWidget.setMetaDataAttribute("width", "575");
pageTextForm.textWidget.setMetaDataAttribute("height", "500"); pageTextForm.textWidget.setMetaDataAttribute("height", "500");
pageTextForm.textWidget.setWrap(CMSDHTMLEditor.SOFT); 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.saveCancelSection = new SaveCancelSection();
pageTextForm.add(pageTextForm.saveCancelSection, ColumnPanel.FULL_WIDTH); pageTextForm.add(pageTextForm.saveCancelSection, ColumnPanel.FULL_WIDTH);
@ -717,7 +726,8 @@ public abstract class TextAssetBody
// optionally, we clear the text of MSWord tags every time // optionally, we clear the text of MSWord tags every time
// the text is submitted/saved // the text is submitted/saved
if (CMSConfig.getConfig().isSaveTextCleansWordTags()) { if (CMSConfig.getConfig().isSaveTextCleansWordTags()) {
pageTextForm.saveCancelSection.getSaveButton().setOnClick("wordClean_" pageTextForm.saveCancelSection.getSaveButton().setOnClick(
"wordClean_"
+ PageTextForm.TEXT_ENTRY + PageTextForm.TEXT_ENTRY
+ "();"); + "();");
} }

View File

@ -32,9 +32,9 @@ import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.bebop.table.TableModel; import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder; import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.bebop.Table; import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString; 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 * @param objModel The selection model which feeds domain objects to this
* property sheet. * 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())); setModelBuilder(new TMBAdapter(new DomainObjectModelBuilder()));
getColumn(1).setCellRenderer(new TextAssetBodyLabelCellRenderer()); getColumn(1).setCellRenderer(new TextAssetBodyLabelCellRenderer());
} }
@ -64,7 +67,6 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
// public final static String MIME_TYPE_KEY // public final static String MIME_TYPE_KEY
// = TextAssetBodyLabelCellRenderer.MIME_TYPE_KEY; // = TextAssetBodyLabelCellRenderer.MIME_TYPE_KEY;
private static final String ERROR = "No current property. " private static final String ERROR = "No current property. "
+ "Make sure that nextRow() was " + "Make sure that nextRow() was "
+ "called at least once."; + "called at least once.";
@ -138,7 +140,8 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
public PropertySheetModel makeModel(final PropertySheet sheet, public PropertySheetModel makeModel(final PropertySheet sheet,
final PageState state) { final PageState state) {
TextAssetBodyPropertySheet propSheet = (TextAssetBodyPropertySheet) sheet; TextAssetBodyPropertySheet propSheet
= (TextAssetBodyPropertySheet) sheet;
throw new UnsupportedOperationException("ToDo"); throw new UnsupportedOperationException("ToDo");
} }

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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();
}
}

View File

@ -25,14 +25,21 @@ import org.librecms.contentsection.ContentItem;
import com.arsdigita.cms.ui.workflow.WorkflowRequestLocal; import com.arsdigita.cms.ui.workflow.WorkflowRequestLocal;
import org.libreccm.cdi.utils.CdiUtil;
public class ItemWorkflowRequestLocal extends WorkflowRequestLocal { public class ItemWorkflowRequestLocal extends WorkflowRequestLocal {
@Override @Override
protected final Object initialValue(final PageState state) { protected final Object initialValue(final PageState state) {
final ContentItem item = CMS.getContext().getContentItem(); 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);
} }
} }

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@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;
}
}

View File

@ -58,8 +58,7 @@ class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final WorkflowManager workflowManager = cdiUtil.findBean( final WorkflowManager workflowManager = cdiUtil.findBean(
WorkflowManager.class); WorkflowManager.class);
final WorkflowState workflowState = workflowManager final WorkflowState workflowState = workflow.getState();
.getWorkflowState(workflow);
if (workflowState == WorkflowState.STARTED) { if (workflowState == WorkflowState.STARTED) {
final AssignedTaskController controller = cdiUtil.findBean( final AssignedTaskController controller = cdiUtil.findBean(

View File

@ -461,6 +461,7 @@ public class MultilingualItemResolver implements ItemResolver {
* *
* @return generated URL string * @return generated URL string
*/ */
@Transactional(Transactional.TxType.REQUIRED)
protected String generateDraftURL(final ContentSection section, protected String generateDraftURL(final ContentSection section,
final Long itemId) { final Long itemId) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
@ -504,6 +505,7 @@ public class MultilingualItemResolver implements ItemResolver {
* the given <code>section</code>, which will be presented within * the given <code>section</code>, which will be presented within
* the given <code>templateContext</code> * the given <code>templateContext</code>
*/ */
@Transactional(Transactional.TxType.REQUIRED)
protected String generateLiveURL(final ContentSection section, protected String generateLiveURL(final ContentSection section,
final ContentItem item, final ContentItem item,
final String templateContext) { final String templateContext) {
@ -555,6 +557,7 @@ public class MultilingualItemResolver implements ItemResolver {
* *
* @return a URL which can be used to preview the given <code>item</code> * @return a URL which can be used to preview the given <code>item</code>
*/ */
@Transactional(Transactional.TxType.REQUIRED)
protected String generatePreviewURL(final ContentSection section, protected String generatePreviewURL(final ContentSection section,
final ContentItem item, final ContentItem item,
final String templateContext) { final String templateContext) {
@ -595,6 +598,7 @@ public class MultilingualItemResolver implements ItemResolver {
* to, or <code>null</code> if no ID has been found in the * to, or <code>null</code> if no ID has been found in the
* <code>url</code> * <code>url</code>
*/ */
@Transactional(Transactional.TxType.REQUIRED)
protected ContentItem getItemFromDraftURL(final String url) { protected ContentItem getItemFromDraftURL(final String url) {
LOGGER.debug("Looking up the item from draft URL ", 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 * @return The Content Item instance, it can also be either Bundle or Folder
* objects, depending on URL and file language extension * objects, depending on URL and file language extension
*/ */
@Transactional(Transactional.TxType.REQUIRED)
protected ContentItem getItemFromLiveURL(final String url, protected ContentItem getItemFromLiveURL(final String url,
final Folder parentFolder) { final Folder parentFolder) {
@ -693,6 +698,7 @@ public class MultilingualItemResolver implements ItemResolver {
* @return a two-element string array, the first element containing the * @return a two-element string array, the first element containing the
* bundle name, and the second element containing the lang string * bundle name, and the second element containing the lang string
*/ */
@Transactional(Transactional.TxType.REQUIRED)
protected String[] getNameAndLangFromURLFrag(final String url) { protected String[] getNameAndLangFromURLFrag(final String url) {
String name; String name;
String lang = null; String lang = null;
@ -791,6 +797,7 @@ public class MultilingualItemResolver implements ItemResolver {
* *
* @return The negotiated lang instance for the current request. * @return The negotiated lang instance for the current request.
*/ */
@Transactional(Transactional.TxType.REQUIRED)
protected ContentItem getItemFromLangAndBundle(final String lang, protected ContentItem getItemFromLangAndBundle(final String lang,
final ContentItem item) { final ContentItem item) {
return item; return item;

View File

@ -129,7 +129,11 @@ public class DomainObjectPropertySheet extends PropertySheet {
this.objectSelectionModel = objectSelectionModel; this.objectSelectionModel = objectSelectionModel;
properties = new LinkedList<>(); properties = new LinkedList<>();
if (selectedLanguageParam == null) {
this.selectedLanguageParam = new StringParameter("selected_language");
} else {
this.selectedLanguageParam = selectedLanguageParam; this.selectedLanguageParam = selectedLanguageParam;
}
toStringFormatter = new SimpleAttributeFormatter(); toStringFormatter = new SimpleAttributeFormatter();
recursiveFormatter = new RecursiveAttributeFormatter(); recursiveFormatter = new RecursiveAttributeFormatter();

View File

@ -152,19 +152,6 @@ public class WorkflowManager {
return workflow; return workflow;
} }
@Transactional(Transactional.TxType.REQUIRED)
public WorkflowState getWorkflowState(final Workflow workflow) {
// Get a non detached entity
final Workflow theWorkflow = workflowRepo
.findById(workflow.getWorkflowId())
.orElseThrow(() -> new IllegalArgumentException(String
.format("No Workflow with ID in the database.",
workflow.getWorkflowId())));
return theWorkflow.getState();
}
/** /**
* Helper method for * Helper method for
* {@link #createWorkflow(org.libreccm.workflow.WorkflowTemplate, org.libreccm.core.CcmObject)} * {@link #createWorkflow(org.libreccm.workflow.WorkflowTemplate, org.libreccm.core.CcmObject)}