Search in sources :

Example 1 with SwiftResponse

use of com.cloud.api.response.SwiftResponse in project CloudStack-archive by CloudStack-extras.

the class ListSwiftsCmd method execute.

@Override
public void execute() {
    List<? extends Swift> result = _resourceService.listSwifts(this);
    ListResponse<SwiftResponse> response = new ListResponse<SwiftResponse>();
    List<SwiftResponse> swiftResponses = new ArrayList<SwiftResponse>();
    if (result != null) {
        SwiftResponse swiftResponse = null;
        for (Swift swift : result) {
            swiftResponse = _responseGenerator.createSwiftResponse(swift);
            swiftResponse.setResponseName(getCommandName());
            swiftResponse.setObjectName("swift");
            swiftResponses.add(swiftResponse);
        }
    }
    response.setResponses(swiftResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) SwiftResponse(com.cloud.api.response.SwiftResponse) ArrayList(java.util.ArrayList) Swift(com.cloud.storage.Swift)

Example 2 with SwiftResponse

use of com.cloud.api.response.SwiftResponse in project CloudStack-archive by CloudStack-extras.

the class AddSwiftCmd method execute.

@Override
public void execute() {
    try {
        Swift result = _resourceService.discoverSwift(this);
        SwiftResponse swiftResponse = null;
        if (result != null) {
            swiftResponse = _responseGenerator.createSwiftResponse(result);
            swiftResponse.setResponseName(getCommandName());
            swiftResponse.setObjectName("swift");
            this.setResponseObject(swiftResponse);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Swift");
        }
    } catch (DiscoveryException ex) {
        String errMsg = "Failed to add Swift due to " + ex.toString();
        s_logger.warn(errMsg, ex);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, errMsg);
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) SwiftResponse(com.cloud.api.response.SwiftResponse) Swift(com.cloud.storage.Swift) DiscoveryException(com.cloud.exception.DiscoveryException)

Aggregations

SwiftResponse (com.cloud.api.response.SwiftResponse)2 Swift (com.cloud.storage.Swift)2 ServerApiException (com.cloud.api.ServerApiException)1 ListResponse (com.cloud.api.response.ListResponse)1 DiscoveryException (com.cloud.exception.DiscoveryException)1 ArrayList (java.util.ArrayList)1