mirror of https://github.com/apache/cloudstack.git
Added new parameter to listCapabilities identifying if regular user can create projects
This commit is contained in:
parent
8384b0102f
commit
e1cf8e4933
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -15,4 +15,6 @@ public interface ProjectManager extends ProjectService {
|
|||
List<Long> listPermittedProjectAccounts(long accountId);
|
||||
|
||||
boolean projectInviteRequired();
|
||||
|
||||
boolean allowUserToCreateProject();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, String> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue