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
|
package org.openecomp.core.tools.main;
import org.openecomp.core.tools.commands.AddContributorCommand;
import org.openecomp.core.tools.commands.HealAll;
import org.openecomp.core.tools.commands.PopulateUserPermissions;
import org.openecomp.core.tools.commands.SetHealingFlag;
import org.openecomp.core.tools.exportinfo.ExportDataCommand;
import org.openecomp.core.tools.importinfo.ImportDataCommand;
import org.openecomp.core.tools.util.ToolsUtil;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import java.time.Duration;
import java.time.Instant;
import static org.openecomp.core.tools.util.Utils.printMessage;
public class ZusammenMainTool {
private static final String GLOBAL_USER = "GLOBAL_USER";
private static Logger logger = LoggerFactory.getLogger(ZusammenMainTool.class);
private static int status = 0;
public static void main(String[] args) {
COMMANDS command = getCommand(args);
if (command == null) {
printMessage(logger,
"parameter -c is mandatory. script usage: zusammenMainTool.sh -c {command name} " +
"[additional arguments depending on the command] ");
printMessage(logger,
"reset old version: -c RESET_OLD_VERSION [-v {version}]");
printMessage(logger,
"export: -c EXPORT [-i {item id}]");
printMessage(logger,
"import: -c IMPORT -f {zip file full path}");
printMessage(logger,
"heal all: -c HEAL_ALL [-t {number of threads}]");
printMessage(logger,
"add users as contributors: -c ADD_CONTRIBUTOR [-p {item id list file path}] -u {user " +
"list file path}");
System.exit(-1);
}
Instant startTime = Instant.now();
SessionContextProviderFactory.getInstance().createInterface().create(GLOBAL_USER, "dox");
switch (command) {
case RESET_OLD_VERSION:
SetHealingFlag.populateHealingTable(ToolsUtil.getParam("v", args));
break;
case EXPORT:
ExportDataCommand.exportData(ToolsUtil.getParam("i", args));
break;
case IMPORT:
ImportDataCommand.execute(ToolsUtil.getParam("f", args));
break;
case HEAL_ALL:
HealAll.healAll(ToolsUtil.getParam("t", args));
break;
case POPULATE_USER_PERMISSIONS:
PopulateUserPermissions.execute();
break;
case ADD_CONTRIBUTOR:
AddContributorCommand.add(ToolsUtil.getParam("p", args), ToolsUtil.getParam("u", args));
}
Instant stopTime = Instant.now();
Duration duration = Duration.between(startTime, stopTime);
long minutesPart = duration.toMinutes();
long secondsPart = duration.minusMinutes(minutesPart).getSeconds();
printMessage(logger,
"Zusammen tools command:[] finished . Total run time was : " + minutesPart + ":" +
secondsPart
+ " minutes");
System.exit(status);
}
private static COMMANDS getCommand(String[] args) {
String commandSrt = ToolsUtil.getParam("c", args);
try {
return COMMANDS.valueOf(commandSrt);
} catch (IllegalArgumentException iae) {
printMessage(logger, "message:" + commandSrt + " is illegal.");
}
return null;
}
private enum COMMANDS {
RESET_OLD_VERSION,
EXPORT,
IMPORT,
HEAL_ALL,
POPULATE_USER_PERMISSIONS,
ADD_CONTRIBUTOR
}
}
|