use of org.apache.cloudstack.api.response.ProjectResponse in project cloudstack by apache.
the class ProjectJoinDaoImpl method newProjectResponse.
@Override
public ProjectResponse newProjectResponse(ProjectJoinVO proj) {
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
Long tag_id = proj.getTagId();
if (tag_id != null && tag_id.longValue() > 0) {
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)
Account account = _accountDao.findByIdIncludingRemoved(proj.getProjectAccountId());
AccountJoinVO accountJn = ApiDBUtils.newAccountView(account);
_accountJoinDao.setResourceLimits(accountJn, false, response);
response.setProjectAccountName(accountJn.getAccountName());
response.setObjectName("project");
return response;
}
use of org.apache.cloudstack.api.response.ProjectResponse in project cloudstack by apache.
the class UpdateProjectCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceAllocationException {
CallContext.current().setEventDetails("Project id: " + getId());
if (getAccountName() != null && getUserId() != null) {
throw new InvalidParameterValueException("Account name and user ID are mutually exclusive. Provide either account name" + "to update account or user ID to update the user of the project");
}
Project project = null;
if (isSwapOwner()) {
project = _projectService.updateProject(getId(), getDisplayText(), getAccountName());
} else {
project = _projectService.updateProject(getId(), getDisplayText(), getAccountName(), getUserId(), getAccountRole());
}
if (project != null) {
ProjectResponse response = _responseGenerator.createProjectResponse(project);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update a project");
}
}
use of org.apache.cloudstack.api.response.ProjectResponse in project cloudstack by apache.
the class ViewResponseHelper method createProjectResponse.
public static List<ProjectResponse> createProjectResponse(ProjectJoinVO... projects) {
Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<Long, ProjectResponse>();
// Initialise the prjdatalist with the input data
for (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<ProjectResponse>(prjDataList.values());
}
use of org.apache.cloudstack.api.response.ProjectResponse in project cloudstack by apache.
the class SuspendProjectCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
CallContext.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(ApiErrorCode.INTERNAL_ERROR, "Failed to suspend a project");
}
}
use of org.apache.cloudstack.api.response.ProjectResponse in project cloudstack by apache.
the class ActivateProjectCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
CallContext.current().setEventDetails("Project id: " + getId());
Project project = _projectService.activateProject(getId());
if (project != null) {
ProjectResponse response = _responseGenerator.createProjectResponse(project);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to activate a project");
}
}
Aggregations