Class ContentNetworkFile

java.lang.Object
org.alfresco.jlan.server.filesys.NetworkFile
All Implemented Interfaces:
NetworkFileLegacyReferenceCount, org.alfresco.jlan.server.filesys.cache.NetworkFileStateInterface
Direct Known Subclasses:
MSOfficeContentNetworkFile, OpenOfficeContentNetworkFile

public class ContentNetworkFile extends NodeRefNetworkFile
Implementation of the NetworkFile for direct interaction with the channel repository.

This provides the interaction with the Alfresco Content Model file/folder structure.

Author:
Derek Hulley
  • Field Summary

    Fields inherited from class org.alfresco.filesys.repo.NodeRefNetworkFile

    m_nodeRef, m_pid

    Fields inherited from class org.alfresco.jlan.server.filesys.NetworkFile

    ATTRIBUTESONLY, Created, DelayedClose, DelayedWriteError, DeleteOnClose, IOPending, m_accessDate, m_allowedAccess, m_attrib, m_closed, m_createDate, m_dirId, m_fid, m_fileSize, m_fullName, m_grantedAccess, m_modifyDate, m_name, m_streamId, m_streamName, m_uniqueId, m_writeCount, READONLY, READWRITE, WRITEONLY
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ContentNetworkFile(NodeService nodeService, ContentService contentService, MimetypeService mimetypeService, NodeRef nodeRef, String name)
    Class constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the file
    createFile(NodeService nodeService, ContentService contentService, MimetypeService mimetypeService, CifsHelper cifsHelper, NodeRef nodeRef, String path, boolean readOnly, boolean attributesOnly, org.alfresco.jlan.server.SrvSession sess)
    Helper method to create a network file given a node reference.
    void
    Flush and buffered data for this file
    final boolean
    Determine if the file content data has been opened
    final boolean
    Return the modified status
    void
    openContent(boolean write, boolean trunc)
    Opens the channel for reading or writing depending on the access mode.
    void
    openFile(boolean createFlag)
    Open the file
    int
    readFile(byte[] buffer, int length, int position, long fileOffset)
    Read from the file.
    long
    seekFile(long pos, int typ)
    Seek to a new position in the file
    Return the file details as a string
    void
    truncateFile(long size)
    Truncate or extend the file to the specified length
    void
    writeFile(byte[] buffer, int length, int position, long fileOffset)
    Write a block of data to the file.

    Methods inherited from class org.alfresco.filesys.alfresco.AlfrescoNetworkFile

    allowsOpenCloseViaNetworkFile, getFileState, setFileState

    Methods inherited from class org.alfresco.jlan.server.filesys.NetworkFile

    addLock, close, getAccessDate, getAccessToken, getAllowedAccess, getCreationDate, getDirectoryId, getFileAttributes, getFileId, getFileSize, getFileSizeInt, getFullName, getFullNameStream, getGrantedAccess, getGrantedAccessAsString, getLockAt, getLockList, getModifyDate, getName, getOpLock, getProtocolId, getStreamId, getStreamName, getUniqueId, getWriteCount, hasAccessDate, hasAccessToken, hasCreationDate, hasDelayedClose, hasDelayedWriteError, hasDeleteOnClose, hasIOPending, hasLocks, hasModifyDate, hasNTAttribute, hasOpLock, incrementWriteCount, isArchived, isClosed, isDirectory, isForce, isHidden, isReadOnly, isStream, isSystem, numberOfLocks, removeAllLocks, removeLock, setAccessDate, setAccessToken, setAllowedAccess, setAttributes, setClosed, setCreationDate, setDelayedClose, setDelayedWriteError, setDeleteOnClose, setDirectoryId, setFileId, setFileSize, setFileSize, setForce, setFullName, setGrantedAccess, setIOPending, setModifyDate, setName, setOpLock, setProtocolId, setStatusFlag, setStreamId, setStreamName, setUniqueId, setUniqueId, setUniqueId, wasCreated

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ContentNetworkFile

      protected ContentNetworkFile(NodeService nodeService, ContentService contentService, MimetypeService mimetypeService, NodeRef nodeRef, String name)
      Class constructor
      Parameters:
      nodeService - NodeService
      contentService - ContentService
      mimetypeService - mimetypeService
      nodeRef - NodeRef
      name - String
  • Method Details

    • createFile

      public static ContentNetworkFile createFile(NodeService nodeService, ContentService contentService, MimetypeService mimetypeService, CifsHelper cifsHelper, NodeRef nodeRef, String path, boolean readOnly, boolean attributesOnly, org.alfresco.jlan.server.SrvSession sess)
      Helper method to create a network file given a node reference.
    • toString

      public String toString()
      Return the file details as a string
      Overrides:
      toString in class org.alfresco.jlan.server.filesys.NetworkFile
      Returns:
      String
    • hasContent

      public final boolean hasContent()
      Determine if the file content data has been opened
      Returns:
      boolean
    • openContent

      public void openContent(boolean write, boolean trunc) throws org.alfresco.jlan.server.filesys.AccessDeniedException, org.alfresco.error.AlfrescoRuntimeException
      Opens the channel for reading or writing depending on the access mode.

      Side effect: sets fileSize

      If the channel is already open, it is left.

      Parameters:
      write - true if the channel must be writable
      trunc - true if the writable channel does not require the previous content data
      Throws:
      org.alfresco.jlan.server.filesys.AccessDeniedException - if this network file is read only
      org.alfresco.error.AlfrescoRuntimeException - if this network file represents a directory
      See Also:
      • NetworkFile.getGrantedAccess()
      • NetworkFile.READONLY
      • NetworkFile.WRITEONLY
      • NetworkFile.READWRITE
    • closeFile

      public void closeFile() throws IOException
      Close the file
      Specified by:
      closeFile in class org.alfresco.jlan.server.filesys.NetworkFile
      Throws:
      IOException
    • truncateFile

      public void truncateFile(long size) throws IOException
      Truncate or extend the file to the specified length
      Specified by:
      truncateFile in class org.alfresco.jlan.server.filesys.NetworkFile
      Parameters:
      size - long
      Throws:
      IOException
    • writeFile

      public void writeFile(byte[] buffer, int length, int position, long fileOffset) throws IOException
      Write a block of data to the file.
      Specified by:
      writeFile in class org.alfresco.jlan.server.filesys.NetworkFile
      Parameters:
      buffer - byte[]
      length - int
      position - int
      fileOffset - long
      Throws:
      IOException
    • readFile

      public int readFile(byte[] buffer, int length, int position, long fileOffset) throws IOException
      Read from the file.
      Specified by:
      readFile in class org.alfresco.jlan.server.filesys.NetworkFile
      Parameters:
      buffer - byte[]
      length - int
      position - int
      fileOffset - long
      Returns:
      Length of data read.
      Throws:
      IOException
    • openFile

      public void openFile(boolean createFlag) throws IOException
      Open the file
      Specified by:
      openFile in class org.alfresco.jlan.server.filesys.NetworkFile
      Parameters:
      createFlag - boolean
      Throws:
      IOException
    • seekFile

      public long seekFile(long pos, int typ) throws IOException
      Seek to a new position in the file
      Specified by:
      seekFile in class org.alfresco.jlan.server.filesys.NetworkFile
      Parameters:
      pos - long
      typ - int
      Returns:
      long
      Throws:
      IOException
    • flushFile

      public void flushFile() throws IOException
      Flush and buffered data for this file
      Specified by:
      flushFile in class org.alfresco.jlan.server.filesys.NetworkFile
      Throws:
      IOException
    • isModified

      public final boolean isModified()
      Return the modified status
      Returns:
      boolean