1
1
package com .scalableminds .webknossos .datastore .explore
2
2
3
3
import com .scalableminds .util .geometry .Vec3Int
4
+ import com .scalableminds .util .mvc .Formatter
4
5
import com .scalableminds .util .tools .{Fox , FoxImplicits }
5
6
import com .scalableminds .webknossos .datastore .DataStoreConfig
6
7
import com .scalableminds .webknossos .datastore .datavault .VaultPath
@@ -16,6 +17,7 @@ import com.scalableminds.webknossos.datastore.storage.{DataVaultCredential, Data
16
17
import com .typesafe .scalalogging .LazyLogging
17
18
import net .liftweb .common .Box .tryo
18
19
import net .liftweb .common .{Box , Empty , Failure , Full }
20
+ import play .api .i18n .MessagesProvider
19
21
import play .api .libs .json .{Json , OFormat }
20
22
21
23
import java .net .URI
@@ -49,10 +51,12 @@ class ExploreRemoteLayerService @Inject()(dataVaultService: DataVaultService,
49
51
dataStoreConfig : DataStoreConfig )
50
52
extends ExploreLayerUtils
51
53
with FoxImplicits
54
+ with Formatter
52
55
with LazyLogging {
53
56
54
57
def exploreRemoteDatasource (parameters : List [ExploreRemoteLayerParameters ], reportMutable : ListBuffer [String ])(
55
- implicit ec : ExecutionContext ): Fox [GenericDataSource [DataLayer ]] =
58
+ implicit ec : ExecutionContext ,
59
+ mp : MessagesProvider ): Fox [GenericDataSource [DataLayer ]] =
56
60
for {
57
61
exploredLayersNested <- Fox .serialCombined(parameters)(
58
62
parameters =>
@@ -75,7 +79,8 @@ class ExploreRemoteLayerService @Inject()(dataVaultService: DataVaultService,
75
79
private def exploreRemoteLayersForOneUri (layerUri : String ,
76
80
credentialId : Option [String ],
77
81
reportMutable : ListBuffer [String ])(
78
- implicit ec : ExecutionContext ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] =
82
+ implicit ec : ExecutionContext ,
83
+ mp : MessagesProvider ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] =
79
84
for {
80
85
uri <- tryo(new URI (removeNeuroglancerPrefixesFromUri(removeHeaderFileNamesFromUriSuffix(layerUri)))) ?~> s " Received invalid URI: $layerUri"
81
86
_ <- bool2Fox(uri.getScheme != null ) ?~> s " Received invalid URI: $layerUri"
@@ -116,7 +121,8 @@ class ExploreRemoteLayerService @Inject()(dataVaultService: DataVaultService,
116
121
credentialId : Option [String ],
117
122
explorers : List [RemoteLayerExplorer ],
118
123
reportMutable : ListBuffer [String ])(
119
- implicit ec : ExecutionContext ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] =
124
+ implicit ec : ExecutionContext ,
125
+ mp : MessagesProvider ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] =
120
126
remotePathsWithDepth match {
121
127
case Nil =>
122
128
Fox .empty
@@ -139,7 +145,8 @@ class ExploreRemoteLayerService @Inject()(dataVaultService: DataVaultService,
139
145
explorers : List [RemoteLayerExplorer ],
140
146
credentialId : Option [String ],
141
147
reportMutable : ListBuffer [String ])(
142
- implicit ec : ExecutionContext ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] =
148
+ implicit ec : ExecutionContext ,
149
+ mp : MessagesProvider ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] =
143
150
Fox
144
151
.sequence(explorers.map { explorer =>
145
152
{
@@ -160,12 +167,13 @@ class ExploreRemoteLayerService @Inject()(dataVaultService: DataVaultService,
160
167
explorer : RemoteLayerExplorer ,
161
168
path : VaultPath ,
162
169
reportMutable : ListBuffer [String ])(
163
- implicit ec : ExecutionContext ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] = explorationResult match {
170
+ implicit ec : ExecutionContext ,
171
+ mp : MessagesProvider ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] = explorationResult match {
164
172
case Full (layersWithVoxelSizes) =>
165
173
reportMutable += s " Found ${layersWithVoxelSizes.length} ${explorer.name} layers at $path. "
166
174
Fox .successful(layersWithVoxelSizes)
167
175
case f : Failure =>
168
- reportMutable += s " Error when reading $path as ${explorer.name}: ${Fox .failureChainAsString(f )}"
176
+ reportMutable += s " Error when reading $path as ${explorer.name}: ${formatFailureChain(f, messagesProviderOpt = Some (mp) )}"
169
177
Fox .empty
170
178
case Empty =>
171
179
reportMutable += s " Error when reading $path as ${explorer.name}: Empty "
@@ -179,7 +187,8 @@ class ExploreRemoteLayerService @Inject()(dataVaultService: DataVaultService,
179
187
credentialId : Option [String ],
180
188
explorers : List [RemoteLayerExplorer ],
181
189
reportMutable : ListBuffer [String ])(
182
- implicit ec : ExecutionContext ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] =
190
+ implicit ec : ExecutionContext ,
191
+ mp : MessagesProvider ): Fox [List [(DataLayerWithMagLocators , VoxelSize )]] =
183
192
explorationResultOfPath match {
184
193
case Full (layersWithVoxelSizes) =>
185
194
Fox .successful(layersWithVoxelSizes)
0 commit comments