com.arsdigita.cms
Class ImageAsset

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.domain.ObservableDomainObject
          extended bycom.arsdigita.kernel.ACSObject
              extended bycom.arsdigita.versioning.VersionedACSObject
                  extended bycom.arsdigita.cms.ContentItem
                      extended bycom.arsdigita.cms.Asset
                          extended bycom.arsdigita.cms.BinaryAsset
                              extended bycom.arsdigita.cms.ImageAsset
All Implemented Interfaces:
com.arsdigita.auditing.Audited, CustomCopy
Direct Known Subclasses:
ReusableImageAsset

public class ImageAsset
extends BinaryAsset

An asset representing an image. An ImageAsset is deleted when its parent content item is deleted and is not intended to be reused between content items..

Version:
$Revision: #19 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Jack Chung, Stanislav Freidin
See Also:
ReusableImageAsset, BinaryAsset

Field Summary
static String BASE_DATA_OBJECT_TYPE
           
static String CONTENT
           
static String HEIGHT
           
static String MIME_GIF
           
static String MIME_JPEG
           
static String versionId
           
static String WIDTH
           
 
Fields inherited from class com.arsdigita.cms.Asset
DESCRIPTION, MIME_TYPE, NAME
 
Fields inherited from class com.arsdigita.cms.ContentItem
ANCESTORS, AUDITING, CHILDREN, CONTENT_SECTION, CONTENT_TYPE, DRAFT, DRAFT_VERSION, LANGUAGE, LIVE, PARENT, PENDING, VERSION, VERSIONS
 
Fields inherited from class com.arsdigita.versioning.VersionedACSObject
IS_DELETED, MASTER
 
Fields inherited from class com.arsdigita.kernel.ACSObject
CONTAINER, DEFAULT_DOMAIN_CLASS, DISPLAY_NAME, ID, OBJECT_TYPE
 
Constructor Summary
ImageAsset()
          Default constructor.
ImageAsset(BigDecimal id)
          Constructor.
ImageAsset(com.arsdigita.persistence.DataObject obj)
           
ImageAsset(com.arsdigita.persistence.OID oid)
          Constructor.
ImageAsset(String type)
           
 
Method Summary
static ImageAssetCollection getAllImages()
          Retrieve all images in the database.
 String getBaseDataObjectType()
           
protected  byte[] getContent()
          Retrieves the Blob content.
 BigDecimal getHeight()
           
static ImageAssetCollection getImagesByKeyword(String keyword)
          Find all images whose name matches the specified keyword
static ImageAssetCollection getImagesByKeyword(String keyword, String context)
          Find all images whose name matches the specified keyword
 BigDecimal getWidth()
           
protected  void guessSize(File file, com.arsdigita.mimetypes.ImageMimeType mime)
          Guess image size by loading it from file.
 void loadFromFile(String fileName, File file, String defaultMimeType)
          Load the image asset from the specified file.
protected  void setContent(byte[] content)
          Sets the Blob content.
 void setHeight(BigDecimal height)
           
 void setWidth(BigDecimal width)
           
 void writeToFile(File file)
          Write the image asset content to a file.
 
Methods inherited from class com.arsdigita.cms.BinaryAsset
getSize, readBytes, writeBytes
 
Methods inherited from class com.arsdigita.cms.Asset
getDescription, getMimeType, setDescription, setMimeType
 
Methods inherited from class com.arsdigita.cms.ContentItem
addCategory, addPendingVersion, afterSave, assertDraft, assertLive, assertMaster, assertPending, beforeDelete, beforeSave, canPublishToFS, copy, copy, copyProperty, copyProperty, copyServices, copyServicesFrom, createLiveVersion, createPendingVersion, get, getCategories, getCategoryCollection, getChildren, getContentSection, getContentType, getCreationDate, getCreationIP, getCreationUser, getDisplayName, getDraftVersion, getLanguage, getLastModifiedDate, getLastModifiedIP, getLastModifiedUser, getLifecycle, getLiveVersion, getLocale, getName, getParent, getPath, getPathInfo, getPathInfo, getPathNoJsp, getPendingVersions, getPublicVersion, getVersion, getWorkingVersion, initialize, isDraftVersion, isLive, isLiveVersion, isPendingVersion, isPublished, makeCopy, promotePendingVersion, publish, publishToFS, removeCategory, removeLifecycle, removePendingVersion, set, setContentSection, setContentType, setDefaultCategory, setLanguage, setLifecycle, setLive, setLiveVersion, setName, setParent, setVersion, setVersionRecursively, unpublish, unpublishFromFS
 
Methods inherited from class com.arsdigita.versioning.VersionedACSObject
applyTag, applyUniqueTag, autoPropagateMaster, getMaster, getRolledBackTo, getTransactions, getTransactions, isMaster, isRolledBack, isSubtype, permanentlyDelete, propagateMaster, recordAttributeChange, rollBackTo, rollBackTo, rollForward, save, setMaster, trackChanges
 
Methods inherited from class com.arsdigita.kernel.ACSObject
assertPrivilege, checkPrivilege, doCreateCheck, doWriteCheck, getContainer, getDefaultDomainClass, getID, getSpecificObjectType, getSpecificOID, gimmeContainer, isContainerModified, setID, setID
 
Methods inherited from class com.arsdigita.domain.ObservableDomainObject
addObserver, getObservers
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, afterDelete, clear, delete, disconnect, equals, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, setAssociation, setAssociation, specializeDataObject, specializeDataObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

BASE_DATA_OBJECT_TYPE

public static final String BASE_DATA_OBJECT_TYPE
See Also:
Constant Field Values

CONTENT

public static final String CONTENT
See Also:
Constant Field Values

HEIGHT

public static final String HEIGHT
See Also:
Constant Field Values

WIDTH

public static final String WIDTH
See Also:
Constant Field Values

MIME_JPEG

public static final String MIME_JPEG
See Also:
Constant Field Values

MIME_GIF

public static final String MIME_GIF
See Also:
Constant Field Values
Constructor Detail

ImageAsset

public ImageAsset()
Default constructor. This creates a new image asset.


ImageAsset

public ImageAsset(com.arsdigita.persistence.OID oid)
           throws com.arsdigita.domain.DataObjectNotFoundException
Constructor. The contained DataObject is retrieved from the persistent storage mechanism with an OID specified by oid.

Parameters:
oid - The OID for the retrieved DataObject.

ImageAsset

public ImageAsset(BigDecimal id)
           throws com.arsdigita.domain.DataObjectNotFoundException
Constructor. The contained DataObject is retrieved from the persistent storage mechanism with an OID specified by id and ImageAsset.BASE_DATA_OBJECT_TYPE.

Parameters:
id - The id for the retrieved DataObject.

ImageAsset

public ImageAsset(com.arsdigita.persistence.DataObject obj)

ImageAsset

public ImageAsset(String type)
Method Detail

getBaseDataObjectType

public String getBaseDataObjectType()
Specified by:
getBaseDataObjectType in class BinaryAsset
Returns:
the base PDL object type for this item. Child classes should override this method to return the correct value

getWidth

public BigDecimal getWidth()

setWidth

public void setWidth(BigDecimal width)

getHeight

public BigDecimal getHeight()

setHeight

public void setHeight(BigDecimal height)

getContent

protected byte[] getContent()
Retrieves the Blob content.

Specified by:
getContent in class BinaryAsset
Returns:
the Blob content

setContent

protected void setContent(byte[] content)
Sets the Blob content.

Specified by:
setContent in class BinaryAsset
Parameters:
content - the binary data to be put into the Blob

loadFromFile

public void loadFromFile(String fileName,
                         File file,
                         String defaultMimeType)
                  throws IOException
Load the image asset from the specified file. Automatically guesses the mime type of the file. If the file is a jpeg, tries to automatically determine width and height, as well.

Parameters:
fileName - The original name of the file
file - The actual file on the server
defaultMimeType - The default mime type for the file
Throws:
IOException

writeToFile

public void writeToFile(File file)
                 throws IOException
Write the image asset content to a file.

Specified by:
writeToFile in class Asset
Parameters:
file - The file on the server to write to.
Throws:
IOException

guessSize

protected void guessSize(File file,
                         com.arsdigita.mimetypes.ImageMimeType mime)
Guess image size by loading it from file. Set the WIDTH and HEIGHT attributes, if possible


getAllImages

public static ImageAssetCollection getAllImages()
Retrieve all images in the database. Extremely expensive !

Returns:
a collection of ImageAssets

getImagesByKeyword

public static ImageAssetCollection getImagesByKeyword(String keyword,
                                                      String context)
Find all images whose name matches the specified keyword

Parameters:
keyword - a String keyword
context - the context for the retrieved items. Should be ContentItem.DRAFT or ContentItem.LIVE
Returns:
a collection of images whose name matches the keyword

getImagesByKeyword

public static ImageAssetCollection getImagesByKeyword(String keyword)
Find all images whose name matches the specified keyword

Parameters:
keyword - a String keyword
Returns:
a collection of images whose name matches the keyword


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2352 UTC