Skip to content

Commit 6d97e1f

Browse files
committed
Add first version
1 parent f75a194 commit 6d97e1f

File tree

29 files changed

+1897
-7
lines changed

29 files changed

+1897
-7
lines changed

api/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@
7171
<artifactId>cloud-framework-direct-download</artifactId>
7272
<version>${project.version}</version>
7373
</dependency>
74+
<dependency>
75+
<groupId>org.eclipse.persistence</groupId>
76+
<artifactId>javax.persistence</artifactId>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.apache.cloudstack</groupId>
80+
<artifactId>cloud-framework-db</artifactId>
81+
<version>${project.version}</version>
82+
</dependency>
7483
</dependencies>
7584
<build>
7685
<plugins>

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,11 @@ public class EventTypes {
785785
public static final String EVENT_SHAREDFS_EXPUNGE = "SHAREDFS.EXPUNGE";
786786
public static final String EVENT_SHAREDFS_RECOVER = "SHAREDFS.RECOVER";
787787

788+
// GUI Theme
789+
public static final String EVENT_GUI_THEME_CREATE = "GUI.THEME.CREATE";
790+
public static final String EVENT_GUI_THEME_REMOVE = "GUI.THEME.REMOVE";
791+
public static final String EVENT_GUI_THEME_UPDATE = "GUI.THEME.UPDATE";
792+
788793
static {
789794

790795
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@@ -1273,6 +1278,11 @@ public class EventTypes {
12731278
entityEventDetails.put(EVENT_SHAREDFS_DESTROY, SharedFS.class);
12741279
entityEventDetails.put(EVENT_SHAREDFS_EXPUNGE, SharedFS.class);
12751280
entityEventDetails.put(EVENT_SHAREDFS_RECOVER, SharedFS.class);
1281+
1282+
// GUI theme
1283+
entityEventDetails.put(EVENT_GUI_THEME_CREATE, "GuiTheme");
1284+
entityEventDetails.put(EVENT_GUI_THEME_REMOVE, "GuiTheme");
1285+
entityEventDetails.put(EVENT_GUI_THEME_UPDATE, "GuiTheme");
12761286
}
12771287

12781288
public static boolean isNetworkEvent(String eventType) {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,20 @@ public class ApiConstants {
11911191
"numeric value will be applied; if the result is neither a boolean nor a numeric value, the tariff will not be applied. If the rule is not informed, the tariff " +
11921192
"value will be applied.";
11931193

1194+
public static final String CSS = "css";
1195+
1196+
public static final String JSON_CONFIGURATION = "jsonconfiguration";
1197+
1198+
public static final String COMMON_NAMES = "commonnames";
1199+
1200+
public static final String COMMON_NAME = "commonname";
1201+
1202+
public static final String DOMAIN_IDS = "domainids";
1203+
1204+
public static final String SHOW_PUBLIC = "showpublic";
1205+
1206+
public static final String LIST_ONLY_DEFAULT_THEME = "listonlydefaulttheme";
1207+
11941208
/**
11951209
* This enum specifies IO Drivers, each option controls specific policies on I/O.
11961210
* 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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import org.apache.cloudstack.api.response.GuestOsMappingResponse;
6969
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
7070
import org.apache.cloudstack.api.response.GuestVlanResponse;
71+
import org.apache.cloudstack.api.response.GuiThemeResponse;
7172
import org.apache.cloudstack.api.response.HostForMigrationResponse;
7273
import org.apache.cloudstack.api.response.HostResponse;
7374
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
@@ -153,6 +154,7 @@
153154
import org.apache.cloudstack.direct.download.DirectDownloadCertificate;
154155
import org.apache.cloudstack.direct.download.DirectDownloadCertificateHostMap;
155156
import org.apache.cloudstack.direct.download.DirectDownloadManager;
157+
import org.apache.cloudstack.gui.themes.GuiThemeVO;
156158
import org.apache.cloudstack.management.ManagementServerHost;
157159
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
158160
import org.apache.cloudstack.region.PortableIp;
@@ -568,4 +570,6 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
568570
BackupRepositoryResponse createBackupRepositoryResponse(BackupRepository repository);
569571

570572
SharedFSResponse createSharedFSResponse(ResponseView view, SharedFS sharedFS);
573+
574+
GuiThemeResponse createGuiThemeResponse(GuiThemeVO guiThemeVO);
571575
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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.api.command.user.gui.themes;
18+
19+
import org.apache.cloudstack.acl.RoleType;
20+
import org.apache.cloudstack.api.APICommand;
21+
import org.apache.cloudstack.api.ApiConstants;
22+
import org.apache.cloudstack.api.ApiErrorCode;
23+
import org.apache.cloudstack.api.BaseCmd;
24+
import org.apache.cloudstack.api.Parameter;
25+
import org.apache.cloudstack.api.ServerApiException;
26+
import org.apache.cloudstack.api.response.GuiThemeResponse;
27+
import org.apache.cloudstack.context.CallContext;
28+
import org.apache.cloudstack.gui.themes.GuiThemeVO;
29+
import org.apache.cloudstack.gui.themes.GuiThemeService;
30+
31+
import javax.inject.Inject;
32+
33+
@APICommand(name = "createGuiTheme", description = "Creates a customized GUI theme for a set of Common Names (fixed or wildcard), a set of domain UUIDs, and/or a set of " +
34+
"account UUIDs.", responseObject = GuiThemeResponse.class, entityType = {GuiThemeVO.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
35+
since = "4.18.0.4-scclouds", authorized = {RoleType.Admin})
36+
public class CreateGuiThemeCmd extends BaseCmd {
37+
38+
@Inject
39+
GuiThemeService guiThemeService;
40+
41+
@Parameter(name = ApiConstants.NAME, required = true, type = CommandType.STRING, length = 2048, description = "A name to identify the theme.")
42+
private String name;
43+
44+
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, length = 4096, description = "A description for the theme.")
45+
private String description;
46+
47+
@Parameter(name = ApiConstants.CSS, type = CommandType.STRING, length = 65535, description = "The CSS to be retrieved and imported into the GUI " +
48+
"when matching the theme access configurations.")
49+
private String css;
50+
51+
@Parameter(name = ApiConstants.JSON_CONFIGURATION, type = CommandType.STRING, length = 65535, description = "The JSON with the configurations to be " +
52+
"retrieved and imported into the GUI when matching the theme access configurations.")
53+
private String jsonConfiguration;
54+
55+
@Parameter(name = ApiConstants.COMMON_NAMES, type = CommandType.STRING, length = 65535, description = "A set of Common Names (CN) (fixed or " +
56+
"wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com")
57+
private String commonNames;
58+
59+
@Parameter(name = ApiConstants.DOMAIN_IDS, type = CommandType.STRING, length = 65535, description = "A set of domain UUIDs (also known as ID for " +
60+
"the end-user) separated by comma that can retrieve the theme.")
61+
private String domainIds;
62+
63+
@Parameter(name = ApiConstants.ACCOUNT_IDS, type = CommandType.STRING, length = 65535, description = "A set of account UUIDs (also known as ID for" +
64+
" the end-user) separated by comma that can retrieve the theme.")
65+
private String accountIds;
66+
67+
@Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "Defines whether a theme can be retrieved by anyone when only " +
68+
"the `commonNames` is informed. If the `domainIds` or `accountIds` is informed, it is considered as `false`.")
69+
private Boolean isPublic = true;
70+
71+
public String getName() {
72+
return name;
73+
}
74+
75+
public String getDescription() {
76+
return description;
77+
}
78+
79+
public String getCss() {
80+
return css;
81+
}
82+
83+
public String getJsonConfiguration() {
84+
return jsonConfiguration;
85+
}
86+
87+
public String getCommonNames() {
88+
return commonNames;
89+
}
90+
91+
public String getDomainIds() {
92+
return domainIds;
93+
}
94+
95+
public String getAccountIds() {
96+
return accountIds;
97+
}
98+
99+
public Boolean getPublic() {
100+
return isPublic;
101+
}
102+
103+
public void setIsPublic(Boolean isPublic) {
104+
this.isPublic = isPublic;
105+
}
106+
107+
@Override
108+
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);
111+
112+
if (guiThemeVO == null) {
113+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create the GUI theme.");
114+
}
115+
116+
GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiThemeVO);
117+
response.setResponseName(getCommandName());
118+
this.setResponseObject(response);
119+
}
120+
121+
@Override
122+
public long getEntityOwnerId() {
123+
return CallContext.current().getCallingAccountId();
124+
}
125+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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.api.command.user.gui.themes;
18+
19+
import org.apache.cloudstack.acl.RoleType;
20+
import org.apache.cloudstack.api.APICommand;
21+
import org.apache.cloudstack.api.ApiConstants;
22+
import org.apache.cloudstack.api.BaseListCmd;
23+
import org.apache.cloudstack.api.Parameter;
24+
import org.apache.cloudstack.api.response.AccountResponse;
25+
import org.apache.cloudstack.api.response.DomainResponse;
26+
import org.apache.cloudstack.api.response.GuiThemeResponse;
27+
import org.apache.cloudstack.api.response.ListResponse;
28+
import org.apache.cloudstack.gui.themes.GuiThemeVO;
29+
import org.apache.cloudstack.gui.themes.GuiThemeService;
30+
31+
import javax.inject.Inject;
32+
33+
@APICommand(name = "listGuiThemes", description = "Lists GUI themes.", responseObject = GuiThemeResponse.class, entityType = {GuiThemeVO.class},
34+
since = "4.18.0.4-scclouds", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.User, RoleType.DomainAdmin, RoleType.ResourceAdmin})
35+
public class ListGuiThemesCmd extends BaseListCmd {
36+
37+
@Inject
38+
GuiThemeService guiThemeService;
39+
40+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The theme ID.", entityType = GuiThemeResponse.class)
41+
private Long id;
42+
43+
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the theme.")
44+
private String name;
45+
46+
@Parameter(name = ApiConstants.COMMON_NAME, type = CommandType.STRING, description = "The internet Common Name (CN) to be filtered.")
47+
private String commonName;
48+
49+
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "The ID of the domain to be filtered.")
50+
private Long domainId;
51+
52+
@Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "The ID of the account to be filtered.")
53+
private Long accountId;
54+
55+
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "Whether to list all themes.")
56+
private boolean listAll = false;
57+
58+
@Parameter(name = ApiConstants.SHOW_REMOVED, type = CommandType.BOOLEAN, description = "Whether to list removed themes.")
59+
private boolean showRemoved = false;
60+
61+
@Parameter(name = ApiConstants.SHOW_PUBLIC, type = CommandType.BOOLEAN, description = "Whether to list public themes.")
62+
private Boolean showPublic;
63+
64+
@Parameter(name = ApiConstants.LIST_ONLY_DEFAULT_THEME, type = CommandType.BOOLEAN, description = "Whether to only list the default theme.")
65+
private boolean listOnlyDefaultTheme = false;
66+
67+
public Long getId() {
68+
return id;
69+
}
70+
71+
public String getName() {
72+
return name;
73+
}
74+
75+
public String getCommonName() {
76+
return commonName;
77+
}
78+
79+
public Long getDomainId() {
80+
return domainId;
81+
}
82+
83+
public Long getAccountId() {
84+
return accountId;
85+
}
86+
87+
public boolean getListAll() {
88+
return listAll;
89+
}
90+
91+
public boolean getShowRemoved() {
92+
return showRemoved;
93+
}
94+
95+
public Boolean getShowPublic() {
96+
return showPublic;
97+
}
98+
99+
public boolean getListOnlyDefaultTheme() {
100+
return listOnlyDefaultTheme;
101+
}
102+
103+
@Override
104+
public void execute() {
105+
ListResponse<GuiThemeResponse> response = guiThemeService.listGuiThemes(this);
106+
response.setResponseName(getCommandName());
107+
this.setResponseObject(response);
108+
}
109+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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.api.command.user.gui.themes;
18+
19+
import org.apache.cloudstack.acl.RoleType;
20+
import org.apache.cloudstack.api.APICommand;
21+
import org.apache.cloudstack.api.ApiConstants;
22+
import org.apache.cloudstack.api.BaseCmd;
23+
import org.apache.cloudstack.api.Parameter;
24+
import org.apache.cloudstack.api.response.GuiThemeResponse;
25+
import org.apache.cloudstack.api.response.SuccessResponse;
26+
import org.apache.cloudstack.context.CallContext;
27+
import org.apache.cloudstack.gui.themes.GuiThemeVO;
28+
import org.apache.cloudstack.gui.themes.GuiThemeService;
29+
30+
import javax.inject.Inject;
31+
32+
@APICommand(name = "removeGuiTheme", description = "Removes an existing GUI theme.", responseObject = GuiThemeResponse.class, entityType = {GuiThemeVO.class},
33+
since = "4.18.0.4-scclouds", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin})
34+
public class RemoveGuiThemeCmd extends BaseCmd {
35+
36+
@Inject
37+
GuiThemeService guiThemeService;
38+
39+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuiThemeResponse.class, required = true,
40+
description = "The unique identifier of the GUI theme to be removed.")
41+
private Long id;
42+
43+
public Long getId() {
44+
return id;
45+
}
46+
47+
@Override
48+
public void execute() {
49+
CallContext.current().setEventDetails(String.format("ID: %s", getId()));
50+
guiThemeService.removeGuiTheme(this);
51+
final SuccessResponse response = new SuccessResponse();
52+
response.setResponseName(getCommandName());
53+
response.setSuccess(true);
54+
setResponseObject(response);
55+
}
56+
57+
@Override
58+
public long getEntityOwnerId() {
59+
return CallContext.current().getCallingAccountId();
60+
}
61+
}

0 commit comments

Comments
 (0)