cloudstack/server/src/com/cloud/api/commands/DeleteLoadBalancerRuleCmd.java
Kris McQueen 2a4ddac41a Change getResponse() to return a ResponseObject so that the caller can choose how to serialize. This in in preparation for serializing the async commands to the database with class information and deserializing them into the ResponseObject itself when queryAsyncJobResult is called. Once the ResponseObject is deserialized, the proper string can be returned to the caller.
The previous behavior had the JSON response from the command embedded into the queryAsyncJobResult response as a string rather than a JSON object which prevented the client from being able to read the response.  With this new behavior an actual JSON object should be returned which can then be parsed on the client side.
2010-09-23 17:34:28 -07:00

68 lines
2.4 KiB
Java

/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseCmd.Manager;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ResponseObject;
import com.cloud.api.response.SuccessResponse;
@Implementation(method="deleteLoadBalancerRule", manager=Manager.NetworkManager)
public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteLoadBalancerRuleCmd.class.getName());
private static final String s_name = "deleteloadbalancerruleresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name="id", type=CommandType.LONG, required=true)
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getName() {
return s_name;
}
@Override
public ResponseObject getResponse() {
Boolean success = (Boolean)getResponseObject();
SuccessResponse response = new SuccessResponse();
response.setSuccess(success);
response.setResponseName(getName());
return response;
}
}