From 743be91e20bda3cc2b6659c1ebd0e2d3774c230c Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Fri, 9 Dec 2011 12:34:17 -0800 Subject: [PATCH] Added projectinviterequired capability to the listCapabilities API response --- api/src/com/cloud/api/ApiConstants.java | 1 + .../api/commands/ListCapabilitiesCmd.java | 1 + .../api/response/CapabilitiesResponse.java | 29 ++++++------------- .../cloud/api/response/ProjectResponse.java | 1 + .../com/cloud/projects/ProjectManager.java | 3 ++ .../cloud/projects/ProjectManagerImpl.java | 6 ++++ .../cloud/server/ManagementServerImpl.java | 2 ++ 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index df01e6d660d..5e94085093a 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -319,6 +319,7 @@ public class ApiConstants { public static final String ASSOCIATED_NETWORK_ID = "associatednetworkid"; public static final String SOURCE_NAT_SUPPORTED = "sourcenatsupported"; public static final String RESOURCE_STATE = "resourcestate"; + public static final String PROJECT_INVITE_REQUIRED = "projectinviterequired"; public enum HostDetails { all, capacity, events, stats, min; diff --git a/api/src/com/cloud/api/commands/ListCapabilitiesCmd.java b/api/src/com/cloud/api/commands/ListCapabilitiesCmd.java index 87e9f37d54a..792047b22f4 100644 --- a/api/src/com/cloud/api/commands/ListCapabilitiesCmd.java +++ b/api/src/com/cloud/api/commands/ListCapabilitiesCmd.java @@ -51,6 +51,7 @@ public class ListCapabilitiesCmd extends BaseCmd { response.setUserPublicTemplateEnabled((Boolean)capabilities.get("userPublicTemplateEnabled")); response.setSupportELB((String)capabilities.get("supportELB")); response.setFirewallRuleUiEnabled((Boolean) capabilities.get("firewallRuleUiEnabled")); + response.setProjectInviteRequired((Boolean)capabilities.get("projectInviteRequired")); response.setObjectName("capability"); response.setResponseName(getCommandName()); this.setResponseObject(response); diff --git a/api/src/com/cloud/api/response/CapabilitiesResponse.java b/api/src/com/cloud/api/response/CapabilitiesResponse.java index 8f3ec32ed52..357b4517887 100644 --- a/api/src/com/cloud/api/response/CapabilitiesResponse.java +++ b/api/src/com/cloud/api/response/CapabilitiesResponse.java @@ -18,9 +18,11 @@ package com.cloud.api.response; +import com.cloud.api.ApiConstants; import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; +@SuppressWarnings("unused") public class CapabilitiesResponse extends BaseResponse { @SerializedName("securitygroupsenabled") @Param(description="true if security groups support is enabled, false otherwise") private boolean securityGroupsEnabled; @@ -36,26 +38,17 @@ public class CapabilitiesResponse extends BaseResponse { @SerializedName("supportELB") @Param(description="true if region supports elastic load balancer on basic zones") private String supportELB; - - public boolean getSecurityGroupsEnabled() { - return securityGroupsEnabled; - } + + @SerializedName(ApiConstants.PROJECT_INVITE_REQUIRED) @Param(description="If invitation confirmation is required when add account to project") + private Boolean projectInviteRequired; public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) { this.securityGroupsEnabled = securityGroupsEnabled; } - public String getCloudStackVersion() { - return cloudStackVersion; - } - public void setCloudStackVersion(String cloudStackVersion) { this.cloudStackVersion = cloudStackVersion; } - - public boolean getUserPublicTemplateEnabled() { - return securityGroupsEnabled; - } public void setUserPublicTemplateEnabled(boolean userPublicTemplateEnabled) { this.userPublicTemplateEnabled = userPublicTemplateEnabled; @@ -65,15 +58,11 @@ public class CapabilitiesResponse extends BaseResponse { this.supportELB = supportELB; } - public String getSupportELB() { - return supportELB; - } - public void setFirewallRuleUiEnabled(boolean firewallRuleUiEnabled) { this.firewallRuleUiEnabled = firewallRuleUiEnabled; } - - public boolean getFirewallRuleUiEnabled() { - return firewallRuleUiEnabled; - } + + public void setProjectInviteRequired(Boolean projectInviteRequired) { + this.projectInviteRequired = projectInviteRequired; + } } diff --git a/api/src/com/cloud/api/response/ProjectResponse.java b/api/src/com/cloud/api/response/ProjectResponse.java index 2d9a89ea5dd..4459cad0555 100644 --- a/api/src/com/cloud/api/response/ProjectResponse.java +++ b/api/src/com/cloud/api/response/ProjectResponse.java @@ -46,6 +46,7 @@ public class ProjectResponse extends BaseResponse{ @SerializedName(ApiConstants.STATE) @Param(description="the state of the project") private String state; + public void setId(Long id) { this.id.setValue(id); diff --git a/server/src/com/cloud/projects/ProjectManager.java b/server/src/com/cloud/projects/ProjectManager.java index c12582ed1f0..ff56a53d434 100644 --- a/server/src/com/cloud/projects/ProjectManager.java +++ b/server/src/com/cloud/projects/ProjectManager.java @@ -1,3 +1,4 @@ + package com.cloud.projects; import java.util.List; @@ -12,4 +13,6 @@ public interface ProjectManager extends ProjectService { boolean deleteAccountFromProject(long projectId, long accountId); List listPermittedProjectAccounts(long accountId); + + boolean projectInviteRequired(); } diff --git a/server/src/com/cloud/projects/ProjectManagerImpl.java b/server/src/com/cloud/projects/ProjectManagerImpl.java index d0e958c6340..2a0f625acd6 100755 --- a/server/src/com/cloud/projects/ProjectManagerImpl.java +++ b/server/src/com/cloud/projects/ProjectManagerImpl.java @@ -1124,4 +1124,10 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ } } } + + @Override + public boolean projectInviteRequired() { + return _invitationRequired; + } + } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 16a70644ea7..f2f59ceb69f 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -3110,6 +3110,8 @@ public class ManagementServerImpl implements ManagementServer { capabilities.put("cloudStackVersion", getVersion()); capabilities.put("supportELB", supportELB); capabilities.put("firewallRuleUiEnabled", (firewallRuleUiEnabled != null && firewallRuleUiEnabled.equals("true")) ? true : false); + capabilities.put("firewallRuleUiEnabled", (firewallRuleUiEnabled != null && firewallRuleUiEnabled.equals("true")) ? true : false); + capabilities.put("projectInviteRequired", _projectMgr.projectInviteRequired()); return capabilities; }