Skip to content
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

GUI whitelabel runtime system #8942

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@
<artifactId>cloud-framework-direct-download</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-framework-db</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
10 changes: 10 additions & 0 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,11 @@ public class EventTypes {
public static final String EVENT_QUOTA_TARIFF_DELETE = "QUOTA.TARIFF.DELETE";
public static final String EVENT_QUOTA_TARIFF_UPDATE = "QUOTA.TARIFF.UPDATE";

// GUI Theme
public static final String EVENT_GUI_THEME_CREATE = "GUI.THEME.CREATE";
public static final String EVENT_GUI_THEME_REMOVE = "GUI.THEME.REMOVE";
public static final String EVENT_GUI_THEME_UPDATE = "GUI.THEME.UPDATE";

static {

// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
Expand Down Expand Up @@ -1191,6 +1196,11 @@ public class EventTypes {
entityEventDetails.put(EVENT_QUOTA_TARIFF_CREATE, QuotaTariff.class);
entityEventDetails.put(EVENT_QUOTA_TARIFF_DELETE, QuotaTariff.class);
entityEventDetails.put(EVENT_QUOTA_TARIFF_UPDATE, QuotaTariff.class);

// GUI theme
entityEventDetails.put(EVENT_GUI_THEME_CREATE, "GuiTheme");
entityEventDetails.put(EVENT_GUI_THEME_REMOVE, "GuiTheme");
entityEventDetails.put(EVENT_GUI_THEME_UPDATE, "GuiTheme");
}

public static boolean isNetworkEvent(String eventType) {
Expand Down
16 changes: 16 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,22 @@ public class ApiConstants {

public static final String PARAMETER_DESCRIPTION_IS_TAG_A_RULE = "Whether the informed tag is a JS interpretable rule or not.";

public static final String CSS = "css";

public static final String JSON_CONFIGURATION = "jsonconfiguration";

public static final String COMMON_NAMES = "commonnames";

public static final String COMMON_NAME = "commonname";

public static final String DOMAIN_IDS = "domainids";

public static final String SHOW_PUBLIC = "showpublic";

public static final String LIST_ONLY_DEFAULT_THEME = "listonlydefaulttheme";

public static final String RECURSIVE_DOMAINS = "recursivedomains";

/**
* This enum specifies IO Drivers, each option controls specific policies on I/O.
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.apache.cloudstack.api.response.GuestOsMappingResponse;
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
import org.apache.cloudstack.api.response.GuestVlanResponse;
import org.apache.cloudstack.api.response.GuiThemeResponse;
import org.apache.cloudstack.api.response.HostForMigrationResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
Expand Down Expand Up @@ -145,6 +146,7 @@
import org.apache.cloudstack.direct.download.DirectDownloadCertificate;
import org.apache.cloudstack.direct.download.DirectDownloadCertificateHostMap;
import org.apache.cloudstack.direct.download.DirectDownloadManager;
import org.apache.cloudstack.gui.themes.GuiThemeJoinVO;
import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
import org.apache.cloudstack.region.PortableIp;
Expand Down Expand Up @@ -549,4 +551,6 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
ObjectStoreResponse createObjectStoreResponse(ObjectStore os);

BucketResponse createBucketResponse(Bucket bucket);

GuiThemeResponse createGuiThemeResponse(GuiThemeJoinVO guiThemeJoinVO);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// 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.themes;

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.themes.GuiThemeJoinVO;
import org.apache.cloudstack.gui.themes.GuiThemeVO;
import org.apache.cloudstack.gui.themes.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 = {GuiThemeVO.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
since = "4.20.0.0", authorized = {RoleType.Admin})
public class CreateGuiThemeCmd extends BaseCmd {

Check warning on line 37 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L37 was not covered by tests

@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/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L68 was not covered by tests
"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/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L70 was not covered by tests

@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/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L72 was not covered by tests
"value is false.")
private Boolean recursiveDomains = false;

Check warning on line 74 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L74 was not covered by tests

public String getName() {
return name;

Check warning on line 77 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L77 was not covered by tests
}

public String getDescription() {
return description;

Check warning on line 81 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L81 was not covered by tests
}

public String getCss() {
return css;

Check warning on line 85 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L85 was not covered by tests
}

public String getJsonConfiguration() {
return jsonConfiguration;

Check warning on line 89 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L89 was not covered by tests
}

public String getCommonNames() {
return commonNames;

Check warning on line 93 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L93 was not covered by tests
}

public String getDomainIds() {
return domainIds;

Check warning on line 97 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L97 was not covered by tests
}

public String getAccountIds() {
return accountIds;

Check warning on line 101 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L101 was not covered by tests
}

public Boolean getPublic() {
return isPublic;

Check warning on line 105 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L105 was not covered by tests
}

public Boolean getRecursiveDomains() {
return recursiveDomains;

Check warning on line 109 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L109 was not covered by tests
}

@Override
public void execute() {
CallContext.current().setEventDetails(String.format("Name: %s, AccountIDs: %s, DomainIDs: %s, RecursiveDomains: %s, CommonNames: %s", getName(), getAccountIds(),
getDomainIds(), getRecursiveDomains(), getCommonNames()));
GuiThemeJoinVO guiTheme = guiThemeService.createGuiTheme(this);

Check warning on line 116 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java#L114-L116

Added lines #L114 - L116 were not covered by tests

if (guiTheme == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create the GUI theme.");

Check warning on line 119 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L119 was not covered by tests
}

GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiTheme);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}

Check warning on line 125 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java#L122-L125

Added lines #L122 - L125 were not covered by tests

@Override
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();

Check warning on line 129 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L129 was not covered by tests
}
}
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.themes;

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.themes.GuiThemeVO;
import org.apache.cloudstack.gui.themes.GuiThemeService;

import javax.inject.Inject;

@APICommand(name = "listGuiThemes", description = "Lists GUI themes.", responseObject = GuiThemeResponse.class, entityType = {GuiThemeVO.class},
since = "4.20.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.User, RoleType.DomainAdmin,
RoleType.ResourceAdmin})
public class ListGuiThemesCmd extends BaseListCmd {

Check warning on line 36 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L36

Added line #L36 was not covered by tests

@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/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L56

Added line #L56 was not covered by tests
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/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L59

Added line #L59 was not covered by tests
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/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L65

Added line #L65 was not covered by tests
private boolean listOnlyDefaultTheme = false;

public Long getId() {
return id;

Check warning on line 69 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L69

Added line #L69 was not covered by tests
}

public String getName() {
return name;

Check warning on line 73 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L73

Added line #L73 was not covered by tests
}

public String getCommonName() {
return commonName;

Check warning on line 77 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L77

Added line #L77 was not covered by tests
}

public Long getDomainId() {
return domainId;

Check warning on line 81 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L81

Added line #L81 was not covered by tests
}

public Long getAccountId() {
return accountId;

Check warning on line 85 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L85

Added line #L85 was not covered by tests
}

public boolean getListAll() {
return listAll;

Check warning on line 89 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L89

Added line #L89 was not covered by tests
}

public boolean getShowRemoved() {
return showRemoved;

Check warning on line 93 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L93

Added line #L93 was not covered by tests
}

public Boolean getShowPublic() {
return showPublic;

Check warning on line 97 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L97

Added line #L97 was not covered by tests
}

public boolean getListOnlyDefaultTheme() {
return listOnlyDefaultTheme;

Check warning on line 101 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L101

Added line #L101 was not covered by tests
}

@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/themes/ListGuiThemesCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java#L106-L109

Added lines #L106 - L109 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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.themes;

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.themes.GuiThemeVO;
import org.apache.cloudstack.gui.themes.GuiThemeService;

import javax.inject.Inject;

@APICommand(name = "removeGuiTheme", description = "Removes an existing GUI theme.", responseObject = GuiThemeResponse.class, entityType = {GuiThemeVO.class},
since = "4.20.0.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin})
public class RemoveGuiThemeCmd extends BaseCmd {

Check warning on line 34 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/RemoveGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/RemoveGuiThemeCmd.java#L34

Added line #L34 was not covered by tests

@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 44 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/RemoveGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/RemoveGuiThemeCmd.java#L44

Added line #L44 was not covered by tests
}

@Override
public void execute() {
CallContext.current().setEventDetails(String.format("ID: %s", getId()));
guiThemeService.removeGuiTheme(this);
final SuccessResponse response = new SuccessResponse();
response.setResponseName(getCommandName());
response.setSuccess(true);
setResponseObject(response);
}

Check warning on line 55 in api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/RemoveGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/RemoveGuiThemeCmd.java#L49-L55

Added lines #L49 - L55 were not covered by tests

@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/themes/RemoveGuiThemeCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/RemoveGuiThemeCmd.java#L59

Added line #L59 was not covered by tests
}
}