com.prosysopc.ua.types.opcua.server
Class FileTypeNode

java.lang.Object
  extended by com.prosysopc.ua.nodes.AbstractUaNode
      extended by com.prosysopc.ua.server.nodes.ServerNode
          extended by com.prosysopc.ua.server.nodes.BaseNode
              extended by com.prosysopc.ua.server.nodes.UaInstanceNode
                  extended by com.prosysopc.ua.server.nodes.UaObjectNode
                      extended by com.prosysopc.ua.server.nodes.AbstractGeneratedObjectNode
                          extended by com.prosysopc.ua.types.opcua.server.BaseObjectTypeNode
                              extended by com.prosysopc.ua.types.opcua.server.FileTypeNodeBase
                                  extended by com.prosysopc.ua.types.opcua.server.FileTypeNode
All Implemented Interfaces:
UaInstance, UaNode, UaObject, GeneratedNode, UaCallable, BaseInstanceType, BaseObjectType, FileType
Direct Known Subclasses:
AddressSpaceFileTypeNodeBase, TrustListTypeNodeBase

public class FileTypeNode
extends FileTypeNodeBase

Implementation of the OPC UA FileType object type.

Internally uses RandomAccessFile instances to manage the file streams required for reading and writing the files in the file system.


Field Summary
 
Fields inherited from class com.prosysopc.ua.server.nodes.BaseNode
NODE_VERSION_PROPERTY_NAME
 
Fields inherited from class com.prosysopc.ua.server.nodes.ServerNode
eventListeners, INITIALIZATION_TIME, nodeManager, supportedAttributesMap
 
Fields inherited from interface com.prosysopc.ua.types.opcua.FileType
CLOSE, GET_POSITION, MIME_TYPE, OPEN, OPEN_COUNT, READ, SET_POSITION, SIZE, USER_WRITABLE, WRITABLE, WRITE
 
Constructor Summary
protected FileTypeNode(NodeManagerUaNode nodeManager, org.opcfoundation.ua.builtintypes.NodeId nodeId, org.opcfoundation.ua.builtintypes.QualifiedName browseName, org.opcfoundation.ua.builtintypes.LocalizedText displayName)
           
 
Method Summary
 void afterCreate()
          This method is called after NodeBuilder has constructed the instance, it is called for every sub-node that also implement this interface
protected  void checkFileExists()
           
 void close(Session session, Long fileHandle)
          Close the file handle
 int getCurrentOpenCount()
           
 long getCurrentPosition(Session session, Long fileHandle)
          Get the current position of the fileHandle
 long getCurrentSize()
           
 org.opcfoundation.ua.builtintypes.DateTime getCurrentTimestamp()
          Get the file's modification time.
 File getFile()
           
protected  RandomAccessFile getRandomAccessFile(Session session, Long fileHandle)
           
 org.opcfoundation.ua.builtintypes.DateTime getTimestamp()
          Get the file's modification time.
 boolean isCurrentWritable()
          Whether the file can be written to in general.
 boolean isWriting()
           
protected  void onClose(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle)
           
protected  org.opcfoundation.ua.builtintypes.UnsignedLong onGetPosition(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle)
           
protected  org.opcfoundation.ua.builtintypes.UnsignedInteger onOpen(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.UnsignedByte mode)
           
protected  org.opcfoundation.ua.builtintypes.ByteString onRead(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle, Integer length)
           
protected  void onSetPosition(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle, org.opcfoundation.ua.builtintypes.UnsignedLong position)
           
protected  void onWrite(ServiceContext serviceContext, org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle, org.opcfoundation.ua.builtintypes.ByteString data)
           
 Long open(Session session, Set<FileTypeOpenMode> mode)
          Opens the file for reading or writing.
 byte[] read(Session session, Long fileHandle, int length)
          Read data from the physical file.
 void setCurrentPosition(Session session, Long fileHandle, long position)
          Set the current position of the fileHandle.
 void setCurrentWritable(boolean writable)
          Define whether the file can be written to in general.
 void setFile(File file)
           
 void setSize(org.opcfoundation.ua.builtintypes.UnsignedLong size, org.opcfoundation.ua.builtintypes.StatusCode status, org.opcfoundation.ua.builtintypes.DateTime timestamp)
           
 void updateFileSize()
           
protected  void updateOpenCount()
           
 void write(Session session, Long fileHandle, byte[] data)
           
 
Methods inherited from class com.prosysopc.ua.types.opcua.server.FileTypeNodeBase
callMethod, close, getCloseMethodImplementation, getCloseNode, getFileTypeNodeInitializer, getGetPositionMethodImplementation, getGetPositionNode, getMimeType, getMimeTypeNode, getOpenCount, getOpenCountNode, getOpenMethodImplementation, getOpenNode, getPosition, getReadMethodImplementation, getReadNode, getSetPositionMethodImplementation, getSetPositionNode, getSize, getSizeNode, getUserWritableNode, getWritableNode, getWriteMethodImplementation, getWriteNode, isUserWritable, isWritable, open, read, setCloseMethodImplementation, setFileTypeNodeInitializer, setGetPositionMethodImplementation, setMimeType, setOpenCount, setOpenCount, setOpenMethodImplementation, setPosition, setReadMethodImplementation, setSetPositionMethodImplementation, setSize, setSize, setUserWritable, setWritable, setWriteMethodImplementation, write
 
Methods inherited from class com.prosysopc.ua.types.opcua.server.BaseObjectTypeNode
isCacheMethodIds, setCacheMethodIds
 
Methods inherited from class com.prosysopc.ua.server.nodes.AbstractGeneratedObjectNode
afterCreateInitIfExists, afterCreateSetValueIfExists, callAfterCreateIfExists, getDefaultTypeDefinition, getQualifiedName, isComponentMatch
 
Methods inherited from class com.prosysopc.ua.server.nodes.UaObjectNode
addCallListener, callMethod, deleteIfNodeExists, getAttributes, getAttributes, getEventNotifier, getIcon, getNodeClass, initSupportedAttributes, readAttributeValue, removeCallListener, setAttributes, setEventNotifier, setIcon, toString, writeAttributeValue
 
Methods inherited from class com.prosysopc.ua.server.nodes.UaInstanceNode
addModellingRule, beforeAddReference, getTypeDefinition, getTypeDefinitionId, hasTypeDefinition, registerOverridePlainMethod, setTypeDefinition, setTypeDefinitionId, setTypeDefinitionId, supportsTypeDefinitionNode
 
Methods inherited from class com.prosysopc.ua.server.nodes.BaseNode
addPlainProperty, addPlainVariable, assertTypeSupport, assertTypeSupport, createNodeId, createNodeId, createReflectiveInstanceProperty, createReflectiveInstanceProperty, deleteReference, deleteReference, doAddProperty, getAttributes, getBrowseName, getComponent, getComponents, getDescription, getDescription, getDisplayName, getDisplayName, getMethod, getNodeVersion, getNodeVersionValue, getProperties, getProperty, getPropertyValue, getReferencesAsList, getStandardBrowseName, getStandardDisplayText, getUserWriteMask, getWriteMask, hasProperty, hasReference, hasUserWriteAccess, hasWriteAccess, incNodeVersion, initNodeVersion, isChildOfType, readAttribute, readAttribute, registerCallbackProperty, registerPlainInstanceProperty, registerPlainInstanceProperty, registerPlainProperty, registerPlainProperty, registerPlainVariable, registerPlainVariable, registerReflectiveInstanceProperty, registerReflectiveInstanceVariable, registerReflectiveProperty, registerReflectiveVariable, removeProperty, setAccessLevelRecursively, setAccessLevelRecursively, setAttribute, setBrowseName, setDescription, setDisplayName, setNodeVersionValue, setPropertyValue, setUserWriteMask, setWriteMask, writeAttribute
 
Methods inherited from class com.prosysopc.ua.server.nodes.ServerNode
addComponent, addDataChangeListener, addEventListener, addNewReference, addNewReference, addOrganizes, addProperties, addProperty, addReference, addReference, addReference, addReference, addReference, addReference, afterAddReference, afterDeleteReference, dataChange, deleteReference, deleteReference, deleteReferences, doDeleteReference, equals, findPlaceholders, fireDataChange, fireEvent, fireEventInParents, getAddressSpace, getDefaultBrowseName, getNodeId, getNodeManager, getReference, getReferenceList, getReferences, getSupportedAttributes, getTargetNodes, hashCode, isAddNotifierReferencesToServerObject, isFalseOrNull, isMandatory, isMonitoredForEvents, isTrueOrNull, isType, referenceTypeInherits, removeComponent, removeDataChangeListener, removeEventListener, setAddNotifierReferencesToServerObject, setReferences, supportsAttribute, translateBrowsePathToNodeIds, validateHasEventSourceChain, validateHasEventSourceChain
 
Methods inherited from class com.prosysopc.ua.nodes.AbstractUaNode
getForwardReferences, getInverseReferences, getReferences, getReferences, referenceTypeInherits
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.prosysopc.ua.types.opcua.BaseInstanceType
getQualifiedName
 
Methods inherited from interface com.prosysopc.ua.nodes.UaObject
callMethod, getEventNotifier, getIcon, setEventNotifier, setIcon
 
Methods inherited from interface com.prosysopc.ua.nodes.UaInstance
getTypeDefinition, getTypeDefinitionId, setTypeDefinition, setTypeDefinitionId, setTypeDefinitionId
 
Methods inherited from interface com.prosysopc.ua.nodes.UaNode
addComponent, addProperty, addReference, addReference, addReference, deleteReference, deleteReference, deleteReference, deleteReference, getAddressSpace, getAttributes, getBrowseName, getComponent, getComponents, getDescription, getDisplayName, getForwardReferences, getInverseReferences, getMethod, getNodeClass, getNodeId, getNodeVersion, getProperties, getProperty, getReference, getReferences, getReferences, getSupportedAttributes, getUserWriteMask, getWriteMask, hasUserWriteAccess, hasWriteAccess, readAttribute, readAttribute, removeComponent, removeProperty, setAttribute, setAttributes, setBrowseName, setDescription, setDisplayName, setReferences, setUserWriteMask, setWriteMask, supportsAttribute, writeAttribute
 

Constructor Detail

FileTypeNode

protected FileTypeNode(NodeManagerUaNode nodeManager,
                       org.opcfoundation.ua.builtintypes.NodeId nodeId,
                       org.opcfoundation.ua.builtintypes.QualifiedName browseName,
                       org.opcfoundation.ua.builtintypes.LocalizedText displayName)
Method Detail

afterCreate

public void afterCreate()
Description copied from interface: GeneratedNode
This method is called after NodeBuilder has constructed the instance, it is called for every sub-node that also implement this interface

Specified by:
afterCreate in interface GeneratedNode
Overrides:
afterCreate in class FileTypeNodeBase

close

public void close(Session session,
                  Long fileHandle)
           throws StatusException
Close the file handle

Throws:
StatusException

getCurrentOpenCount

public int getCurrentOpenCount()
Returns:
the number of currently open file handles

getCurrentPosition

public long getCurrentPosition(Session session,
                               Long fileHandle)
                        throws StatusException
Get the current position of the fileHandle

Parameters:
session - the client session that is making the read
fileHandle - the handle to the file, received in open
Returns:
the current byte position
Throws:
StatusException - if the fileHandle is invalid

getCurrentSize

public long getCurrentSize()
                    throws StatusException
Returns:
the size of the file in bytes, or -1 if the file cannot be read.
Throws:
StatusException - with Bad_NotFound if the file is not defined or does not exist

getCurrentTimestamp

public org.opcfoundation.ua.builtintypes.DateTime getCurrentTimestamp()
                                                               throws StatusException
Get the file's modification time.

Returns:
the last modified time of the file as DateTime
Throws:
StatusException - with Bad_NotFound if the file is not defined or does not exist

getFile

public File getFile()
Returns:
the file

getTimestamp

public org.opcfoundation.ua.builtintypes.DateTime getTimestamp()
                                                        throws StatusException
Get the file's modification time.

Returns:
the last modified time of the file as DateTime
Throws:
StatusException - with Bad_NotFound if the file is not defined or does not exist

isCurrentWritable

public boolean isCurrentWritable()
Whether the file can be written to in general.

Returns:
true if the file can be opened for writing by anyone.

isWriting

public boolean isWriting()
Returns:
the writing

open

public Long open(Session session,
                 Set<FileTypeOpenMode> mode)
          throws StatusException
Opens the file for reading or writing. The file can be opened for reading several times, unless it is currently open for writing. It can be opened for writing only once at a time.

Parameters:
session - the client session that is making the read
mode - the opening mode (read/write, etc.)
Returns:
a fileHandle which can be used to refer to the file in read, write and close
Throws:
StatusException - with StatusCodes.Bad_NotFound if the file does not exist

read

public byte[] read(Session session,
                   Long fileHandle,
                   int length)
            throws StatusException
Read data from the physical file.

Parameters:
session - the client session that is making the read
fileHandle - the handle to the file, received in open
length - the number of bytes to read
Returns:
the bytes that are read from the file
Throws:
StatusException - with Bad_InvalidState if the file is not open for reading, i.e. fileHandle is invalid, or with Bad_UnexpectedError if there is an IOException

setCurrentPosition

public void setCurrentPosition(Session session,
                               Long fileHandle,
                               long position)
                        throws StatusException
Set the current position of the fileHandle.

Parameters:
session - the client session that is making the read
fileHandle - the handle to the file, received in open
position - .longValue() the new position
Throws:
StatusException - if the fileHandle is invalid

setCurrentWritable

public void setCurrentWritable(boolean writable)
                        throws StatusException
Define whether the file can be written to in general.

Parameters:
writable - set to true if the file can be opened for writing by anyone.
Throws:
StatusException

setFile

public void setFile(File file)
Parameters:
file -

setSize

public void setSize(org.opcfoundation.ua.builtintypes.UnsignedLong size,
                    org.opcfoundation.ua.builtintypes.StatusCode status,
                    org.opcfoundation.ua.builtintypes.DateTime timestamp)
Parameters:
size -
status -
timestamp -

updateFileSize

public void updateFileSize()

write

public void write(Session session,
                  Long fileHandle,
                  byte[] data)
           throws StatusException
Parameters:
session -
fileHandle -
data -
Throws:
StatusException

checkFileExists

protected void checkFileExists()
                        throws StatusException
Throws:
StatusException

getRandomAccessFile

protected RandomAccessFile getRandomAccessFile(Session session,
                                               Long fileHandle)
                                        throws StatusException
Parameters:
session -
fileHandle -
Returns:
Throws:
StatusException

onClose

protected void onClose(ServiceContext serviceContext,
                       org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle)
                throws StatusException
Specified by:
onClose in class FileTypeNodeBase
Throws:
StatusException

onGetPosition

protected org.opcfoundation.ua.builtintypes.UnsignedLong onGetPosition(ServiceContext serviceContext,
                                                                       org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle)
                                                                throws StatusException
Specified by:
onGetPosition in class FileTypeNodeBase
Throws:
StatusException

onOpen

protected org.opcfoundation.ua.builtintypes.UnsignedInteger onOpen(ServiceContext serviceContext,
                                                                   org.opcfoundation.ua.builtintypes.UnsignedByte mode)
                                                            throws StatusException
Specified by:
onOpen in class FileTypeNodeBase
Throws:
StatusException

onRead

protected org.opcfoundation.ua.builtintypes.ByteString onRead(ServiceContext serviceContext,
                                                              org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle,
                                                              Integer length)
                                                       throws StatusException
Specified by:
onRead in class FileTypeNodeBase
Throws:
StatusException

onSetPosition

protected void onSetPosition(ServiceContext serviceContext,
                             org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle,
                             org.opcfoundation.ua.builtintypes.UnsignedLong position)
                      throws StatusException
Specified by:
onSetPosition in class FileTypeNodeBase
Throws:
StatusException

onWrite

protected void onWrite(ServiceContext serviceContext,
                       org.opcfoundation.ua.builtintypes.UnsignedInteger fileHandle,
                       org.opcfoundation.ua.builtintypes.ByteString data)
                throws StatusException
Specified by:
onWrite in class FileTypeNodeBase
Throws:
StatusException

updateOpenCount

protected void updateOpenCount()
                        throws StatusException
Throws:
StatusException


Copyright © 2018. All rights reserved.