Search in sources :

Example 1 with ProjectResponse

use of com.cloud.api.response.ProjectResponse in project CloudStack-archive by CloudStack-extras.

the class CreateProjectCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    Project project = _projectService.enableProject(this.getEntityId());
    if (project != null) {
        ProjectResponse response = _responseGenerator.createProjectResponse(project);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a project");
    }
}
Also used : Project(com.cloud.projects.Project) ProjectResponse(com.cloud.api.response.ProjectResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 2 with ProjectResponse

use of com.cloud.api.response.ProjectResponse in project CloudStack-archive by CloudStack-extras.

the class ActivateProjectCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    UserContext.current().setEventDetails("Project id: " + getId());
    Project project = _projectService.activateProject(id);
    if (project != null) {
        ProjectResponse response = _responseGenerator.createProjectResponse(project);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to activate a project");
    }
}
Also used : Project(com.cloud.projects.Project) ProjectResponse(com.cloud.api.response.ProjectResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 3 with ProjectResponse

use of com.cloud.api.response.ProjectResponse in project cosmic by MissionCriticalCloud.

the class UpdateProjectCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceAllocationException {
    CallContext.current().setEventDetails("Project id: " + getId());
    final Project project = _projectService.updateProject(getId(), getDisplayText(), getAccountName());
    if (project != null) {
        final ProjectResponse response = _responseGenerator.createProjectResponse(project);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update a project");
    }
}
Also used : Project(com.cloud.projects.Project) ProjectResponse(com.cloud.api.response.ProjectResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 4 with ProjectResponse

use of com.cloud.api.response.ProjectResponse in project cosmic by MissionCriticalCloud.

the class CreateProjectCmd method execute.

// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final Project project = _projectService.enableProject(this.getEntityId());
    if (project != null) {
        final ProjectResponse response = _responseGenerator.createProjectResponse(project);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a project");
    }
}
Also used : Project(com.cloud.projects.Project) ProjectResponse(com.cloud.api.response.ProjectResponse) ServerApiException(com.cloud.api.ServerApiException)

Example 5 with ProjectResponse

use of com.cloud.api.response.ProjectResponse in project CloudStack-archive by CloudStack-extras.

the class ListProjectsCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
    List<? extends Project> projects = _projectService.listProjects(id, name, displayText, state, this.getAccountName(), this.getDomainId(), this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), this.listAll(), this.isRecursive());
    ListResponse<ProjectResponse> response = new ListResponse<ProjectResponse>();
    List<ProjectResponse> projectResponses = new ArrayList<ProjectResponse>();
    for (Project project : projects) {
        ProjectResponse projectResponse = _responseGenerator.createProjectResponse(project);
        projectResponses.add(projectResponse);
    }
    response.setResponses(projectResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : Project(com.cloud.projects.Project) ProjectResponse(com.cloud.api.response.ProjectResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList)

Aggregations

ProjectResponse (com.cloud.api.response.ProjectResponse)11 Project (com.cloud.projects.Project)9 ServerApiException (com.cloud.api.ServerApiException)8 ArrayList (java.util.ArrayList)2 AccountJoinVO (com.cloud.api.query.vo.AccountJoinVO)1 ProjectJoinVO (com.cloud.api.query.vo.ProjectJoinVO)1 ResourceTagJoinVO (com.cloud.api.query.vo.ResourceTagJoinVO)1 ListResponse (com.cloud.api.response.ListResponse)1 Account (com.cloud.user.Account)1 Hashtable (java.util.Hashtable)1