MPA ImageAsset durch ReusableImageAsset ersetzt

git-svn-id: https://svn.libreccm.org/ccm/trunk@1538 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2012-03-07 14:37:44 +00:00
parent 291e6bbe68
commit 18eb7f05c6
4 changed files with 86 additions and 92 deletions

View File

@ -21,7 +21,7 @@ model com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.TextAsset; import com.arsdigita.cms.TextAsset;
import com.arsdigita.cms.ImageAsset; import com.arsdigita.cms.ReusableImageAsset;
// object type to hold sections for multi-part article content type // object type to hold sections for multi-part article content type
@ -32,7 +32,7 @@ object type ArticleSection extends ContentPage {
component TextAsset[0..1] text = join ct_mp_sections.text component TextAsset[0..1] text = join ct_mp_sections.text
to cms_text.text_id; to cms_text.text_id;
component ImageAsset[0..1] image = join ct_mp_sections.image component ReusableImageAsset[0..1] image = join ct_mp_sections.image
to cms_images.image_id; to cms_images.image_id;
reference key (ct_mp_sections.section_id); reference key (ct_mp_sections.section_id);

View File

@ -18,21 +18,15 @@
*/ */
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.*;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.TextAsset;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import org.apache.log4j.Logger;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.apache.log4j.Logger;
/** /**
* Represents a section within a MultiPartArticle * Represents a section within a MultiPartArticle
@ -130,15 +124,15 @@ public class ArticleSection extends ContentPage {
} }
/** Accessor. Get the image associated with this item. */ /** Accessor. Get the image associated with this item. */
public ImageAsset getImage() { public ReusableImageAsset getImage() {
if ( get(IMAGE) == null ) { if ( get(IMAGE) == null ) {
return null; return null;
} }
return new ImageAsset((DataObject)get(IMAGE)); return new ReusableImageAsset((DataObject)get(IMAGE));
} }
/** Mutator. Set the image associated with this item. */ /** Mutator. Set the image associated with this item. */
public void setImage(ImageAsset image) { public void setImage(ReusableImageAsset image) {
setAssociation(IMAGE, image); setAssociation(IMAGE, image);
} }
@ -269,7 +263,7 @@ public class ArticleSection extends ContentPage {
/** /**
* This overrides the method on ContentItem, the API of which * This overrides the method on ContentItem, the API of which
* says that this method can return a null eg. if the method is * says that this method can return a null eg. if the method is
* called on an Article's ImageAsset. * called on an Article's ReusableImageAsset.
* *
* However there seems to be a problem with ArticleSections returning * However there seems to be a problem with ArticleSections returning
* null when they shouldn't. If that happens we are going to look up the * null when they shouldn't. If that happens we are going to look up the

View File

@ -29,8 +29,8 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.FileUpload; import com.arsdigita.bebop.form.FileUpload;
import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.form.TextField;
import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.cms.ui.ImageDisplay; import com.arsdigita.cms.ui.ImageDisplay;
import com.arsdigita.cms.contenttypes.util.MPArticleGlobalizationUtil; import com.arsdigita.cms.contenttypes.util.MPArticleGlobalizationUtil;
import com.arsdigita.dispatcher.MultipartHttpServletRequest; import com.arsdigita.dispatcher.MultipartHttpServletRequest;
@ -113,7 +113,7 @@ public class ImageUploadSection extends FormSection
FormData data = event.getFormData(); FormData data = event.getFormData();
PageState state = event.getPageState(); PageState state = event.getPageState();
ImageAsset image = (ImageAsset)m_selImage.getSelectedObject(state); ReusableImageAsset image = (ReusableImageAsset)m_selImage.getSelectedObject(state);
m_currentImage.setVisible(state, false); m_currentImage.setVisible(state, false);
m_imageDisplay.setVisible(state, false); m_imageDisplay.setVisible(state, false);
@ -162,16 +162,16 @@ public class ImageUploadSection extends FormSection
* Process the image upload. Should be called form the form * Process the image upload. Should be called form the form
* process listener. * process listener.
*/ */
public ImageAsset processImageUpload(FormSectionEvent event) { public ReusableImageAsset processImageUpload(FormSectionEvent event) {
ImageAsset a = null; ReusableImageAsset a = null;
FormData data = event.getFormData(); FormData data = event.getFormData();
File image = getImage(event); File image = getImage(event);
if ( image != null ) { if ( image != null ) {
try { try {
a = new ImageAsset(); a = new ReusableImageAsset();
a.loadFromFile(getImageFilename(event), image, ImageAsset.MIME_JPEG); a.loadFromFile(getImageFilename(event), image, ReusableImageAsset.MIME_JPEG);
a.setDescription((String)data.get(m_name + CAPTION)); a.setDescription((String)data.get(m_name + CAPTION));
} catch ( Exception ex ) { } catch ( Exception ex ) {
log.error("Could not load " + getImageFilename(event)); log.error("Could not load " + getImageFilename(event));

View File

@ -37,7 +37,7 @@ import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.TrimmedStringParameter; import com.arsdigita.bebop.parameters.TrimmedStringParameter;
import com.arsdigita.cms.ImageAsset; import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.TextAsset; import com.arsdigita.cms.TextAsset;
import com.arsdigita.cms.contenttypes.ArticleSection; import com.arsdigita.cms.contenttypes.ArticleSection;
@ -109,8 +109,8 @@ public class SectionEditForm extends Form {
m_container = container; m_container = container;
m_imageParam = new BigDecimalParameter(IMAGE_PARAM); m_imageParam = new BigDecimalParameter(IMAGE_PARAM);
m_selImage = new ItemSelectionModel(ImageAsset.class.getName(), m_selImage = new ItemSelectionModel(ReusableImageAsset.class.getName(),
ImageAsset.BASE_DATA_OBJECT_TYPE, ReusableImageAsset.BASE_DATA_OBJECT_TYPE,
m_imageParam); m_imageParam);
m_textParam = new BigDecimalParameter(TEXT_PARAM); m_textParam = new BigDecimalParameter(TEXT_PARAM);
@ -218,7 +218,7 @@ public class SectionEditForm extends Form {
data.put(TEXT, t.getText()); data.put(TEXT, t.getText());
} }
ImageAsset img = section.getImage(); ReusableImageAsset img = section.getImage();
if (img != null) { if (img != null) {
m_selImage.setSelectedObject(state, img); m_selImage.setSelectedObject(state, img);
} }
@ -316,10 +316,10 @@ public class SectionEditForm extends Form {
section.setPageBreak(pageBreak); section.setPageBreak(pageBreak);
// get the image asset // get the image asset
ImageAsset imageAsset = m_imageUpload.processImageUpload(event); ReusableImageAsset reusableImageAsset = m_imageUpload.processImageUpload(event);
if ( imageAsset != null ) { if ( reusableImageAsset != null ) {
section.setImage(imageAsset); section.setImage(reusableImageAsset);
m_selImage.setSelectedObject(state, imageAsset); m_selImage.setSelectedObject(state, reusableImageAsset);
} }