use of com.cloud.api.response.ProjectResponse in project CloudStack-archive by CloudStack-extras.
the class SuspendProjectCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
UserContext.current().setEventDetails("Project Id: " + id);
Project project = _projectService.suspendProject(id);
if (project != null) {
ProjectResponse response = _responseGenerator.createProjectResponse(project);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to suspend a project");
}
}
use of com.cloud.api.response.ProjectResponse in project CloudStack-archive by CloudStack-extras.
the class UpdateProjectCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceAllocationException {
UserContext.current().setEventDetails("Project id: " + getId());
Project project = _projectService.updateProject(getId(), getDisplayText(), getAccountName());
if (project != null) {
ProjectResponse response = _responseGenerator.createProjectResponse(project);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update a project");
}
}
use of com.cloud.api.response.ProjectResponse in project cosmic by MissionCriticalCloud.
the class ViewResponseHelper method createProjectResponse.
public static List<ProjectResponse> createProjectResponse(final ProjectJoinVO... projects) {
final Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<>();
// Initialise the prjdatalist with the input data
for (final ProjectJoinVO p : projects) {
ProjectResponse pData = prjDataList.get(p.getId());
if (pData == null) {
// first time encountering this vm
pData = ApiDBUtils.newProjectResponse(p);
} else {
// update those 1 to many mapping fields
pData = ApiDBUtils.fillProjectDetails(pData, p);
}
prjDataList.put(p.getId(), pData);
}
return new ArrayList<>(prjDataList.values());
}
use of com.cloud.api.response.ProjectResponse in project cosmic by MissionCriticalCloud.
the class ProjectJoinDaoImpl method newProjectResponse.
@Override
public ProjectResponse newProjectResponse(final ProjectJoinVO proj) {
final ProjectResponse response = new ProjectResponse();
response.setId(proj.getUuid());
response.setName(proj.getName());
response.setDisplaytext(proj.getDisplayText());
if (proj.getState() != null) {
response.setState(proj.getState().toString());
}
response.setDomainId(proj.getDomainUuid());
response.setDomain(proj.getDomainName());
response.setOwner(proj.getOwner());
// update tag information
final Long tag_id = proj.getTagId();
if (tag_id != null && tag_id.longValue() > 0) {
final ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
if (vtag != null) {
response.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
}
}
// set resource limit/count information for the project (by getting the info of the project's account)
final Account account = _accountDao.findByIdIncludingRemoved(proj.getProjectAccountId());
final AccountJoinVO accountJn = ApiDBUtils.newAccountView(account);
_accountJoinDao.setResourceLimits(accountJn, false, response);
response.setObjectName("project");
return response;
}
use of com.cloud.api.response.ProjectResponse in project cosmic by MissionCriticalCloud.
the class SuspendProjectCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
CallContext.current().setEventDetails("Project Id: " + id);
final Project project = _projectService.suspendProject(id);
if (project != null) {
final ProjectResponse response = _responseGenerator.createProjectResponse(project);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to suspend a project");
}
}
Aggregations