-
Notifications
You must be signed in to change notification settings - Fork 1.2k
GUI whitelabel runtime system #8942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 23 commits
7727b28
65e83c2
69ce3db
cdb6e89
1af256b
ccfa622
90c966b
40af044
0d3bee5
4b45e09
25c5551
412c146
10ab939
6a3f8ea
6915fd6
a79a546
1a547d7
dd8233f
17fade4
b26c8d5
65fcd8f
9e4db1d
6374971
c5f3efd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package org.apache.cloudstack.api.command.user.gui.theme; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.response.GuiThemeResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
| import org.apache.cloudstack.gui.theme.GuiTheme; | ||
| import org.apache.cloudstack.gui.theme.GuiThemeJoin; | ||
| import org.apache.cloudstack.gui.theme.GuiThemeService; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @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 " + | ||
| "account UUIDs.", responseObject = GuiThemeResponse.class, entityType = {GuiTheme.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, | ||
| since = "4.20.0.0", authorized = {RoleType.Admin}) | ||
| public class CreateGuiThemeCmd extends BaseCmd { | ||
|
|
||
| @Inject | ||
| GuiThemeService guiThemeService; | ||
|
|
||
| @Parameter(name = ApiConstants.NAME, required = true, type = CommandType.STRING, length = 2048, description = "A name to identify the theme.") | ||
| private String name; | ||
|
|
||
| @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, length = 4096, description = "A description for the theme.") | ||
| private String description; | ||
|
|
||
| @Parameter(name = ApiConstants.CSS, type = CommandType.STRING, length = 65535, description = "The CSS to be retrieved and imported into the GUI " + | ||
| "when matching the theme access configurations.") | ||
| private String css; | ||
|
|
||
| @Parameter(name = ApiConstants.JSON_CONFIGURATION, type = CommandType.STRING, length = 65535, description = "The JSON with the configurations to be " + | ||
| "retrieved and imported into the GUI when matching the theme access configurations.") | ||
| private String jsonConfiguration; | ||
|
|
||
| @Parameter(name = ApiConstants.COMMON_NAMES, type = CommandType.STRING, length = 65535, description = "A set of Common Names (CN) (fixed or " + | ||
| "wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com") | ||
| private String commonNames; | ||
|
|
||
| @Parameter(name = ApiConstants.DOMAIN_IDS, type = CommandType.STRING, length = 65535, description = "A set of domain UUIDs (also known as ID for " + | ||
| "the end-user) separated by comma that can retrieve the theme.") | ||
| private String domainIds; | ||
|
|
||
| @Parameter(name = ApiConstants.ACCOUNT_IDS, type = CommandType.STRING, length = 65535, description = "A set of account UUIDs (also known as ID for" + | ||
| " the end-user) separated by comma that can retrieve the theme.") | ||
| private String accountIds; | ||
|
|
||
| @Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "Defines whether a theme can be retrieved by anyone when only " + | ||
|
Check warning on line 68 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
| "the `commonNames` is informed. If the `domainIds` or `accountIds` is informed, it is considered as `false`.") | ||
| private Boolean isPublic = true; | ||
|
Check warning on line 70 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| @Parameter(name = ApiConstants.RECURSIVE_DOMAINS, type = CommandType.BOOLEAN, description = "Defines whether the subdomains of the informed domains are considered. Default " + | ||
|
Check warning on line 72 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
| "value is false.") | ||
| private Boolean recursiveDomains = false; | ||
|
Check warning on line 74 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
Check warning on line 78 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
Check warning on line 82 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public String getCss() { | ||
| return css; | ||
| } | ||
|
Check warning on line 86 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public String getJsonConfiguration() { | ||
| return jsonConfiguration; | ||
| } | ||
|
Check warning on line 90 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public String getCommonNames() { | ||
| return commonNames; | ||
| } | ||
|
Check warning on line 94 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public String getDomainIds() { | ||
| return domainIds; | ||
| } | ||
|
Check warning on line 98 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public String getAccountIds() { | ||
| return accountIds; | ||
| } | ||
|
Check warning on line 102 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public Boolean getPublic() { | ||
| return isPublic; | ||
| } | ||
|
Check warning on line 106 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| public Boolean getRecursiveDomains() { | ||
| return recursiveDomains; | ||
| } | ||
|
Check warning on line 110 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| @Override | ||
| public void execute() { | ||
| GuiThemeJoin guiThemeJoin = guiThemeService.createGuiTheme(this); | ||
|
Check warning on line 114 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| if (guiThemeJoin == null) { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create the GUI theme."); | ||
|
Check warning on line 117 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
| } | ||
|
|
||
| GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiThemeJoin); | ||
| response.setResponseName(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } | ||
|
Check warning on line 123 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return CallContext.current().getCallingAccountId(); | ||
| } | ||
|
Check warning on line 128 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/CreateGuiThemeCmd.java
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package org.apache.cloudstack.api.command.user.gui.theme; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.BaseListCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.response.AccountResponse; | ||
| import org.apache.cloudstack.api.response.DomainResponse; | ||
| import org.apache.cloudstack.api.response.GuiThemeResponse; | ||
| import org.apache.cloudstack.api.response.ListResponse; | ||
| import org.apache.cloudstack.gui.theme.GuiTheme; | ||
| import org.apache.cloudstack.gui.theme.GuiThemeService; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = "listGuiThemes", description = "Lists GUI themes.", responseObject = GuiThemeResponse.class, entityType = {GuiTheme.class}, | ||
| since = "4.20.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.User, RoleType.DomainAdmin, | ||
bernardodemarco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RoleType.ResourceAdmin}) | ||
| public class ListGuiThemesCmd extends BaseListCmd { | ||
|
|
||
| @Inject | ||
| GuiThemeService guiThemeService; | ||
|
|
||
| @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The theme ID.", entityType = GuiThemeResponse.class) | ||
| private Long id; | ||
|
|
||
| @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the theme.") | ||
| private String name; | ||
|
|
||
| @Parameter(name = ApiConstants.COMMON_NAME, type = CommandType.STRING, description = "The internet Common Name (CN) to be filtered.") | ||
| private String commonName; | ||
|
|
||
| @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "The ID of the domain to be filtered.") | ||
| private Long domainId; | ||
|
|
||
| @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "The ID of the account to be filtered.") | ||
| private Long accountId; | ||
|
|
||
| @Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "Whether to list all themes.") | ||
|
Check warning on line 56 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
| private boolean listAll = false; | ||
|
|
||
| @Parameter(name = ApiConstants.SHOW_REMOVED, type = CommandType.BOOLEAN, description = "Whether to list removed themes.") | ||
|
Check warning on line 59 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
| private boolean showRemoved = false; | ||
|
|
||
| @Parameter(name = ApiConstants.SHOW_PUBLIC, type = CommandType.BOOLEAN, description = "Whether to list public themes.") | ||
| private Boolean showPublic; | ||
|
|
||
| @Parameter(name = ApiConstants.LIST_ONLY_DEFAULT_THEME, type = CommandType.BOOLEAN, description = "Whether to only list the default theme.") | ||
|
Check warning on line 65 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
| private boolean listOnlyDefaultTheme = false; | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
Check warning on line 70 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
Check warning on line 74 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| public String getCommonName() { | ||
| return commonName; | ||
| } | ||
|
Check warning on line 78 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| public Long getDomainId() { | ||
| return domainId; | ||
| } | ||
|
Check warning on line 82 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| public Long getAccountId() { | ||
| return accountId; | ||
| } | ||
|
Check warning on line 86 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| public boolean getListAll() { | ||
| return listAll; | ||
| } | ||
|
Check warning on line 90 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| public boolean getShowRemoved() { | ||
| return showRemoved; | ||
| } | ||
|
Check warning on line 94 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| public Boolean getShowPublic() { | ||
| return showPublic; | ||
| } | ||
|
Check warning on line 98 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| public boolean getListOnlyDefaultTheme() { | ||
| return listOnlyDefaultTheme; | ||
| } | ||
|
Check warning on line 102 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
|
|
||
| @Override | ||
| public void execute() { | ||
| ListResponse<GuiThemeResponse> response = guiThemeService.listGuiThemes(this); | ||
| response.setResponseName(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } | ||
|
Check warning on line 109 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/ListGuiThemesCmd.java
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package org.apache.cloudstack.api.command.user.gui.theme; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.response.GuiThemeResponse; | ||
| import org.apache.cloudstack.api.response.SuccessResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
| import org.apache.cloudstack.gui.theme.GuiTheme; | ||
| import org.apache.cloudstack.gui.theme.GuiThemeService; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = "removeGuiTheme", description = "Removes an existing GUI theme.", responseObject = GuiThemeResponse.class, entityType = {GuiTheme.class}, | ||
| since = "4.20.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin}) | ||
bernardodemarco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public class RemoveGuiThemeCmd extends BaseCmd { | ||
|
|
||
| @Inject | ||
| GuiThemeService guiThemeService; | ||
|
|
||
| @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuiThemeResponse.class, required = true, | ||
| description = "The unique identifier of the GUI theme to be removed.") | ||
| private Long id; | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
Check warning on line 45 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java
|
||
|
|
||
| @Override | ||
| public void execute() { | ||
| guiThemeService.removeGuiTheme(this); | ||
| final SuccessResponse response = new SuccessResponse(); | ||
| response.setResponseName(getCommandName()); | ||
| response.setSuccess(true); | ||
| setResponseObject(response); | ||
| } | ||
|
Check warning on line 54 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java
|
||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return CallContext.current().getCallingAccountId(); | ||
| } | ||
|
Check warning on line 59 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/theme/RemoveGuiThemeCmd.java
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.