org.rhq.core.domain.configuration
Class RawConfiguration

java.lang.Object
  extended by org.rhq.core.domain.configuration.RawConfiguration
All Implemented Interfaces:
Serializable, DeepCopyable<RawConfiguration>

public class RawConfiguration
extends Object
implements Serializable, DeepCopyable<RawConfiguration>

Resources support structured configuration as well as raw configuration which is represented by this class. A raw configuration is typically in the form of a file on the file system. This could be httpd.conf in the case of apache.

A raw configuration is stored as a CLOB and has a SHA-256 hash with which it can be uniquely identified.

A RawConfiguration is always associated with its parent Configuration which can be structured, raw, or both. A Configuration can have multiple RawConfigurations associated with it. Suppose for apache that each virtual host configuration is stored in a separate file. We might have a single Configuration object that represents all of the apache configuration, and that object may contain multiple RawConfigurations for each of the virtual host config files.

See Also:
Serialized Form

Field Summary
 String errorMessage
          THis value is not persisted to the database, but is set when validation indicates that there is a problem with the file structure.
 
Constructor Summary
RawConfiguration()
           
 
Method Summary
 RawConfiguration deepCopy(boolean keepId)
          Creates a deep copy of this object that includes all of the properties except for the parent configuration.
 boolean equals(Object obj)
          Two RawConfiguration objects are considered equal when the following conditions hold: Both have the same sha256 and path property is null for both or Both have the same sha256, path property is non-null and equal for both Note: This definition of equality holdsonly when comparing RawConfigurations belonging to the same resource.
 Configuration getConfiguration()
           
 String getContents()
           
 long getCtime()
           
 int getId()
           
 long getMtime()
           
 String getPath()
           
 String getSha256()
           
 int hashCode()
           
 void setConfiguration(Configuration configuration)
           
 void setContents(String contents, String sha256)
          Replaces the contents of the raw configuration.
 void setId(int id)
           
 void setPath(String path)
           
 void setSha256(String digestString)
           
 String toString()
          Returns a string representation of this object that is in the following format, RawConfiguration[id=1, path=/foo/bar/raw.txt, sha256=13xcx9sd82e, configuration=]
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

errorMessage

public String errorMessage
THis value is not persisted to the database, but is set when validation indicates that there is a problem with the file structure.

Constructor Detail

RawConfiguration

public RawConfiguration()
Method Detail

getId

public int getId()
Returns:
The database identifier or primary key

setId

public void setId(int id)

getPath

public String getPath()
Returns:
The file system path of the configuration that this object represents

setPath

public void setPath(String path)
Parameters:
path - The new file system path of the configuration file represented by this object

getContents

public String getContents()
Returns:
The contents of the raw configuration which typically will be a file

setContents

public void setContents(String contents,
                        String sha256)
Replaces the contents of the raw configuration. The SHA-256 hash returned from getSha256() will be updated as well.

Parameters:
contents - The new contents
sha256 - the digest string representing the sha256 hash of the given contents

getSha256

public String getSha256()
Returns:
A SHA-256 hash of the contents for this raw configuration, which can be accessed via getContents()

setSha256

public void setSha256(String digestString)

getCtime

public long getCtime()
Returns:
A timestamp of when this object was created

getMtime

public long getMtime()
Returns:
A timestamp of when this object was last modified

getConfiguration

public Configuration getConfiguration()
Returns:
The owning Configuration object

setConfiguration

public void setConfiguration(Configuration configuration)
Parameters:
configuration - The parent configuration object

equals

public boolean equals(Object obj)
Two RawConfiguration objects are considered equal when the following conditions hold: Note: This definition of equality holdsonly when comparing RawConfigurations belonging to the same resource.

Overrides:
equals in class Object
Parameters:
obj - The object to compare for equality
Returns:
true if obj is a RawConfiguration and has the same values for the sha256 and path properties.

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
A hash which is calculated from the sha256 and path properties.

toString

public String toString()
Returns a string representation of this object that is in the following format, RawConfiguration[id=1, path=/foo/bar/raw.txt, sha256=13xcx9sd82e, configuration=]

Overrides:
toString in class Object
Returns:
A string representation of this object

deepCopy

public RawConfiguration deepCopy(boolean keepId)
Creates a deep copy of this object that includes all of the properties except for the parent configuration. If the keepId flag is false, then the id property is not copied.

Specified by:
deepCopy in interface DeepCopyable<RawConfiguration>
Parameters:
keepId - A flag indicating whether or not the id should be copied
Returns:
A copy of this object


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.