-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for bulk copying files to another project
- Loading branch information
Showing
29 changed files
with
748 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/model/CopyFileDestination.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model | ||
|
||
import ch.epfl.bluebrain.nexus.delta.sdk.model.IdSegment | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag | ||
|
||
/** | ||
* Details of the file we're creating in the copy | ||
* | ||
* @param project | ||
* Orgnization and project for the new file | ||
* @param fileId | ||
* Optional identifier for the new file | ||
* @param storage | ||
* Optional storage for the new file which must have the same type as the source file's storage | ||
* @param tag | ||
* Optional tag to create the new file with | ||
* @param filename | ||
* Optional filename for the new file. If omitted, the source filename will be used | ||
*/ | ||
final case class CopyFileDestination( | ||
project: ProjectRef, | ||
fileId: Option[IdSegment], | ||
storage: Option[IdSegment], | ||
tag: Option[UserTag], | ||
filename: Option[String] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...in/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/routes/CopyFilePayload.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package ch.epfl.bluebrain.nexus.delta.plugins.storage.files.routes | ||
|
||
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.FileId | ||
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.FileRejection.InvalidFileLookup | ||
import ch.epfl.bluebrain.nexus.delta.sdk.model.IdSegment | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag | ||
import io.circe.Decoder | ||
|
||
final case class CopyFilePayload( | ||
destFilename: Option[String], | ||
sourceProj: ProjectRef, | ||
sourceFile: IdSegment, | ||
sourceTag: Option[UserTag], | ||
sourceRev: Option[Int] | ||
) { | ||
def toSourceFileId: Either[InvalidFileLookup, FileId] = (sourceTag, sourceRev) match { | ||
case (Some(tag), None) => Right(FileId(sourceFile, tag, sourceProj)) | ||
case (None, Some(rev)) => Right(FileId(sourceFile, rev, sourceProj)) | ||
case (None, None) => Right(FileId(sourceFile, sourceProj)) | ||
case (Some(_), Some(_)) => Left(InvalidFileLookup(sourceFile)) | ||
} | ||
} | ||
|
||
object CopyFilePayload { | ||
|
||
implicit val dec: Decoder[CopyFilePayload] = Decoder.instance { cur => | ||
for { | ||
destFilename <- cur.get[Option[String]]("destinationFilename") | ||
sourceProj <- cur.get[ProjectRef]("sourceProjectRef") | ||
sourceFileId <- cur.get[String]("sourceFileId").map(IdSegment(_)) | ||
sourceTag <- cur.get[Option[UserTag]]("sourceTag") | ||
sourceRev <- cur.get[Option[Int]]("sourceRev") | ||
} yield CopyFilePayload(destFilename, sourceProj, sourceFileId, sourceTag, sourceRev) | ||
} | ||
} |
Oops, something went wrong.