-
Notifications
You must be signed in to change notification settings - Fork 2
/
PluginManager.bbj
715 lines (548 loc) · 25.4 KB
/
PluginManager.bbj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
use java.util.Base64
use java.util.HashMap
use java.util.Iterator
use java.util.ArrayList
use java.lang.StringBuilder
use java.util.Arrays
use java.lang.reflect.Array
use java.nio.file.StandardCopyOption
use java.nio.file.Files
use com.google.gson.JsonArray
use com.google.gson.JsonObject
use java.io.IOException
use java.io.BufferedReader
use java.io.InputStreamReader
use java.io.File
use ::PluginManager/src/TagVersionComparator.bbj::TagVersionComparator
use ::PluginManager/gen/BBjPluginJsonGenerator.bbj::BBjPluginJsonGenerator
use ::PluginManager/src/Tag.bbj::Tag
use ::PluginManager/src/BBjPlugin.bbj::BBjPlugin
use ::PluginManager/src/RemoteBBjPlugin.bbj::RemoteBBjPlugin
use ::PluginManager/src/GithubApiService.bbj::GithubApiService
use ::PluginManager/src/InstalledBBjPlugin.bbj::InstalledBBjPlugin
use ::PluginManager/src/BBjPluginListParser.bbj::BBjPluginListParser
use ::PluginManager/src/InstallationService.bbj::InstallationService
use ::PluginManager/src/AuthenticationService.bbj::AuthenticationService
use ::PluginManager/src/CustomPluginListHandler.bbj::CustomPluginListHandler
use ::PluginManager/src/InstalledPluginFolderParser.bbj::InstalledPluginFolderParser
use ::PluginManager/update/PluginManagerLauncher.bbj::PluginManagerLauncher
class public PluginManager
field private File pluginsHome!
field private File pluginManagerDirectory!
field private AuthenticationService authService!
field private ArrayList remotePlugins!
field private ArrayList installedPlugins!
field private GithubApiService githubApiService!
field private InstallationService installationService!
field private BBjPluginJsonGenerator pluginJsonGenerator!
field private PluginManagerLauncher pluginManagerLauncher!
field private CustomPluginListHandler customPluginListHandler!
field private InstalledPluginFolderParser pluginFolderParser!
method public PluginManager()
#pluginManagerLauncher! = new PluginManagerLauncher()
#pluginsHome! = #pluginManagerLauncher!.getPluginsHome()
#authService! = new AuthenticationService()
#pluginManagerDirectory! = new File(#pluginsHome!, "PluginManager")
#githubApiService! = new GithubApiService()
#pluginJsonGenerator! = new BBjPluginJsonGenerator()
#installationService! = new InstallationService()
#pluginFolderParser! = new InstalledPluginFolderParser(#this!)
#installedPlugins! = #pluginFolderParser!.getInstalledPlugins(#pluginsHome!)
declare File bbjPluginListFile!
bbjPluginListFile! = new File(#pluginManagerDirectory!, "bbj-plugin-list.json")
#remotePlugins! = BBjPluginListParser.parse(bbjPluginListFile!)
rem Maps the correct plugin names to the installed plugins
rem This method was created because some people used a different plugin
rem name in the bbj-plugin.json than the Github project repository name
#installationService!.mapPluginNames(#installedPlugins!, #remotePlugins!)
declare File customPluginListFile!
customPluginListFile! = new File(#pluginManagerDirectory!, "custom-plugin-list.json")
#customPluginListHandler! = new CustomPluginListHandler(customPluginListFile!)
if(customPluginListFile!.exists()) then
declare ArrayList customSourcePluginList!
customSourcePluginList! = BBjPluginListParser.parse(customPluginListFile!)
if(customSourcePluginList! <> null() AND !customSourcePluginList!.isEmpty()) then
for i=0 to customSourcePluginList!.size()-1
cast(RemoteBBjPlugin, customSourcePluginList!.get(i)).setCustomSourcePlugin(Boolean.TRUE)
next i
#remotePlugins!.addAll(customSourcePluginList!)
endif
endif
rem Adding the RemoteBBjPlugin objects as dependencies for the installed plugins
#pluginFolderParser!.addDependencies(#installedPlugins!)
rem mark plugins as installed or not installed depending on the remote plugin list
#initialisePluginState()
installedVersion = 0
installedVersion = PluginManagerLauncher.getProgramVersion(err=*next)
incorporatedVersion = 0
incorporatedVersion = ::PluginManager/update/PluginManagerLauncher.bbj::PluginManagerLauncher.getProgramVersion(err=*next)
if(incorporatedVersion > installedVersion) then
declare StringBuilder sb!
sb! = new StringBuilder()
sb!.append("An update is available for the PluginManagerLauncher.bbj program.")
sb!.append("Would you like to perform an update (the currently installed program will be renamed so that you can always perform a rollback) ?")
a = msgbox(sb!.toString(), 4)
if(a = 6) then
#updateLauncher()
endif
endif
methodend
method private void updateLauncher()
declare File currentProgramFile!
currentProgramFile! = new File(BBjAPI().getFileSystem().resolvePath("PluginManagerLauncher.bbj"))
declare File backupFile!
backupFile! = new File(#pluginsHome!, "PluginManagerLauncher_back.bbj")
backupFile!.createNewFile()
arr! = Array.newInstance(Class.forName("java.nio.file.StandardCopyOption"), 1)
Array.set(arr!, 0, StandardCopyOption.COPY_ATTRIBUTES)
Array.set(arr!, 0, StandardCopyOption.REPLACE_EXISTING)
Files.move(currentProgramFile!.toPath(), backupFile!.toPath(), arr!)
declare File newProgramFile!
newProgramFile! = new File(#pluginManagerDirectory!, "update/PluginManagerLauncher.bbj")
Files.move(newProgramFile!.toPath(), currentProgramFile!.toPath(), arr!)
methodend
method public void addCustomBBjPluginRepository(String url!, Boolean useCredentials!)
json! = null()
if(useCredentials!) then
username! = #authService!.getUsername()
password! = #authService!.getPassword()
if(username! = null() OR password! = null()) then
throw "Unable to verify the Github credentials", 255
endif
endif
json! = #githubApiService!.getProjectJson(url!, username!, password!)
if(json! = null()) then
throw "Failed to retrieve the project's information", 255
endif
declare JsonObject jsonObject!
jsonObject! = #pluginJsonGenerator!.getProjectJsonObject(json!, username!, password!)
jsonObject!.addProperty("password_required", useCredentials!)
#customPluginListHandler!.addCustomPlugin(jsonObject!)
declare RemoteBBjPlugin remotePlugin!
remotePlugin! = BBjPluginListParser.getRemotePluginFromJson(jsonObject!, #remotePlugins!)
remotePlugin!.setCustomSourcePlugin(Boolean.TRUE)
remotePlugin!.setPasswordRequired(useCredentials!)
#remotePlugins!.add(remotePlugin!)
methodend
method public void removeCustomPluginRepository(RemoteBBjPlugin remotePlugin!)
#customPluginListHandler!.removeCustomPlugin(remotePlugin!.getID())
#remotePlugins!.remove(remotePlugin!)
methodend
method public ArrayList getCustomRemoteBBjPluginList()
declare Iterator it!
it! = #remotePlugins!.iterator()
declare ArrayList customPluginList!
customPluginList! = new ArrayList()
declare RemoteBBjPlugin remotePlugin!
while(it!.hasNext())
remotePlugin! = cast(RemoteBBjPlugin, it!.next())
if(remotePlugin!.isCustomSourcePlugin()) then
customPluginList!.add(remotePlugin!)
endif
wend
methodret customPluginList!
methodend
method public Boolean areGithubCredentialsValid()
username! = #authService!.getUsername()
password! = #authService!.getPassword()
if(username! = null() OR password! = null()) then
throw "Unable to verify the Github credentials", 255
endif
methodret #githubApiService!.areGithubCredentialsValid(username!, password!)
methodend
method public void setGihubCredentials(String username!, String password!, Boolean saveCredentials!)
#authService!.setUsername(username!, saveCredentials!)
#authService!.setPassword(username!, saveCredentials!)
methodend
method public Boolean areGithubCredentialsSaved()
methodret #authService!.isUsernameSaved() OR #authService!.isPasswordSaved()
methodend
method public Boolean isPluginProjectAccessible(String repoURL!, Boolean useCredentials!)
if(useCredentials!) then
username! = #authService!.getUsername()
password! = #authService!.getPassword()
if(username! = null() OR password! = null()) then
throw "Unable to verify the Github credentials", 255
endif
methodret #githubApiService!.isRepositoryAccessible(repoURL!, username!, password!)
endif
methodret #githubApiService!.isRepositoryAccessible(repoURL!)
methodend
rem /**
rem * Parses the installed and remote plugin lists and sets the isInstalled flag for the remote plugins,
rem * the updateAvailable flag for the installed plugins.
rem */
method private void initialisePluginState()
if(#installedPlugins! = null() OR #installedPlugins!.isEmpty()) then
methodret
endif
declare Tag tag!
declare Iterator it!
declare RemoteBBjPlugin remotePlugin!
declare InstalledBBjPlugin installedPlugin!
it! = #installedPlugins!.iterator()
while(it!.hasNext())
installedPlugin! = cast(InstalledBBjPlugin, it!.next())
remotePlugin! = cast(RemoteBBjPlugin, #getRemotePlugin(installedPlugin!.getName()))
if(remotePlugin! = null()) then
continue
endif
rem mark the remote plugin as installed
remotePlugin!.setInstalled(Boolean.TRUE)
tag! = remotePlugin!.getTag(installedPlugin!.getTag().getName())
if(tag! = null()) then
continue
endif
#setUpdateAvailableFlag(installedPlugin!, tag!, remotePlugin!)
wend
methodend
rem /**
rem * Checks if the given InstalledBBPlugin's version(=Tag) can be updated or not.
rem *
rem * If the given Tag is the master tag, the timestamp of the last change and the timestamp of the installation will be compared.
rem * For all other tags, the tag name will be compared.
rem */
method public void setUpdateAvailableFlag(InstalledBBjPlugin installedPlugin!, Tag tag!, RemoteBBjPlugin remotePlugin!)
if(tag!.isMaster()) then
if(tag!.getLastChangeDate().after(installedPlugin!.getInstallationDate())) then
installedPlugin!.setUpdateAvailable(Boolean.TRUE)
endif
methodret
endif
version! = tag!.getName()
rem RemoteBBjPlugin::getTagList(Boolean includeMaster!, Boolean sortByNewestVersion)
rem tagList! = remotePlugin!.getTagList(Boolean.FALSE, Boolean.TRUE)
latestPluginVersionTag! = remotePlugin!.getLatestVersionTag()
latestPluginVersionTagName! = latestPluginVersionTag!.getName()
if(!latestPluginVersionTagName!.equals(version!)) then
rem if #compare(latestPluginVersionTagName!, version!) = 1 then
installedPlugin!.setUpdateAvailable(Boolean.TRUE)
rem endif
endif
methodend
method public BBjPlugin getInstalledPlugin(String pluginName!)
methodret #getBBjPluginFromList(pluginName!, #installedPlugins!)
methodend
rem /**
rem * Returns a list with the available RemoteBBjPlugin objects
rem *
rem * @return A list with the available plugin objects
rem */
method public BBjPlugin getRemotePlugin(String pluginName!)
methodret #getBBjPluginFromList(pluginName!, #remotePlugins!)
methodend
rem /**
rem * Parses the given list of plugin objects, and returns the plugin with the given name or null
rem * if none has the given name.
rem *
rem * @return the plugin with the given name from the given list, or null if none has the given name.
rem */
method private BBjPlugin getBBjPluginFromList(String pluginName!, ArrayList pluginList!)
declare Iterator it!
it! = pluginList!.iterator()
declare BBjPlugin bbjPlugin!
while(it!.hasNext())
bbjPlugin! = cast(BBjPlugin, it!.next())
if(bbjPlugin!.getName().equals(pluginName!)) then
methodret bbjPlugin!
endif
wend
methodret null()
methodend
rem /**
rem * Installes the BBjPlugin with the given name
rem *
rem * @param pluginName! The name of the plugin to install
rem */
method public void installPlugin(RemoteBBjPlugin remotePlugin!, Tag tag!)
declare InstalledBBjPlugin installedPlugin!
if(remotePlugin!.isPasswordRequired()) then
username! = bbjapi().getStbl("gitUsername", err=*next)
password! = bbjapi().getStbl("gitPassword", err=*next)
if(username! = null() OR password! = null()) then
declare BBjThinClient thinClient!
thinClient! = bbjapi().getThinClient()
username! = thinClient!.getUserProperty("gitUsername", err=*next)
password! = thinClient!.getUserProperty("gitPassword", err=*next)
if(username! = null() OR password! = null()) then
throw "Unable to verify the Github credentials", 255
endif
endif
installedPlugin! = #installationService!.installPlugin(remotePlugin!, tag!, username!, password!)
else
installedPlugin! = #installationService!.installPlugin(remotePlugin!, tag!)
endif
if installedPlugin! = null() then
a = msgbox("Failed to install the selected plugin")
methodret
endif
#pluginFolderParser!.setHasConfigurationProgram(installedPlugin!)
#pluginFolderParser!.setHasDemo(installedPlugin!)
#installedPlugins!.add(installedPlugin!)
#setUpdateAvailableFlag(installedPlugin!, installedPlugin!.getTag(), remotePlugin!)
methodend
rem /**
rem * Uninstalls the BBj plugin with the given name.
rem *
rem * @param pluginName! The name of the plugin to uninstall
rem */
method public void uninstallPlugin(String name!)
if(name! = null()) then
throw "Unknown plugin: " + name!, 255
endif
REM serach for plugin
declare Iterator it!
declare ArrayList installedPlugins!
installedPlugins! = #getInstalledPluginList()
it! = installedPlugins!.iterator()
if it!<>null() then
declare InstalledBBjPlugin plugin!
plugin! = cast(InstalledBBjPlugin,it!.next())
if plugin!.getName()=name! then
REM uninstall plugin
#installationService!.uninstallPlugin(plugin!)
methodret
endif
endif
REM error out if nothing was found
throw "Unknown plugin: " + name!, 255
methodend
rem /**
rem * Uninstalls the BBj plugin with the given name.
rem *
rem * @param pluginName! The name of the plugin to uninstall
rem */
method public void uninstallPlugin(InstalledBBjPlugin installedPlugin!)
if(installedPlugin! = null()) then
throw "Unknown plugin: " + pluginName!, 255
endif
#installationService!.uninstallPlugin(installedPlugin!)
rem set the install flag of the remote plugin to false
declare RemoteBBjPlugin remotePlugin!
remotePlugin! = cast(RemoteBBjPlugin, #getRemotePlugin(installedPlugin!.getName()))
rem Check if the plugin's remote pendant exists, which might not always be the case with custom plugins
if(remotePlugin! <> null()) then
remotePlugin!.setInstalled(Boolean.FALSE)
endif
#installedPlugins!.remove(installedPlugin!)
methodend
rem /**
rem * Returns true if the given remote plugin with the given tag is installed,
rem * false otherwise.
rem */
method public Boolean isRemotePluginInstalled(RemoteBBjPlugin remotePlugin!, Tag tag!)
remotePluginId = remotePlugin!.getID()
declare Iterator it!
it! = #installedPlugins!.iterator()
declare InstalledBBjPlugin installedPlugin!
while(it!.hasNext())
installedPlugin! = cast(InstalledBBjPlugin, it!.next())
if(installedPlugin!.getID() = remotePluginId) then
if(installedPlugin!.getTag().getName().equals(tag!.getName())) then
methodret Boolean.TRUE
endif
endif
wend
methodret Boolean.FALSE
methodend
method public ArrayList getInstalledPluginList()
methodret #installedPlugins!
methodend
method public ArrayList getRemotePluginList(Boolean includeDevelopmentPlugins!)
if(includeDevelopmentPlugins!) then
methodret #remotePlugins!
endif
declare RemoteBBjPlugin remotePlugin!
declare ArrayList availablePluginList!
availablePluginList! = new ArrayList()
declare Iterator it!
it! = #remotePlugins!.iterator()
while(it!.hasNext())
remotePlugin! = cast(RemoteBBjPlugin, it!.next())
if(!remotePlugin!.isDevelopmentPlugin()) then
availablePluginList!.add(remotePlugin!)
endif
wend
methodret availablePluginList!
methodend
method public void updatePlugin(InstalledBBjPlugin plugin!)
declare RemoteBBjPlugin remotePlugin!
remotePlugin! = cast(RemoteBBjPlugin, #getRemotePlugin(plugin!.getName()))
if(remotePlugin! = null()) then
throw "Missing BBj Plugin project", 260
methodret
endif
declare Tag tag!
tag! = cast(Tag, remotePlugin!.getTag(plugin!.getTag().getName()))
if(tag! = null()) then
throw "Unknown Version Tag", 260
methodret
endif
if(!tag!.isMaster()) then
latestVersionTagName! = tag!.getName()
declare Tag currentTag!
declare ArrayList tagList!
tagList! = remotePlugin!.getTagList(Boolean.FALSE, Boolean.TRUE)
java.util.Collections.sort(tagList!, new TagVersionComparator())
tag! = cast(Tag, tagList!.get(0))
rem TODO
rem declare Iterator it!
rem it! = tagList!.iterator()
rem while(it!.hasNext())
rem currentTag! = cast(Tag, it!.next())
rem if #compare(currentTag!.getName(), tag!.getName()) = 1 then
rem rem if(num(currentTag!.getName()) > num(tag!.getName())) then
rem latestVersionTagName! = currentTag!.getName()
rem break
rem endif
rem wend
rem tag! = cast(Tag, remotePlugin!.getTag(latestVersionTagName!))
endif
rem TODO Make sure not to delete any files that the user created
#installationService!.uninstallPlugin(plugin!)
#installedPlugins!.remove(plugin!)
declare InstalledBBjPlugin installedPlugin!
installedPlugin! = #installationService!.installPlugin(remotePlugin!, tag!)
#pluginFolderParser!.setHasDemo(installedPlugin!)
#pluginFolderParser!.setHasConfigurationProgram(installedPlugin!)
plugin!.setInstallationDate(new java.util.Date())
plugin!.setLastChangedDate(tag!.getLastChangeDate())
#installedPlugins!.add(installedPlugin!)
methodend
rem /**
rem * Executes the Demo.bbj file in the given plugin's Demo folder.
rem */
method public void runDemo(InstalledBBjPlugin installedPlugin!, String demoProgramName!)
demoFolder! = new File(installedPlugin!.getInstallationDirectory(), "Demo")
if !demoFolder!.exists() then
demoFolder! = new File(installedPlugin!.getInstallationDirectory(), "demo")
endif
REM get my Current CommandLine object
myCFG! = BBjAPI().getConfig().getCurrentCommandLineObject()
myCFG!.setQuiet(Boolean.TRUE)
myCFG!.setProgramName(demoFolder!.getAbsolutePath() + File.separator + demoProgramName!)
REM Run my new BBj Session with my CommandLine Object
x = BBjAPI().newBBjSession(myCFG!)
methodend
rem /**
rem * Runs the given plugin's configuration program with the given name.
rem *
rem * @param installedPlugin! The installed plugin whose configuration program will be run
rem * @param configProgramName! The name of the configuration program to run
rem */
method public void runConfigurationProgram(InstalledBBjPlugin installedPlugin!, String configProgramName!)
if(!installedPlugin!.hasConfigurationProgram()) then
methodret
endif
pluginDirectory! = installedPlugin!.getInstallationDirectory().toString() + File.separator + "cfg"
command! = argv(0) + " -q " + "-WD" + pluginDirectory! + " " + configProgramName!
print "launching: " + command!
a = scall(command! + " &")
methodend
method public Boolean hasDependencies(Tag tag!)
if(#hasBBjDependency(tag!) OR #hasDependenciesToBBjPlugins(tag!)) then
methodret Boolean.TRUE
endif
methodret Boolean.FALSE
methodend
rem /**
rem * Returns true if the given Tag object has a dependency to a specific BBj Revision, false otherwise.
rem *
rem * @return true if the plugin has a dependency to a BBj revision, false otherwise.
rem */
method public Boolean hasBBjDependency(Tag tag!)
if(tag! = null()) then
throw "null object: tag!", 255
endif
if(tag!.getBBjDependency() <> null() AND !tag!.getBBjDependency().isEmpty()) then
methodret Boolean.TRUE
endif
methodret Boolean.FALSE
methodend
rem /**
rem * Returns true if the plugin with the given name and the given tag name
rem * has dependencies to other plugins, false otherwise.
rem *
rem * @param pluginName! The name of the plugin.
rem * @param tagName! The name of the plugin's tag.
rem *
rem * @return true if the plugin has dependencies to BBj Plugins, false otherwise.
rem */
method public Boolean hasDependenciesToBBjPlugins(Tag tag!)
if(tag! = null()) then
throw "null object: tag!" , 255
endif
methodret !tag!.getPluginDependencyMap().isEmpty()
methodend
method public Tag getRemotePluginTag(String pluginName!, String tagName!)
declare RemoteBBjPlugin remotePlugin!
remotePlugin! = cast(RemoteBBjPlugin, #getRemotePlugin(pluginName!))
if(remotePlugin! = null()) then
throw "Unknown plugin: " + pluginName!, 255
endif
if(!remotePlugin!.hasTag(tagName!)) then
throw "Unknown Tag: " + tagName!, 255
endif
methodret remotePlugin!.getTag(tagName!)
methodend
method public Boolean areDependenciesInstalled(Tag tag!)
if(tag! = null()) then
throw "null object: tag!", 255
endif
declare HashMap dependencyMap!
dependencyMap! = tag!.getPluginDependencyMap()
declare Tag dependencyTag!
declare RemoteBBjPlugin remotePlugin!
declare Iterator it!
it! = dependencyMap!.entrySet().iterator()
while(it!.hasNext())
entry! = it!.next()
remotePlugin! = cast(RemoteBBjPlugin, entry!.getKey())
dependencyTag! = cast(Tag, entry!.getValue())
if(!#isRemotePluginInstalled(remotePlugin!, dependencyTag!)) then
methodret Boolean.FALSE
endif
wend
methodret Boolean.TRUE
methodend
rem /**
rem * Returns true if the installed BBj Version is newer than the specified min version
rem */
method public Boolean isBBjVersionValid(Tag tag!)
if(tag! = null()) then
throw "null object: tag!" , 255
endif
if(!#hasBBjDependency(tag!)) then
methodret Boolean.TRUE
endif
if("REV " + str(tag!.getBBjDependency()) <= REV) then
methodret Boolean.TRUE
endif
methodret Boolean.FALSE
methodend
method public Boolean isDependency(InstalledBBjPlugin bbjPlugin!)
methodret !#getDependentPlugins(bbjPlugin!).isEmpty()
methodend
method public ArrayList getDependentPlugins(InstalledBBjPlugin bbjPlugin!)
if(bbjPlugin! = null()) then
throw "null object: bbjPlugin!",255
endif
declare ArrayList dependentPlugins!
declare RemoteBBjPlugin remotePlugin!
declare InstalledBBjPlugin installedPlugin!
dependentPlugins! = new ArrayList()
remotePlugin! = cast(RemoteBBjPlugin, #getRemotePlugin(bbjPlugin!.getName()))
declare Iterator it!
it! = #installedPlugins!.iterator()
while(it!.hasNext())
installedPlugin! = cast(InstalledBBjPlugin,it!.next())
if(installedPlugin!.getID() = bbjPlugin!.getID()) then
continue
endif
if(installedPlugin!.getTag().getPluginDependencyMap().containsKey(remotePlugin!)) then
dependentPlugins!.add(installedPlugin!)
endif
wend
methodret dependentPlugins!
methodend
classend