diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index 42902100d1b..4802b6ecacc 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -318,6 +318,7 @@ public class ApiConstants { public static final String RESOURCE_STATE = "resourcestate"; public static final String PROJECT_INVITE_REQUIRED = "projectinviterequired"; public static final String RESTART_REQUIRED = "restartrequired"; + public static final String ALLOW_USER_CREATE_PROJECTS = "allowusercreateprojects"; 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 792047b22f4..166a72c57ae 100644 --- a/api/src/com/cloud/api/commands/ListCapabilitiesCmd.java +++ b/api/src/com/cloud/api/commands/ListCapabilitiesCmd.java @@ -52,6 +52,7 @@ public class ListCapabilitiesCmd extends BaseCmd { response.setSupportELB((String)capabilities.get("supportELB")); response.setFirewallRuleUiEnabled((Boolean) capabilities.get("firewallRuleUiEnabled")); response.setProjectInviteRequired((Boolean)capabilities.get("projectInviteRequired")); + response.setAllowUsersCreateProjects((Boolean)capabilities.get("allowusercreateprojects")); 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 357b4517887..2aad4254b68 100644 --- a/api/src/com/cloud/api/response/CapabilitiesResponse.java +++ b/api/src/com/cloud/api/response/CapabilitiesResponse.java @@ -41,6 +41,10 @@ public class CapabilitiesResponse extends BaseResponse { @SerializedName(ApiConstants.PROJECT_INVITE_REQUIRED) @Param(description="If invitation confirmation is required when add account to project") private Boolean projectInviteRequired; + + @SerializedName(ApiConstants.ALLOW_USER_CREATE_PROJECTS) @Param(description="true if regular user is allowed to create projects") + private Boolean allowUsersCreateProjects; + public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) { this.securityGroupsEnabled = securityGroupsEnabled; @@ -65,4 +69,9 @@ public class CapabilitiesResponse extends BaseResponse { public void setProjectInviteRequired(Boolean projectInviteRequired) { this.projectInviteRequired = projectInviteRequired; } + + public void setAllowUsersCreateProjects(Boolean allowUsersCreateProjects) { + this.allowUsersCreateProjects = allowUsersCreateProjects; + } + } diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 326a5faf664..1df36afd815 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -321,7 +321,6 @@ public enum Config { ProjectInvitationExpirationTime("Project Defaults", ManagementServer.class, Long.class, "project.invite.timeout", "86400", "Invitation expiration time (in seconds). Default is 1 day - 86400 seconds", null), AllowUserToCreateProject("Project Defaults", ManagementServer.class, Long.class, "allow.user.create.projects", "true", "If regular user can create a project; true by default", null), - ProjectEmailSender("Project Defaults", ManagementServer.class, String.class, "project.email.sender", null, "Sender of project invitation email (will be in the From header of the email)", null), ProjectSMTPHost("Project Defaults", ManagementServer.class, String.class, "project.smtp.host", null, "SMTP hostname used for sending out email project invitations", null), ProjectSMTPPassword("Project Defaults", ManagementServer.class, String.class, "project.smtp.password", null, "Password for SMTP authentication (applies only if project.smtp.useAuth is true)", null), diff --git a/server/src/com/cloud/projects/ProjectManager.java b/server/src/com/cloud/projects/ProjectManager.java index ff56a53d434..b99996be49a 100644 --- a/server/src/com/cloud/projects/ProjectManager.java +++ b/server/src/com/cloud/projects/ProjectManager.java @@ -15,4 +15,6 @@ public interface ProjectManager extends ProjectService { List listPermittedProjectAccounts(long accountId); boolean projectInviteRequired(); + + boolean allowUserToCreateProject(); } diff --git a/server/src/com/cloud/projects/ProjectManagerImpl.java b/server/src/com/cloud/projects/ProjectManagerImpl.java index 950f1f9a0b4..b5a6b0ab60c 100755 --- a/server/src/com/cloud/projects/ProjectManagerImpl.java +++ b/server/src/com/cloud/projects/ProjectManagerImpl.java @@ -113,7 +113,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ protected boolean _invitationRequired = false; protected long _invitationTimeOut = 86400000; - protected boolean _allowUserToCreateProjet = true; + protected boolean _allowUserToCreateProject = true; protected ScheduledExecutorService _executor; protected int _projectCleanupExpInvInterval = 60; //Interval defining how often project invitation cleanup thread is running @@ -125,7 +125,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ Map configs = _configDao.getConfiguration(params); _invitationRequired = Boolean.valueOf(configs.get(Config.ProjectInviteRequired.key())); _invitationTimeOut = Long.valueOf(configs.get(Config.ProjectInvitationExpirationTime.key()))*1000; - _allowUserToCreateProjet = Boolean.valueOf(configs.get(Config.AllowUserToCreateProject.key())); + _allowUserToCreateProject = Boolean.valueOf(configs.get(Config.AllowUserToCreateProject.key())); // set up the email system for project invitations @@ -173,7 +173,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ Account owner = caller; //check if the user authorized to create the project - if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && !_allowUserToCreateProjet) { + if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL && !_allowUserToCreateProject) { throw new PermissionDeniedException("Regular user is not permitted to create a project"); } @@ -1147,4 +1147,9 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ return _invitationRequired; } + @Override + public boolean allowUserToCreateProject() { + return _allowUserToCreateProject; + } + } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 67630053992..e61360884fd 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -3122,6 +3122,7 @@ public class ManagementServerImpl implements ManagementServer { 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()); + capabilities.put("allowusercreateprojects", _projectMgr.allowUserToCreateProject()); return capabilities; }