Package com.cloud.utils

Examples of com.cloud.utils.IdentityProxy


                // copy over the IdentityProxy information as well and throw the serverapiexception.
                ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                if (idList != null) {
                  // Iterate through entire arraylist and copy over each proxy id.
                  for (int i = 0 ; i < idList.size(); i++) {
                    IdentityProxy obj = idList.get(i);
                    e.addProxyObject(obj.getTableName(), obj.getValue(), obj.getidFieldName());
                  }
                }
                // Also copy over the cserror code and the function/layer in which it was thrown.
              e.setCSErrorCode(ref.getCSErrorCode());
                throw e;
            } else if (ex instanceof PermissionDeniedException) {
              PermissionDeniedException ref = (PermissionDeniedException)ex;
              ServerApiException e = new ServerApiException(BaseCmd.ACCOUNT_ERROR, ex.getMessage());
                // copy over the IdentityProxy information as well and throw the serverapiexception.
              ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                if (idList != null) {
                  // Iterate through entire arraylist and copy over each proxy id.
                  for (int i = 0 ; i < idList.size(); i++) {
                    IdentityProxy obj = idList.get(i);
                    e.addProxyObject(obj.getTableName(), obj.getValue(), obj.getidFieldName());
                  }
                }
                e.setCSErrorCode(ref.getCSErrorCode());
                throw e;
            } else if (ex instanceof ServerApiException) {
View Full Code Here


                if (ex instanceof ServerApiException) {
                  ServerApiException ref = (ServerApiException) ex;
                  ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                  if (idList != null) {
                    for (int i=0; i < idList.size(); i++) {
                      IdentityProxy id = idList.get(i);
                      apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
                    }                   
                  }
                  // Also copy over the cserror code and the function/layer in which it was thrown.
                  apiResponse.setCSErrorCode(ref.getCSErrorCode());
                } else if (ex instanceof PermissionDeniedException) {
                  PermissionDeniedException ref = (PermissionDeniedException) ex;
                  ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                  if (idList != null) {
                    for (int i=0; i < idList.size(); i++) {
                      IdentityProxy id = idList.get(i);
                      apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
                    }                   
                  }
                  // Also copy over the cserror code and the function/layer in which it was thrown.
                  apiResponse.setCSErrorCode(ref.getCSErrorCode());
                } else if (ex instanceof InvalidParameterValueException) {
                  InvalidParameterValueException ref = (InvalidParameterValueException) ex;
                  ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                  if (idList != null) {
                    for (int i=0; i < idList.size(); i++) {
                      IdentityProxy id = idList.get(i);
                      apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
                    }                   
                  }
                  // Also copy over the cserror code and the function/layer in which it was thrown.
                  apiResponse.setCSErrorCode(ref.getCSErrorCode());
                }
View Full Code Here

    super();
    setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName()));
  }
 
  public void addProxyObject(String tableName, Long id, String idFieldName) {
    idList.add(new IdentityProxy(tableName, id, idFieldName));
    return;
  }
View Full Code Here

    public void setErrorText(String errorText) {
        this.errorText = errorText;
    }

    public void addProxyObject(String tableName, Long id, String idFieldName) {
        idList.add(new IdentityProxy(tableName, id, idFieldName));
        return;
    }
View Full Code Here

                // copy over the IdentityProxy information as well and throw the serverapiexception.
                ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                if (idList != null) {
                  // Iterate through entire arraylist and copy over each proxy id.
                  for (int i = 0 ; i < idList.size(); i++) {
                    IdentityProxy obj = idList.get(i);
                    e.addProxyObject(obj.getTableName(), obj.getValue(), obj.getidFieldName());
                  }
                }
                // Also copy over the cserror code and the function/layer in which it was thrown.
              e.setCSErrorCode(ref.getCSErrorCode());
                throw e;
            } else if (ex instanceof PermissionDeniedException) {
              PermissionDeniedException ref = (PermissionDeniedException)ex;
              ServerApiException e = new ServerApiException(BaseCmd.ACCOUNT_ERROR, ex.getMessage());
                // copy over the IdentityProxy information as well and throw the serverapiexception.
              ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                if (idList != null) {
                  // Iterate through entire arraylist and copy over each proxy id.
                  for (int i = 0 ; i < idList.size(); i++) {
                    IdentityProxy obj = idList.get(i);
                    e.addProxyObject(obj.getTableName(), obj.getValue(), obj.getidFieldName());
                  }
                }
                e.setCSErrorCode(ref.getCSErrorCode());
                throw e;
            } else if (ex instanceof ServerApiException) {
View Full Code Here

                if (ex instanceof ServerApiException) {
                  ServerApiException ref = (ServerApiException) ex;
                  ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                  if (idList != null) {
                    for (int i=0; i < idList.size(); i++) {
                      IdentityProxy id = idList.get(i);
                      apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
                    }                   
                  }
                  // Also copy over the cserror code and the function/layer in which it was thrown.
                  apiResponse.setCSErrorCode(ref.getCSErrorCode());
                } else if (ex instanceof PermissionDeniedException) {
                  PermissionDeniedException ref = (PermissionDeniedException) ex;
                  ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                  if (idList != null) {
                    for (int i=0; i < idList.size(); i++) {
                      IdentityProxy id = idList.get(i);
                      apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
                    }                   
                  }
                  // Also copy over the cserror code and the function/layer in which it was thrown.
                  apiResponse.setCSErrorCode(ref.getCSErrorCode());
                } else if (ex instanceof InvalidParameterValueException) {
                  InvalidParameterValueException ref = (InvalidParameterValueException) ex;
                  ArrayList<IdentityProxy> idList = ref.getIdProxyList();
                  if (idList != null) {
                    for (int i=0; i < idList.size(); i++) {
                      IdentityProxy id = idList.get(i);
                      apiResponse.addProxyObject(id.getTableName(), id.getValue(), id.getidFieldName());
                    }                   
                  }
                  // Also copy over the cserror code and the function/layer in which it was thrown.
                  apiResponse.setCSErrorCode(ref.getCSErrorCode());
                }
View Full Code Here

                } else {
                    throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + " as it's no longer active");                   
                }
            } else {
                List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
                idList.add(new IdentityProxy("domain", domainId, "domainId"));
                throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain with specified id");
            }
        }

        if (projectId != null) {
View Full Code Here

  protected ArrayList<IdentityProxy> idList = new ArrayList<IdentityProxy>();
 
  protected int csErrorCode;
 
  public void addProxyObject(String tableName, Long id, String idFieldName) {
    idList.add(new IdentityProxy(tableName, id, idFieldName));
    return;
  }
View Full Code Here

                                subObj.setObjectName(serializedName.value());
                            }
                            serializeResponseObjXML(sb, subObj);
                        } else if (value instanceof IdentityProxy) {
                          // Only exception reponses carry a list of IdentityProxy objects.
                          IdentityProxy idProxy = (IdentityProxy)value;                         
                          String id = (idProxy.getValue() != null ? String.valueOf(idProxy.getValue()) : "");
                          if(!id.isEmpty()) {
                            IdentityDao identityDao = new IdentityDaoImpl();
                            id = identityDao.getIdentityUuid(idProxy.getTableName(), id);
                          }                         
                          if(id != null && !id.isEmpty()) {
                            // If this is the first IdentityProxy field encountered, put in a uuidList tag.
                            if (!usedUuidList) {
                              sb.append("<" + serializedName.value() + ">");
                              usedUuidList = true;
                            }
                            sb.append("<" + "uuid" + ">" + id + "</" + "uuid" + ">");                           
                          }
                          // Append the new idFieldName property also.
                          String idFieldName = idProxy.getidFieldName();
                          if (idFieldName != null) {
                            sb.append("<" + "uuidProperty" + ">" + idFieldName + "</" + "uuidProperty" + ">");                           
                          }
                        }                       
                    }
                    if (usedUuidList) {
                      // close the uuidList.
                      sb.append("</" + serializedName.value() + ">");
                    }
                } else if (fieldValue instanceof Date) {
                    sb.append("<" + serializedName.value() + ">" + BaseCmd.getDateString((Date) fieldValue) + "</" + serializedName.value() + ">");               
                } else if (fieldValue instanceof IdentityProxy) {                 
                  IdentityProxy idProxy = (IdentityProxy)fieldValue;
                  String id = (idProxy.getValue() != null ? String.valueOf(idProxy.getValue()) : "");
                  if(!id.isEmpty()) {
                    IdentityDao identityDao = new IdentityDaoImpl();
                    if(idProxy.getTableName() != null) {
                        id = identityDao.getIdentityUuid(idProxy.getTableName(), id);
                    } else {
                        s_logger.warn("IdentityProxy sanity check issue, invalid IdentityProxy table name found in class: " + obj.getClass().getName());
                    }
                  }
                  if(id != null && !id.isEmpty())
View Full Code Here

 
  @Override
  public IdentityProxy deserialize(JsonElement src, Type srcType,
      JsonDeserializationContext context) throws JsonParseException {

    IdentityProxy obj = new IdentityProxy();
    JsonObject json = src.getAsJsonObject();
    obj.setTableName(json.get("_tableName").getAsString());
    if(json.get("_value") != null)
      obj.setValue(json.get("_value").getAsLong());
    return obj;
  }
View Full Code Here

TOP

Related Classes of com.cloud.utils.IdentityProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.