mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Change two static response views to Full and Restricted.
This commit is contained in:
parent
7ed030115e
commit
81a794a5d3
@ -40,7 +40,7 @@ public @interface APICommand {
|
||||
|
||||
String since() default "";
|
||||
|
||||
ResponseView responseView() default ResponseView.Admin;
|
||||
ResponseView responseView() default ResponseView.Full;
|
||||
|
||||
RoleType[] authorized() default {};
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public interface ResponseObject {
|
||||
void setJobStatus(Integer jobStatus);
|
||||
|
||||
public enum ResponseView {
|
||||
Admin,
|
||||
User
|
||||
Full,
|
||||
Restricted
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
|
||||
|
||||
@APICommand(name = "listVirtualMachines", description = "List the virtual machines owned by the account.", responseObject = UserVmResponse.class, responseView = ResponseView.Admin)
|
||||
@APICommand(name = "listVirtualMachines", description = "List the virtual machines owned by the account.", responseObject = UserVmResponse.class, responseView = ResponseView.Full)
|
||||
public class ListVMsCmdByAdmin extends ListVMsCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListVMsCmdByAdmin.class.getName());
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
|
||||
|
||||
@APICommand(name = "listVirtualMachines", description = "List the virtual machines owned by the account.", responseObject = UserVmResponse.class, responseView = ResponseView.User)
|
||||
@APICommand(name = "listVirtualMachines", description = "List the virtual machines owned by the account.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted)
|
||||
public class ListVMsCmd extends BaseListTaggedResourcesCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListVMsCmd.class.getName());
|
||||
|
||||
|
||||
@ -887,9 +887,9 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
||||
return cmdList.get(0);
|
||||
else {
|
||||
// determine the cmd class based on calling context
|
||||
ResponseView view = ResponseView.User;
|
||||
ResponseView view = ResponseView.Restricted;
|
||||
if (_accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())) {
|
||||
view = ResponseView.Admin;
|
||||
view = ResponseView.Full;
|
||||
}
|
||||
for (Class<?> cmdClass : cmdList) {
|
||||
APICommand at = cmdClass.getAnnotation(APICommand.class);
|
||||
|
||||
@ -737,9 +737,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
||||
public ListResponse<UserVmResponse> searchForUserVMs(ListVMsCmd cmd) {
|
||||
Pair<List<UserVmJoinVO>, Integer> result = searchForUserVMsInternal(cmd);
|
||||
ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
|
||||
ResponseView respView = ResponseView.User;
|
||||
ResponseView respView = ResponseView.Restricted;
|
||||
if (cmd instanceof ListVMsCmdByAdmin) {
|
||||
respView = ResponseView.Admin;
|
||||
respView = ResponseView.Full;
|
||||
}
|
||||
List<UserVmResponse> vmResponses = ViewResponseHelper.createUserVmResponse(respView, "virtualmachine", cmd.getDetails(),
|
||||
result.first().toArray(new UserVmJoinVO[result.first().size()]));
|
||||
|
||||
@ -127,7 +127,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
|
||||
}
|
||||
userVmResponse.setZoneId(userVm.getDataCenterUuid());
|
||||
userVmResponse.setZoneName(userVm.getDataCenterName());
|
||||
if (view == ResponseView.Admin || ((view == null) && ((caller == null) || (_accountMgr.isRootAdmin(caller.getId()))))) {
|
||||
if (view == ResponseView.Full || ((view == null) && ((caller == null) || (_accountMgr.isRootAdmin(caller.getId()))))) {
|
||||
userVmResponse.setInstanceName(userVm.getInstanceName());
|
||||
userVmResponse.setHostId(userVm.getHostUuid());
|
||||
userVmResponse.setHostName(userVm.getHostName());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user