use of org.apache.cloudstack.api.ResponseObject in project cloudstack by apache.
the class ApiSerializerHelper method toSerializedString.
public static String toSerializedString(Object result) {
if (result != null) {
Class<?> clz = result.getClass();
Gson gson = ApiGsonHelper.getBuilder().create();
if (result instanceof ResponseObject) {
return clz.getName() + token + ((ResponseObject) result).getObjectName() + token + gson.toJson(result);
} else {
return clz.getName() + token + gson.toJson(result);
}
}
return null;
}
use of org.apache.cloudstack.api.ResponseObject in project cloudstack by apache.
the class ApiServer method createLoginResponse.
private ResponseObject createLoginResponse(HttpSession session) {
LoginCmdResponse response = new LoginCmdResponse();
response.setTimeout(session.getMaxInactiveInterval());
final String user_UUID = (String) session.getAttribute("user_UUID");
response.setUserId(user_UUID);
final String domain_UUID = (String) session.getAttribute("domain_UUID");
response.setDomainId(domain_UUID);
synchronized (session) {
session.removeAttribute("user_UUID");
session.removeAttribute("domain_UUID");
}
final Enumeration attrNames = session.getAttributeNames();
if (attrNames != null) {
while (attrNames.hasMoreElements()) {
final String attrName = (String) attrNames.nextElement();
final Object attrObj = session.getAttribute(attrName);
if (ApiConstants.USERNAME.equalsIgnoreCase(attrName)) {
response.setUsername(attrObj.toString());
}
if (ApiConstants.ACCOUNT.equalsIgnoreCase(attrName)) {
response.setAccount(attrObj.toString());
}
if (ApiConstants.FIRSTNAME.equalsIgnoreCase(attrName)) {
response.setFirstName(attrObj.toString());
}
if (ApiConstants.LASTNAME.equalsIgnoreCase(attrName)) {
response.setLastName(attrObj.toString());
}
if (ApiConstants.TYPE.equalsIgnoreCase(attrName)) {
response.setType((attrObj.toString()));
}
if (ApiConstants.TIMEZONE.equalsIgnoreCase(attrName)) {
response.setTimeZone(attrObj.toString());
}
if (ApiConstants.TIMEZONEOFFSET.equalsIgnoreCase(attrName)) {
response.setTimeZoneOffset(attrObj.toString());
}
if (ApiConstants.REGISTERED.equalsIgnoreCase(attrName)) {
response.setRegistered(attrObj.toString());
}
if (ApiConstants.SESSIONKEY.equalsIgnoreCase(attrName)) {
response.setSessionKey(attrObj.toString());
}
}
}
response.setResponseName("loginresponse");
return response;
}
Aggregations