org.drools.repository
Class AssetItem

java.lang.Object
  extended by org.drools.repository.Item
      extended by org.drools.repository.VersionableItem
          extended by org.drools.repository.CategorisableItem
              extended by org.drools.repository.AssetItem

public class AssetItem
extends CategorisableItem

The AssetItem class is used to abstract away the details of the underlying JCR repository. It is used to pass information about assets stored in the repository.


Field Summary
static String ASSET_NODE_TYPE_NAME
          The name of the asset node type
static String CONTENT_PROPERTY_ATTACHMENT_FILENAME
           
static String CONTENT_PROPERTY_BINARY_NAME
           
static String CONTENT_PROPERTY_NAME
           
static String DATE_EFFECTIVE_PROPERTY_NAME
          The name of the date effective property on the asset node type
static String DATE_EXPIRED_PROPERTY_NAME
          The name of the date expired property on the asset node type
static String DISABLED_PROPERTY_NAME
           
static String MODULE_NAME_PROPERTY
           
 
Fields inherited from class org.drools.repository.VersionableItem
CATEGORY_PROPERTY_NAME, CHECKIN_COMMENT, CONTENT_PROPERTY_ARCHIVE_FLAG, COVERAGE_PROPERTY_NAME, CREATOR_PROPERTY_NAME, DEFAULT_CONTENT_FORMAT, DESCRIPTION_PROPERTY_NAME, FORMAT_PROPERTY_NAME, LAST_CONTRIBUTOR_PROPERTY_NAME, LAST_MODIFIED_PROPERTY_NAME, PUBLISHER_PROPERTY_NAME, RELATION_PROPERTY_NAME, RIGHTS_PROPERTY_NAME, SOURCE_PROPERTY_NAME, STATE_PROPERTY_NAME, SUBJECT_PROPERTY_NAME, TITLE_PROPERTY_NAME, TYPE_PROPERTY_NAME, VERSION_NUMBER_PROPERTY_NAME
 
Fields inherited from class org.drools.repository.Item
node, rulesRepository
 
Constructor Summary
AssetItem()
           
AssetItem(RulesRepository rulesRepository, javax.jcr.Node node)
          Constructs a AssetItem object, setting its node attribute to the specified node.
 
Method Summary
static String[] getAssetNameFromFileName(String fileName)
          This converts a "filename" to an asset name.
 byte[] getBinaryContentAsBytes()
          This is a convenience method for returning the binary data as a byte array.
 InputStream getBinaryContentAttachment()
          If this asset contains binary data, this is how you return it.
 String getBinaryContentAttachmentFileName()
          Get the name of the "file" attachment, if one is set.
 String getContent()
          returns the string contents of the asset node.
 String getContent(Boolean fromRepo)
          Only for use in the StorageEventManager, for passing the fromRepo parameter returns the string contents of the asset node.
 long getContentLength()
          returns the number of bytes of the content.
 Calendar getDateEffective()
           
 Calendar getDateExpired()
           
 boolean getDisabled()
           
 AssetHistoryIterator getHistory()
           
 ModuleItem getModule()
          This will get the module an asset item belongs to.
 String getModuleName()
          Get the name of the enclosing module.
protected  String getPath()
           
 VersionableItem getPrecedingVersion()
          Clients of this method can cast the resulting object to the type of object they are calling the method on (e.g.
 VersionableItem getSucceedingVersion()
          Clients of this method can cast the resulting object to the type of object they are calling the method on (e.g.
 String getUserProperty(String property)
           
 boolean isBinary()
          True if this is a binary asset (or has binary content).
 void remove()
          This will remove the item.
 String toString()
          Nicely formats the information contained by the node that this object encapsulates
 AssetItem updateBinaryContentAttachment(InputStream data)
          If the asset is a binary asset, then use this to update the content (do NOT use text).
 void updateBinaryContentAttachmentFileName(String name)
          Optionally set the filename to be associated with the binary content.
 AssetItem updateContent(String newRuleContent)
          This will update the asset's content (checking it out if it is not already).
 void updateDateEffective(Calendar newDateEffective)
          Creates a new version of this asset node, updating the effective date for the asset node.
 void updateDateExpired(Calendar newDateExpired)
          Creates a new version of this asset node, updating the expired date for the asset node.
 void updateDisabled(boolean disabled)
          Creates a new version of this asset node, updating the disable value for the asset node.
 void updateUserProperty(String propertyName, String value)
          This updates a user defined property (not one of the intrinsic ones).
 
Methods inherited from class org.drools.repository.CategorisableItem
addCategory, getCategories, getCategorySummary, removeCategory, removeCategory, updateCategoryList
 
Methods inherited from class org.drools.repository.VersionableItem
archiveItem, checkin, checkIsUpdateable, checkout, checkout, getCheckinComment, getCoverage, getCreatedDate, getCreator, getDescription, getExternalRelation, getExternalSource, getFormat, getLastContributor, getLastModified, getLongProperty, getName, getPrecedingVersionNode, getPublisher, getRealContentFromVersion, getRights, getState, getStateDescription, getStringProperty, getStringPropertyArray, getSubject, getSucceedingVersionNode, getTitle, getType, getUUID, getVersionContentNode, getVersionManager, getVersionNumber, getVersionSnapshotUUID, isArchived, isHistoricalVersion, sameState, updateCoverage, updateDescription, updateExternalRelation, updateExternalSource, updateFormat, updatePublisher, updateRights, updateState, updateState, updateStringArrayProperty, updateStringProperty, updateStringProperty, updateSubject, updateTitle, updateType
 
Methods inherited from class org.drools.repository.Item
equals, getNode, getRulesRepository, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ASSET_NODE_TYPE_NAME

public static final String ASSET_NODE_TYPE_NAME
The name of the asset node type

See Also:
Constant Field Values

CONTENT_PROPERTY_NAME

public static final String CONTENT_PROPERTY_NAME
See Also:
Constant Field Values

CONTENT_PROPERTY_BINARY_NAME

public static final String CONTENT_PROPERTY_BINARY_NAME
See Also:
Constant Field Values

CONTENT_PROPERTY_ATTACHMENT_FILENAME

public static final String CONTENT_PROPERTY_ATTACHMENT_FILENAME
See Also:
Constant Field Values

DATE_EFFECTIVE_PROPERTY_NAME

public static final String DATE_EFFECTIVE_PROPERTY_NAME
The name of the date effective property on the asset node type

See Also:
Constant Field Values

DISABLED_PROPERTY_NAME

public static final String DISABLED_PROPERTY_NAME
See Also:
Constant Field Values

DATE_EXPIRED_PROPERTY_NAME

public static final String DATE_EXPIRED_PROPERTY_NAME
The name of the date expired property on the asset node type

See Also:
Constant Field Values

MODULE_NAME_PROPERTY

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

AssetItem

public AssetItem(RulesRepository rulesRepository,
                 javax.jcr.Node node)
          throws RulesRepositoryException
Constructs a AssetItem object, setting its node attribute to the specified node.

Parameters:
rulesRepository - the rulesRepository that instantiated this object
node - the node in the repository that this AssetItem corresponds to
Throws:
RulesRepositoryException

AssetItem

public AssetItem()
Method Detail

getContent

public String getContent()
                  throws RulesRepositoryException
returns the string contents of the asset node. If this is a binary asset, this will return null (use getBinaryContent instead).

Throws:
RulesRepositoryException

getContent

public String getContent(Boolean fromRepo)
                  throws RulesRepositoryException
Only for use in the StorageEventManager, for passing the fromRepo parameter returns the string contents of the asset node. If this is a binary asset, this will return null (use getBinaryContent instead).

Throws:
RulesRepositoryException

getContentLength

public long getContentLength()
returns the number of bytes of the content.


isBinary

public boolean isBinary()
True if this is a binary asset (or has binary content).


getBinaryContentAttachment

public InputStream getBinaryContentAttachment()
If this asset contains binary data, this is how you return it. Otherwise it will return null.


getBinaryContentAttachmentFileName

public String getBinaryContentAttachmentFileName()
Get the name of the "file" attachment, if one is set. Null otherwise


getBinaryContentAsBytes

public byte[] getBinaryContentAsBytes()
This is a convenience method for returning the binary data as a byte array.


getDateEffective

public Calendar getDateEffective()
                          throws RulesRepositoryException
Returns:
the date the rule becomes effective
Throws:
RulesRepositoryException

getDisabled

public boolean getDisabled()
                    throws RulesRepositoryException
Returns:
if this asset is disabled
Throws:
RulesRepositoryException

updateDateEffective

public void updateDateEffective(Calendar newDateEffective)
                         throws RulesRepositoryException
Creates a new version of this asset node, updating the effective date for the asset node.

Parameters:
newDateEffective - the new effective date for the rule
Throws:
RulesRepositoryException

updateDisabled

public void updateDisabled(boolean disabled)
                    throws RulesRepositoryException
Creates a new version of this asset node, updating the disable value for the asset node.

Parameters:
disabled - is this asset disabled
Throws:
RulesRepositoryException

getDateExpired

public Calendar getDateExpired()
                        throws RulesRepositoryException
Returns:
the date the rule becomes expired
Throws:
RulesRepositoryException

updateDateExpired

public void updateDateExpired(Calendar newDateExpired)
                       throws RulesRepositoryException
Creates a new version of this asset node, updating the expired date for the asset node.

Parameters:
newDateExpired - the new expired date for the rule
Throws:
RulesRepositoryException

updateContent

public AssetItem updateContent(String newRuleContent)
                        throws RulesRepositoryException
This will update the asset's content (checking it out if it is not already). This will not save the session or create a new version of the node (this has to be done seperately, as several properties may change as part of one edit). This is only used if the asset is a textual asset. For binary, use the updateBinaryContent method instead.

Throws:
RulesRepositoryException

updateBinaryContentAttachment

public AssetItem updateBinaryContentAttachment(InputStream data)
If the asset is a binary asset, then use this to update the content (do NOT use text).


updateBinaryContentAttachmentFileName

public void updateBinaryContentAttachmentFileName(String name)
Optionally set the filename to be associated with the binary content.


updateUserProperty

public void updateUserProperty(String propertyName,
                               String value)
This updates a user defined property (not one of the intrinsic ones).


toString

public String toString()
Nicely formats the information contained by the node that this object encapsulates

Overrides:
toString in class Object

getPrecedingVersion

public VersionableItem getPrecedingVersion()
                                    throws RulesRepositoryException
Description copied from class: VersionableItem
Clients of this method can cast the resulting object to the type of object they are calling the method on (e.g.
           RuleItem item;
           ...
           RuleItem predcessor = (RuleItem) item.getPrecedingVersion();
         

Specified by:
getPrecedingVersion in class VersionableItem
Returns:
a VersionableItem object encapsulating the predessor node of this node in the version history, or null if no predecessor version exists
Throws:
RulesRepositoryException

getSucceedingVersion

public VersionableItem getSucceedingVersion()
                                     throws RulesRepositoryException
Description copied from class: VersionableItem
Clients of this method can cast the resulting object to the type of object they are calling the method on (e.g.
           RuleItem item;
           ...
           RuleItem successor = (RuleItem) item.getSucceedingVersion();
         

Specified by:
getSucceedingVersion in class VersionableItem
Returns:
a VersionableItem object encapsulating the successor node of this node in the version history.
Throws:
RulesRepositoryException

getModuleName

public String getModuleName()
Get the name of the enclosing module. As assets are stored in versionable subfolders, this means walking up 2 levels in the hierarchy to get to the enclosing "module" node.


getUserProperty

public String getUserProperty(String property)
Returns:
A property value (for a user defined property).

remove

public void remove()
This will remove the item. The repository will need to be saved for this to take effect. Typically the package that contains this should be versioned before removing this, to make it easy to roll back.


getHistory

public AssetHistoryIterator getHistory()
Specified by:
getHistory in class VersionableItem
Returns:
An iterator over the nodes history.

getModule

public ModuleItem getModule()
This will get the module an asset item belongs to.


getAssetNameFromFileName

public static String[] getAssetNameFromFileName(String fileName)
This converts a "filename" to an asset name. File name is foo.drl -> ["foo", "drl"]

Parameters:
fileName -
Returns:

getPath

protected String getPath()


Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.