Skip to content

Commit 133c2c0

Browse files
committed
Add support for custom GUI labels to the GUI whitelabel runtime system
1 parent 2fd83e1 commit 133c2c0

15 files changed

Lines changed: 116 additions & 13 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,7 @@ public class ApiConstants {
13971397
public static final String CSS = "css";
13981398

13991399
public static final String JSON_CONFIGURATION = "jsonconfiguration";
1400+
public static final String CUSTOM_LABELS_PATH = "customlabelspath";
14001401

14011402
public static final String COMMON_NAMES = "commonnames";
14021403

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public class CreateGuiThemeCmd extends BaseCmd {
5353
"retrieved and imported into the GUI when matching the theme access configurations.")
5454
private String jsonConfiguration;
5555

56+
@Parameter(name = ApiConstants.CUSTOM_LABELS_PATH, type = CommandType.STRING, length = 65535, description = "The JSON with the custom labels to be " +
57+
"retrieved and imported into the GUI when matching the theme access configurations.")
58+
private String customLabelsPath;
59+
5660
@Parameter(name = ApiConstants.COMMON_NAMES, type = CommandType.STRING, length = 65535, description = "A set of Common Names (CN) (fixed or " +
5761
"wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com")
5862
private String commonNames;
@@ -89,6 +93,10 @@ public String getJsonConfiguration() {
8993
return jsonConfiguration;
9094
}
9195

96+
public String getCustomLabelsPath() {
97+
return customLabelsPath;
98+
}
99+
92100
public String getCommonNames() {
93101
return commonNames;
94102
}

api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/UpdateGuiThemeCmd.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public class UpdateGuiThemeCmd extends BaseCmd {
5656
"retrieved and imported into the GUI when matching the theme access configurations.")
5757
private String jsonConfiguration;
5858

59+
@Parameter(name = ApiConstants.CUSTOM_LABELS_PATH, type = CommandType.STRING, length = 65535, description = "The JSON with the custom labels to be " +
60+
"retrieved and imported into the GUI when matching the theme access configurations.")
61+
private String customLabelsPath;
62+
5963
@Parameter(name = ApiConstants.COMMON_NAMES, type = CommandType.STRING, length = 65535, description = "A set of Common Names (CN) (fixed or " +
6064
"wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com")
6165
private String commonNames;
@@ -96,6 +100,10 @@ public String getJsonConfiguration() {
96100
return jsonConfiguration;
97101
}
98102

103+
public String getCustomLabelsPath() {
104+
return customLabelsPath;
105+
}
106+
99107
public String getCommonNames() {
100108
return commonNames;
101109
}

api/src/main/java/org/apache/cloudstack/api/response/GuiThemeResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public class GuiThemeResponse extends BaseResponse {
4848
@Param(description = "The JSON with the configurations to be retrieved and imported into the GUI when matching the theme access configurations.")
4949
private String jsonConfiguration;
5050

51+
@SerializedName(ApiConstants.CUSTOM_LABELS_PATH)
52+
@Param(description = "The JSON with the custom labels to be retrieved and imported into the GUI when matching the theme access configurations.")
53+
private String customLabelsPath;
54+
5155
@SerializedName(ApiConstants.COMMON_NAMES)
5256
@Param(description = "A set of Common Names (CN) (fixed or wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com")
5357
private String commonNames;
@@ -121,6 +125,14 @@ public void setJsonConfiguration(String jsonConfiguration) {
121125
this.jsonConfiguration = jsonConfiguration;
122126
}
123127

128+
public String getCustomLabelsPath() {
129+
return customLabelsPath;
130+
}
131+
132+
public void setCustomLabelsPath(String customLabelsPath) {
133+
this.customLabelsPath = customLabelsPath;
134+
}
135+
124136
public String getCommonNames() {
125137
return commonNames;
126138
}

api/src/main/java/org/apache/cloudstack/gui/theme/GuiTheme.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public interface GuiTheme extends InternalIdentity, Identity {
3737

3838
boolean getIsPublic();
3939

40+
String getCustomLabelsPath();
41+
4042
void setId(Long id);
4143

4244
void setUuid(String uuid);
@@ -58,4 +60,6 @@ public interface GuiTheme extends InternalIdentity, Identity {
5860
boolean isRecursiveDomains();
5961

6062
void setRecursiveDomains(boolean recursiveDomains);
63+
64+
void setCustomLabelsPath(String customLabelsPath);
6165
}

api/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeJoin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ public interface GuiThemeJoin extends InternalIdentity, Identity {
4444
Date getCreated();
4545

4646
Date getRemoved();
47+
48+
String getCustomLabelsPath();
4749
}

engine/schema/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeJoinVO.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public class GuiThemeJoinVO implements GuiThemeJoin {
4848
@Column(name = "json_configuration", nullable = false, length = 65535)
4949
private String jsonConfiguration;
5050

51+
@Column(name = "custom_labels_path", nullable = false, length = 65535)
52+
private String customLabelsPath;
53+
5154
@Column(name = "common_names", length = 65535)
5255
private String commonNames;
5356

@@ -74,6 +77,24 @@ public class GuiThemeJoinVO implements GuiThemeJoin {
7477
public GuiThemeJoinVO() {
7578
}
7679

80+
public GuiThemeJoinVO(Long id, String uuid, String name, String description, String css, String jsonConfiguration, String customLabelsPath, String commonNames, String domains,
81+
String accounts, boolean recursiveDomains, boolean isPublic, Date created, Date removed) {
82+
this.id = id;
83+
this.uuid = uuid;
84+
this.name = name;
85+
this.description = description;
86+
this.css = css;
87+
this.jsonConfiguration = jsonConfiguration;
88+
this.customLabelsPath = customLabelsPath;
89+
this.commonNames = commonNames;
90+
this.domains = domains;
91+
this.accounts = accounts;
92+
this.recursiveDomains = recursiveDomains;
93+
this.isPublic = isPublic;
94+
this.created = created;
95+
this.removed = removed;
96+
}
97+
7798
@Override
7899
public long getId() {
79100
return id;
@@ -138,4 +159,9 @@ public Date getCreated() {
138159
public Date getRemoved() {
139160
return removed;
140161
}
162+
163+
@Override
164+
public String getCustomLabelsPath() {
165+
return customLabelsPath;
166+
}
141167
}

engine/schema/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeVO.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public class GuiThemeVO implements GuiTheme {
5353
@Column(name = "json_configuration", length = 65535)
5454
private String jsonConfiguration;
5555

56+
@Column(name = "custom_labels_path", nullable = false, length = 65535)
57+
private String customLabelsPath;
58+
5659
@Column(name = "is_public")
5760
private boolean isPublic;
5861

@@ -71,11 +74,12 @@ public GuiThemeVO() {
7174

7275
}
7376

74-
public GuiThemeVO(String name, String description, String css, String jsonConfiguration, boolean recursiveDomains, boolean isPublic, Date created, Date removed) {
77+
public GuiThemeVO(String name, String description, String css, String jsonConfiguration, String customLabelsPath, boolean recursiveDomains, boolean isPublic, Date created, Date removed) {
7578
this.name = name;
7679
this.description = description;
7780
this.css = css;
7881
this.jsonConfiguration = jsonConfiguration;
82+
this.customLabelsPath = customLabelsPath;
7983
this.recursiveDomains = recursiveDomains;
8084
this.isPublic = isPublic;
8185
this.created = created;
@@ -113,6 +117,10 @@ public String getJsonConfiguration() {
113117
}
114118

115119
@Override
120+
public String getCustomLabelsPath() {
121+
return customLabelsPath;
122+
}
123+
116124
public Date getCreated() {
117125
return created;
118126
}
@@ -158,6 +166,10 @@ public void setJsonConfiguration(String jsonConfiguration) {
158166
}
159167

160168
@Override
169+
public void setCustomLabelsPath(String customLabelsPath) {
170+
this.customLabelsPath = customLabelsPath;
171+
}
172+
161173
public void setCreated(Date created) {
162174
this.created = created;
163175
}

engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,6 @@ INSERT INTO cloud.role_permissions (uuid, role_id, rule, permission, sort_order)
208208
SELECT uuid(), role_id, 'quotaResourceStatement', permission, sort_order
209209
FROM cloud.role_permissions rp
210210
WHERE rule = 'quotaStatement' AND NOT EXISTS(SELECT 1 FROM cloud.role_permissions rp_ WHERE rp.role_id = rp_.role_id AND rp_.rule = 'quotaResourceStatement');
211+
212+
-- Add custom labels to GUI themes
213+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.gui_themes', 'custom_labels_path', 'TEXT DEFAULT NULL');

engine/schema/src/main/resources/META-INF/db/views/cloud.gui_themes_view.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SELECT
2727
`cloud`.`gui_themes`.`description` AS `description`,
2828
`cloud`.`gui_themes`.`css` AS `css`,
2929
`cloud`.`gui_themes`.`json_configuration` AS `json_configuration`,
30+
`cloud`.`gui_themes`.`custom_labels_path` AS `custom_labels_path`,
3031
(SELECT group_concat(gtd.`value` separator ',') FROM `cloud`.`gui_themes_details` gtd WHERE gtd.`type` = 'commonName' AND gtd.gui_theme_id = `cloud`.`gui_themes`.`id`) common_names,
3132
(SELECT group_concat(gtd.`value` separator ',') FROM `cloud`.`gui_themes_details` gtd WHERE gtd.`type` = 'domain' AND gtd.gui_theme_id = `cloud`.`gui_themes`.`id`) domains,
3233
(SELECT group_concat(gtd.`value` separator ',') FROM `cloud`.`gui_themes_details` gtd WHERE gtd.`type` = 'account' AND gtd.gui_theme_id = `cloud`.`gui_themes`.`id`) accounts,

0 commit comments

Comments
 (0)