CCM NG/ccm-cms: AssetPane
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4661 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
da2050e8e4
commit
dc1ec63e51
|
|
@ -18,21 +18,153 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.ui.assets;
|
package com.arsdigita.cms.ui.assets;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Container;
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
import com.arsdigita.bebop.Form;
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.SingleSelectionModel;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
import org.librecms.contentsection.Asset;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
public class AssetForm extends Form {
|
public abstract class AssetForm extends Form implements FormInitListener,
|
||||||
|
FormProcessListener,
|
||||||
public AssetForm(final String name) {
|
FormSubmissionListener {
|
||||||
super(name);
|
|
||||||
|
private static final String ASSET_TITLE = "asset-title";
|
||||||
|
|
||||||
|
private final AssetPane assetPane;
|
||||||
|
private final SingleSelectionModel<Long> selectionModel;
|
||||||
|
|
||||||
|
private TextField title;
|
||||||
|
private SaveCancelSection saveCancelSection;
|
||||||
|
|
||||||
|
public AssetForm(final AssetPane assetPane) {
|
||||||
|
super("asset-form", new ColumnPanel(2));
|
||||||
|
|
||||||
|
this.assetPane = assetPane;
|
||||||
|
selectionModel = assetPane.getSelectedAssetModel();
|
||||||
|
|
||||||
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetForm(final String name, final Container container) {
|
private void initComponents() {
|
||||||
super(name, container);
|
add(new Label(new GlobalizedMessage("cms.ui.asset.title",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
title = new TextField(ASSET_TITLE);
|
||||||
|
add(title);
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
|
||||||
|
saveCancelSection = new SaveCancelSection();
|
||||||
|
add(saveCancelSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addWidgets() {
|
||||||
|
//Nothing here
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getTitle(final PageState state) {
|
||||||
|
return (String) title.getValue(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Optional<Asset> getSelectedAsset(final PageState state) {
|
||||||
|
|
||||||
|
if (selectionModel.getSelectedKey(state) == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final AssetRepository assetRepo = cdiUtil.findBean(
|
||||||
|
AssetRepository.class);
|
||||||
|
final Asset asset = assetRepo
|
||||||
|
.findById(selectionModel.getSelectedKey(state))
|
||||||
|
.orElseThrow(() -> new IllegalArgumentException(String.format(
|
||||||
|
"No asset with ID %d in the database.",
|
||||||
|
selectionModel.getSelectedKey(state))));
|
||||||
|
return Optional.of(asset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
final Optional<Asset> selectedAsset = getSelectedAsset(state);
|
||||||
|
|
||||||
|
if (selectedAsset.isPresent()) {
|
||||||
|
title.setValue(state,
|
||||||
|
selectedAsset
|
||||||
|
.get()
|
||||||
|
.getTitle()
|
||||||
|
.getValue(KernelConfig
|
||||||
|
.getConfig()
|
||||||
|
.getDefaultLocale()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
||||||
|
final Optional<Asset> selectedAsset = getSelectedAsset(state);
|
||||||
|
final Asset asset;
|
||||||
|
if (selectedAsset.isPresent()) {
|
||||||
|
asset = selectedAsset.get();
|
||||||
|
updateAsset(asset, state);
|
||||||
|
} else {
|
||||||
|
asset = createAsset(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
asset.getTitle().addValue(
|
||||||
|
KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) title.getValue(state));
|
||||||
|
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final AssetRepository assetRepo = cdiUtil
|
||||||
|
.findBean(AssetRepository.class);
|
||||||
|
assetRepo.save(asset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Asset createAsset(final PageState state)
|
||||||
|
throws FormProcessException;
|
||||||
|
|
||||||
|
protected abstract void updateAsset(final Asset asset,
|
||||||
|
final PageState state)
|
||||||
|
throws FormProcessException;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submitted(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if (saveCancelSection.getCancelButton().isSelected(state)) {
|
||||||
|
selectionModel.clearSelection(state);
|
||||||
|
assetPane.browseMode(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* 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.assets;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class AssetFormController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -29,6 +29,7 @@ import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.Paginator;
|
import com.arsdigita.bebop.Paginator;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
import com.arsdigita.bebop.RequestLocal;
|
import com.arsdigita.bebop.RequestLocal;
|
||||||
import com.arsdigita.bebop.Resettable;
|
import com.arsdigita.bebop.Resettable;
|
||||||
import com.arsdigita.bebop.SaveCancelSection;
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
|
@ -52,6 +53,7 @@ import com.arsdigita.bebop.form.Option;
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
import com.arsdigita.bebop.form.Submit;
|
import com.arsdigita.bebop.form.Submit;
|
||||||
import com.arsdigita.bebop.parameters.ArrayParameter;
|
import com.arsdigita.bebop.parameters.ArrayParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.LongParameter;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
|
@ -83,6 +85,8 @@ import org.libreccm.categorization.CategoryManager;
|
||||||
import org.libreccm.core.CcmObject;
|
import org.libreccm.core.CcmObject;
|
||||||
import org.libreccm.core.UnexpectedErrorException;
|
import org.libreccm.core.UnexpectedErrorException;
|
||||||
import org.libreccm.security.PermissionChecker;
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.librecms.assets.AssetTypeInfo;
|
||||||
|
import org.librecms.assets.AssetTypesManager;
|
||||||
import org.librecms.contentsection.Asset;
|
import org.librecms.contentsection.Asset;
|
||||||
import org.librecms.contentsection.AssetManager;
|
import org.librecms.contentsection.AssetManager;
|
||||||
import org.librecms.contentsection.AssetRepository;
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
|
@ -92,6 +96,8 @@ import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
|
||||||
|
|
@ -113,10 +119,11 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
private final SingleSelectionModel selectionModel;
|
private final SingleSelectionModel selectionModel;
|
||||||
private final FolderSelectionModel folderSelectionModel;
|
private final FolderSelectionModel folderSelectionModel;
|
||||||
private final FolderRequestLocal folderRequestLocal;
|
private final FolderRequestLocal folderRequestLocal;
|
||||||
|
private final SingleSelectionModel<Long> selectedAssetModel;
|
||||||
private final ArrayParameter sourcesParameter = new ArrayParameter(
|
private final ArrayParameter sourcesParameter = new ArrayParameter(
|
||||||
new StringParameter(SOURCES_PARAM));
|
new StringParameter(SOURCES_PARAM));
|
||||||
private final StringParameter actionParameter = new StringParameter(
|
private final StringParameter actionParameter = new StringParameter(
|
||||||
ACTION_PARAM);
|
ACTION_PARAM);
|
||||||
|
|
||||||
private AssetFolderBrowser folderBrowser;
|
private AssetFolderBrowser folderBrowser;
|
||||||
private Form browserForm;
|
private Form browserForm;
|
||||||
|
|
@ -129,6 +136,7 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
private SegmentedPanel.Segment actionsSegment;
|
private SegmentedPanel.Segment actionsSegment;
|
||||||
private SegmentedPanel.Segment newFolderSegment;
|
private SegmentedPanel.Segment newFolderSegment;
|
||||||
private SegmentedPanel.Segment editFolderSegment;
|
private SegmentedPanel.Segment editFolderSegment;
|
||||||
|
private SegmentedPanel.Segment editAssetSegement;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public AssetPane() {
|
public AssetPane() {
|
||||||
|
|
@ -137,8 +145,8 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
@Override
|
@Override
|
||||||
protected Folder getRootFolder(final PageState state) {
|
protected Folder getRootFolder(final PageState state) {
|
||||||
final ContentSection section = CMS
|
final ContentSection section = CMS
|
||||||
.getContext()
|
.getContext()
|
||||||
.getContentSection();
|
.getContentSection();
|
||||||
return section.getRootAssetsFolder();
|
return section.getRootAssetsFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,20 +157,23 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
@Override
|
@Override
|
||||||
protected Long getRootFolderID(final PageState state) {
|
protected Long getRootFolderID(final PageState state) {
|
||||||
final ContentSection section = CMS
|
final ContentSection section = CMS
|
||||||
.getContext()
|
.getContext()
|
||||||
.getContentSection();
|
.getContentSection();
|
||||||
return section.getRootAssetsFolder().getObjectId();
|
return section.getRootAssetsFolder().getObjectId();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
folderRequestLocal = new FolderRequestLocal(folderSelectionModel);
|
folderRequestLocal = new FolderRequestLocal(folderSelectionModel);
|
||||||
|
|
||||||
|
selectedAssetModel = new ParameterSingleSelectionModel<>(
|
||||||
|
new LongParameter("selected-asset"));
|
||||||
|
|
||||||
final SegmentedPanel left = new SegmentedPanel();
|
final SegmentedPanel left = new SegmentedPanel();
|
||||||
setLeft(left);
|
setLeft(left);
|
||||||
|
|
||||||
final Label heading = new Label(
|
final Label heading = new Label(
|
||||||
new GlobalizedMessage("cms.ui.folder_browser",
|
new GlobalizedMessage("cms.ui.folder_browser",
|
||||||
CmsConstants.CMS_BUNDLE));
|
CmsConstants.CMS_BUNDLE));
|
||||||
left.addSegment(heading, tree);
|
left.addSegment(heading, tree);
|
||||||
|
|
||||||
// final Text placeholder = new Text("Placeholder");
|
// final Text placeholder = new Text("Placeholder");
|
||||||
|
|
@ -180,15 +191,15 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
browserForm.setMethod(Form.GET);
|
browserForm.setMethod(Form.GET);
|
||||||
folderBrowser = new AssetFolderBrowser(folderSelectionModel);
|
folderBrowser = new AssetFolderBrowser(folderSelectionModel);
|
||||||
final Paginator paginator = new Paginator(
|
final Paginator paginator = new Paginator(
|
||||||
new AssetFolderBrowserPaginationModelBuilder(folderBrowser),
|
new AssetFolderBrowserPaginationModelBuilder(folderBrowser),
|
||||||
CMSConfig.getConfig().getFolderBrowseListSize());
|
CMSConfig.getConfig().getFolderBrowseListSize());
|
||||||
folderBrowser.setPaginator(paginator);
|
folderBrowser.setPaginator(paginator);
|
||||||
|
|
||||||
final CheckboxGroup checkboxGroup = new CheckboxGroup(sourcesParameter);
|
final CheckboxGroup checkboxGroup = new CheckboxGroup(sourcesParameter);
|
||||||
browserForm.add(checkboxGroup);
|
browserForm.add(checkboxGroup);
|
||||||
final TableColumn checkboxCol = new TableColumn();
|
final TableColumn checkboxCol = new TableColumn();
|
||||||
checkboxCol.setHeaderValue(
|
checkboxCol.setHeaderValue(
|
||||||
new GlobalizedMessage("empty_text", CmsConstants.CMS_BUNDLE));
|
new GlobalizedMessage("empty_text", CmsConstants.CMS_BUNDLE));
|
||||||
checkboxCol.setCellRenderer(new TableCellRenderer() {
|
checkboxCol.setCellRenderer(new TableCellRenderer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -213,31 +224,31 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
browserForm.add(folderBrowser);
|
browserForm.add(folderBrowser);
|
||||||
final SimpleContainer actionFormContainer = new SimpleContainer();
|
final SimpleContainer actionFormContainer = new SimpleContainer();
|
||||||
actionFormContainer.add(new Label(
|
actionFormContainer.add(new Label(
|
||||||
new GlobalizedMessage(
|
new GlobalizedMessage(
|
||||||
"cms.ui.folder.edit_selection",
|
"cms.ui.folder.edit_selection",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE)));
|
CmsConstants.CMS_FOLDER_BUNDLE)));
|
||||||
actionSelect = new SingleSelect(actionParameter);
|
actionSelect = new SingleSelect(actionParameter);
|
||||||
actionSelect.addOption(
|
actionSelect.addOption(
|
||||||
new Option(COPY,
|
new Option(COPY,
|
||||||
new Label(new GlobalizedMessage(
|
new Label(new GlobalizedMessage(
|
||||||
"cms.ui.folder.copy.action",
|
"cms.ui.folder.copy.action",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE))));
|
CmsConstants.CMS_FOLDER_BUNDLE))));
|
||||||
actionSelect.addOption(
|
actionSelect.addOption(
|
||||||
new Option(MOVE,
|
new Option(MOVE,
|
||||||
new Label(new GlobalizedMessage(
|
new Label(new GlobalizedMessage(
|
||||||
"cms.ui.folder.move.action",
|
"cms.ui.folder.move.action",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE))));
|
CmsConstants.CMS_FOLDER_BUNDLE))));
|
||||||
actionFormContainer.add(actionSelect);
|
actionFormContainer.add(actionSelect);
|
||||||
actionSubmit = new Submit(
|
actionSubmit = new Submit(
|
||||||
"Go",
|
"Go",
|
||||||
new GlobalizedMessage("cms.ui.folder.go",
|
new GlobalizedMessage("cms.ui.folder.go",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE));
|
CmsConstants.CMS_FOLDER_BUNDLE));
|
||||||
actionFormContainer.add(actionSubmit);
|
actionFormContainer.add(actionSubmit);
|
||||||
browserForm.addProcessListener(new FormProcessListener() {
|
browserForm.addProcessListener(new FormProcessListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(final FormSectionEvent event)
|
public void process(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
|
@ -253,7 +264,7 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(final FormSectionEvent event)
|
public void process(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
|
@ -274,12 +285,12 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
});
|
});
|
||||||
targetSelector.addValidationListener(
|
targetSelector.addValidationListener(
|
||||||
new TargetSelectorValidationListener());
|
new TargetSelectorValidationListener());
|
||||||
targetSelector.addSubmissionListener(new FormSubmissionListener() {
|
targetSelector.addSubmissionListener(new FormSubmissionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void submitted(final FormSectionEvent event)
|
public void submitted(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
|
@ -287,8 +298,8 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
reset(state);
|
reset(state);
|
||||||
browseMode(state);
|
browseMode(state);
|
||||||
throw new FormProcessException(new GlobalizedMessage(
|
throw new FormProcessException(new GlobalizedMessage(
|
||||||
"cms.ui.folder.cancelled",
|
"cms.ui.folder.cancelled",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE));
|
CmsConstants.CMS_FOLDER_BUNDLE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,13 +321,13 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
final Label target = (Label) event.getTarget();
|
final Label target = (Label) event.getTarget();
|
||||||
|
|
||||||
final long selectedId = Long.parseLong(selectionModel
|
final long selectedId = Long.parseLong(selectionModel
|
||||||
.getSelectedKey(state).toString());
|
.getSelectedKey(state).toString());
|
||||||
final long currentFolderId = folderSelectionModel
|
final long currentFolderId = folderSelectionModel
|
||||||
.getSelectedObject(state).getObjectId();
|
.getSelectedObject(state).getObjectId();
|
||||||
target.setLabel(String.format(
|
target.setLabel(String.format(
|
||||||
"selectedId = %d; currentFolderId = %d",
|
"selectedId = %d; currentFolderId = %d",
|
||||||
selectedId,
|
selectedId,
|
||||||
currentFolderId));
|
currentFolderId));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -329,19 +340,19 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
actionsSegment.add(actions);
|
actionsSegment.add(actions);
|
||||||
|
|
||||||
final FolderCreateForm folderCreateForm = new FolderCreateForm(
|
final FolderCreateForm folderCreateForm = new FolderCreateForm(
|
||||||
"fcreat", folderSelectionModel);
|
"fcreat", folderSelectionModel);
|
||||||
folderCreateForm.addSubmissionListener(new FormSubmissionListener() {
|
folderCreateForm.addSubmissionListener(new FormSubmissionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void submitted(final FormSectionEvent event)
|
public void submitted(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
if (event.getSource() == folderCreateForm
|
if (event.getSource() == folderCreateForm
|
||||||
&& folderCreateForm.isCancelled(state)) {
|
&& folderCreateForm.isCancelled(state)) {
|
||||||
browseMode(state);
|
browseMode(state);
|
||||||
throw new FormProcessException(new GlobalizedMessage(
|
throw new FormProcessException(new GlobalizedMessage(
|
||||||
"cms.ui.cancelled", CmsConstants.CMS_BUNDLE));
|
"cms.ui.cancelled", CmsConstants.CMS_BUNDLE));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -351,7 +362,7 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(final FormSectionEvent event)
|
public void process(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
final Object source = event.getSource();
|
final Object source = event.getSource();
|
||||||
|
|
@ -362,24 +373,24 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
});
|
});
|
||||||
newFolderSegment = panel.addSegment(
|
newFolderSegment = panel.addSegment(
|
||||||
new Label(new GlobalizedMessage("cms.ui.new_folder",
|
new Label(new GlobalizedMessage("cms.ui.new_folder",
|
||||||
CmsConstants.CMS_BUNDLE)),
|
CmsConstants.CMS_BUNDLE)),
|
||||||
folderCreateForm);
|
folderCreateForm);
|
||||||
|
|
||||||
final FolderEditorForm folderEditorForm = new FolderEditorForm(
|
final FolderEditorForm folderEditorForm = new FolderEditorForm(
|
||||||
"fedit", folderSelectionModel);
|
"fedit", folderSelectionModel);
|
||||||
folderEditorForm.addSubmissionListener(new FormSubmissionListener() {
|
folderEditorForm.addSubmissionListener(new FormSubmissionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void submitted(final FormSectionEvent event)
|
public void submitted(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
if (event.getSource() == folderEditorForm
|
if (event.getSource() == folderEditorForm
|
||||||
&& folderEditorForm.isCancelled(state)) {
|
&& folderEditorForm.isCancelled(state)) {
|
||||||
browseMode(state);
|
browseMode(state);
|
||||||
throw new FormProcessException(new GlobalizedMessage(
|
throw new FormProcessException(new GlobalizedMessage(
|
||||||
"cms.ui.cancelled", CmsConstants.CMS_BUNDLE));
|
"cms.ui.cancelled", CmsConstants.CMS_BUNDLE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -388,7 +399,7 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(final FormSectionEvent event)
|
public void process(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
final Object source = event.getSource();
|
final Object source = event.getSource();
|
||||||
|
|
@ -399,13 +410,13 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
});
|
});
|
||||||
editFolderSegment = panel.addSegment(
|
editFolderSegment = panel.addSegment(
|
||||||
new Label(new GlobalizedMessage("cms.ui.edit_folder",
|
new Label(new GlobalizedMessage("cms.ui.edit_folder",
|
||||||
CmsConstants.CMS_BUNDLE)),
|
CmsConstants.CMS_BUNDLE)),
|
||||||
folderEditorForm);
|
folderEditorForm);
|
||||||
|
|
||||||
final ActionLink createFolderAction = new ActionLink(
|
final ActionLink createFolderAction = new ActionLink(
|
||||||
new Label(new GlobalizedMessage("cms.ui.new_folder",
|
new Label(new GlobalizedMessage("cms.ui.new_folder",
|
||||||
CmsConstants.CMS_BUNDLE)));
|
CmsConstants.CMS_BUNDLE)));
|
||||||
createFolderAction.addActionListener(new ActionListener() {
|
createFolderAction.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -421,8 +432,8 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
actions.addAction(createFolderAction);
|
actions.addAction(createFolderAction);
|
||||||
|
|
||||||
final ActionLink editFolderAction = new ActionLink(
|
final ActionLink editFolderAction = new ActionLink(
|
||||||
new Label(new GlobalizedMessage("cms.ui.edit_folder",
|
new Label(new GlobalizedMessage("cms.ui.edit_folder",
|
||||||
CmsConstants.CMS_BUNDLE)));
|
CmsConstants.CMS_BUNDLE)));
|
||||||
editFolderAction.addActionListener(new ActionListener() {
|
editFolderAction.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -437,6 +448,54 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
});
|
});
|
||||||
actions.addAction(editFolderAction);
|
actions.addAction(editFolderAction);
|
||||||
|
|
||||||
|
final Form newAssetForm = new Form("new-asset-form",
|
||||||
|
new BoxPanel(BoxPanel.HORIZONTAL));
|
||||||
|
newAssetForm.add(new Label(new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.new", CmsConstants.CMS_BUNDLE)));
|
||||||
|
final SingleSelect newAssetTypeSelect = new SingleSelect(
|
||||||
|
"new-asset-type-select");
|
||||||
|
try {
|
||||||
|
newAssetTypeSelect.addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepare(final PrintEvent event) {
|
||||||
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final AssetTypesManager typesManager = cdiUtil
|
||||||
|
.findBean(AssetTypesManager.class);
|
||||||
|
final SingleSelect target = (SingleSelect) event.getTarget();
|
||||||
|
for (final AssetTypeInfo type : typesManager
|
||||||
|
.getAvailableAssetTypes()) {
|
||||||
|
final String labelKey = type.getLabelKey();
|
||||||
|
final String labelBundle = type.getLabelBundle();
|
||||||
|
final ResourceBundle bundle = ResourceBundle
|
||||||
|
.getBundle(labelBundle);
|
||||||
|
final String label = bundle.getString(labelKey);
|
||||||
|
target.addOption(new Option(
|
||||||
|
type.getAssetClass().getName(),
|
||||||
|
new Text(label)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} catch (TooManyListenersException ex) {
|
||||||
|
throw new UnexpectedErrorException(ex);
|
||||||
|
}
|
||||||
|
newAssetForm.add(newAssetTypeSelect);
|
||||||
|
newAssetForm.add(new Submit(new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.new.create", CmsConstants.CMS_BUNDLE)));
|
||||||
|
newAssetForm.addProcessListener(new FormProcessListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
//Nothing yet
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
actionsSegment.add(newAssetForm);
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -518,6 +577,10 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected SingleSelectionModel<Long> getSelectedAssetModel() {
|
||||||
|
return selectedAssetModel;
|
||||||
|
}
|
||||||
|
|
||||||
private String[] getSources(final PageState state) {
|
private String[] getSources(final PageState state) {
|
||||||
|
|
||||||
final String[] result = (String[]) state.getValue(sourcesParameter);
|
final String[] result = (String[]) state.getValue(sourcesParameter);
|
||||||
|
|
@ -545,7 +608,7 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final AssetFolderBrowserController controller = cdiUtil.findBean(
|
final AssetFolderBrowserController controller = cdiUtil.findBean(
|
||||||
AssetFolderBrowserController.class);
|
AssetFolderBrowserController.class);
|
||||||
|
|
||||||
controller.moveObjects(target, objectIds);
|
controller.moveObjects(target, objectIds);
|
||||||
}
|
}
|
||||||
|
|
@ -554,7 +617,7 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final AssetFolderBrowserController controller = cdiUtil.findBean(
|
final AssetFolderBrowserController controller = cdiUtil.findBean(
|
||||||
AssetFolderBrowserController.class);
|
AssetFolderBrowserController.class);
|
||||||
|
|
||||||
controller.copyObjects(target, objectIds);
|
controller.copyObjects(target, objectIds);
|
||||||
}
|
}
|
||||||
|
|
@ -569,14 +632,14 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
if (!selectionModel.isSelected(state)) {
|
if (!selectionModel.isSelected(state)) {
|
||||||
final String folder = state
|
final String folder = state
|
||||||
.getRequest()
|
.getRequest()
|
||||||
.getParameter(SET_FOLDER);
|
.getParameter(SET_FOLDER);
|
||||||
|
|
||||||
if (folder == null) {
|
if (folder == null) {
|
||||||
final Category root = CMS
|
final Category root = CMS
|
||||||
.getContext()
|
.getContext()
|
||||||
.getContentSection()
|
.getContentSection()
|
||||||
.getRootAssetsFolder();
|
.getRootAssetsFolder();
|
||||||
final Long folderId = root.getObjectId();
|
final Long folderId = root.getObjectId();
|
||||||
|
|
||||||
selectionModel.setSelectedKey(state, folderId);
|
selectionModel.setSelectedKey(state, folderId);
|
||||||
|
|
@ -596,18 +659,18 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
final Category root = CMS
|
final Category root = CMS
|
||||||
.getContext()
|
.getContext()
|
||||||
.getContentSection()
|
.getContentSection()
|
||||||
.getRootAssetsFolder();
|
.getRootAssetsFolder();
|
||||||
|
|
||||||
if (!root.equals(folderRequestLocal.getFolder(state))) {
|
if (!root.equals(folderRequestLocal.getFolder(state))) {
|
||||||
// Expand the ancestor nodes of the currently
|
// Expand the ancestor nodes of the currently
|
||||||
// selected node.
|
// selected node.
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final FolderTreeModelController controller = cdiUtil.findBean(
|
final FolderTreeModelController controller = cdiUtil.findBean(
|
||||||
FolderTreeModelController.class);
|
FolderTreeModelController.class);
|
||||||
final List<Long> ancestorIds = controller.findAncestorIds(
|
final List<Long> ancestorIds = controller.findAncestorIds(
|
||||||
folderRequestLocal.getFolder(state));
|
folderRequestLocal.getFolder(state));
|
||||||
ancestorIds.forEach(id -> tree.expand(id.toString(), state));
|
ancestorIds.forEach(id -> tree.expand(id.toString(), state));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -629,8 +692,8 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
@Override
|
@Override
|
||||||
protected Long getRootFolderID(final PageState state) {
|
protected Long getRootFolderID(final PageState state) {
|
||||||
final ContentSection section = CMS
|
final ContentSection section = CMS
|
||||||
.getContext()
|
.getContext()
|
||||||
.getContentSection();
|
.getContentSection();
|
||||||
return section.getRootAssetsFolder().getObjectId();
|
return section.getRootAssetsFolder().getObjectId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -648,37 +711,37 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
final Label label = (Label) event.getTarget();
|
final Label label = (Label) event.getTarget();
|
||||||
final int numberOfItems = getSources(state).length;
|
final int numberOfItems = getSources(state).length;
|
||||||
final Category folder = (Category) folderSelectionModel
|
final Category folder = (Category) folderSelectionModel
|
||||||
.getSelectedObject(state);
|
.getSelectedObject(state);
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final CategoryManager categoryManager = cdiUtil
|
final CategoryManager categoryManager = cdiUtil
|
||||||
.findBean(CategoryManager.class);
|
.findBean(CategoryManager.class);
|
||||||
|
|
||||||
final String targetFolderPath;
|
final String targetFolderPath;
|
||||||
if (targetFolderModel.getSelectedObject(state) == null) {
|
if (targetFolderModel.getSelectedObject(state) == null) {
|
||||||
targetFolderPath = "";
|
targetFolderPath = "";
|
||||||
} else {
|
} else {
|
||||||
targetFolderPath = categoryManager.getCategoryPath(
|
targetFolderPath = categoryManager.getCategoryPath(
|
||||||
targetFolderModel.getSelectedObject(state));
|
targetFolderModel.getSelectedObject(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMove(state)) {
|
if (isMove(state)) {
|
||||||
label.setLabel(new GlobalizedMessage(
|
label.setLabel(new GlobalizedMessage(
|
||||||
"cms.ui.folder.move",
|
"cms.ui.folder.move",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE,
|
CmsConstants.CMS_FOLDER_BUNDLE,
|
||||||
new Object[]{
|
new Object[]{
|
||||||
numberOfItems,
|
numberOfItems,
|
||||||
categoryManager.getCategoryPath(folder),
|
categoryManager.getCategoryPath(folder),
|
||||||
targetFolderPath
|
targetFolderPath
|
||||||
}));
|
}));
|
||||||
} else if (isCopy(state)) {
|
} else if (isCopy(state)) {
|
||||||
label.setLabel(new GlobalizedMessage(
|
label.setLabel(new GlobalizedMessage(
|
||||||
"cms.ui.folder.copy",
|
"cms.ui.folder.copy",
|
||||||
CMS_BUNDLE,
|
CMS_BUNDLE,
|
||||||
new Object[]{
|
new Object[]{
|
||||||
numberOfItems,
|
numberOfItems,
|
||||||
categoryManager.getCategoryPath(folder),
|
categoryManager.getCategoryPath(folder),
|
||||||
targetFolderPath
|
targetFolderPath
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -707,18 +770,18 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final FolderManager folderManager = cdiUtil.findBean(
|
final FolderManager folderManager = cdiUtil.findBean(
|
||||||
FolderManager.class);
|
FolderManager.class);
|
||||||
if (!folderManager.getParentFolder(folder).isPresent()) {
|
if (!folderManager.getParentFolder(folder).isPresent()) {
|
||||||
folderTree.expand(Long.toString(folder.getObjectId()),
|
folderTree.expand(Long.toString(folder.getObjectId()),
|
||||||
state);
|
state);
|
||||||
} else {
|
} else {
|
||||||
final List<Folder> parents = folderManager
|
final List<Folder> parents = folderManager
|
||||||
.getParentFolders(folder);
|
.getParentFolders(folder);
|
||||||
parents
|
parents
|
||||||
.stream()
|
.stream()
|
||||||
.map(parent -> Long.toString(parent.getObjectId()))
|
.map(parent -> Long.toString(parent.getObjectId()))
|
||||||
.forEach(folderId -> folderTree.expand(folderId,
|
.forEach(folderId -> folderTree.expand(folderId,
|
||||||
state));
|
state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -743,7 +806,7 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
private class FolderTreeCellRenderer implements TreeCellRenderer {
|
private class FolderTreeCellRenderer implements TreeCellRenderer {
|
||||||
|
|
||||||
private final RequestLocal invalidFoldersRequestLocal
|
private final RequestLocal invalidFoldersRequestLocal
|
||||||
= new RequestLocal();
|
= new RequestLocal();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the folders appropriately. The selected folder is a bold
|
* Render the folders appropriately. The selected folder is a bold
|
||||||
|
|
@ -767,18 +830,18 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
if (invalidFoldersRequestLocal.get(state) == null) {
|
if (invalidFoldersRequestLocal.get(state) == null) {
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final AssetFolderBrowserController controller = cdiUtil
|
final AssetFolderBrowserController controller = cdiUtil
|
||||||
.findBean(AssetFolderBrowserController.class);
|
.findBean(AssetFolderBrowserController.class);
|
||||||
invalidFolders = controller.createInvalidTargetsList(
|
invalidFolders = controller.createInvalidTargetsList(
|
||||||
Arrays.asList(getSources(state)));
|
Arrays.asList(getSources(state)));
|
||||||
invalidFoldersRequestLocal.set(state, invalidFolders);
|
invalidFoldersRequestLocal.set(state, invalidFolders);
|
||||||
} else {
|
} else {
|
||||||
invalidFolders = (List<String>) invalidFoldersRequestLocal
|
invalidFolders = (List<String>) invalidFoldersRequestLocal
|
||||||
.get(state);
|
.get(state);
|
||||||
}
|
}
|
||||||
final Label label = new Label(value.toString());
|
final Label label = new Label(value.toString());
|
||||||
|
|
||||||
if (invalidFolders.contains(String.format(
|
if (invalidFolders.contains(String.format(
|
||||||
FOLDER_BROWSER_KEY_PREFIX_FOLDER + "%s", key))) {
|
FOLDER_BROWSER_KEY_PREFIX_FOLDER + "%s", key))) {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -794,11 +857,11 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TargetSelectorValidationListener
|
private class TargetSelectorValidationListener
|
||||||
implements FormValidationListener {
|
implements FormValidationListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(final FormSectionEvent event)
|
public void validate(final FormSectionEvent event)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
|
@ -810,24 +873,24 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
final FormData data = event.getFormData();
|
final FormData data = event.getFormData();
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
data.addError(new GlobalizedMessage(
|
data.addError(new GlobalizedMessage(
|
||||||
"cms.ui.folder.need_select_target_folder",
|
"cms.ui.folder.need_select_target_folder",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE));
|
CmsConstants.CMS_FOLDER_BUNDLE));
|
||||||
//If the target is null, we can skip the rest of the checks
|
//If the target is null, we can skip the rest of the checks
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.equals(folderSelectionModel.getSelectedObject(state))) {
|
if (target.equals(folderSelectionModel.getSelectedObject(state))) {
|
||||||
data.addError(new GlobalizedMessage(
|
data.addError(new GlobalizedMessage(
|
||||||
"cms.ui.folder.not_within_same_folder",
|
"cms.ui.folder.not_within_same_folder",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE));
|
CmsConstants.CMS_FOLDER_BUNDLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check create item permission
|
// check create item permission
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||||
PermissionChecker.class);
|
PermissionChecker.class);
|
||||||
if (!permissionChecker.isPermitted(
|
if (!permissionChecker.isPermitted(
|
||||||
ItemPrivileges.CREATE_NEW, target)) {
|
ItemPrivileges.CREATE_NEW, target)) {
|
||||||
data.addError("cms.ui.folder.no_permission_for_item",
|
data.addError("cms.ui.folder.no_permission_for_item",
|
||||||
CmsConstants.CMS_FOLDER_BUNDLE);
|
CmsConstants.CMS_FOLDER_BUNDLE);
|
||||||
}
|
}
|
||||||
|
|
@ -848,34 +911,34 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final FolderRepository folderRepo = cdiUtil
|
final FolderRepository folderRepo = cdiUtil
|
||||||
.findBean(FolderRepository.class);
|
.findBean(FolderRepository.class);
|
||||||
final AssetRepository assetRepo = cdiUtil
|
final AssetRepository assetRepo = cdiUtil
|
||||||
.findBean(AssetRepository.class);
|
.findBean(AssetRepository.class);
|
||||||
final AssetManager assetManager = cdiUtil
|
final AssetManager assetManager = cdiUtil
|
||||||
.findBean(AssetManager.class);
|
.findBean(AssetManager.class);
|
||||||
final AssetFolderBrowserController controller = cdiUtil
|
final AssetFolderBrowserController controller = cdiUtil
|
||||||
.findBean(AssetFolderBrowserController.class);
|
.findBean(AssetFolderBrowserController.class);
|
||||||
final FolderManager folderManager = cdiUtil
|
final FolderManager folderManager = cdiUtil
|
||||||
.findBean(FolderManager.class);
|
.findBean(FolderManager.class);
|
||||||
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
final PermissionChecker permissionChecker = cdiUtil.findBean(
|
||||||
PermissionChecker.class);
|
PermissionChecker.class);
|
||||||
|
|
||||||
final CcmObject object;
|
final CcmObject object;
|
||||||
final String name;
|
final String name;
|
||||||
if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
|
if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
|
||||||
|
|
||||||
final long folderId = Long.parseLong(objectId.substring(
|
final long folderId = Long.parseLong(objectId.substring(
|
||||||
FOLDER_BROWSER_KEY_PREFIX_FOLDER.length()));
|
FOLDER_BROWSER_KEY_PREFIX_FOLDER.length()));
|
||||||
final Folder folder = folderRepo.findById(folderId).orElseThrow(
|
final Folder folder = folderRepo.findById(folderId).orElseThrow(
|
||||||
() -> new IllegalArgumentException(String.format(
|
() -> new IllegalArgumentException(String.format(
|
||||||
"No folder with id %d in database.", folderId)));
|
"No folder with id %d in database.", folderId)));
|
||||||
|
|
||||||
name = folder.getName();
|
name = folder.getName();
|
||||||
|
|
||||||
//Check if folder or subfolder contains in use assets
|
//Check if folder or subfolder contains in use assets
|
||||||
if (isMove(state)) {
|
if (isMove(state)) {
|
||||||
final FolderManager.FolderIsMovable movable = folderManager
|
final FolderManager.FolderIsMovable movable = folderManager
|
||||||
.folderIsMovable(folder, target);
|
.folderIsMovable(folder, target);
|
||||||
switch (movable) {
|
switch (movable) {
|
||||||
case DIFFERENT_SECTIONS:
|
case DIFFERENT_SECTIONS:
|
||||||
addErrorMessage(data,
|
addErrorMessage(data,
|
||||||
|
|
@ -907,23 +970,23 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new UnexpectedErrorException(String.format(
|
throw new UnexpectedErrorException(String.format(
|
||||||
"Unknown state '%s' for '%s'.",
|
"Unknown state '%s' for '%s'.",
|
||||||
movable,
|
movable,
|
||||||
FolderManager.FolderIsMovable.class.
|
FolderManager.FolderIsMovable.class.
|
||||||
getName()));
|
getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object = folder;
|
object = folder;
|
||||||
} else if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_ASSET)) {
|
} else if (objectId.startsWith(FOLDER_BROWSER_KEY_PREFIX_ASSET)) {
|
||||||
final long assetId = Long.parseLong(objectId.substring(
|
final long assetId = Long.parseLong(objectId.substring(
|
||||||
FOLDER_BROWSER_KEY_PREFIX_ASSET.length()));
|
FOLDER_BROWSER_KEY_PREFIX_ASSET.length()));
|
||||||
final Asset asset = assetRepo
|
final Asset asset = assetRepo
|
||||||
.findById(assetId)
|
.findById(assetId)
|
||||||
.orElseThrow(() -> new IllegalArgumentException(
|
.orElseThrow(() -> new IllegalArgumentException(
|
||||||
String.format(
|
String.format(
|
||||||
"No asset with id %d in the database.",
|
"No asset with id %d in the database.",
|
||||||
assetId)));
|
assetId)));
|
||||||
|
|
||||||
name = asset.getDisplayName();
|
name = asset.getDisplayName();
|
||||||
|
|
||||||
|
|
@ -934,11 +997,11 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
object = asset;
|
object = asset;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException(String.format(
|
throw new IllegalArgumentException(String.format(
|
||||||
"Provided objectId '%s' does not start with '%s' "
|
"Provided objectId '%s' does not start with '%s' "
|
||||||
+ "or '%s'.",
|
+ "or '%s'.",
|
||||||
objectId,
|
objectId,
|
||||||
FOLDER_BROWSER_KEY_PREFIX_FOLDER,
|
FOLDER_BROWSER_KEY_PREFIX_FOLDER,
|
||||||
FOLDER_BROWSER_KEY_PREFIX_ASSET));
|
FOLDER_BROWSER_KEY_PREFIX_ASSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
final long count = controller.countObjects(target, name);
|
final long count = controller.countObjects(target, name);
|
||||||
|
|
@ -950,7 +1013,7 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
|
|
||||||
if (!(permissionChecker.isPermitted(
|
if (!(permissionChecker.isPermitted(
|
||||||
ItemPrivileges.DELETE, object))
|
ItemPrivileges.DELETE, object))
|
||||||
&& isMove(state)) {
|
&& isMove(state)) {
|
||||||
addErrorMessage(data,
|
addErrorMessage(data,
|
||||||
"cms.ui.folder.no_permission_for_item",
|
"cms.ui.folder.no_permission_for_item",
|
||||||
object.getDisplayName());
|
object.getDisplayName());
|
||||||
|
|
@ -977,8 +1040,8 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
@Override
|
@Override
|
||||||
protected Folder getRootFolder(final PageState state) {
|
protected Folder getRootFolder(final PageState state) {
|
||||||
final ContentSection section = CMS
|
final ContentSection section = CMS
|
||||||
.getContext()
|
.getContext()
|
||||||
.getContentSection();
|
.getContentSection();
|
||||||
|
|
||||||
return section.getRootAssetsFolder();
|
return section.getRootAssetsFolder();
|
||||||
}
|
}
|
||||||
|
|
@ -992,9 +1055,9 @@ public class AssetPane extends LayoutPanel implements Resettable {
|
||||||
if (key instanceof String) {
|
if (key instanceof String) {
|
||||||
final Long keyAsLong;
|
final Long keyAsLong;
|
||||||
if (((String) key).startsWith(
|
if (((String) key).startsWith(
|
||||||
FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
|
FOLDER_BROWSER_KEY_PREFIX_FOLDER)) {
|
||||||
keyAsLong = Long.parseLong(((String) key).substring(
|
keyAsLong = Long.parseLong(((String) key).substring(
|
||||||
FOLDER_BROWSER_KEY_PREFIX_FOLDER.length()));
|
FOLDER_BROWSER_KEY_PREFIX_FOLDER.length()));
|
||||||
} else {
|
} else {
|
||||||
keyAsLong = Long.parseLong((String) key);
|
keyAsLong = Long.parseLong((String) key);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
/*
|
||||||
|
* 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.assets.forms;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetForm;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
import org.librecms.assets.Bookmark;
|
||||||
|
import org.librecms.contentsection.Asset;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class BookmarkForm extends AssetForm {
|
||||||
|
|
||||||
|
private TextArea description;
|
||||||
|
private TextField url;
|
||||||
|
|
||||||
|
public BookmarkForm(final AssetPane assetPane) {
|
||||||
|
super(assetPane);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
|
||||||
|
add(new Label(
|
||||||
|
new GlobalizedMessage("cms.ui.assets.bookmark.description",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
description = new TextArea("bookmark-description");
|
||||||
|
add(description);
|
||||||
|
|
||||||
|
add(new Label(new GlobalizedMessage("cms.ui.assets.bookmark.url",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
url = new TextField("bookmark-url");
|
||||||
|
add(url);
|
||||||
|
|
||||||
|
addValidationListener(new FormValidationListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
final FormData data = event.getFormData();
|
||||||
|
|
||||||
|
try {
|
||||||
|
new URL((String) url.getValue(state));
|
||||||
|
} catch (MalformedURLException ex) {
|
||||||
|
data.addError(new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.bookmark.url.malformed",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Asset createAsset(final PageState state)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
Objects.requireNonNull(state);
|
||||||
|
|
||||||
|
final Bookmark bookmark = new Bookmark();
|
||||||
|
|
||||||
|
bookmark
|
||||||
|
.getDescription()
|
||||||
|
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) description.getValue(state));
|
||||||
|
|
||||||
|
try {
|
||||||
|
bookmark.setUrl(new URL((String) url.getValue(state)));
|
||||||
|
} catch (MalformedURLException ex) {
|
||||||
|
throw new FormProcessException(new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.bookmark.url.malformed",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
return bookmark;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateAsset(final Asset asset, final PageState state)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
Objects.requireNonNull(asset);
|
||||||
|
Objects.requireNonNull(state);
|
||||||
|
|
||||||
|
if (!(asset instanceof Bookmark)) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Provided asset is not an instance of class (or sub class of) "
|
||||||
|
+ "'%s' but is an instance of class '%s'",
|
||||||
|
Bookmark.class.getName(),
|
||||||
|
asset.getClass().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Bookmark bookmark = (Bookmark) asset;
|
||||||
|
|
||||||
|
bookmark
|
||||||
|
.getDescription()
|
||||||
|
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) description.getValue(state));
|
||||||
|
|
||||||
|
try {
|
||||||
|
bookmark.setUrl(new URL((String) url.getValue(state)));
|
||||||
|
} catch (MalformedURLException ex) {
|
||||||
|
throw new FormProcessException(new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.bookmark.url.malformed",
|
||||||
|
CmsConstants.CMS_BUNDLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
/*
|
||||||
|
* 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.assets.forms;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetForm;
|
||||||
|
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
import org.librecms.assets.LegalMetadata;
|
||||||
|
import org.librecms.contentsection.Asset;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class LegalMetadataForm extends AssetForm {
|
||||||
|
|
||||||
|
private TextArea rightsHolder;
|
||||||
|
private TextArea rights;
|
||||||
|
private TextArea publisher;
|
||||||
|
private TextArea creator;
|
||||||
|
|
||||||
|
public LegalMetadataForm(final AssetPane assetPane) {
|
||||||
|
super(assetPane);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
add(new Label(new GlobalizedMessage(
|
||||||
|
"cms.ui.assets.legalmetadata.rightsholder",
|
||||||
|
CmsConstants.CMS_BUNDLE)));
|
||||||
|
|
||||||
|
rightsHolder = new TextArea("legalmetadata-rightsholder");
|
||||||
|
add(rightsHolder);
|
||||||
|
|
||||||
|
rights = new TextArea("legalmetadata-rights");
|
||||||
|
add(rights);
|
||||||
|
|
||||||
|
publisher = new TextArea("legalmetadata-rights");
|
||||||
|
add(publisher);
|
||||||
|
|
||||||
|
creator = new TextArea("legalmetadata-creator");
|
||||||
|
add(creator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Asset createAsset(final PageState state)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
Objects.requireNonNull(state);
|
||||||
|
|
||||||
|
final LegalMetadata legalMetadata = new LegalMetadata();
|
||||||
|
|
||||||
|
legalMetadata.setRightsHolder((String) rightsHolder.getValue(state));
|
||||||
|
legalMetadata.getRights().addValue(
|
||||||
|
KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) rights.getValue(state));
|
||||||
|
|
||||||
|
legalMetadata.setPublisher((String) publisher.getValue(state));
|
||||||
|
legalMetadata.setCreator((String) creator.getValue(state));
|
||||||
|
|
||||||
|
return legalMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateAsset(final Asset asset, final PageState state)
|
||||||
|
throws FormProcessException {
|
||||||
|
|
||||||
|
Objects.requireNonNull(asset);
|
||||||
|
Objects.requireNonNull(state);
|
||||||
|
|
||||||
|
if (!(asset instanceof LegalMetadata)) {
|
||||||
|
throw new IllegalArgumentException(String.format(
|
||||||
|
"Provided asset is not an instance of '%s' (or a sub class) "
|
||||||
|
+ "but is an instance of class '%s'.",
|
||||||
|
LegalMetadata.class.getName(),
|
||||||
|
asset.getClass().getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
final LegalMetadata legalMetadata = (LegalMetadata) asset;
|
||||||
|
|
||||||
|
legalMetadata.setRightsHolder((String) rightsHolder.getValue(state));
|
||||||
|
legalMetadata.getRights().addValue(
|
||||||
|
KernelConfig.getConfig().getDefaultLocale(),
|
||||||
|
(String) rights.getValue(state));
|
||||||
|
|
||||||
|
legalMetadata.setPublisher((String) publisher.getValue(state));
|
||||||
|
legalMetadata.setCreator((String) creator.getValue(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,9 @@ import org.libreccm.modules.ShutdownEvent;
|
||||||
import org.libreccm.modules.UnInstallEvent;
|
import org.libreccm.modules.UnInstallEvent;
|
||||||
import org.libreccm.web.ApplicationType;
|
import org.libreccm.web.ApplicationType;
|
||||||
import org.libreccm.web.CcmApplication;
|
import org.libreccm.web.CcmApplication;
|
||||||
|
import org.librecms.assets.AssetTypes;
|
||||||
|
import org.librecms.assets.Bookmark;
|
||||||
|
import org.librecms.assets.LegalMetadata;
|
||||||
import org.librecms.contentsection.ContentSection;
|
import org.librecms.contentsection.ContentSection;
|
||||||
import org.librecms.contentsection.ContentSectionCreator;
|
import org.librecms.contentsection.ContentSectionCreator;
|
||||||
import org.librecms.contentsection.ContentSectionSetup;
|
import org.librecms.contentsection.ContentSectionSetup;
|
||||||
|
|
@ -57,6 +60,7 @@ import java.util.Properties;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ContentTypes({Article.class, Event.class, MultiPartArticle.class, News.class})
|
@ContentTypes({Article.class, Event.class, MultiPartArticle.class, News.class})
|
||||||
|
@AssetTypes({Bookmark.class, LegalMetadata.class})
|
||||||
public class Cms implements CcmModule {
|
public class Cms implements CcmModule {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(Cms.class);
|
private static final Logger LOGGER = LogManager.getLogger(Cms.class);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* 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 org.librecms.assets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants for assets.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public final class AssetConstants {
|
||||||
|
|
||||||
|
private AssetConstants() {
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String ASSETS_BUNDLE = "org.librecms.assets.Assets";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.assets;
|
package org.librecms.assets;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ui.assets.forms.BookmarkForm;
|
||||||
|
|
||||||
import org.librecms.contentsection.Asset;
|
import org.librecms.contentsection.Asset;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -37,13 +39,19 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
import static org.librecms.assets.AssetConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An assets for managing bookmarks which can be used to create links. Useful
|
* An assets for managing bookmarks which can be used to create links. Useful if
|
||||||
* if the same link appears in multiple places.
|
* the same link appears in multiple places.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AssetType(assetForm = BookmarkForm.class,
|
||||||
|
labelBundle = ASSETS_BUNDLE,
|
||||||
|
labelKey = "bookmark.label",
|
||||||
|
descriptionBundle = ASSETS_BUNDLE,
|
||||||
|
descriptionKey = "bookmark.description")
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "BOOKMARKS", schema = DB_SCHEMA)
|
@Table(name = "BOOKMARKS", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
|
@ -53,13 +61,13 @@ public class Bookmark extends Asset implements Serializable {
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
@AssociationOverride(
|
@AssociationOverride(
|
||||||
name = "values",
|
name = "values",
|
||||||
joinTable = @JoinTable(name = "BOOKMARK_DESCRIPTIONS",
|
joinTable = @JoinTable(name = "BOOKMARK_DESCRIPTIONS",
|
||||||
schema = DB_SCHEMA,
|
schema = DB_SCHEMA,
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "ASSET_ID")
|
@JoinColumn(name = "ASSET_ID")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
|
|
||||||
|
|
@ -130,7 +138,7 @@ public class Bookmark extends Asset implements Serializable {
|
||||||
@Override
|
@Override
|
||||||
public String toString(final String data) {
|
public String toString(final String data) {
|
||||||
return super.toString(String.format(", description = %s, "
|
return super.toString(String.format(", description = %s, "
|
||||||
+ "url = %s%s",
|
+ "url = %s%s",
|
||||||
Objects.toString(description),
|
Objects.toString(description),
|
||||||
Objects.toString(url),
|
Objects.toString(url),
|
||||||
data));
|
data));
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.assets;
|
package org.librecms.assets;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ui.assets.forms.LegalMetadataForm;
|
||||||
|
|
||||||
import org.librecms.contentsection.Asset;
|
import org.librecms.contentsection.Asset;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
|
@ -39,6 +41,7 @@ import javax.persistence.JoinTable;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
import static org.librecms.assets.AssetConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for storing legal metadata about a resource (a content item or an
|
* Container for storing legal metadata about a resource (a content item or an
|
||||||
|
|
@ -46,6 +49,11 @@ import static org.librecms.CmsConstants.*;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@AssetType(assetForm = LegalMetadataForm.class,
|
||||||
|
labelKey = "legal_metadata.label",
|
||||||
|
labelBundle = ASSETS_BUNDLE,
|
||||||
|
descriptionKey = "legal_metadata.description",
|
||||||
|
descriptionBundle = ASSETS_BUNDLE)
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "LEGAL_METADATA", schema = DB_SCHEMA)
|
@Table(name = "LEGAL_METADATA", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
|
@ -86,7 +94,7 @@ public class LegalMetadata extends Asset implements Serializable {
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "LEGAL_METADATA_ID")
|
@JoinColumn(name = "LEGAL_METADATA_ID")
|
||||||
})
|
})
|
||||||
@Column(name ="CONTRIBUTORS")
|
@Column(name = "CONTRIBUTORS")
|
||||||
private List<String> contributors;
|
private List<String> contributors;
|
||||||
|
|
||||||
public LegalMetadata() {
|
public LegalMetadata() {
|
||||||
|
|
|
||||||
|
|
@ -246,3 +246,5 @@ cms.ui.type.select=Select Content Type
|
||||||
cms.ui.type.select.none=There are no available content types to select
|
cms.ui.type.select.none=There are no available content types to select
|
||||||
cms.ui.assets=Assets
|
cms.ui.assets=Assets
|
||||||
cms.ui.folder.no_assets=No assets
|
cms.ui.folder.no_assets=No assets
|
||||||
|
cms.ui.assets.new=Create new asset
|
||||||
|
cms.ui.assets.new.create=Create asset
|
||||||
|
|
|
||||||
|
|
@ -245,3 +245,5 @@ cms.ui.type.select=Dolkumententype ausw\u00e4hlen
|
||||||
cms.ui.type.select.none=Keine verf\u00fcgbaren Dokumententypen
|
cms.ui.type.select.none=Keine verf\u00fcgbaren Dokumententypen
|
||||||
cms.ui.assets=Medien & Daten
|
cms.ui.assets=Medien & Daten
|
||||||
cms.ui.folder.no_assets=Keine Medien oder Datens\u00e4tze vorhanden
|
cms.ui.folder.no_assets=Keine Medien oder Datens\u00e4tze vorhanden
|
||||||
|
cms.ui.assets.new=Neues Asset anlegen
|
||||||
|
cms.ui.assets.new.create=Asset anlegen
|
||||||
|
|
|
||||||
|
|
@ -204,3 +204,5 @@ cms.ui.type.select=Select Content Type
|
||||||
cms.ui.type.select.none=There are no available content types to select
|
cms.ui.type.select.none=There are no available content types to select
|
||||||
cms.ui.assets=Assets
|
cms.ui.assets=Assets
|
||||||
cms.ui.folder.no_assets=No assets
|
cms.ui.folder.no_assets=No assets
|
||||||
|
cms.ui.assets.new=Create new asset
|
||||||
|
cms.ui.assets.new.create=Create asset
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
bookmark.label=Bookmark
|
||||||
|
bookmark.description=Asset type to store URLs to external resources.
|
||||||
|
legal_metadata.label=Legal metadata
|
||||||
|
legal_metadata.description=Stores legal metadata like the informations about the creator of an image etc.
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
bookmark.label=Lesezeichen (URL)
|
||||||
|
bookmark.description=Dieser Asset-Typ dient zur Ablage von URLs zu externen Resourcen.
|
||||||
|
legal_metadata.label=Rechtliche Informationen
|
||||||
|
legal_metadata.description=Rechtliche Informationen, z.B. die Urheberschaft von Bildern etc.
|
||||||
Loading…
Reference in New Issue