diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticle.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticle.java
index 78ec304a8..238dc5b9c 100644
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticle.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticle.java
@@ -18,16 +18,10 @@
*/
package com.arsdigita.cms.contenttypes;
-import com.arsdigita.cms.ImageAsset;
-import com.arsdigita.cms.ImageAssetCollection;
import com.arsdigita.cms.TextPage;
import com.arsdigita.domain.DataObjectNotFoundException;
-import com.arsdigita.persistence.DataAssociation;
-import com.arsdigita.persistence.DataAssociationCursor;
-import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
-import com.arsdigita.util.Assert;
import java.math.BigDecimal;
@@ -43,10 +37,6 @@ public class GenericArticle extends TextPage {
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.GenericArticle";
- protected static final String IMAGES = "imageAssets";
-
- private static final String IMAGE_CAPTIONS = "imageCaptions";
-
private static org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(GenericArticle.class);
@@ -98,101 +88,4 @@ public class GenericArticle extends TextPage {
public String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
-
- /**
- * Add an image to this article. If the image is already added
- * to the article, the caption will be updated.
- *
- * @param image the image to add
- * @param caption the caption for the image
- * @return true if image is added and false if caption is updated
- */
- public boolean addImage(ImageAsset image, String caption) {
- ImageAssetCollection col = getImages();
- col.addEqualsFilter(GenericArticleImageAssociation.IMAGE_ID,image.getID());
- boolean toReturn = false;
- GenericArticleImageAssociation assn = null;
- if (col.next()) {
- assn = (GenericArticleImageAssociation)(col.getDomainObject());
- col.close();
- } else {
- assn = new GenericArticleImageAssociation();
- String name = this.getName();
- Assert.exists(name, String.class);
- String imgName = image.getName();
- Assert.exists(imgName, String.class);
- assn.setName(name + "/" + imgName);
- assn.setArticle(this);
- assn.setImage(image);
- toReturn = true;
- assn.setMaster(this);
- }
- assn.setCaption(caption);
- assn.save();
- return toReturn;
- }
-
- /**
- * Get the caption of the image
- * @deprecated Do not use this method, it will always return the
- * first available caption regardless of what image is in use. Use
- * GenericArticleImageAssnCollection.getCaption() or
- * GenericArticleImageAssociation.getCaption().
- * @return the caption, or null if the image is not associated to this
- * article
- */
- public String getCaption(ImageAsset image) {
- DataCollection col = (DataCollection)get(IMAGE_CAPTIONS);
- String caption = null;
- if (col.next()) {
- caption = (String)col.getDataObject().get("caption");
- }
- col.close();
- return caption;
- }
-
- /**
- * Remove a image from this article.
- * @return true is the image is removed, false otherwise.
- */
- public boolean removeImage(ImageAsset image) {
- GenericArticleImageAssociation assn = GenericArticleImageAssociation
- .retrieveAssociation(getID(), image.getID());
- if (assn != null) {
- assn.delete();
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the images for this article
- */
- public ImageAssetCollection getImages() {
- DataAssociationCursor dac = ((DataAssociation) get(IMAGE_CAPTIONS)).cursor();
- ImageAssetCollection images = new GenericArticleImageAssnCollection(dac);
- return images;
- }
-
- /**
- * Unassociate all images from this article
- */
- public void clearImages() {
- ImageAssetCollection images = getImages();
- while(images.next()) {
- images.getDomainObject().delete();
- }
- }
-
- @Override
- protected void propagateMaster(com.arsdigita.versioning.VersionedACSObject master) {
- super.propagateMaster(master);
- ImageAssetCollection collection = getImages();
- while (collection.next()) {
- GenericArticleImageAssociation assn = (GenericArticleImageAssociation)(collection.getDomainObject());
- assn.setMaster(master);
- assn.save();
- }
- }
}
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticleImageAssnCollection.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticleImageAssnCollection.java
deleted file mode 100644
index 31820c65d..000000000
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticleImageAssnCollection.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.contenttypes;
-
-import com.arsdigita.cms.ImageAsset;
-import com.arsdigita.cms.ImageAssetCollection;
-import com.arsdigita.domain.DomainObject;
-import com.arsdigita.persistence.DataCollection;
-import com.arsdigita.persistence.Filter;
-
-/**
- * This class contains contains a collection of ArticleImageAssociations, each
- * of which points to an image, and each of which has a caption. Ideally it
- * should be constructed with a DataCollection of ArticleImageAssociations
- * which has been filtered on isDeleted=0, or there will be deleted associations
- * in the collection. It extends ImageAssetCollection because we need to pass
- * it off as an ImageAssetCollection at various places in the UI code.
- *
- * @see com.arsdigita.domain.DomainCollection
- * @see com.arsdigita.persistence.DataCollection
- *
- *
- * @author Hugh Brock .
- * @version $Id: GenericArticleImageAssnCollection.java 287 2005-02-22 00:29:02Z sskracic $
- */
-public class GenericArticleImageAssnCollection extends ImageAssetCollection {
-
- /**
- * Constructor. Should only be called from Article.getImages()
- *
- **/
- protected GenericArticleImageAssnCollection(DataCollection dataCollection) {
- super(dataCollection);
- }
-
- /**
- * Returns a DomainObject (the
- * GenericArticleImageAssociation for the current position in the
- * collection.
- *
- **/
- public DomainObject getDomainObject() {
- return new GenericArticleImageAssociation
- (m_dataCollection.getDataObject());
- }
-
- /**
- * Returns a Image for the current position in
- * the collection.
- *
- **/
- public ImageAsset getImage() {
- return ((GenericArticleImageAssociation)getDomainObject()).getImage();
- }
-
- public String getCaption() {
- return ((GenericArticleImageAssociation)getDomainObject()).getCaption();
- }
-
- // Exposed methods
- public Filter addEqualsFilter(String attribute, Object value) {
- return m_dataCollection.addEqualsFilter(attribute, value);
- }
-
-
-}
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticleImageAssociation.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticleImageAssociation.java
deleted file mode 100644
index 2104fa5f1..000000000
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/GenericArticleImageAssociation.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.contenttypes;
-
-import com.arsdigita.cms.ContentItem;
-import com.arsdigita.cms.CustomCopy;
-import com.arsdigita.cms.ImageAsset;
-import com.arsdigita.cms.ItemCollection;
-import com.arsdigita.cms.ItemCopier;
-import com.arsdigita.domain.DataObjectNotFoundException;
-import com.arsdigita.domain.DomainObjectFactory;
-import com.arsdigita.persistence.DataCollection;
-import com.arsdigita.persistence.DataObject;
-import com.arsdigita.persistence.OID;
-import com.arsdigita.persistence.SessionManager;
-import com.arsdigita.persistence.metadata.Property;
-import com.arsdigita.util.Assert;
-import com.arsdigita.versioning.VersionedACSObject;
-
-import java.math.BigDecimal;
-
-/**
- * This class associates an GenericArticle and an Image with a particular
- * caption.
- *
- * @author Jack Chung (flattop@arsdigita.com)
- * @version $Revision: #17 $ $Date: 2004/08/17 $
- * @version $Id: GenericArticleImageAssociation.java 287 2005-02-22 00:29:02Z sskracic $
- */
-public class GenericArticleImageAssociation extends ContentItem {
-
- public static final String BASE_DATA_OBJECT_TYPE =
- "com.arsdigita.cms.GenericArticleImageAssociation";
-
- protected static final String ARTICLE = "captionArticle";
- protected static final String IMAGE = "imageAsset";
- protected static final String CAPTION = "caption";
- protected static final String ARTICLE_ID = "articleId";
- protected static final String IMAGE_ID = "imageId";
-
-
- /**
- * Default constructor.
- **/
- public GenericArticleImageAssociation() {
- super(BASE_DATA_OBJECT_TYPE);
- }
-
- /**
- * Constructor retrieves the contained DataObject from the
- * persistent storage mechanism with an OID specified by
- * oid.
- *
- * @param oid The OID for the retrieved
- * DataObject.
- **/
- public GenericArticleImageAssociation(OID oid) throws DataObjectNotFoundException {
- super(oid);
- }
- public GenericArticleImageAssociation(DataObject obj) {
- super(obj);
- }
-
-
- public GenericArticleImageAssociation(String type) {
- super(type);
- }
-
- /**
- * This returns the association object that is specified by
- * the passed in IDs or it returns null if no such association exists
- */
- public static GenericArticleImageAssociation retrieveAssociation
- (BigDecimal articleID, BigDecimal imageID) {
- DataCollection collection = SessionManager.getSession().retrieve
- (BASE_DATA_OBJECT_TYPE);
- collection.addEqualsFilter(ARTICLE_ID, articleID);
- collection.addEqualsFilter(IMAGE_ID, imageID);
- // no deleted associations, please
- collection.addEqualsFilter(VersionedACSObject.IS_DELETED, new BigDecimal(0));
- if (collection.next()) {
- GenericArticleImageAssociation association =
- new GenericArticleImageAssociation(collection.getDataObject());
- collection.close();
- return association;
- }
- return null;
- }
-
- /**
- * This returns true if the image is associated with at least one article.
- */
- public static boolean imageHasDirectAssociation
- (BigDecimal imageID) {
- DataCollection collection = SessionManager.getSession().retrieve
- (BASE_DATA_OBJECT_TYPE);
- collection.addEqualsFilter(IMAGE_ID, imageID);
- // no deleted associations, please
- collection.addEqualsFilter(VersionedACSObject.IS_DELETED, new BigDecimal(0));
- if (collection.next()) {
- collection.close();
- return true;
- }
- return false;
- }
-
- /**
- * This returns true if the image is associated with at least one article.
- */
-
- public static boolean imageHasAssociation
- (BigDecimal imageID) {
- try {
- ImageAsset asset = (ImageAsset) DomainObjectFactory.newInstance
- (new OID(ImageAsset.BASE_DATA_OBJECT_TYPE, imageID));
- return asset == null ? false : imageHasAssociation(asset);
- } catch (DataObjectNotFoundException e) {
- // can't find asset, return false
- return false;
- }
- }
- /**
- * This returns true if the image is associated with at least one article, checking both liveand draft versions
- */
- public static boolean imageHasAssociation
- (ImageAsset image) {
- Assert.exists(image);
- boolean returnValue = imageHasDirectAssociation(image.getID());
- if (!returnValue) {
- if (!image.getVersion().equals(ContentItem.DRAFT)) {
- ContentItem item = image.getWorkingVersion();
- if (item != null) {
- returnValue = imageHasDirectAssociation(item.getID());
- }
- }
- }
- if (!returnValue) {
- if (!image.getVersion().equals(ContentItem.PENDING)) {
- ItemCollection pendingVersions = image.getPendingVersions();
- while(pendingVersions.next()) {
- ContentItem item = pendingVersions.getContentItem();
- returnValue = returnValue || imageHasDirectAssociation(item.getID());
- }
- }
- }
- if (!returnValue) {
- if (!image.getVersion().equals(ContentItem.LIVE)) {
- ContentItem item = image.getLiveVersion();
- if (item != null) {
- returnValue = imageHasDirectAssociation(item.getID());
- }
- }
- }
-
- DataCollection collection = SessionManager.getSession().retrieve
- (BASE_DATA_OBJECT_TYPE);
- collection.addEqualsFilter(IMAGE_ID, image.getID());
- // no deleted associations, please
- collection.addEqualsFilter(VersionedACSObject.IS_DELETED, new BigDecimal(0));
- if (collection.next()) {
- collection.close();
- return true;
- }
- return false;
- }
-
- public BigDecimal getArticleID() {
- return (BigDecimal) get(ARTICLE_ID);
- }
-
- public GenericArticle getArticle() {
- DataCollection col = SessionManager.getSession().retrieve(ARTICLE);
- if (col.next()) {
- GenericArticle art = new GenericArticle(col.getDataObject());
- col.close();
- return art;
- }
- return null;
- }
-
- public void setArticle(GenericArticle article) {
- setAssociation(ARTICLE, article);
- }
-
- public BigDecimal getImageID() {
- return (BigDecimal) get(IMAGE_ID);
- }
-
- public ImageAsset getImage() {
- return (ImageAsset) DomainObjectFactory.
- newInstance((DataObject) get(IMAGE));
- }
-
- public void setImage(ImageAsset image) {
- setAssociation(IMAGE, image);
- }
-
- public String getCaption() {
- return (String) get(CAPTION);
- }
-
- public void setCaption(String caption) {
- set(CAPTION, caption);
- }
-
- /**
- * Auto-publish the associated ReusableImageAssociation if it is not yet live
- *
- * @param source the source CustomCopy item
- * @param property the property to copy
- * @param copier a temporary class that is able to copy a child item
- * correctly.
- * @return true if the property was copied; false to indicate
- * that regular metadata-driven methods should be used
- * to copy the property.
- */
- @Override
- public boolean copyProperty(final CustomCopy source,
- final Property property,
- final ItemCopier copier) {
- String attribute = property.getName();
- // don't copy these attributes. they're controlled by explicit associations
- if (IMAGE_ID.equals(attribute) || ARTICLE_ID.equals(attribute)) {
- return true;
- }
-
- if (copier.getCopyType() == ItemCopier.VERSION_COPY
- && IMAGE.equals(attribute)) {
- ImageAsset image = ((GenericArticleImageAssociation)source).getImage();
- if (image != null) {
- ImageAsset liveImage = (ImageAsset) image.getLiveVersion();
- if (liveImage == null) {
- liveImage = (ImageAsset) image.createLiveVersion();
- }
- }
- // This method only makes sure that the ReusableImageAsset
- // is auto-published. It still returns false so that the
- // copier can generate PublishedLink objects appropriately.
- return false;
- }
- return super.copyProperty(source, property, copier);
- }
-
-}
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/ImageDisplay.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/ImageDisplay.java
deleted file mode 100755
index ebca00eac..000000000
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/ImageDisplay.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.contenttypes.ui;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SimpleComponent;
-import com.arsdigita.cms.CMS;
-import com.arsdigita.cms.ImageAsset;
-import com.arsdigita.cms.ItemSelectionModel;
-import com.arsdigita.cms.dispatcher.Utilities;
-import com.arsdigita.mimetypes.MimeType;
-import com.arsdigita.xml.Element;
-
-import java.math.BigDecimal;
-
-
-/**
- * Displays a single ImageAsset, showing its image, width, height,
- * name and mime-type. If the ImageAsset in the selection model is null,
- * be nice about it.
- *
- * @author Hugh Brock (hbrock@redhat.com)
- * @version $Id: ImageDisplay.java 1967 2009-08-29 21:05:51Z pboy $
- */
-public class ImageDisplay extends SimpleComponent {
-
- private final ItemSelectionModel m_item;
-
- /**
- * Construct a new ImageDisplay
- *
- * @param m The {@link ItemSelectionModel} which will supply
- * this component with the {@link ImageAsset}
- */
- public ImageDisplay(ItemSelectionModel m) {
- super();
-
- m_item = m;
- }
-
- /**
- * @return the {@link ItemSelectionModel} which supplies this
- * component with the {@link ImageAsset}
- */
- public final ItemSelectionModel getImageSelectionModel() {
- return m_item;
- }
-
- public void generateXML(PageState state, Element parent) {
- if ( isVisible(state) ) {
-
- ImageAsset image = getImageAsset(state);
-
- if (image != null) {
- Element element = new Element("cms:imageDisplay", CMS.CMS_XML_NS);
-
- generateImagePropertiesXML(image, state, element);
-
- exportAttributes(element);
- parent.addContent(element);
- }
- }
- }
-
- protected void generateImagePropertiesXML(ImageAsset image,
- PageState state,
- Element element) {
- element.addAttribute("name", image.getName());
- element.addAttribute("src", Utilities.getImageURL(image));
-
- BigDecimal width = image.getWidth();
- if ( width != null ) {
- element.addAttribute("width", width.toString());
- }
-
- BigDecimal height = image.getHeight();
- if ( height != null ) {
- element.addAttribute("height", height.toString());
- }
-
- MimeType mimeType = image.getMimeType();
- if ( mimeType != null ) {
- element.addAttribute("mime_type", mimeType.getLabel());
- }
- }
-
- protected ImageAsset getImageAsset(PageState state) {
- ImageAsset image = (ImageAsset) m_item.getSelectedObject(state);
- return image;
- }
-
-}
diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/StreamImage.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/StreamImage.java
index e98911b3f..9c94f0a83 100755
--- a/ccm-cms/src/com/arsdigita/cms/dispatcher/StreamImage.java
+++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/StreamImage.java
@@ -21,13 +21,10 @@ package com.arsdigita.cms.dispatcher;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.cms.contenttypes.GenericArticle;
import com.arsdigita.cms.ImageAsset;
-import com.arsdigita.cms.ImageAssetCollection;
-import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.dispatcher.RequestContext;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainObjectFactory;
-import com.arsdigita.kernel.ACSObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.toolbox.ui.OIDParameter;
import com.arsdigita.versioning.Transaction;
@@ -150,19 +147,6 @@ public class StreamImage extends ResourceHandlerImpl {
"no ImageAsset with oid " + oid);
return;
}
-
- } else {
- ImageAssetCollection col = article.getImages();
- col.addEqualsFilter(ACSObject.ID, imageId);
- if (col.next()) {
- image = col.getImage();
- col.close();
- } else {
- response.sendError(HttpServletResponse.SC_NOT_FOUND,
- "failed to retrieve ImageAsset " + imageId);
- return;
- }
-
}
diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ArticleImageDisplay.java b/ccm-cms/src/com/arsdigita/cms/ui/ArticleImageDisplay.java
deleted file mode 100755
index dddbbe383..000000000
--- a/ccm-cms/src/com/arsdigita/cms/ui/ArticleImageDisplay.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.cms.contenttypes.GenericArticle;
-import com.arsdigita.cms.ImageAsset;
-import com.arsdigita.cms.ItemSelectionModel;
-import com.arsdigita.util.Assert;
-import com.arsdigita.xml.Element;
-
-
-/**
- * Extends {@link ImageDisplay} to display the first
- * (according to the order attribute) image associated with an {@link GenericArticle}
- * The typical usage for this component is
- *
- *ArticleImageDisplay d = new ArticleImageDisplay(myItemSelectionModel, false);
- *
- * @version $Revision: #8 $ $DateTime: 2004/08/17 23:15:09 $
- * @author Michael Pih (pihman@arsdigita.com)
- * @author Stanislav Freidin (stas@arsdigita.com)
- * @version $Id: ArticleImageDisplay.java 287 2005-02-22 00:29:02Z sskracic $
- */
-public class ArticleImageDisplay extends ImageDisplay {
-
- private final ItemSelectionModel m_article;
-
-
- /**
- * Construct a new ArticleImageDisplay
- *
- * @param article the {@link ItemSelectionModel} which
- * supplies the {@link GenericArticle}
- *
- * @param assets the {@link ItemSelectionModel} which
- * supplies the {@link ImageAsset} for the article; it is
- * the parent's responsibility to register any state parameters
- * for this model
- */
- public ArticleImageDisplay(ItemSelectionModel article,
- ItemSelectionModel assets) {
- super(assets);
-
- m_article = article;
- }
-
- /**
- * @return The item selection model which supplies the
- * current article
- */
- public final ItemSelectionModel getArticleSelectionModel() {
- return m_article;
- }
-
- /**
- * @param state The page state
- * @return the currently selected article
- * @post ( return != null )
- */
- protected GenericArticle getArticle(PageState state) {
- GenericArticle article = (GenericArticle) m_article.getSelectedObject(state);
- Assert.exists(article, "GenericArticle");
- return article;
- }
-
- /**
- * Adds the image caption as an attribute of the DOM element.
- */
- protected void generateImagePropertiesXML(ImageAsset image,
- PageState state,
- Element element) {
-
- super.generateImagePropertiesXML(image, state, element);
-
- GenericArticle article = getArticle(state);
- String caption = article.getCaption(image);
- if ( caption != null ) {
- element.addAttribute("caption", caption);
- }
- }
-
-}
diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java
index d84cc3af7..fa4d5621e 100755
--- a/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java
+++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java
@@ -30,7 +30,6 @@ import com.arsdigita.bebop.table.DefaultTableCellRenderer;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
-import com.arsdigita.cms.contenttypes.GenericArticleImageAssociation;
import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.dispatcher.Utilities;
@@ -66,9 +65,7 @@ import org.apache.log4j.Logger;
public class ImageBrowser extends Table {
private ImageBrowserModelBuilder m_builder;
-
- private static final String[] HEADERS =
- {"Thumbnail", "Name", "Size", "Type", "Action", ""};
+ private static final String[] HEADERS = {"Thumbnail", "Name", "Size", "Type", "Action", ""};
private static final int THUMB = 0;
private static final int NAME = 1;
private static final int SIZE = 2;
@@ -76,9 +73,7 @@ public class ImageBrowser extends Table {
private static final int LINK = 4;
private static final int DELETE = 5;
private static final int NUM_COLUMNS = 6;
-
private int m_thumbSize;
-
private static final Logger s_log = Logger.getLogger(ImageBrowser.class);
/**
@@ -134,7 +129,7 @@ public class ImageBrowser extends Table {
* request
*/
public ImageBrowserModel getImageBrowserModel(PageState state) {
- return ((ImageModelAdapter)getTableModel(state)).getModel();
+ return ((ImageModelAdapter) getTableModel(state)).getModel();
}
/**
@@ -143,18 +138,19 @@ public class ImageBrowser extends Table {
* linkClicked method.
*/
public static abstract class LinkActionListener
- extends TableActionAdapter {
+ extends TableActionAdapter {
public void cellSelected(TableActionEvent e) {
int c = e.getColumn().intValue();
- if(c == LINK) {
- linkClicked(e.getPageState(), new BigDecimal((String)e.getRowKey()));
- } else if (c==DELETE) {
- deleteClicked(e.getPageState(), new BigDecimal((String)e.getRowKey()));
+ if (c == LINK) {
+ linkClicked(e.getPageState(), new BigDecimal((String) e.getRowKey()));
+ } else if (c == DELETE) {
+ deleteClicked(e.getPageState(), new BigDecimal((String) e.getRowKey()));
}
}
public abstract void linkClicked(PageState state, BigDecimal imageId);
+
public abstract void deleteClicked(PageState state, BigDecimal imageId);
}
@@ -162,9 +158,9 @@ public class ImageBrowser extends Table {
private class ThumbnailCellRenderer implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value,
- boolean isSelected, Object key,
- int row, int column) {
- ImageAsset a = (ImageAsset)value;
+ boolean isSelected, Object key,
+ int row, int column) {
+ ImageAsset a = (ImageAsset) value;
String url = Utilities.getImageURL(a);
Image img = new Image(URL.getDispatcherPath() + url);
@@ -178,11 +174,10 @@ public class ImageBrowser extends Table {
w = m_thumbSize;
h = m_thumbSize;
} else {
- Dimension d = ImageSizer.getScaledSize (
- width.intValue(), height.intValue(), m_thumbSize, m_thumbSize
- );
- w = (int)d.getWidth();
- h = (int)d.getHeight();
+ Dimension d = ImageSizer.getScaledSize(
+ width.intValue(), height.intValue(), m_thumbSize, m_thumbSize);
+ w = (int) d.getWidth();
+ h = (int) d.getHeight();
}
img.setWidth(Integer.toString(w));
@@ -195,22 +190,24 @@ public class ImageBrowser extends Table {
// Renders the delete link if the user has permission to delete
// the asset and it's not used in an article.
private class DeleteCellRenderer extends DefaultTableCellRenderer {
+
public DeleteCellRenderer() {
super(true);
}
+
+ @Override
public Component getComponent(Table table, PageState state, Object value,
- boolean isSelected, Object key,
- int row, int column)
- {
+ boolean isSelected, Object key,
+ int row, int column) {
boolean canDelete = false;
SecurityManager sm = Utilities.getSecurityManager(state);
- if (sm.canAccess(state.getRequest(),SecurityManager.DELETE_IMAGES) ) {
+ if (sm.canAccess(state.getRequest(), SecurityManager.DELETE_IMAGES)) {
try {
- ImageAsset asset = (ImageAsset) DomainObjectFactory.newInstance
- (new OID(ImageAsset.BASE_DATA_OBJECT_TYPE,(BigDecimal) key));
- if (!GenericArticleImageAssociation.imageHasAssociation(asset)) {
- canDelete = true;
- }
+ ImageAsset asset = (ImageAsset) DomainObjectFactory.newInstance(new OID(ImageAsset.BASE_DATA_OBJECT_TYPE, (BigDecimal) key));
+//XXX Find a new way to figure out, if this image is used by any CI so we can decide if it can be deleted
+// if (!GenericArticleImageAssociation.imageHasAssociation(asset)) {
+// canDelete = true;
+// }
} catch (DataObjectNotFoundException e) {
// can't find asset, can't delete it
}
@@ -223,13 +220,11 @@ public class ImageBrowser extends Table {
return new Label("");
}
}
-
-
}
// Converts an ImageBrowserModelBuilder to a TableModelBuilder
private static class BuilderAdapter extends LockableImpl
- implements TableModelBuilder {
+ implements TableModelBuilder {
private ImageBrowserModelBuilder m_builder;
@@ -239,10 +234,10 @@ public class ImageBrowser extends Table {
public TableModel makeModel(Table t, PageState s) {
return new ImageModelAdapter(
- m_builder.makeModel((ImageBrowser)t, s)
- );
+ m_builder.makeModel((ImageBrowser) t, s));
}
+ @Override
public void lock() {
m_builder.lock();
super.lock();
@@ -269,40 +264,50 @@ public class ImageBrowser extends Table {
public Object getElementAt(int columnIndex) {
ImageAsset a = m_model.getImageAsset();
- switch(columnIndex) {
- case ImageBrowser.THUMB:
- return a;
+ switch (columnIndex) {
+ case ImageBrowser.THUMB:
+ return a;
- case ImageBrowser.NAME:
- return a.getName();
+ case ImageBrowser.NAME:
+ return a.getName();
- case ImageBrowser.SIZE:
- StringBuffer buf = new StringBuffer();
- BigDecimal v;
+ case ImageBrowser.SIZE:
+ StringBuilder buf = new StringBuilder();
+ BigDecimal v;
- v = a.getWidth();
- if(v == null) buf.append("???"); else buf.append(v.toString());
- buf.append(" x ");
+ v = a.getWidth();
+ if (v == null) {
+ buf.append("???");
+ } else {
+ buf.append(v.toString());
+ }
+ buf.append(" x ");
- v = a.getHeight();
- if(v == null) buf.append("???"); else buf.append(v.toString());
+ v = a.getHeight();
+ if (v == null) {
+ buf.append("???");
+ } else {
+ buf.append(v.toString());
+ }
- return buf.toString();
+ return buf.toString();
- case ImageBrowser.TYPE:
- MimeType m = a.getMimeType();
- if(m == null) return "???";
+ case ImageBrowser.TYPE:
+ MimeType m = a.getMimeType();
+ if (m == null) {
+ return "???";
+ }
- return m.getMimeType();
+ return m.getMimeType();
- case ImageBrowser.LINK:
- return "select";
+ case ImageBrowser.LINK:
+ return "select";
- case ImageBrowser.DELETE:
- return "delete";
+ case ImageBrowser.DELETE:
+ return "delete";
- default:
- return null;
+ default:
+ return null;
}
}
@@ -314,5 +319,4 @@ public class ImageBrowser extends Table {
return m_model;
}
}
-
}
diff --git a/ccm-cms/src/com/arsdigita/cms/ui/SingleImageSelectionModel.java b/ccm-cms/src/com/arsdigita/cms/ui/SingleImageSelectionModel.java
deleted file mode 100755
index a1218a34d..000000000
--- a/ccm-cms/src/com/arsdigita/cms/ui/SingleImageSelectionModel.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui;
-
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.ParameterSingleSelectionModel;
-import com.arsdigita.bebop.SingleSelectionModel;
-import com.arsdigita.bebop.parameters.BigDecimalParameter;
-import com.arsdigita.cms.contenttypes.GenericArticle;
-import com.arsdigita.cms.ImageAsset;
-import com.arsdigita.cms.ImageAssetCollection;
-import com.arsdigita.cms.ItemSelectionModel;
-import com.arsdigita.domain.DomainObject;
-
-
-/**
- * Selects a single image for an article.
- *
- * @see com.arsdigita.cms.ui.authoring.ArticleImage
- * @see com.arsdigita.cms.ui.ArticleImageDisplay
- *
- * @version $Id: SingleImageSelectionModel.java 287 2005-02-22 00:29:02Z sskracic $
- * @author Stanislav Freidin
- */
-
-public class SingleImageSelectionModel extends ItemSelectionModel {
-
- private ItemSelectionModel m_articleModel;
-
- /**
- * Construct a new SingleImageSelectionModel
- *
- * @param javaClass the Java class name of the {@link ImageAsset} subclass
- * that this model deals with
- * @param objetcType the PDL object type of the {@link ImageAsset} subclass
- * that this model deals with
- * @param param the {@link BigDecimalParameter} where the image ID will
- * be stored
- * @param articleModel the {@link ItemSelectionModel} which will supply
- * the current article
- */
- public SingleImageSelectionModel(
- String javaClass, String objectType, BigDecimalParameter param,
- ItemSelectionModel articleModel
- ) {
- this(javaClass, objectType, new ParameterSingleSelectionModel(param),
- articleModel);
- }
-
- /**
- * Construct a new SingleImageSelectionModel
- *
- * @param javaClass the Java class name of the {@link ImageAsset} subclass
- * that this model deals with
- * @param objetcType the PDL object type of the {@link ImageAsset} subclass
- * that this model deals with
- * @param imageModel the {@link SingleSelectionModel} which will store the
- * image ID
- * @param articleModel the {@link ItemSelectionModel} which will supply
- * the current article
- */
- public SingleImageSelectionModel(
- String javaClass, String objectType, SingleSelectionModel imageModel,
- ItemSelectionModel articleModel
- ) {
- super(javaClass, objectType, imageModel);
- m_articleModel = articleModel;
- }
-
- /**
- * Construct a new SingleImageSelectionModel
- *
- * @param imageModel the {@link SingleSelectionModel} which will store the
- * image ID
- * @param articleModel the {@link ItemSelectionModel} which will supply
- * the current article
- */
- public SingleImageSelectionModel(
- SingleSelectionModel imageModel, ItemSelectionModel articleModel
- ) {
- this(ImageAsset.class.getName(), ImageAsset.BASE_DATA_OBJECT_TYPE,
- imageModel, articleModel);
- }
-
- /**
- * Construct a new SingleImageSelectionModel
- *
- * @param param the {@link BigDecimalParameter} where the image ID will
- * be stored
- *
- * @param articleModel the {@link ItemSelectionModel} which will supply
- * the current article
- */
- public SingleImageSelectionModel(
- BigDecimalParameter param, ItemSelectionModel articleModel
- ) {
- this(ImageAsset.class.getName(), ImageAsset.BASE_DATA_OBJECT_TYPE,
- param, articleModel);
- }
-
- // Load the first asset for the article, if neccessary.
- private void checkAsset(PageState state) {
- if ( !isInitialized(state) ) {
- // Load the object from the item.
- com.arsdigita.cms.ContentItem temp =
- (com.arsdigita.cms.ContentItem)m_articleModel.getSelectedObject(state);
- GenericArticle item = null;
- if ( temp != null ) {
- item =
- (GenericArticle) com.arsdigita.cms.ACSObjectFactory.castContentItem(temp);
- }
- if ( item != null ) {
- ImageAssetCollection images = item.getImages();
- if ( images.next() ) {
- setSelectedObject(state, images.getImage());
- images.close();
- }
- }
- }
- }
-
- /**
- * Get the currently selected image. If no image is selected,
- * select the first image for the article.
- */
- public DomainObject getSelectedObject(PageState state) {
- checkAsset(state);
- return super.getSelectedObject(state);
- }
-
- /**
- * Get the id of the currently selected image
- */
- public Object getSelectedKey(PageState state) {
- checkAsset(state);
- return super.getSelectedKey(state);
- }
-
- /**
- * @return the {@link ItemSelectionModel} which supplies the article
- */
- public ItemSelectionModel getArticleSelectionModel() {
- return m_articleModel;
- }
-}
diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/ArticleImage.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/ArticleImage.java
deleted file mode 100755
index 8768bbe1a..000000000
--- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/ArticleImage.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.ui.authoring;
-
-
-import com.arsdigita.bebop.ActionLink;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Label;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.bebop.event.ActionEvent;
-import com.arsdigita.bebop.event.ActionListener;
-import com.arsdigita.bebop.event.FormProcessListener;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.bebop.event.FormSubmissionListener;
-import com.arsdigita.bebop.parameters.BigDecimalParameter;
-import com.arsdigita.bebop.parameters.StringParameter;
-import com.arsdigita.cms.contenttypes.GenericArticle;
-import com.arsdigita.cms.ImageAsset;
-import com.arsdigita.cms.ImageAssetCollection;
-import com.arsdigita.cms.ItemSelectionModel;
-import com.arsdigita.cms.dispatcher.Utilities;
-import com.arsdigita.cms.ui.ArticleImageDisplay;
-import com.arsdigita.cms.ui.CMSContainer;
-import com.arsdigita.cms.ui.ContentItemPage;
-import com.arsdigita.cms.ui.ImageChooser;
-import com.arsdigita.cms.ui.SecurityPropertyEditor;
-import com.arsdigita.cms.ui.SingleImageSelectionModel;
-import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
-import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer;
-import com.arsdigita.cms.util.GlobalizationUtil;
-import com.arsdigita.util.Assert;
-import com.arsdigita.xml.Element;
-import org.apache.log4j.Logger;
-
-
-/**
- * Display the image associated with the article (if any),
- * and present UI controls for associating a new image.
- * This component contains two {@link PropertyEditor}
- * instances: one instance that shows up when the article has
- * no associated image, and another instance that shows up when
- * the article has at least one image.
- *
- * This class actually contains four inner classes: - *
ImageSelectionForm (which
- * is another inner class). The ArticleImageChooser
- * uses the {@link ImageChooser} to select an image, then shows the
- * form in order to assign a caption to the image and complete the
- * image selection process.
- *