Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Add more methods to file connectors #18

Merged
merged 5 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ class FileSystemActor extends Actor {
}
case CreateDirectory(folderName) =>
try {
sender ! fixPath(folderName).mkdir()
sender ! fixPath(folderName).mkdirs()
} catch {
case _: Exception => sender ! false
}
case Exists(pathInResources) =>
try {
sender ! fixPath(pathInResources).exists
} catch {
case _: Exception => sender ! false
}
case Delete(pathInResources) =>
try{
sender ! fixPath(pathInResources).delete
} catch {
case _: Exception => sender ! false
}
Expand Down Expand Up @@ -124,4 +136,18 @@ object FileSystemActor {
*/
case class CreateDirectory(folderName: String) extends ActorMessage

/**
* Send a Exists-Object to the FileSystemActor to check if a file or folder exists
*
* @param pathInResources the relative Path in the resource folder
*/
case class Exists(pathInResources: String) extends ActorMessage

/**
* Send a Delete-Object to the FileSystemActor to remove a file or folder
*
* @param pathInResources the relative Path in the resource folder
*/
case class Delete(pathInResources: String) extends ActorMessage

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class FileConnector(override val sourceIdentifier: String) extends Connector(sou

def createDirectory(folderName: String): Boolean = fileActor.??[Boolean](5){CreateDirectory(folderName)}.get

def exists(pathInResources: String): Boolean = fileActor.??[Boolean](5){Exists(pathInResources)}.get

def delete(pathInResources: String): Boolean = fileActor.??[Boolean](5){Delete(pathInResources)}.get

override def start(): Boolean = {
logger info s"Started file connector! Source identifier is: '$sourceIdentifier'."
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class FileOutputImpl extends OutputImpl[FileConnector] with FileOutput with With
sourceConnector.get.createDirectory(folderName)
}

override def exists(pathInResources: String): Boolean = {
sourceConnector.get.exists(pathInResources)
}

override def delete(pathInResources: String): Boolean = {
sourceConnector.get.delete(pathInResources)
}

override def start() = true

}