Last update: 2011-06-23

org.proteios.core
Class News

java.lang.Object
  extended by org.proteios.core.BasicItem<NewsData>
      extended by org.proteios.core.News
All Implemented Interfaces:
AccessControlled, Controlled, Identifiable, Nameable, Removable, Validatable

public class News
extends BasicItem<NewsData>
implements Nameable, Removable, Validatable

This class represents news items.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Field Summary
static Item TYPE
          The type of item represented by this class.
 
Fields inherited from interface org.proteios.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
 
Method Summary
static News getById(DbControl dc, int id)
          Get a News item when you know the ID.
 String getDescription()
          Get the description for the item.
 Date getEndDate()
          Get the end date and time for this news item to be published.
 String getName()
          Get the name of the item.
 Date getNewsDate()
          Get the date that is shown in listings.
static ItemQuery<News> getQuery()
          Get a query configured to retrieve news.
 Date getStartDate()
          Get the start date and time for this news item to be published.
 Item getType()
          Get the type of item represented by the object.
 boolean isRemoved()
          Check if the removed flag is set for this item.
 boolean isUsed()
          Always return FALSE.
 void setDescription(String description)
          Set the description for the item.
 void setEndDate(Date endDate)
          Set the end date and time for this item to be published.
 void setName(String name)
          Set the name of the item.
 void setNewsDate(Date newsDate)
          Set the date that is shown in listings.
 void setRemoved(boolean removed)
          Set the removed flag for this item.
 void setStartDate(Date startDate)
          Set the start date and time for this item to be published.
 
Methods inherited from class org.proteios.core.BasicItem
checkPermission, equals, getDbControl, getId, getPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.proteios.core.Identifiable
getId, getVersion
 
Methods inherited from interface org.proteios.core.AccessControlled
checkPermission, hasPermission
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.NEWS, getType()
Method Detail

getById

public static News getById(DbControl dc,
                           int id)
                    throws ItemNotFoundException,
                           PermissionDeniedException,
                           BaseException
Get a News item when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The ID of the item to load
Returns:
The News item
Throws:
ItemNotFoundException - If an item with the specified ID is not found
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the item
BaseException - If there is another error

getQuery

public static ItemQuery<News> getQuery()
Get a query configured to retrieve news. If the logged in user doesn't have generic permission to all news, or if no user is logged in, only news which have a start date before today and an end date after today are returned.

Returns:
An ItemQuery object

getType

public Item getType()
Description copied from interface: Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.

Specified by:
getType in interface Identifiable
Returns:
A value indicating the type of item

getName

public String getName()
Description copied from interface: Nameable
Get the name of the item.

Specified by:
getName in interface Nameable
Returns:
A String with the name of the item

setName

public void setName(String name)
             throws PermissionDeniedException,
                    InvalidDataException
Description copied from interface: Nameable
Set the name of the item. The name cannot be null and mustn't be longer than the value specified by the Nameable.MAX_NAME_LENGTH constant.

Specified by:
setName in interface Nameable
Parameters:
name - The new name for the item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the name is null or longer than specified by the Nameable.MAX_NAME_LENGTH constant

getDescription

public String getDescription()
Description copied from interface: Nameable
Get the description for the item.

Specified by:
getDescription in interface Nameable
Returns:
A String with a description of the item

setDescription

public void setDescription(String description)
                    throws PermissionDeniedException,
                           InvalidDataException
Description copied from interface: Nameable
Set the description for the item. The description can be null but mustn't be longer than the value specified by the Nameable.MAX_DESCRIPTION_LENGTH constant.

Specified by:
setDescription in interface Nameable
Parameters:
description - The new description for the item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the description longer than specified by the Nameable.MAX_DESCRIPTION_LENGTH constant

isRemoved

public boolean isRemoved()
Description copied from interface: Removable
Check if the removed flag is set for this item.

Specified by:
isRemoved in interface Removable
Returns:
TRUE if the item is flagged as removed, FALSE otherwise

setRemoved

public void setRemoved(boolean removed)
                throws PermissionDeniedException
Description copied from interface: Removable
Set the removed flag for this item.

Specified by:
setRemoved in interface Removable
Parameters:
removed - TRUE if the item should be flagged as removed, FALSE otherwise
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.DELETE permission for setting the flag to TRUE or Permission.WRITE permission for setting the flag to FALSE

isUsed

public boolean isUsed()
               throws BaseException
Always return FALSE. A News item is not used by other items.

Specified by:
isUsed in class BasicItem<NewsData>
Returns:
TRUE if this item is used, FALSE otherwise
Throws:
BaseException

getStartDate

public Date getStartDate()
Get the start date and time for this news item to be published.

Returns:
The date and time

setStartDate

public void setStartDate(Date startDate)
                  throws PermissionDeniedException,
                         InvalidDataException
Set the start date and time for this item to be published.

Parameters:
startDate - The new date and time
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission
InvalidDataException - If the date is null

getNewsDate

public Date getNewsDate()
Get the date that is shown in listings.

Returns:
The date and time

setNewsDate

public void setNewsDate(Date newsDate)
                 throws PermissionDeniedException,
                        InvalidDataException
Set the date that is shown in listings.

Parameters:
newsDate - The new date and time
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission
InvalidDataException - If the date is null

getEndDate

public Date getEndDate()
Get the end date and time for this news item to be published. If this value is null, the new item is published forever.

Returns:
The date and time

setEndDate

public void setEndDate(Date endDate)
                throws PermissionDeniedException
Set the end date and time for this item to be published.

Parameters:
endDate - The new date and time, or null to publish this new item forever
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission

Last update: 2011-06-23