1
1
"use strict" ;
2
2
3
3
const { Result } = require ( "./types" ) ;
4
+ const { RepositoryOps } = require ( "./operations" ) ;
4
5
const g_lib = require ( "../support" ) ;
5
6
6
7
/**
@@ -137,11 +138,6 @@ const validateGlobusConfig = (config) => {
137
138
errors . push ( endpointValidation . error . message ) ;
138
139
}
139
140
140
- const domainValidation = validateNonEmptyString ( config . domain , "Domain" ) ;
141
- if ( ! domainValidation . ok ) {
142
- errors . push ( domainValidation . error . message ) ;
143
- }
144
-
145
141
if ( errors . length > 0 ) {
146
142
return Result . err ( {
147
143
code : g_lib . ERR_INVALID_PARAM ,
@@ -175,7 +171,7 @@ const validateMetadataConfig = (config) => {
175
171
176
172
// Metadata repositories don't need Globus-specific fields
177
173
// But should not have them either
178
- const invalidFields = [ "pub_key" , "address" , "endpoint" , "path" , "exp_path" , "domain" ] ;
174
+ const invalidFields = [ "pub_key" , "address" , "endpoint" , "path" , "exp_path" ] ;
179
175
const presentInvalidFields = invalidFields . filter ( ( field ) => config [ field ] !== undefined ) ;
180
176
181
177
if ( presentInvalidFields . length > 0 ) {
@@ -215,6 +211,29 @@ const validateAllocationParams = (params) => {
215
211
return Result . ok ( true ) ;
216
212
} ;
217
213
214
+ // Validates that a repository supports data operations
215
+ const validateRepositorySupportsDataOperations = ( repoId , dataId , errorMessage ) => {
216
+ const findResult = RepositoryOps . find ( repoId ) ;
217
+ if ( findResult . ok ) {
218
+ const repository = findResult . value ;
219
+ const dataOpsResult = RepositoryOps . supportsDataOperations ( repository ) ;
220
+
221
+ if ( dataOpsResult . ok && ! dataOpsResult . value ) {
222
+ const defaultMessage =
223
+ errorMessage || `Data operations not supported for ${ repository . type } repository` ;
224
+ throw [
225
+ g_lib . ERR_INVALID_OPERATION ,
226
+ defaultMessage ,
227
+ {
228
+ repo_type : repository . type ,
229
+ repo_id : repository . data . _id ,
230
+ data_id : dataId ,
231
+ } ,
232
+ ] ;
233
+ }
234
+ }
235
+ } ;
236
+
218
237
module . exports = {
219
238
validateNonEmptyString,
220
239
validateCommonFields,
@@ -223,4 +242,5 @@ module.exports = {
223
242
validateGlobusConfig,
224
243
validateMetadataConfig,
225
244
validateAllocationParams,
245
+ validateRepositorySupportsDataOperations,
226
246
} ;
0 commit comments