Skip to content

Commit 08f2ec5

Browse files
committed
Merge pull request #1263 from rafaelweingartner/lrg-cs-hackday-018
Removed unused code from com.cloud.api.ApiServer**Removed \_ from variables names**: private variables with \_ at the beginning 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 be accessible (setAccessible(true)). Thus, there is no reason for handleAsyncJobPublishEvent be a private method and lead some other dev to wrong conclusions about the use of the 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 Spring, they were changed to non-static. With that, calls from com.cloud.api.ApiServlet.ApiServlet() that used static methods from ApiServer, were 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 added in the interface (org.apache.cloudstack.api.ApiServerService, interface implemented by class ApiServer). * pr/1263: The goal of this PR is to review com.cloud.api.ApiServer class, with the following actions: Signed-off-by: Will Stevens <williamstevens@gmail.com>
2 parents 749b716 + 48888e7 commit 08f2ec5

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)