Class RepositoryFile

All Implemented Interfaces:
Identifiable, Serializable
Direct Known Subclasses:
RepositoryExecutableFile

public class RepositoryFile extends RepositoryItem
The class that represents a file that is stored in the repository.
Since:
1.1
See Also:
  • Constructor Details

    • RepositoryFile

      public RepositoryFile(String typeId, String id, String name, String path, long revision, RepositoryItem.State state, String createdBy, Date created, String lastModifiedBy, Date lastModified, String propertiesLastModifiedBy, Date propertiesLastModified, String description, RepositoryItem.Syncable syncable, List<Attribute> attributes, long size, boolean checkedOut, String checkedOutBy, Date checkedOutDate, boolean versioned, String version, String comment, boolean locked, RepositoryFile.SigningStatus signingStatus, VersionLimits versionLimits, String digest)
      It is not intended or recommended that the consumer of the API construct these objects. They should only deal with the repository file objects returned by the API.
      Parameters:
      typeId - The object type identifier of the repository file.
      id - The unique identifier of the repository file.
      name - The name of the file.
      path - The full path to the file in the repository, which includes the name.
      revision - The internally managed revision number of the repository file.
      state - The current state of the repository file.
      createdBy - The user who created the repository file.
      created - The date on which the repository file was created.
      lastModifiedBy - The user who last modified the repository file's content.
      lastModified - The date on which the repository file's content was last modified.
      propertiesLastModifiedBy - the user who last modified the repository file's properties.
      propertiesLastModified - the date on which the repository file's properties were last modified.
      description - The description of the file.
      syncable - Indicates whether the file can be copied to the user's workspace.
      attributes - The extended attributes that are defined on the repository file.
      size - The size (in bytes) of the file.
      checkedOut - Indicates whether the file is currently checked out.
      checkedOutBy - The user who has the file checked out (if it is checked out).
      checkedOutDate - The date on which the file was checked out (if it is checked out).
      versioned - Indicates whether the file is versioned.
      version - The current version of the file (if it is versioned).
      comment - The comment specified when the content was created.
      locked - Indicates whether the file is locked.
      signingStatus - The signature status of the file.
      versionLimits - The version retention limits of the file.
      digest - The digest value of the file based on the MD5 algorithm.
  • Method Details

    • getSize

      public long getSize()
      Gets the size (in bytes) of the repository file.
      Returns:
      The size (in bytes) of the repository file.
    • isCheckedOut

      public boolean isCheckedOut()
      Indicates whether the file is checked out or not.
      Returns:
      true if the repository file is checked out, false otherwise.
    • getCheckedOutBy

      public String getCheckedOutBy()
      Gets the user who has the file checked out, if it is checked out.
      Returns:
      The user who has the file checked out, if it is checked out.
    • getCheckedOutDate

      public Date getCheckedOutDate()
      Gets the date on which the file was checked out, if it is checked out.
      Returns:
      The date the on which file was checked out, if it is checked out.
    • isVersioned

      public boolean isVersioned()
      Indicates whether the file is versioned or not.
      Returns:
      true if the repository file is versioned, false otherwise.
    • getVersion

      public String getVersion()
      Gets the current version of the file, if it is versioned.
      Returns:
      The current version of the file, if it is versioned.
    • getComment

      public String getComment()
      Gets the comment that was specified when the content was created.
      Returns:
      The comment that was specified when the content was created.
    • getDigest

      public String getDigest()
      Gets the digest value of the file based on the MD5 algorithm.

      Here is sample java code to generate the digest value for a local file. If the value from the code below is equal to the value returned from this method, the files are the same.

        import java.io.File;
        import java.io.FileInputStream;
        import java.io.InputStream;
        import java.security.MessageDigest;
        import org.apache.commons.codec.binary.Hex;
        
        private String getLocalFileDigest(InputStream in, MessageDigest md5) throws Exception {
            byte[] byteArray = new byte[1024];
            int bytesCount = 0;
            
            //Read file data and update in message digest
            while ((bytesCount = in.read(byteArray)) != -1) {
                md5.update(byteArray, 0, bytesCount);
            }
          
            return new String(Hex.encodeHex(md5.digest())).toUpperCase();
        }
       
       
      Returns:
      The digest value of the file based on the MD5 algorithm.
    • getSigningStatus

      public RepositoryFile.SigningStatus getSigningStatus()
      Gets the signature status of the file.
      Returns:
      The signature status of the file.
    • getVersionLimits

      public VersionLimits getVersionLimits()
      Gets the version retention limits of the file.
      Returns:
      The version retention limits of the file.
    • setVersionLimits

      public void setVersionLimits(VersionLimits versionLimits)
      Sets the major and minor versions to retain for a versioned file. The default limit is null, which means that there is no limit. If version limits are applied, the value must be in the range of 1 to 10.
      Parameters:
      versionLimits - The limit of major and minor versions to retain for a versioned file.
    • getMajorLimit

      public Integer getMajorLimit()
      Gets the limit of major versions to retain for a file. The default limit is null, which means that there is no limit. If version limits are applied, the value must be in the range of 1 to 10.
      Returns:
      The limit of major versions to retain for a file
    • getMinorLimit

      public Integer getMinorLimit()
      Gets the limit of minor versions to retain for a file. The default limit is null which means there is no limit. If version limits are applied, the value must be in the range of 1 to 10.
      Returns:
      The limit of minor versions to retain for a file.
    • isLocked

      public boolean isLocked()
      Indicates whether the file is locked.
      Returns:
      true if the repository file is locked, false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class RepositoryItem
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class RepositoryItem
    • toString

      public String toString()
      Overrides:
      toString in class RepositoryItem