Java part for the media authoring step.
parent
90471ca4e3
commit
f4b73670af
|
|
@ -18,13 +18,14 @@
|
|||
*/
|
||||
package org.librecms.ui.contentsections.documents;
|
||||
|
||||
import org.librecms.ui.contentsections.documents.media.MediaStep;
|
||||
import org.librecms.ui.contentsections.documents.media.MediaStepService;
|
||||
import org.librecms.ui.contentsections.documents.relatedinfo.RelatedInfoStep;
|
||||
import org.librecms.ui.contentsections.documents.relatedinfo.RelatedInfoStepService;
|
||||
import org.librecms.ui.contenttypes.MvcArticlePropertiesStep;
|
||||
import org.librecms.ui.contenttypes.MvcArticleTextBodyStep;
|
||||
import org.librecms.ui.contenttypes.MvcArticleTextBodyStepResources;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
|
|
@ -38,24 +39,23 @@ public class CmsMvcAuthoringSteps implements MvcAuthoringSteps {
|
|||
|
||||
@Override
|
||||
public Set<Class<?>> getClasses() {
|
||||
final Set<Class<?>> classes = new HashSet<>();
|
||||
classes.add(ExampleAuthoringStep.class);
|
||||
|
||||
classes.add(CategorizationStep.class);
|
||||
classes.add(RelatedInfoStep.class);
|
||||
classes.add(MvcArticlePropertiesStep.class);
|
||||
classes.add(MvcArticleTextBodyStep.class);
|
||||
|
||||
return classes;
|
||||
return Set.of(
|
||||
ExampleAuthoringStep.class,
|
||||
CategorizationStep.class,
|
||||
MediaStep.class,
|
||||
RelatedInfoStep.class,
|
||||
MvcArticlePropertiesStep.class,
|
||||
MvcArticleTextBodyStep.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Class<?>> getResourceClasses() {
|
||||
final Set<Class<?>> classes = new HashSet<>();
|
||||
classes.add(MvcArticleTextBodyStepResources.class);
|
||||
classes.add(RelatedInfoStepService.class);
|
||||
|
||||
return classes;
|
||||
return Set.of(
|
||||
MediaStepService.class,
|
||||
MvcArticleTextBodyStepResources.class,
|
||||
RelatedInfoStepService.class
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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.ui.contentsections.documents.media;
|
||||
|
||||
/**
|
||||
* A DTO for providing data about an {@link ItemAttachment} containing a media
|
||||
* asset in a form suitable for a MVC view.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class MediaAttachmentDto {
|
||||
|
||||
/**
|
||||
* The ID of the attachment.
|
||||
*/
|
||||
private long attachmentId;
|
||||
|
||||
/**
|
||||
* The UUID of the attachment.
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* The sort key of the attachment.
|
||||
*/
|
||||
private long sortKey;
|
||||
|
||||
/**
|
||||
* The name of the asset type.
|
||||
*/
|
||||
private String assetType;
|
||||
|
||||
/**
|
||||
* Label for the type of the asset of the attachment.
|
||||
*/
|
||||
private String assetTypeLabel;
|
||||
|
||||
/**
|
||||
* The UUID of the attachment asset.
|
||||
*/
|
||||
private String assetUuid;
|
||||
|
||||
/**
|
||||
* The title of the media asset assigned to an content item. This value is
|
||||
* determined from the title of the asset using {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)
|
||||
* }.
|
||||
*/
|
||||
private String title;
|
||||
|
||||
public long getAttachmentId() {
|
||||
return attachmentId;
|
||||
}
|
||||
|
||||
public void setAttachmentId(final long attachmentId) {
|
||||
this.attachmentId = attachmentId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public long getSortKey() {
|
||||
return sortKey;
|
||||
}
|
||||
|
||||
public void setSortKey(long sortKey) {
|
||||
this.sortKey = sortKey;
|
||||
}
|
||||
|
||||
public String getAssetTypeLabel() {
|
||||
return assetTypeLabel;
|
||||
}
|
||||
|
||||
public void setAssetTypeLabel(final String assetTypeLabel) {
|
||||
this.assetTypeLabel = assetTypeLabel;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAssetUuid() {
|
||||
return assetUuid;
|
||||
}
|
||||
|
||||
public void setAssetUuid(final String assetUuid) {
|
||||
this.assetUuid = assetUuid;
|
||||
}
|
||||
|
||||
public String getAssetType() {
|
||||
return assetType;
|
||||
}
|
||||
|
||||
public void setAssetType(final String assetType) {
|
||||
this.assetType = assetType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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.ui.contentsections.documents.media;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Named("CmsMediaDetailsModel")
|
||||
public class MediaDetailsModel {
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
/**
|
||||
* The identifier of the {@link AttachmentList} of the link.
|
||||
*/
|
||||
private String listIdentifier;
|
||||
|
||||
/**
|
||||
* The UUID of the link.
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
private String name;
|
||||
|
||||
private String sectionName;
|
||||
|
||||
private String mediaType;
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(final String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public String getListIdentifier() {
|
||||
return listIdentifier;
|
||||
}
|
||||
|
||||
public void setListIdentifier(final String listIdentifier) {
|
||||
this.listIdentifier = listIdentifier;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSectionName() {
|
||||
return sectionName;
|
||||
}
|
||||
|
||||
public void setSectionName(final String sectionName) {
|
||||
this.sectionName = sectionName;
|
||||
}
|
||||
|
||||
public String getMediaType() {
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
public void setMediaType(final String mediaType) {
|
||||
this.mediaType = mediaType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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.ui.contentsections.documents.media;
|
||||
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* Model used by the media list details view.
|
||||
*
|
||||
* @see MediaStep
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Named("CmsMediaListDetailsModel")
|
||||
public class MediaListDetailsModel {
|
||||
|
||||
/**
|
||||
* The {@link GlobalizationHelper} is used here for retrieving some
|
||||
* localized values. The purpose of this model is to provide the properties
|
||||
* of an {@link AttachmentList} is a form that is directly usable in the
|
||||
* template of the details view. The data of the model is provided by the
|
||||
* {@link RelatedInfoStep}.
|
||||
*/
|
||||
@Inject
|
||||
private GlobalizationHelper globalizationHelper;
|
||||
|
||||
private boolean canEdit;
|
||||
|
||||
/**
|
||||
* UUID of the {@link AttachmentList} shown.
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* Name of the {@link AttachmentList} shown.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Preprocessed localized title values of the {@link AttachmentList}. This
|
||||
* map is generated by transforming the locales the
|
||||
* {@link AttachmentList#title} to a string using {@link Locale#toString()}.
|
||||
*/
|
||||
private Map<String, String> titles;
|
||||
|
||||
/**
|
||||
* Preprocessed localized description values of the {@link AttachmentList}.
|
||||
* This map is generated by transforming the locales the
|
||||
* {@link AttachmentList#description} to a string using
|
||||
* {@link Locale#toString()}.
|
||||
*/
|
||||
private Map<String, String> descriptions;
|
||||
|
||||
/**
|
||||
* Not used locales for the title. These are the locales returned by
|
||||
* {@link GlobalizationHelper#getAvailableLocales()} minus the locales
|
||||
* returned by {@link LocalizedString#getAvailableLocales()} for
|
||||
* {@link AttachmentList#title}.
|
||||
*/
|
||||
private List<String> unusedTitleLocales;
|
||||
|
||||
/**
|
||||
* Not used locales for the description. These are the locales returned by
|
||||
* {@link GlobalizationHelper#getAvailableLocales()} minus the locales
|
||||
* returned by {@link LocalizedString#getAvailableLocales()} for
|
||||
* {@link AttachmentList#description}.
|
||||
*/
|
||||
private List<String> unusedDescriptionLocales;
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Map<String, String> getTitles() {
|
||||
return Collections.unmodifiableMap(titles);
|
||||
}
|
||||
|
||||
public void setTitles(final Map<String, String> titles) {
|
||||
this.titles = new HashMap<>(titles);
|
||||
}
|
||||
|
||||
public Map<String, String> getDescriptions() {
|
||||
return Collections.unmodifiableMap(descriptions);
|
||||
}
|
||||
|
||||
public void setDescriptions(final Map<String, String> descriptions) {
|
||||
this.descriptions = new HashMap<>(descriptions);
|
||||
}
|
||||
|
||||
public List<String> getUnusedTitleLocales() {
|
||||
return Collections.unmodifiableList(unusedTitleLocales);
|
||||
}
|
||||
|
||||
public void setUnusedTitleLocales(final List<String> unusedTitleLocales) {
|
||||
this.unusedTitleLocales = new ArrayList<>(unusedTitleLocales);
|
||||
}
|
||||
|
||||
public List<String> getUnusedDescriptionLocales() {
|
||||
return Collections.unmodifiableList(unusedDescriptionLocales);
|
||||
}
|
||||
|
||||
public void setUnusedDescriptionLocales(
|
||||
final List<String> unusedDescriptionLocales
|
||||
) {
|
||||
this.unusedDescriptionLocales
|
||||
= new ArrayList<>(unusedDescriptionLocales);
|
||||
}
|
||||
|
||||
public boolean getCanEdit() {
|
||||
return canEdit;
|
||||
}
|
||||
|
||||
public void setCanEdit(final boolean canEdit) {
|
||||
this.canEdit = canEdit;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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.ui.contentsections.documents.media;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A data transfer object used by the template for the listing of the
|
||||
* {@link AttachmentList}s containing media attachments of a
|
||||
* {@link ContentItem}.
|
||||
*
|
||||
* @see MediaStep
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class MediaListDto {
|
||||
|
||||
/**
|
||||
* The ID of the list.
|
||||
*/
|
||||
private long listId;
|
||||
|
||||
/**
|
||||
* The UUID of the list.
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
/**
|
||||
* The name of the list.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The order value of the list.
|
||||
*/
|
||||
private long order;
|
||||
|
||||
/**
|
||||
* The title of the list. This value is determined using
|
||||
* {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)}.
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* The description of the list. This value is determined using
|
||||
* {@link GlobalizationHelper#getValueFromLocalizedString(org.libreccm.l10n.LocalizedString)}.
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* The @link{ItemAttachment}s associated with the {@link AttachmentList}.
|
||||
*/
|
||||
private List<MediaAttachmentDto> attachments;
|
||||
|
||||
public long getListId() {
|
||||
return listId;
|
||||
}
|
||||
|
||||
public void setListId(final long listId) {
|
||||
this.listId = listId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(final String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(long order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<MediaAttachmentDto> getAttachments() {
|
||||
return Collections.unmodifiableList(attachments);
|
||||
}
|
||||
|
||||
public void setAttachments(final List<MediaAttachmentDto> attachments) {
|
||||
this.attachments = new ArrayList<>(attachments);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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.ui.contentsections.documents.media;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class MediaStepAttachmentOrder {
|
||||
|
||||
private List<String> attachmentListsOrder;
|
||||
|
||||
private Map<String, List<String>> attachmentsOrder;
|
||||
|
||||
private List<MovedAttachment> movedAttachments;
|
||||
|
||||
public List<String> getAttachmentListsOrder() {
|
||||
return Collections.unmodifiableList(attachmentListsOrder);
|
||||
}
|
||||
|
||||
public void setAttachmentListsOrder(final List<String> attachmentListsOrder) {
|
||||
this.attachmentListsOrder = new ArrayList<>(attachmentListsOrder);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getAttachmentsOrder() {
|
||||
return Collections.unmodifiableMap(attachmentsOrder);
|
||||
}
|
||||
|
||||
public void setAttachmentsOrder(
|
||||
final Map<String, List<String>> attachmentsOrder
|
||||
) {
|
||||
this.attachmentsOrder = attachmentsOrder
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
entry -> entry.getKey(),
|
||||
entry -> new ArrayList<>(entry.getValue())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public List<MovedAttachment> getMovedAttachments() {
|
||||
return Collections.unmodifiableList(movedAttachments);
|
||||
}
|
||||
|
||||
public void setMovedAttachments(final List<MovedAttachment> movedAttachments) {
|
||||
this.movedAttachments = new ArrayList<>(movedAttachments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"attachmentListsOrder = %s, "
|
||||
+ "attachmentsOrder = %s, "
|
||||
+ "movedAttachments = %s",
|
||||
Objects.toString(attachmentListsOrder),
|
||||
Objects.toString(attachmentsOrder),
|
||||
Objects.toString(movedAttachments)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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.ui.contentsections.documents.media;
|
||||
|
||||
import org.librecms.assets.AudioAsset;
|
||||
import org.librecms.assets.ExternalAudioAsset;
|
||||
import org.librecms.assets.ExternalVideoAsset;
|
||||
import org.librecms.assets.Image;
|
||||
import org.librecms.assets.VideoAsset;
|
||||
import org.librecms.contentsection.AttachmentList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Named("CmsMediaStep")
|
||||
public class MediaStepModel {
|
||||
|
||||
private List<MediaListDto> mediaLists;
|
||||
|
||||
private String mediaAssetPickerBaseUrl;
|
||||
|
||||
private String sectionName;
|
||||
|
||||
/**
|
||||
* Gets the {@link AttachmentList}s containing media assets of the current
|
||||
* content item and converts them to {@link MediaListDto}s to make data
|
||||
* about the lists available in the views.
|
||||
*
|
||||
* @return A list of the {@link AttachmentList} of the current content item.
|
||||
*/
|
||||
public List<MediaListDto> getMediaLists() {
|
||||
return Collections.unmodifiableList(mediaLists);
|
||||
}
|
||||
|
||||
public List<MediaListDto> getAttachmentsLists() {
|
||||
return Collections.unmodifiableList(mediaLists);
|
||||
}
|
||||
|
||||
public void setAttachmentsLists(List<MediaListDto> mediaLists) {
|
||||
this.mediaLists = mediaLists;
|
||||
}
|
||||
|
||||
protected void setMediaLists(
|
||||
final List<MediaListDto> attachmentLists
|
||||
) {
|
||||
this.mediaLists = new ArrayList<>(attachmentLists);
|
||||
}
|
||||
|
||||
public String getMediaAssetPickerBaseUrl() {
|
||||
return mediaAssetPickerBaseUrl;
|
||||
}
|
||||
|
||||
public void setMediaAssetPickerBaseUrl(final String mediaAssetPickerBaseUrl) {
|
||||
this.mediaAssetPickerBaseUrl = mediaAssetPickerBaseUrl;
|
||||
}
|
||||
|
||||
public String getSectionName() {
|
||||
return sectionName;
|
||||
}
|
||||
|
||||
public void setSectionName(final String sectionName) {
|
||||
this.sectionName = sectionName;
|
||||
}
|
||||
|
||||
public String getAudioAssetType() {
|
||||
return AudioAsset.class.getName();
|
||||
}
|
||||
|
||||
public String getExternalAudioAssetType() {
|
||||
return ExternalAudioAsset.class.getName();
|
||||
}
|
||||
|
||||
public String getExternalVideoAssetType() {
|
||||
return ExternalVideoAsset.class.getName();
|
||||
}
|
||||
|
||||
public String getImageType() {
|
||||
return Image.class.getName();
|
||||
}
|
||||
|
||||
public String getVideoAssetType() {
|
||||
return VideoAsset.class.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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.ui.contentsections.documents.media;
|
||||
|
||||
import org.librecms.contentsection.AttachmentList;
|
||||
import org.librecms.contentsection.AttachmentListRepository;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.ContentItemRepository;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
import org.librecms.contentsection.ItemAttachment;
|
||||
import org.librecms.contentsection.ItemAttachmentManager;
|
||||
import org.librecms.ui.contentsections.ContentSectionsUi;
|
||||
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.BadRequestException;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Path(MvcAuthoringSteps.PATH_PREFIX + "media-service")
|
||||
public class MediaStepService {
|
||||
|
||||
@Inject
|
||||
private AttachmentListRepository attachmentListRepo;
|
||||
|
||||
@Inject
|
||||
private ItemAttachmentManager attachmentManager;
|
||||
|
||||
@Inject
|
||||
private ContentItemRepository itemRepo;
|
||||
|
||||
@Inject
|
||||
private ContentSectionsUi sectionsUi;
|
||||
|
||||
@POST
|
||||
@Path("/save-order")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public Response saveOrder(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
final MediaStepAttachmentOrder order
|
||||
) {
|
||||
final ContentSection contentSection = sectionsUi
|
||||
.findContentSection(sectionIdentifier)
|
||||
.orElseThrow(
|
||||
() -> new NotFoundException(
|
||||
String.format(
|
||||
"No content identifed by %s found.",
|
||||
sectionIdentifier
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final ContentItem document = itemRepo
|
||||
.findByPath(contentSection, documentPath)
|
||||
.orElseThrow(
|
||||
() -> new NotFoundException(
|
||||
String.format(
|
||||
"No document for path %s in section %s.",
|
||||
documentPath,
|
||||
contentSection.getLabel()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final List<AttachmentList> attachmentLists = document.getAttachments();
|
||||
final List<String> attachmentListsOrder = order
|
||||
.getAttachmentListsOrder();
|
||||
|
||||
if (attachmentListsOrder.size() != attachmentLists.size()) {
|
||||
throw new BadRequestException(
|
||||
String.format(
|
||||
"Size of lists of attachment lists does not match list of "
|
||||
+ "attachment order list. attachmentLists.size = %d, "
|
||||
+ "attachmentListsOrder.size = %d.",
|
||||
attachmentLists.size(),
|
||||
attachmentListsOrder.size()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
for (int i = 0; i < attachmentListsOrder.size(); i++) {
|
||||
final String listUuid = attachmentListsOrder.get(i);
|
||||
final AttachmentList attachmentList = attachmentLists
|
||||
.stream()
|
||||
.filter(list -> listUuid.equals(list.getUuid()))
|
||||
.findAny()
|
||||
.orElseThrow(
|
||||
() -> new BadRequestException(
|
||||
String.format(
|
||||
"attachmentListsOrder has an entry for attachment "
|
||||
+ "list %s, but there no attachment list with "
|
||||
+ "that UUID.",
|
||||
listUuid
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
attachmentList.setListOrder(i);
|
||||
attachmentListRepo.save(attachmentList);
|
||||
}
|
||||
|
||||
for (final Map.Entry<String, List<String>> attachmentsOrder : order
|
||||
.getAttachmentsOrder().entrySet()) {
|
||||
final AttachmentList attachmentList = document
|
||||
.getAttachments()
|
||||
.stream()
|
||||
.filter(list -> attachmentsOrder.getKey().equals(list.getUuid()))
|
||||
.findAny()
|
||||
.orElseThrow(
|
||||
() -> new BadRequestException(
|
||||
String.format(
|
||||
"attachmentsOrder contains an entry for "
|
||||
+ "attachment list %s, but there no attachment "
|
||||
+ "list with that UUID.",
|
||||
attachmentsOrder.getKey()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final List<ItemAttachment<?>> attachments = attachmentList
|
||||
.getAttachments();
|
||||
if (attachments.size() != attachmentsOrder.getValue().size()) {
|
||||
throw new BadRequestException(
|
||||
String.format(
|
||||
"Size of attachmentsOrder list does not match the size"
|
||||
+ "of the attachments list. "
|
||||
+ "attachmentsOrder.size = %d, "
|
||||
+ "attachmentsList.size = %d",
|
||||
attachmentsOrder.getValue().size(),
|
||||
attachments.size()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
for (int i = 0; i < attachmentsOrder.getValue().size(); i++) {
|
||||
final String attachmentUuid = attachmentsOrder.getValue().get(i);
|
||||
final ItemAttachment<?> attachment = attachments
|
||||
.stream()
|
||||
.filter(current -> attachmentUuid.equals(current.getUuid()))
|
||||
.findAny()
|
||||
.orElseThrow(
|
||||
() -> new BadRequestException(
|
||||
String.format(
|
||||
"attachmentOrder order for attachment list %s "
|
||||
+ "has an entry for attachment %s but "
|
||||
+ "there is attachment with that UUID in "
|
||||
+ "the list.",
|
||||
attachmentList.getUuid(),
|
||||
attachmentUuid
|
||||
)
|
||||
)
|
||||
);
|
||||
attachment.setSortKey(i);
|
||||
attachmentManager.save(attachment);
|
||||
}
|
||||
}
|
||||
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (C) 2021 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.ui.contentsections.documents.media;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class MovedAttachment {
|
||||
|
||||
private String attachmentUuid;
|
||||
|
||||
private String fromListUuid;
|
||||
|
||||
private String toListUuid;
|
||||
|
||||
public String getAttachmentUuid() {
|
||||
return attachmentUuid;
|
||||
}
|
||||
|
||||
public void setAttachmentUuid(final String attachmentUuid) {
|
||||
this.attachmentUuid = attachmentUuid;
|
||||
}
|
||||
|
||||
public String getFromListUuid() {
|
||||
return fromListUuid;
|
||||
}
|
||||
|
||||
public void setFromListUuid(final String fromListUuid) {
|
||||
this.fromListUuid = fromListUuid;
|
||||
}
|
||||
|
||||
public String getToListUuid() {
|
||||
return toListUuid;
|
||||
}
|
||||
|
||||
public void setToListUuid(final String toListUuid) {
|
||||
this.toListUuid = toListUuid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -533,3 +533,5 @@ videoasset.editstep.legelmetadata.remove.submit=Remove legal metadata
|
|||
videoasset.editstep.legelmetadata.rightsholder=Rights Holder
|
||||
videoasset.editstep.legelmetadata.creator=Creator
|
||||
categorization.tree.expand=Expand/Hide subcategories
|
||||
authoringsteps.media.description=Add different media, for example images, videos or audio asset to a content item.
|
||||
authoringsteps.media.label=Media
|
||||
|
|
|
|||
|
|
@ -533,3 +533,5 @@ videoasset.editstep.legelmetadata.remove.submit=Rechtliche Informationen entfern
|
|||
videoasset.editstep.legelmetadata.rightsholder=Rechteinhaber
|
||||
videoasset.editstep.legelmetadata.creator=K\u00fcnstler
|
||||
categorization.tree.expand=Unterkategorien anzeigen/verbergen
|
||||
authoringsteps.media.description=F\u00fcgen Sie Medien, z.B. Bilder, Videos oder Audio-Dateien einem Dokument hinzu.
|
||||
authoringsteps.media.label=Medien
|
||||
|
|
|
|||
Loading…
Reference in New Issue