Skip to content

Commit 8c81493

Browse files
committed
Add guithemedetails join
1 parent 6d97e1f commit 8c81493

File tree

22 files changed

+809
-264
lines changed

22 files changed

+809
-264
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,8 @@ public class ApiConstants {
12051205

12061206
public static final String LIST_ONLY_DEFAULT_THEME = "listonlydefaulttheme";
12071207

1208+
public static final String RECURSIVE_DOMAINS = "recursivedomains";
1209+
12081210
/**
12091211
* This enum specifies IO Drivers, each option controls specific policies on I/O.
12101212
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
import org.apache.cloudstack.direct.download.DirectDownloadCertificate;
155155
import org.apache.cloudstack.direct.download.DirectDownloadCertificateHostMap;
156156
import org.apache.cloudstack.direct.download.DirectDownloadManager;
157-
import org.apache.cloudstack.gui.themes.GuiThemeVO;
157+
import org.apache.cloudstack.gui.themes.GuiThemeJoinVO;
158158
import org.apache.cloudstack.management.ManagementServerHost;
159159
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
160160
import org.apache.cloudstack.region.PortableIp;
@@ -571,5 +571,5 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
571571

572572
SharedFSResponse createSharedFSResponse(ResponseView view, SharedFS sharedFS);
573573

574-
GuiThemeResponse createGuiThemeResponse(GuiThemeVO guiThemeVO);
574+
GuiThemeResponse createGuiThemeResponse(GuiThemeJoinVO guiThemeJoinVO);
575575
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.cloudstack.api.ServerApiException;
2626
import org.apache.cloudstack.api.response.GuiThemeResponse;
2727
import org.apache.cloudstack.context.CallContext;
28+
import org.apache.cloudstack.gui.themes.GuiThemeJoinVO;
2829
import org.apache.cloudstack.gui.themes.GuiThemeVO;
2930
import org.apache.cloudstack.gui.themes.GuiThemeService;
3031

@@ -68,6 +69,10 @@ public class CreateGuiThemeCmd extends BaseCmd {
6869
"the `commonNames` is informed. If the `domainIds` or `accountIds` is informed, it is considered as `false`.")
6970
private Boolean isPublic = true;
7071

72+
@Parameter(name = ApiConstants.RECURSIVE_DOMAINS, type = CommandType.BOOLEAN, description = "Defines whether the subdomains of the informed domains are considered. Default " +
73+
"value is false.")
74+
private Boolean recursiveDomains = false;
75+
7176
public String getName() {
7277
return name;
7378
}
@@ -100,20 +105,21 @@ public Boolean getPublic() {
100105
return isPublic;
101106
}
102107

103-
public void setIsPublic(Boolean isPublic) {
104-
this.isPublic = isPublic;
108+
public Boolean getRecursiveDomains() {
109+
return recursiveDomains;
105110
}
106111

107112
@Override
108113
public void execute() {
109-
CallContext.current().setEventDetails(String.format("Name: %s, AccountIDs: %s, DomainIDs: %s, CommonNames: %s", getName(), getAccountIds(), getDomainIds(), getCommonNames()));
110-
GuiThemeVO guiThemeVO = guiThemeService.createGuiTheme(this);
114+
CallContext.current().setEventDetails(String.format("Name: %s, AccountIDs: %s, DomainIDs: %s, RecursiveDomains: %s, CommonNames: %s", getName(), getAccountIds(),
115+
getDomainIds(), getRecursiveDomains(), getCommonNames()));
116+
GuiThemeJoinVO guiTheme = guiThemeService.createGuiTheme(this);
111117

112-
if (guiThemeVO == null) {
118+
if (guiTheme == null) {
113119
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create the GUI theme.");
114120
}
115121

116-
GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiThemeVO);
122+
GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiTheme);
117123
response.setResponseName(getCommandName());
118124
this.setResponseObject(response);
119125
}

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.cloudstack.api.ServerApiException;
2626
import org.apache.cloudstack.api.response.GuiThemeResponse;
2727
import org.apache.cloudstack.context.CallContext;
28+
import org.apache.cloudstack.gui.themes.GuiThemeJoinVO;
2829
import org.apache.cloudstack.gui.themes.GuiThemeVO;
2930
import org.apache.cloudstack.gui.themes.GuiThemeService;
3031

@@ -63,6 +64,10 @@ public class UpdateGuiThemeCmd extends BaseCmd {
6364
"the end-user) separated by comma that can retrieve the theme.")
6465
private String domainIds;
6566

67+
@Parameter(name = ApiConstants.RECURSIVE_DOMAINS, type = CommandType.BOOLEAN, description = "Defines whether the subdomains of the informed domains are considered. Default " +
68+
"value is false.")
69+
private Boolean recursiveDomains = false;
70+
6671
@Parameter(name = ApiConstants.ACCOUNT_IDS, type = CommandType.STRING, length = 65535, description = "A set of account UUIDs (also known as ID for" +
6772
" the end-user) separated by comma that can retrieve the theme.")
6873
private String accountIds;
@@ -103,21 +108,25 @@ public String getAccountIds() {
103108
return accountIds;
104109
}
105110

111+
public Boolean getRecursiveDomains() {
112+
return recursiveDomains;
113+
}
114+
106115
public Boolean getIsPublic() {
107116
return isPublic;
108117
}
109118

110119
@Override
111120
public void execute() {
112-
CallContext.current().setEventDetails(String.format("ID: %s, Name: %s, AccountIDs: %s, DomainIDs: %s, CommonNames: %s", getId(), getName(), getAccountIds(),
113-
getDomainIds(), getCommonNames()));
114-
GuiThemeVO guiThemeVO = guiThemeService.updateGuiTheme(this);
121+
CallContext.current().setEventDetails(String.format("ID: %s, Name: %s, AccountIDs: %s, DomainIDs: %s, RecursiveDomains: %s, CommonNames: %s", getId(), getName(),
122+
getAccountIds(), getDomainIds(), getRecursiveDomains(), getCommonNames()));
123+
GuiThemeJoinVO guiThemeJoinVO = guiThemeService.updateGuiTheme(this);
115124

116-
if (guiThemeVO == null) {
125+
if (guiThemeJoinVO == null) {
117126
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update the GUI theme.");
118127
}
119128

120-
GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiThemeVO);
129+
GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiThemeJoinVO);
121130
response.setResponseName(getCommandName());
122131
this.setResponseObject(response);
123132
}

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import org.apache.cloudstack.api.ApiConstants;
2222
import org.apache.cloudstack.api.BaseResponse;
2323
import org.apache.cloudstack.api.EntityReference;
24-
import org.apache.cloudstack.gui.themes.GuiThemeVO;
24+
import org.apache.cloudstack.gui.themes.GuiThemeJoinVO;
2525

2626
import java.util.Date;
2727

28-
@EntityReference(value = {GuiThemeVO.class})
28+
@EntityReference(value = {GuiThemeJoinVO.class})
2929
public class GuiThemeResponse extends BaseResponse {
3030

3131
@SerializedName(ApiConstants.ID)
@@ -56,6 +56,10 @@ public class GuiThemeResponse extends BaseResponse {
5656
@Param(description = "A set of domain UUIDs (also known as ID for the end-user) separated by comma that can retrieve the theme.")
5757
private String domainIds;
5858

59+
@SerializedName(ApiConstants.RECURSIVE_DOMAINS)
60+
@Param(description = "Whether to consider the subdomains of the informed domain IDs.")
61+
private Boolean recursiveDomains;
62+
5963
@SerializedName(ApiConstants.ACCOUNT_IDS)
6064
@Param(description = "A set of account UUIDs (also known as ID for the end-user) separated by comma that can retrieve the theme.")
6165
private String accountIds;
@@ -161,6 +165,14 @@ public Date getRemoved() {
161165
return removed;
162166
}
163167

168+
public Boolean getRecursiveDomains() {
169+
return recursiveDomains;
170+
}
171+
172+
public void setRecursiveDomains(Boolean recursiveDomains) {
173+
this.recursiveDomains = recursiveDomains;
174+
}
175+
164176
public void setRemoved(Date removed) {
165177
this.removed = removed;
166178
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.gui.themes;
18+
19+
import org.apache.cloudstack.api.InternalIdentity;
20+
21+
import javax.persistence.Column;
22+
import javax.persistence.Entity;
23+
import javax.persistence.GeneratedValue;
24+
import javax.persistence.GenerationType;
25+
import javax.persistence.Id;
26+
import javax.persistence.Table;
27+
28+
@Entity
29+
@Table(name = "gui_themes_details")
30+
public class GuiThemeDetailsVO implements InternalIdentity {
31+
@Id
32+
@GeneratedValue(strategy = GenerationType.IDENTITY)
33+
@Column(name = "id", nullable = false)
34+
private Long id;
35+
36+
@Column(name = "gui_theme_id", nullable = false)
37+
private Long guiThemeId;
38+
39+
@Column(name = "type", nullable = false, length = 100)
40+
private String type;
41+
42+
@Column(name = "value", nullable = false, length = 65535)
43+
private String value;
44+
45+
public GuiThemeDetailsVO() {
46+
}
47+
48+
public GuiThemeDetailsVO(Long guiThemeId, String type, String value) {
49+
this.guiThemeId = guiThemeId;
50+
this.type = type;
51+
this.value = value;
52+
}
53+
54+
@Override
55+
public long getId() {
56+
return id;
57+
}
58+
59+
public void setId(Long id) {
60+
this.id = id;
61+
}
62+
63+
public Long getGuiThemeId() {
64+
return guiThemeId;
65+
}
66+
67+
public void setGuiThemeId(Long guiThemeId) {
68+
this.guiThemeId = guiThemeId;
69+
}
70+
71+
public String getType() {
72+
return type;
73+
}
74+
75+
public void setType(String type) {
76+
this.type = type;
77+
}
78+
79+
public String getValue() {
80+
return value;
81+
}
82+
83+
public void setValue(String value) {
84+
this.value = value;
85+
}
86+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.gui.themes;
18+
19+
import com.cloud.utils.db.GenericDao;
20+
import org.apache.cloudstack.api.InternalIdentity;
21+
22+
import javax.persistence.Column;
23+
import javax.persistence.Entity;
24+
import javax.persistence.Id;
25+
import javax.persistence.Table;
26+
import javax.persistence.Temporal;
27+
import javax.persistence.TemporalType;
28+
import java.util.Date;
29+
30+
@Entity
31+
@Table(name = "gui_themes_view")
32+
public class GuiThemeJoinVO implements InternalIdentity {
33+
@Id
34+
@Column(name = "id", nullable = false)
35+
private Long id;
36+
37+
@Column(name = "uuid", nullable = false)
38+
private String uuid;
39+
40+
@Column(name = "name", nullable = false, length = 2048)
41+
private String name;
42+
43+
@Column(name = "description", length = 4096)
44+
private String description;
45+
46+
@Column(name = "css", nullable = false, length = 65535)
47+
private String css;
48+
49+
@Column(name = "json_configuration", nullable = false, length = 65535)
50+
private String jsonConfiguration;
51+
52+
@Column(name = "common_names", length = 65535)
53+
private String commonNames;
54+
55+
@Column(name = "domains", length = 65535)
56+
private String domains;
57+
58+
@Column(name = "accounts", length = 65535)
59+
private String accounts;
60+
61+
@Column(name = "recursive_domains")
62+
private boolean recursiveDomains;
63+
64+
@Column(name = "is_public")
65+
private boolean isPublic;
66+
67+
@Column(name = GenericDao.CREATED_COLUMN, nullable = false)
68+
@Temporal(value = TemporalType.TIMESTAMP)
69+
private Date created;
70+
71+
@Column(name = GenericDao.REMOVED_COLUMN)
72+
@Temporal(value = TemporalType.TIMESTAMP)
73+
private Date removed = null;
74+
75+
public GuiThemeJoinVO() {
76+
}
77+
78+
public GuiThemeJoinVO(Long id, String uuid, String name, String description, String css, String jsonConfiguration, String commonNames, String domains,
79+
String accounts, boolean recursiveDomains, boolean isPublic, Date created, Date removed) {
80+
this.id = id;
81+
this.uuid = uuid;
82+
this.name = name;
83+
this.description = description;
84+
this.css = css;
85+
this.jsonConfiguration = jsonConfiguration;
86+
this.commonNames = commonNames;
87+
this.domains = domains;
88+
this.accounts = accounts;
89+
this.recursiveDomains = recursiveDomains;
90+
this.isPublic = isPublic;
91+
this.created = created;
92+
this.removed = removed;
93+
}
94+
95+
public long getId() {
96+
return id;
97+
}
98+
99+
public void setId(Long id) {
100+
this.id = id;
101+
}
102+
103+
public String getUuid() {
104+
return uuid;
105+
}
106+
107+
public String getName() {
108+
return name;
109+
}
110+
111+
public String getDescription() {
112+
return description;
113+
}
114+
115+
public String getCss() {
116+
return css;
117+
}
118+
119+
public String getJsonConfiguration() {
120+
return jsonConfiguration;
121+
}
122+
123+
public String getCommonNames() {
124+
return commonNames;
125+
}
126+
127+
public String getDomains() {
128+
return domains;
129+
}
130+
131+
public String getAccounts() {
132+
return accounts;
133+
}
134+
135+
public boolean isRecursiveDomains() {
136+
return recursiveDomains;
137+
}
138+
139+
public boolean getIsPublic() {
140+
return isPublic;
141+
}
142+
143+
public Date getCreated() {
144+
return created;
145+
}
146+
147+
public Date getRemoved() {
148+
return removed;
149+
}
150+
}

0 commit comments

Comments
 (0)