Class FileManagementConnector
- java.lang.Object
-
- com.ibm.di.connector.Connector
-
- com.ibm.di.connector.filemanagement.FileManagementConnector
-
- All Implemented Interfaces:
ConnectorInterface
,VersionInfoInterface
public class FileManagementConnector extends Connector implements ConnectorInterface
Connector which can read or modify files structure and metadata. It can create, find and delete files and directories. It works on Iterator, Lookup, Delete, AddOnly or Update modes.- Since:
- 7.2
-
-
Field Summary
-
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
-
-
Constructor Summary
Constructors Constructor Description FileManagementConnector()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteEntry(Entry entry, SearchCriteria searchCrit)
Deletes an existing entry.Entry
findEntry(SearchCriteria searchCrit)
Finds an existing entry.void
forceDelete(java.io.File fileToDelete)
Delete the given file or directory.void
forceDelete(java.lang.String filePathToDelete)
Delete the file or directory which path is provided.Entry
getNextEntry()
Returns the next Entry from the connector.java.lang.String
getVersion()
Version information.void
initialize(java.lang.Object o)
Initialize the connector.void
modEntry(Entry newEntry, SearchCriteria searchCrit)
Modifies an existing entry.void
modEntry(Entry newEntry, SearchCriteria searchCrit, Entry oldEntry)
Modifies an existing entry.void
putEntry(Entry newEntry)
Adds a new entry to the data sourcevoid
selectEntries()
Prepare the Connector for sequential read.-
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, extractExceptionInformation, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextClient, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, getUI, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logError, logmsg, pushback, queryOperations, queryReply, querySchema, queryTables, reconnect, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setDebugMode, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface, terminate, terminateServer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.di.connector.ConnectorInterface
getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextClient, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, pushback, queryOperations, queryReply, querySchema, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminate, terminateServer
-
-
-
-
Method Detail
-
initialize
public void initialize(java.lang.Object o) throws java.lang.Exception
Initialize the connector. The connector may be passed a parameter of any kind by the user. It is up to the connector to determine whether this object can be used or not. The parameter is typically provided by a user script. When an AssemblyLine initializes it's Connectors, they are passed a ConnectorMode object.- Specified by:
initialize
in interfaceConnectorInterface
- Overrides:
initialize
in classConnector
- Parameters:
o
- User provided parameter- Throws:
java.lang.Exception
- if the initialization of this connector fails.
-
selectEntries
public void selectEntries() throws java.lang.Exception
Prepare the Connector for sequential read. Setup start directory. When the Connector is used as an Iterator in an AssemblyLine, this method will be called.- Specified by:
selectEntries
in interfaceConnectorInterface
- Overrides:
selectEntries
in classConnector
- Throws:
java.lang.Exception
- if startDirectory parameter is not name of existing directory or maxDirDepth is negative.
-
getNextEntry
public Entry getNextEntry() throws java.lang.Exception
Returns the next Entry from the connector. The entry is populated with attributes and values from the next entry in the input set.Example:
var ctor = input.getConnector(); var entry = ctor.getNextEntry(); for (; entry != null; entry = ctor.getNextEntry()) { main.logmsg("Read entry..."); main.dumpEntry(entry); }
- Specified by:
getNextEntry
in interfaceConnectorInterface
- Overrides:
getNextEntry
in classConnector
- Returns:
- - the next Entry, or null if no more data
- Throws:
java.lang.Exception
- if an error occurs.- See Also:
ConnectorInterface.selectEntries()
-
findEntry
public Entry findEntry(SearchCriteria searchCrit) throws java.lang.Exception
Finds an existing entry. The search criteria specifies which entry to locateHere is an example of how to find all people with names starting with 'J' which are from IBM organization in US.
Example:
var ctor = input.getConnector(); var crit = new com.ibm.di.SearchCriteria("$dn", com.ibm.di.SearchCriteria.SUBSTRING, "c=US,o=IBM"); crit.addCriteria("name", com.ibm.di.SearchCriteria.INITIAL_STRING, "J"); crit.addCriteria("objectclass", com.ibm.di.SearchCriteria.SUBSTRING, "person"); var res = ctor.findEntry(crit); if (res != null) { main.logmsg("Found entry:"); main.dumpEntry(res); } else { if( getFindEntryCount()> 1 ){ main.logmsg("Found these entries:"); while ( (entry = ctor.getNextFindEntry()) != null ) { main.dumpEntry(entry); } } else { main.logmsg("Entry not found!"); } }
- Specified by:
findEntry
in interfaceConnectorInterface
- Overrides:
findEntry
in classConnector
- Parameters:
searchCrit
- The search criteria used to locate the entry to be modified- Returns:
- The entry found, or null if no or multiple entries found
- Throws:
java.lang.Exception
- if an error occurs.
-
deleteEntry
public void deleteEntry(Entry entry, SearchCriteria searchCrit) throws java.lang.Exception
Deletes an existing entry. The search criteria specifies which entry to modify. Some connectors may silently ignore the search criteria. For example, the LDAP connector will use the distinguished name ($dn) from the entry parameter (if it exists) rather than expanding the search criteria and search for the entry. Each connector's inner semantics governs whether the search parameter is used or not.- Specified by:
deleteEntry
in interfaceConnectorInterface
- Overrides:
deleteEntry
in classConnector
- Parameters:
entry
- The entry datasearchCrit
- The search criteria used to locate the entry to be deleted- Throws:
java.lang.Exception
- if an error occurs.
-
forceDelete
public void forceDelete(java.lang.String filePathToDelete) throws java.lang.Exception
Delete the file or directory which path is provided. Both read-only files and non-empty directories will be deleted.- Parameters:
filePathToDelete
- to be deleted.- Throws:
java.lang.Exception
- if the file or directory cannot be deleted.
-
forceDelete
public void forceDelete(java.io.File fileToDelete) throws java.lang.Exception
Delete the given file or directory. Both read-only files and non-empty directories will be deleted.- Parameters:
fileToDelete
- to be deleted.- Throws:
java.lang.Exception
- if the file or directory cannot be deleted.
-
putEntry
public void putEntry(Entry newEntry) throws java.lang.Exception
Adds a new entry to the data sourceExample:
var ctor = write.getConnector(); for (i = 0; i < 10; i++) { var entry = system.newEntry(); entry.setAttribute("linenumber", i); entry.setAttribute("line", i + " line of text..."); main.logmsg("Writes entry to output..."); main.dumpEntry(entry); ctor.putEntry(entry); }
- Specified by:
putEntry
in interfaceConnectorInterface
- Overrides:
putEntry
in classConnector
- Parameters:
newEntry
- The entry data to add- Throws:
java.lang.Exception
- if an error occurs.
-
modEntry
public void modEntry(Entry newEntry, SearchCriteria searchCrit) throws java.lang.Exception
Modifies an existing entry. The new entry data is given by the entry parameter and the search criteria specifies which entry to modify.- Specified by:
modEntry
in interfaceConnectorInterface
- Overrides:
modEntry
in classConnector
- Parameters:
newEntry
- The entry datasearchCrit
- The search criteria used to locate the entry to be modified- Throws:
java.lang.Exception
- if an error occurs.
-
modEntry
public void modEntry(Entry newEntry, SearchCriteria searchCrit, Entry oldEntry) throws java.lang.Exception
Modifies an existing entry. The new entry data is given by the entry parameter and the search criteria specifies which entry to modify.- Specified by:
modEntry
in interfaceConnectorInterface
- Overrides:
modEntry
in classConnector
- Parameters:
newEntry
- The entry datasearchCrit
- The search criteria used to locate the entry to be modifiedoldEntry
- The old entry found by the search criteria- Throws:
java.lang.Exception
- if an error occurs.
-
getVersion
public java.lang.String getVersion()
Version information.- Specified by:
getVersion
in interfaceVersionInfoInterface
- Returns:
- version information
-
-