Template id is not a required parameter when listing templates. The proper serialized name for the async job id is jobid, not id. Sadly, ctxAccoutId != ctxAccountId, ugh, no wonder the UserContext wasn't getting set up correctly. Clean up some miscellaneous unnecessary casts.

This commit is contained in:
Kris McQueen 2010-09-21 17:00:50 -07:00
parent 5a3f4af638
commit c32d6e7524
9 changed files with 22 additions and 25 deletions

View File

@ -284,7 +284,7 @@ public abstract class BaseCmd {
}
// we are ready to store the value for a particular field into the map for this object
mapValue.put(fieldName, (String)params.get(key));
mapValue.put(fieldName, params.get(key));
lowercaseParams.put(paramName, mapArray);
} else {

View File

@ -58,7 +58,7 @@ public class ListTemplatesCmd extends BaseListCmd {
@Parameter(name="domainid", type=CommandType.LONG)
private Long domainId;
@Parameter(name="id", type=CommandType.LONG, required=true)
@Parameter(name="id", type=CommandType.LONG)
private Long id;
@Parameter(name="name", type=CommandType.STRING)

View File

@ -22,7 +22,7 @@ import java.util.Date;
import com.google.gson.annotations.SerializedName;
public class AsyncJobResponse extends BaseResponse {
@SerializedName("id")
@SerializedName("jobid")
private Long id;
@SerializedName("accountid")

View File

@ -438,7 +438,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
// whenever we deserialize, the UserContext needs to be updated
String userIdStr = params.get("ctxUserId");
String acctIdStr = params.get("ctxAccoutId");
String acctIdStr = params.get("ctxAccountId");
Long userId = null;
Account accountObject = null;

View File

@ -1271,10 +1271,10 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
}
} else if (instanceId != null) {
return listNetworkGroupRulesByVM(((Long)instanceId).longValue());
return listNetworkGroupRulesByVM(instanceId.longValue());
} else if (domainId != null) {
if (Boolean.TRUE.equals(recursive)) {
DomainVO domain = _domainDao.findById((Long)domainId);
DomainVO domain = _domainDao.findById(domainId);
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
} else {
sc.setParameters("domainId", domainId);

View File

@ -1704,7 +1704,8 @@ public class ManagementServerImpl implements ManagementServer {
String group = cmd.getGroup();
String userData = cmd.getUserData();
String[] networkGroups = null;
Long size = cmd.getSize();
Long sizeObj = cmd.getSize();
long size = (sizeObj == null) ? 0 : sizeObj;
if ((ctxAccount == null) || isAdmin(ctxAccount.getType())) {
if (domainId != null) {
@ -2700,7 +2701,7 @@ public class ManagementServerImpl implements ManagementServer {
sc.setParameters("domainId", domainId);
}
} else if (domainId != null) {
DomainVO domainVO = _domainDao.findById((Long)domainId);
DomainVO domainVO = _domainDao.findById(domainId);
sc.setJoinParameters("domainSearch", "path", domainVO.getPath() + "%");
}
@ -3281,7 +3282,7 @@ public class ManagementServerImpl implements ManagementServer {
if (accountId != null) {
sc.setParameters("id", accountId);
} else if (domainId != null) {
DomainVO domain = _domainDao.findById((Long)domainId);
DomainVO domain = _domainDao.findById(domainId);
// I want to join on user_vm.domain_id = domain.id where domain.path like 'foo%'
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
@ -3927,7 +3928,7 @@ public class ManagementServerImpl implements ManagementServer {
sc.setParameters("accountName", "%" + accountName + "%");
sc.addAnd("removed", SearchCriteria.Op.NULL);
} else if (isAdmin) {
DomainVO domain = _domainDao.findById((Long)domainId);
DomainVO domain = _domainDao.findById(domainId);
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
}
}
@ -4027,7 +4028,7 @@ public class ManagementServerImpl implements ManagementServer {
if (accountId != null) {
sc.setParameters("accountId", accountId);
} else if (domainId != null) {
DomainVO domain = _domainDao.findById((Long)domainId);
DomainVO domain = _domainDao.findById(domainId);
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
}
@ -4194,7 +4195,7 @@ public class ManagementServerImpl implements ManagementServer {
if (accountId != null) {
sc.setParameters("accountIdEQ", accountId);
} else if (domainId != null) {
DomainVO domain = _domainDao.findById((Long)domainId);
DomainVO domain = _domainDao.findById(domainId);
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
}
if (type != null) {
@ -4292,7 +4293,7 @@ public class ManagementServerImpl implements ManagementServer {
sb.join("vlanSearch", vlanSearch, sb.entity().getVlanDbId(), vlanSearch.entity().getId());
}
if ((isAllocated != null) && ((Boolean) isAllocated == true)) {
if ((isAllocated != null) && (isAllocated == true)) {
sb.and("allocated", sb.entity().getAllocated(), SearchCriteria.Op.NNULL);
}
@ -4300,7 +4301,7 @@ public class ManagementServerImpl implements ManagementServer {
if (accountId != null) {
sc.setParameters("accountIdEQ", accountId);
} else if (domainId != null) {
DomainVO domain = _domainDao.findById((Long)domainId);
DomainVO domain = _domainDao.findById(domainId);
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
}
@ -5135,7 +5136,7 @@ public class ManagementServerImpl implements ManagementServer {
if(intervalType == null) {
throw new InvalidParameterValueException("Unsupported interval type " + intervalType);
}
SnapshotPolicyVO snapPolicy = _snapMgr.getPolicyForVolumeByInterval((Long)volumeId, (short)intervalType.ordinal());
SnapshotPolicyVO snapPolicy = _snapMgr.getPolicyForVolumeByInterval(volumeId, (short)intervalType.ordinal());
if (snapPolicy == null) {
s_logger.warn("Policy with interval "+ intervalType +" not assigned to volume: "+volumeId);
return new ArrayList<SnapshotVO>();

View File

@ -2354,9 +2354,8 @@ public class StorageManagerImpl implements StorageManager {
@Override
public boolean deleteVolume(DeleteVolumeCmd cmd) throws InvalidParameterValueException {
Account account = (Account) UserContext.current().getAccountObject();
Long volumeId = (Long) cmd.getId();
Long volumeId = cmd.getId();
boolean isAdmin;
if (account == null) {

View File

@ -1520,8 +1520,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
@Override
public boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd) throws InvalidParameterValueException {
Long policyId = (Long)cmd.getId();
Long policyId = cmd.getId();
List<Long> policyIds = cmd.getIds();
Long userId = UserContext.current().getUserId();

View File

@ -1106,12 +1106,11 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public boolean deleteTemplate(DeleteTemplateCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException{
public boolean deleteTemplate(DeleteTemplateCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException {
Long templateId = cmd.getId();
Long userId = UserContext.current().getUserId();
Account account = (Account)UserContext.current().getAccountObject();
Long zoneId = (Long)cmd.getZoneId();
Long zoneId = cmd.getZoneId();
VMTemplateVO template = _tmpltDao.findById(templateId.longValue());
if (template == null) {
@ -1140,12 +1139,11 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public boolean deleteIso(DeleteIsoCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException{
public boolean deleteIso(DeleteIsoCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException {
Long templateId = cmd.getId();
Long userId = UserContext.current().getUserId();
Account account = (Account)UserContext.current().getAccountObject();
Long zoneId = (Long)cmd.getZoneId();
Long zoneId = cmd.getZoneId();
VMTemplateVO template = _tmpltDao.findById(templateId.longValue());
if (template == null) {