Skip to content

Commit 48888e7

Browse files
author
gabrascher
committed
The goal of this PR is to review com.cloud.api.ApiServer class, with the
following actions: Removed “_” in beginning of global variables names: Variables was changed from “_<variablename>” to “<variablename>”, as this convension (private veriables with “_”) is common in C++ but not in Java. Removed unused code from ApiServer: - com.cloud.api.ApiServer.getPluggableServices(): Unused method. - com.cloud.api.ApiServer.getApiAccessCheckers(): Unused method. Methods and variables access level reviewed: - com.cloud.api.ApiServer.handleAsyncJobPublishEvent(String, String, Object): This method was private but the annotation @MessageHandler requests public methods, as can be seen in org.apache.cloudstack.framework.messagebus.MessageDispatcher.buildHandlerMethodCache(Class<?>), which searches methods with the @MessageHandler annotation and changes it to accessible (“setAccessible(true)”). Thus, there is no reason for handleAsyncJobPublishEvent be a private method. - Global variables and methods called just by this class (ApiServer) were changed to private. Changed variables and methods from static to non static (if possible): As some variables/methods are used just by one object of this class (instantiated by springer), they were changed to non static. With that, calls from com.cloud.api.ApiServlet.ApiServlet() that used static methods from ApiServer, was changed from ApiServer.<staticMethodName> to _apiServer.<methodName> that refers to the org.apache.cloudstack.api.ApiServerService interface. Thus, methods com.cloud.api.ApiServer.getJSONContentType() and com.cloud.api.ApiServer.isSecureSessionCookieEnabled() had to be included in the interface (org.apache.cloudstack.api.ApiServerService, interface implemented by class ApiServer). However, com.cloud.api.ApiServer.isEncodeApiResponse() was keept static, as its call hierarchy would have to be changed (more than planed for this PR).
1 parent 94a1448 commit 48888e7

4 files changed

Lines changed: 223 additions & 222 deletions

File tree

api/src/org/apache/cloudstack/api/ApiServerService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616
// under the License.
1717
package org.apache.cloudstack.api;
1818

19-
import com.cloud.exception.CloudAuthenticationException;
20-
import javax.servlet.http.HttpSession;
21-
import java.util.Map;
2219
import java.net.InetAddress;
20+
import java.util.Map;
21+
22+
import javax.servlet.http.HttpSession;
23+
24+
import com.cloud.exception.CloudAuthenticationException;
2325

2426
public interface ApiServerService {
2527
public boolean verifyRequest(Map<String, Object[]> requestParameters, Long userId) throws ServerApiException;
2628

2729
public Long fetchDomainId(String domainUUID);
2830

2931
public ResponseObject loginUser(HttpSession session, String username, String password, Long domainId, String domainPath, InetAddress loginIpAddress,
30-
Map<String, Object[]> requestParameters) throws CloudAuthenticationException;
32+
Map<String, Object[]> requestParameters) throws CloudAuthenticationException;
3133

3234
public void logoutUser(long userId);
3335

@@ -40,4 +42,8 @@ public ResponseObject loginUser(HttpSession session, String username, String pas
4042
public String handleRequest(Map params, String responseType, StringBuilder auditTrailSb) throws ServerApiException;
4143

4244
public Class<?> getCmdClass(String cmdName);
45+
46+
public String getJSONContentType();
47+
48+
public boolean isSecureSessionCookieEnabled();
4349
}

0 commit comments

Comments
 (0)