CCM NG/ccm-cms:
- Form for FileAsset - Added FileAsset to known asset types git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4680 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
fe1d5f267f
commit
87ede0d337
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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.PageState;
|
||||
import com.arsdigita.cms.ui.assets.AssetPane;
|
||||
import org.librecms.assets.BinaryAsset;
|
||||
import org.librecms.assets.FileAsset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class FileAssetForm extends BinaryAssetForm {
|
||||
|
||||
public FileAssetForm(final AssetPane assetPane) {
|
||||
super(assetPane);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BinaryAsset createBinaryAsset(final PageState state) {
|
||||
return new FileAsset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ import org.librecms.contenttypes.News;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import org.librecms.assets.FileAsset;
|
||||
|
||||
import org.librecms.assets.SideNote;
|
||||
|
||||
|
|
@ -50,7 +51,8 @@ import org.librecms.assets.SideNote;
|
|||
descBundle = CmsConstants.CONTENT_CENTER_DESC_BUNDLE,
|
||||
creator = ContentCenterAppCreator.class,
|
||||
servlet = ContentCenterServlet.class
|
||||
),
|
||||
)
|
||||
,
|
||||
@ApplicationType(
|
||||
name = CmsConstants.CONTENT_SECTION_APP_TYPE,
|
||||
applicationClass = ContentSection.class,
|
||||
|
|
@ -62,10 +64,14 @@ import org.librecms.assets.SideNote;
|
|||
)
|
||||
}
|
||||
)
|
||||
@ContentTypes({Article.class, Event.class, MultiPartArticle.class, News.class})
|
||||
@AssetTypes({Bookmark.class,
|
||||
ExternalVideoAsset.class,
|
||||
LegalMetadata.class,
|
||||
@ContentTypes({Article.class,
|
||||
Event.class,
|
||||
MultiPartArticle.class,
|
||||
News.class})
|
||||
@AssetTypes({Bookmark.class,
|
||||
ExternalVideoAsset.class,
|
||||
FileAsset.class,
|
||||
LegalMetadata.class,
|
||||
SideNote.class})
|
||||
public class Cms implements CcmModule {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,14 @@
|
|||
* MA 02110-1301 USA
|
||||
*/package org.librecms.assets;
|
||||
|
||||
import com.arsdigita.cms.ui.assets.forms.FileAssetForm;
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
import static org.librecms.CmsConstants.*;
|
||||
import static org.librecms.assets.AssetConstants.*;
|
||||
|
||||
/**
|
||||
* An asset for making files available for download.
|
||||
|
|
@ -32,7 +34,12 @@ import static org.librecms.CmsConstants.*;
|
|||
@Entity
|
||||
@Table(name = "FILES", schema = DB_SCHEMA)
|
||||
@Audited
|
||||
public class File extends BinaryAsset implements Serializable {
|
||||
@AssetType(assetForm = FileAssetForm.class,
|
||||
labelKey = "fileasset.label",
|
||||
labelBundle = ASSETS_BUNDLE,
|
||||
descriptionKey = "fileasset.description",
|
||||
descriptionBundle = ASSETS_BUNDLE)
|
||||
public class FileAsset extends BinaryAsset implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8195062456502964401L;
|
||||
|
||||
|
|
@ -53,16 +60,16 @@ public class File extends BinaryAsset implements Serializable {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!(obj instanceof File)) {
|
||||
if (!(obj instanceof FileAsset)) {
|
||||
return false;
|
||||
}
|
||||
final File other = (File) obj;
|
||||
final FileAsset other = (FileAsset) obj;
|
||||
return other.canEqual(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEqual(final Object obj) {
|
||||
return obj instanceof File;
|
||||
return obj instanceof FileAsset;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -7,3 +7,5 @@ sidenote.label=Side note
|
|||
sidenote.description=Additional information. Usually appears in the right or left column of an webpage.
|
||||
external_video_asset.label=External Video
|
||||
external_video_asset.description=An external video e.g. on YouTube. The presentation will either be a link or an embedded video.
|
||||
fileasset.label=File
|
||||
fileasset.description=A downloadable file, for instance a PDF file or a ZIP file
|
||||
|
|
|
|||
|
|
@ -7,3 +7,5 @@ sidenote.label=Randbemerkung
|
|||
sidenote.description=Randbemerkung mit zus\u00e4tzlichen Informationen. Erscheint in der Regel in der rechten oder linken Spalte einer Webseite.
|
||||
external_video_asset.label=Externes Video
|
||||
external_video_asset.description=Externes Video z.B. auf YouTube. Wird entweder als Link oder eingebettet angezeigt.
|
||||
fileasset.label=Datei
|
||||
fileasset.description=Eine herunterladebare Datei, beispielsweise eine PDF-Datei oder ZIP-Datei
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ import javax.activation.MimeType;
|
|||
import javax.activation.MimeTypeParseException;
|
||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||
|
||||
import org.librecms.assets.File;
|
||||
import org.librecms.assets.FileAsset;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -215,7 +215,7 @@ public class AssetManagerTest {
|
|||
final Folder folder = folderRepo.findById(-420L).get();
|
||||
assertThat(folder, is(not(nullValue())));
|
||||
|
||||
final File file = new File();
|
||||
final FileAsset file = new FileAsset();
|
||||
file.setDisplayName("datasheet.pdf");
|
||||
file.setFileName("datasheet.pdf");
|
||||
file.setMimeType(new MimeType("application/pdf"));
|
||||
|
|
@ -262,7 +262,7 @@ public class AssetManagerTest {
|
|||
"datasets/org/librecms/contentsection/AssetManagerTest/data.xml")
|
||||
@ShouldThrowException(IllegalArgumentException.class)
|
||||
public void shareAssetFolderIsNull() throws MimeTypeParseException {
|
||||
final File file = new File();
|
||||
final FileAsset file = new FileAsset();
|
||||
file.setDisplayName("datasheet.pdf");
|
||||
file.setFileName("datasheet.pdf");
|
||||
file.setMimeType(new MimeType("application/pdf"));
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import java.util.Optional;
|
|||
import javax.inject.Inject;
|
||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||
|
||||
import org.librecms.assets.File;
|
||||
import org.librecms.assets.FileAsset;
|
||||
import org.librecms.assets.Image;
|
||||
import org.librecms.assets.VideoAsset;
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ public class AssetRepositoryTest {
|
|||
assertThat(datasheet.isPresent(), is(true));
|
||||
assertThat(datasheet.get(), is(instanceOf(Asset.class)));
|
||||
assertThat(datasheet.get(), is(instanceOf(BinaryAsset.class)));
|
||||
assertThat(datasheet.get(), is(instanceOf(File.class)));
|
||||
assertThat(datasheet.get(), is(instanceOf(FileAsset.class)));
|
||||
assertThat(datasheet.get().getDisplayName(), is(equalTo(
|
||||
"product1-datasheet.pdf")));
|
||||
|
||||
|
|
@ -274,8 +274,7 @@ public class AssetRepositoryTest {
|
|||
public void findAssetByUuidAndType() {
|
||||
final Optional<Asset> asset = assetRepo.findByUuidAndType(
|
||||
"4635589f-b87a-46d9-979e-6af14af063e5", Image.class);
|
||||
final Optional<Asset> none = assetRepo.findByUuidAndType(
|
||||
"4635589f-b87a-46d9-979e-6af14af063e5", File.class);
|
||||
final Optional<Asset> none = assetRepo.findByUuidAndType("4635589f-b87a-46d9-979e-6af14af063e5", FileAsset.class);
|
||||
|
||||
assertThat(asset.isPresent(), is(true));
|
||||
assertThat(asset.get().getDisplayName(), is(equalTo("header.png")));
|
||||
|
|
@ -293,7 +292,7 @@ public class AssetRepositoryTest {
|
|||
"datasets/org/librecms/contentsection/AssetRepositoryTest/data.xml")
|
||||
public void findAssetByType() {
|
||||
final List<Asset> images = assetRepo.findByType(Image.class);
|
||||
final List<Asset> files = assetRepo.findByType(File.class);
|
||||
final List<Asset> files = assetRepo.findByType(FileAsset.class);
|
||||
|
||||
assertThat(images.isEmpty(), is(false));
|
||||
assertThat(files.isEmpty(), is(false));
|
||||
|
|
@ -402,7 +401,7 @@ public class AssetRepositoryTest {
|
|||
final List<Asset> images = assetRepo.filterByFolderAndType(media,
|
||||
Image.class);
|
||||
final List<Asset> files = assetRepo.filterByFolderAndType(media,
|
||||
File.class);
|
||||
FileAsset.class);
|
||||
final List<Asset> videos = assetRepo.filterByFolderAndType(
|
||||
media, VideoAsset.class);
|
||||
|
||||
|
|
@ -434,7 +433,7 @@ public class AssetRepositoryTest {
|
|||
|
||||
assertThat(assetRepo.countFilterByFolderAndType(media, Image.class),
|
||||
is(3L));
|
||||
assertThat(assetRepo.countFilterByFolderAndType(media, File.class),
|
||||
assertThat(assetRepo.countFilterByFolderAndType(media, FileAsset.class),
|
||||
is(2L));
|
||||
assertThat(assetRepo.countFilterByFolderAndType(media, VideoAsset.class),
|
||||
is(0L));
|
||||
|
|
@ -454,8 +453,7 @@ public class AssetRepositoryTest {
|
|||
|
||||
final List<Asset> result1 = assetRepo.filterByFolderAndTypeAndTitle(
|
||||
media, Image.class, "hea");
|
||||
final List<Asset> result2 = assetRepo.filterByFolderAndTypeAndTitle(
|
||||
media, File.class, "hea");
|
||||
final List<Asset> result2 = assetRepo.filterByFolderAndTypeAndTitle(media, FileAsset.class, "hea");
|
||||
|
||||
assertThat(result1.size(), is(2));
|
||||
assertThat(result2.size(), is(0));
|
||||
|
|
@ -477,8 +475,7 @@ public class AssetRepositoryTest {
|
|||
assertThat(assetRepo.countFilterByFolderAndTypeAndTitle(
|
||||
media, Image.class, "hea"),
|
||||
is(2L));
|
||||
assertThat(assetRepo.countFilterByFolderAndTypeAndTitle(
|
||||
media, File.class, "hea"),
|
||||
assertThat(assetRepo.countFilterByFolderAndTypeAndTitle(media, FileAsset.class, "hea"),
|
||||
is(0L));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue