@@ -45,7 +45,7 @@ public class PrepareDataBase {
45
45
String date ;
46
46
47
47
@ Bean
48
- @ Profile ({"dev" , "prod, stage" })
48
+ @ Profile ({"dev" , "prod, stage" , "debug" })
49
49
@ Autowired
50
50
CommandLineRunner veryImportantFileFighterStartScript (Environment environment ) {
51
51
return args -> {
@@ -70,12 +70,6 @@ CommandLineRunner veryImportantFileFighterStartScript(Environment environment) {
70
70
System .out .println ();
71
71
System .out .println ("-------------------------------< REST API >-------------------------------" );
72
72
System .out .println ();
73
-
74
- /*
75
- System.out.println("╭---╮")
76
- System.out.println("| |")
77
- System.out.println("╰---╯")
78
- */
79
73
};
80
74
}
81
75
@@ -91,26 +85,28 @@ CommandLineRunner initDataBaseProd(UserRepository userRepository, FileSystemRepo
91
85
addDefaultAdminAndRuntimeUser (userRepository );
92
86
log .info ("Inserting Home directories and default structure: {} {}." , fileSystemRepository .save (FileSystemEntity
93
87
.builder ()
94
- .createdByUserId (RUNTIME_USER_ID )
88
+ .lastUpdatedBy (RUNTIME_USER_ID )
89
+ .lastUpdated (Instant .now ().getEpochSecond ())
90
+ .ownerId (1 )
95
91
.fileSystemId (0 )
96
92
.isFile (false )
97
93
.path ("/" )
98
94
.itemIds (new long [0 ])
99
- .lastUpdated (Instant .now ().getEpochSecond ())
100
- .name ("HOME_Admin" )
95
+ .name ("HOME_1" )
101
96
.size (420 )
102
97
.typeId (FOLDER .getId ())
103
98
.visibleForGroupIds (new long []{UNDEFINED .getGroupId (), FAMILY .getGroupId (), ADMIN .getGroupId ()})
104
99
.itemIds (new long []{1 })
105
100
.build ()),
106
101
fileSystemRepository .save (FileSystemEntity .builder ()
107
- .createdByUserId (1 )
108
- .fileSystemId (1 )
109
- .isFile (true )
102
+ .lastUpdatedBy (RUNTIME_USER_ID )
110
103
.lastUpdated (Instant .now ().getEpochSecond ())
104
+ .ownerId (1 ).fileSystemId (1 )
105
+ .isFile (true )
111
106
.name ("dummyFile.txt" )
112
107
.size (420 )
113
108
.typeId (TEXT .getId ())
109
+ .mimeType ("text/plain" )
114
110
.editableFoGroupIds (new long []{FAMILY .getGroupId ()})
115
111
.visibleForGroupIds (new long []{FAMILY .getGroupId ()})
116
112
.build ()));
@@ -136,7 +132,7 @@ CommandLineRunner initDataBaseProd(UserRepository userRepository, FileSystemRepo
136
132
}
137
133
138
134
@ Bean
139
- @ Profile ("dev" )
135
+ @ Profile ({ "dev" , "debug" } )
140
136
CommandLineRunner initDataBaseDev (UserRepository userRepository , AccessTokenRepository accessTokenRepository , FileSystemRepository fileSystemRepository ) {
141
137
return args -> {
142
138
log .info ("Starting with clean user collection." );
@@ -198,7 +194,7 @@ CommandLineRunner initDataBaseDev(UserRepository userRepository, AccessTokenRepo
198
194
log .error ("Inserting Users " + MESSAGE_ON_FAILURE );
199
195
}
200
196
201
- if (fileSystemRepository .findAll ().size () == 6 ) {
197
+ if (fileSystemRepository .findAll ().size () == 8 ) {
202
198
log .info ("Inserting FileSystemEntities " + MESSAGE_ON_SUCCESS );
203
199
} else {
204
200
log .error ("Inserting FileSystemEntities " + MESSAGE_ON_FAILURE );
@@ -266,75 +262,111 @@ private void addDefaultAdminAndRuntimeUser(UserRepository userRepository) {
266
262
}
267
263
268
264
private void addTestingFileSystemItems (FileSystemRepository fileSystemRepository ) {
269
- log .info ("Inserting default fsItems:\n {}\n {}\n {}\n {}\n {}\n {}." ,
265
+ log .info ("Inserting default fsItems:\n {}\n {}\n {}\n {}\n {}\n {}\n {} \n {} ." ,
270
266
fileSystemRepository .save (FileSystemEntity .builder ()
271
- .createdByUserId (RUNTIME_USER_ID )
267
+ .lastUpdatedBy (RUNTIME_USER_ID )
268
+ .ownerId (1 )
269
+ .lastUpdated (Instant .now ().getEpochSecond ())
272
270
.fileSystemId (0 )
273
271
.isFile (false )
274
272
.path ("/" )
275
- .itemIds (new long []{2 , 3 })
276
- .lastUpdated (Instant .now ().getEpochSecond ())
277
- .name ("HOME_User" )
273
+ .name ("HOME_1" )
278
274
.size (4866 )
279
275
.typeId (FOLDER .getId ())
276
+ .itemIds (new long []{2 , 3 , 7 })
280
277
.visibleForGroupIds (new long []{FAMILY .getGroupId (), ADMIN .getGroupId ()})
278
+ .visibleForUserIds (new long []{0 })
279
+ .editableForUserIds (new long []{0 })
281
280
.build ()),
282
281
fileSystemRepository .save (FileSystemEntity .builder ()
283
- .createdByUserId (RUNTIME_USER_ID )
282
+ .lastUpdatedBy (RUNTIME_USER_ID )
283
+ .lastUpdated (Instant .now ().getEpochSecond ())
284
+ .ownerId (2 )
284
285
.fileSystemId (1 )
285
286
.isFile (false )
286
287
.path ("/" )
287
- .lastUpdated (Instant .now ().getEpochSecond ())
288
- .name ("HOME_User1" )
288
+ .name ("HOME_2" )
289
289
.size (0 )
290
290
.typeId (FOLDER .getId ())
291
291
.visibleForGroupIds (new long []{UNDEFINED .getGroupId (), FAMILY .getGroupId (), ADMIN .getGroupId ()})
292
+ .visibleForUserIds (new long []{1 })
293
+ .editableForUserIds (new long []{1 })
292
294
.build ()),
293
295
fileSystemRepository .save (FileSystemEntity .builder ()
294
- .createdByUserId (1 )
296
+ .lastUpdatedBy (1 )
297
+ .lastUpdated (Instant .now ().getEpochSecond ())
298
+ .ownerId (1 )
295
299
.fileSystemId (2 )
296
300
.isFile (true )
297
- .lastUpdated (Instant .now ().getEpochSecond ())
298
301
.name ("dummyFile.txt" )
299
302
.size (420 )
300
303
.typeId (TEXT .getId ())
304
+ .mimeType ("text/plain" )
301
305
.editableFoGroupIds (new long []{FAMILY .getGroupId ()})
302
306
.visibleForGroupIds (new long []{FAMILY .getGroupId ()})
303
307
.build ()),
304
308
fileSystemRepository .save (FileSystemEntity .builder ()
305
- .createdByUserId (1 )
309
+ .lastUpdatedBy (1 )
310
+ .lastUpdated (Instant .now ().getEpochSecond ())
311
+ .ownerId (1 )
312
+ .fileSystemId (7 )
313
+ .isFile (true )
314
+ .name ("visibleNonDeletableText.tex" )
315
+ .size (42 )
316
+ .typeId (TEXT .getId ())
317
+ .mimeType ("text/plain" )
318
+ .visibleForGroupIds (new long []{FAMILY .getGroupId ()})
319
+ .build ()),
320
+ fileSystemRepository .save (FileSystemEntity .builder ()
321
+ .lastUpdatedBy (1 )
322
+ .lastUpdated (Instant .now ().getEpochSecond ())
323
+ .ownerId (1 )
306
324
.fileSystemId (3 )
307
325
.isFile (false )
308
326
.path ("/somefolder" )
309
327
.name ("SomeFolder" )
310
- .lastUpdated (Instant .now ().getEpochSecond ())
311
328
.size (4446 )
312
329
.typeId (FOLDER .getId ())
313
330
.editableFoGroupIds (new long []{FAMILY .getGroupId ()})
314
331
.visibleForGroupIds (new long []{FAMILY .getGroupId ()})
315
- .itemIds (new long []{4 , 5 })
332
+ .itemIds (new long []{4 , 5 , 6 })
316
333
.build ()),
317
334
fileSystemRepository .save (FileSystemEntity .builder ()
318
- .createdByUserId (1 )
335
+ .lastUpdatedBy (1 )
336
+ .lastUpdated (Instant .now ().getEpochSecond ())
337
+ .ownerId (1 )
319
338
.fileSystemId (4 )
320
339
.isFile (true )
321
- .lastUpdated (Instant .now ().getEpochSecond ())
322
340
.name ("secretFileInSomeFolder.txt" )
323
341
.size (3214 )
324
342
.typeId (TEXT .getId ())
343
+ .mimeType ("text/plain" )
325
344
.editableFoGroupIds (new long []{FAMILY .getGroupId ()})
326
345
.visibleForGroupIds (new long []{FAMILY .getGroupId ()})
327
346
.build ()),
328
347
fileSystemRepository .save (FileSystemEntity .builder ()
329
- .createdByUserId (1 )
348
+ .lastUpdatedBy (1 )
349
+ .lastUpdated (Instant .now ().getEpochSecond ())
350
+ .ownerId (1 )
330
351
.fileSystemId (5 )
331
352
.isFile (true )
332
- .lastUpdated (Instant .now ().getEpochSecond ())
333
353
.name ("definitelyNotPorn.mp4" )
334
354
.size (1232 )
335
355
.typeId (VIDEO .getId ())
356
+ .mimeType ("video/mp4" )
336
357
.editableFoGroupIds (new long []{FAMILY .getGroupId ()})
337
358
.visibleForGroupIds (new long []{FAMILY .getGroupId ()})
359
+ .build ()),
360
+ fileSystemRepository .save (FileSystemEntity .builder ()
361
+ .lastUpdatedBy (1 )
362
+ .lastUpdated (Instant .now ().getEpochSecond ())
363
+ .ownerId (1 )
364
+ .fileSystemId (6 )
365
+ .isFile (true )
366
+ .name ("invisible_secret_video.mp4" )
367
+ .size (1232 )
368
+ .typeId (VIDEO .getId ())
369
+ .mimeType ("video/mp4" )
338
370
.build ())
339
371
);
340
372
}
0 commit comments