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-94f89814c4dfccm-docs
parent
08a8a03db7
commit
77ac9d7aaa
|
|
@ -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;
|
||||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ public class GenericArticlePropertiesStep extends SimpleEditStep {
|
|||
}
|
||||
|
||||
protected void setDisplayComponent(final ItemSelectionModel itemModel) {
|
||||
setDisplayComponent(getGenericArticlePropertySheet(itemModel));
|
||||
setDisplayComponent(getGenericArticlePropertySheet(
|
||||
itemModel,
|
||||
selectedLanguageParam));
|
||||
}
|
||||
|
||||
protected StringParameter getSelectedLanguageParam() {
|
||||
|
|
@ -90,16 +92,20 @@ public class GenericArticlePropertiesStep extends SimpleEditStep {
|
|||
* by the ItemSelectionModel passed in.
|
||||
*
|
||||
* @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),
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,16 +38,21 @@ import javax.transaction.Transactional;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@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())
|
||||
|
|
@ -54,4 +66,31 @@ public class ContentItemPageController {
|
|||
.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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -144,6 +149,8 @@ public abstract class TextAssetBody
|
|||
.getName()));
|
||||
}
|
||||
|
||||
this.selectedLanguageParam = selectedLangugeParam;
|
||||
|
||||
if (!CMS_CONFIG.isHideTextAssetUploadFile()) {
|
||||
final PageFileForm pageFileForm = getPageFileForm();
|
||||
addFileWidgets(pageFileForm);
|
||||
|
|
@ -182,7 +189,8 @@ public abstract class TextAssetBody
|
|||
protected DomainObjectPropertySheet getBodyPropertySheet(
|
||||
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("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,7 +726,8 @@ 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.saveCancelSection.getSaveButton().setOnClick(
|
||||
"wordClean_"
|
||||
+ PageTextForm.TEXT_ENTRY
|
||||
+ "();");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.";
|
||||
|
|
@ -138,7 +140,8 @@ public class TextAssetBodyPropertySheet extends DomainObjectPropertySheet {
|
|||
public PropertySheetModel makeModel(final PropertySheet sheet,
|
||||
final PageState state) {
|
||||
|
||||
TextAssetBodyPropertySheet propSheet = (TextAssetBodyPropertySheet) sheet;
|
||||
TextAssetBodyPropertySheet propSheet
|
||||
= (TextAssetBodyPropertySheet) sheet;
|
||||
throw new UnsupportedOperationException("ToDo");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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 <code>section</code>, which will be presented within
|
||||
* the given <code>templateContext</code>
|
||||
*/
|
||||
@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 <code>item</code>
|
||||
*/
|
||||
@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 <code>null</code> if no ID has been found in the
|
||||
* <code>url</code>
|
||||
*/
|
||||
@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;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,11 @@ public class DomainObjectPropertySheet extends PropertySheet {
|
|||
|
||||
this.objectSelectionModel = objectSelectionModel;
|
||||
properties = new LinkedList<>();
|
||||
if (selectedLanguageParam == null) {
|
||||
this.selectedLanguageParam = new StringParameter("selected_language");
|
||||
} else {
|
||||
this.selectedLanguageParam = selectedLanguageParam;
|
||||
}
|
||||
|
||||
toStringFormatter = new SimpleAttributeFormatter();
|
||||
recursiveFormatter = new RecursiveAttributeFormatter();
|
||||
|
|
|
|||
|
|
@ -152,19 +152,6 @@ public class WorkflowManager {
|
|||
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
|
||||
* {@link #createWorkflow(org.libreccm.workflow.WorkflowTemplate, org.libreccm.core.CcmObject)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue