diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index aa71cdc28d2..82327f78ab4 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -116,6 +116,7 @@ import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.Transaction; import com.cloud.utils.encoding.Base64; import com.cloud.utils.exception.CSExceptionErrorCode; +import com.cloud.uuididentity.dao.IdentityDao; public class ApiServer implements HttpRequestHandler { private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName()); @@ -766,6 +767,17 @@ public class ApiServer implements HttpRequestHandler { } return false; } + + public Long fetchDomainId(String domainUUID){ + ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name); + IdentityDao identityDao = locator.getDao(IdentityDao.class); + try{ + Long domainId = identityDao.getIdentityId("domain", domainUUID); + return domainId; + }catch(InvalidParameterValueException ex){ + return null; + } + } public void loginUser(HttpSession session, String username, String password, Long domainId, String domainPath, Map requestParameters) throws CloudAuthenticationException { // We will always use domainId first. If that does not exist, we will use domain name. If THAT doesn't exist diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java index a293df9aa63..148fc5829f2 100755 --- a/server/src/com/cloud/api/ApiServlet.java +++ b/server/src/com/cloud/api/ApiServlet.java @@ -177,7 +177,11 @@ public class ApiServlet extends HttpServlet { Long domainId = null; if ((domainIdArr != null) && (domainIdArr.length > 0)) { try { - domainId = new Long(Long.parseLong(domainIdArr[0])); + //check if UUID is passed in for domain + domainId = _apiServer.fetchDomainId(domainIdArr[0]); + if(domainId == null){ + domainId = new Long(Long.parseLong(domainIdArr[0])); + } auditTrailSb.append(" domainid=" + domainId);// building the params for POST call } catch (NumberFormatException e) { s_logger.warn("Invalid domain id entered by user");