mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
SWIFT : API refine
This commit is contained in:
parent
678ea310d8
commit
5346a61917
@ -24,10 +24,9 @@ import java.util.List;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.BaseCmd;
|
||||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.HostResponse;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.SwiftResponse;
|
||||
@ -35,9 +34,9 @@ import com.cloud.storage.Swift;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@Implementation(description = "List Swift.", responseObject = HostResponse.class)
|
||||
public class ListSwiftsCmd extends BaseCmd {
|
||||
public class ListSwiftsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListSwiftsCmd.class.getName());
|
||||
private static final String s_name = "listswiftresponse";
|
||||
private static final String s_name = "listswiftsresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
@ -79,12 +78,9 @@ public class ListSwiftsCmd extends BaseCmd {
|
||||
swiftResponse.setObjectName("swift");
|
||||
swiftResponses.add(swiftResponse);
|
||||
}
|
||||
response.setResponses(swiftResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
} else {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Swift");
|
||||
}
|
||||
response.setResponses(swiftResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +59,8 @@ import com.cloud.storage.dao.VMTemplateHostDao;
|
||||
import com.cloud.storage.dao.VMTemplateSwiftDao;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.SearchCriteriaService;
|
||||
@ -267,14 +269,13 @@ public class SwiftManagerImpl implements SwiftManager {
|
||||
|
||||
@Override
|
||||
public List<SwiftVO> listSwifts(ListSwiftsCmd cmd) {
|
||||
if (cmd.getId() == null) {
|
||||
return _swiftDao.listAll();
|
||||
} else {
|
||||
List<SwiftVO> list = new ArrayList<SwiftVO>();
|
||||
SwiftVO swift = _swiftDao.findById(cmd.getId());
|
||||
list.add(swift);
|
||||
return list;
|
||||
Filter searchFilter = new Filter(SwiftVO.class, "id", Boolean.TRUE, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
SearchCriteria<SwiftVO> sc = _swiftDao.createSearchCriteria();
|
||||
if (cmd.getId() != null) {
|
||||
sc.addAnd("id", SearchCriteria.Op.EQ, cmd.getId());
|
||||
}
|
||||
return _swiftDao.search(sc, searchFilter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user