Examples of IdentityDaoImpl


Examples of com.cloud.uuididentity.dao.IdentityDaoImpl

                        } 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

Examples of com.cloud.uuididentity.dao.IdentityDaoImpl

    if(SerializationContext.current().getUuidTranslation()) {
      assert(src != null);
      if(src.getValue() == null)
        return context.serialize(null);
 
      IdentityDao identityDao = new IdentityDaoImpl();
      if(src.getTableName() != null) {
        String uuid = identityDao.getIdentityUuid(src.getTableName(), String.valueOf(src.getValue()));
        if(uuid == null)
          return context.serialize(null);
       
        // Exceptions set the _idFieldName in the IdentityProxy structure. So if this field is not
        // null, prepare a structure of uuid and idFieldName and return the json representation of that.
View Full Code Here

Examples of com.cloud.uuididentity.dao.IdentityDaoImpl

   
    @Override
    public void execute(){
        ManagementServerExt _mgrExt = (ManagementServerExt)_mgr;
        List<UsageVO> usageRecords = _mgrExt.getUsageRecords(this);
        IdentityDao identityDao = new IdentityDaoImpl();
        ListResponse<UsageRecordResponse> response = new ListResponse<UsageRecordResponse>();
        List<UsageRecordResponse> usageResponses = new ArrayList<UsageRecordResponse>();
        for (Object usageRecordGeneric : usageRecords) {
            UsageRecordResponse usageRecResponse = new UsageRecordResponse();
            if (usageRecordGeneric instanceof UsageVO) {
                UsageVO usageRecord = (UsageVO)usageRecordGeneric;
     
                Account account = ApiDBUtils.findAccountByIdIncludingRemoved(usageRecord.getAccountId());
                if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
                    //find the project
                    Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
                    usageRecResponse.setProjectId(project.getId());
                    usageRecResponse.setProjectName(project.getName());
                } else {
                    usageRecResponse.setAccountId(account.getId());
                    usageRecResponse.setAccountName(account.getAccountName());
                }
            
                usageRecResponse.setDomainId(usageRecord.getDomainId());
               
                usageRecResponse.setZoneId(usageRecord.getZoneId());
                usageRecResponse.setDescription(usageRecord.getDescription());
                usageRecResponse.setUsage(usageRecord.getUsageDisplay());
                usageRecResponse.setUsageType(usageRecord.getUsageType());
                usageRecResponse.setVirtualMachineId(usageRecord.getVmInstanceId());
                usageRecResponse.setVmName(usageRecord.getVmName());
                usageRecResponse.setTemplateId(usageRecord.getTemplateId());
               
                if(usageRecord.getUsageType() == UsageTypes.RUNNING_VM || usageRecord.getUsageType() == UsageTypes.ALLOCATED_VM){
                  //Service Offering Id
                  usageRecResponse.setOfferingId(identityDao.getIdentityUuid("disk_offering", usageRecord.getOfferingId().toString()));
                  //VM Instance ID
                  usageRecResponse.setUsageId(identityDao.getIdentityUuid("vm_instance", usageRecord.getUsageId().toString()));
                  //Hypervisor Type
                  usageRecResponse.setType(usageRecord.getType());
                 
                } else if(usageRecord.getUsageType() == UsageTypes.IP_ADDRESS){
                  //isSourceNAT
                    usageRecResponse.setSourceNat((usageRecord.getType().equals("SourceNat"))?true:false);
                    //isSystem
                    usageRecResponse.setSystem((usageRecord.getSize() == 1)?true:false);
                    //IP Address ID
                    usageRecResponse.setUsageId(identityDao.getIdentityUuid("user_ip_address", usageRecord.getUsageId().toString()));
                   
                } else if(usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_SENT || usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_RECEIVED){
                  //Device Type
                  usageRecResponse.setType(usageRecord.getType());
                  if(usageRecord.getType().equals("DomainRouter")){
                        //Domain Router Id
                        usageRecResponse.setUsageId(identityDao.getIdentityUuid("vm_instance", usageRecord.getUsageId().toString()));
                  } else {
                    //External Device Host Id
                    usageRecResponse.setUsageId(identityDao.getIdentityUuid("host", usageRecord.getUsageId().toString()))
                  }
                    //Network ID
                    usageRecResponse.setNetworkId(identityDao.getIdentityUuid("networks", usageRecord.getNetworkId().toString()));
                   
                } else if(usageRecord.getUsageType() == UsageTypes.VOLUME){
                    //Volume ID
                    usageRecResponse.setUsageId(identityDao.getIdentityUuid("volumes", usageRecord.getUsageId().toString()));
                    //Volume Size
                    usageRecResponse.setSize(usageRecord.getSize());
                  //Disk Offering Id
                    if(usageRecord.getOfferingId() != null){
                      usageRecResponse.setOfferingId(identityDao.getIdentityUuid("disk_offering", usageRecord.getOfferingId().toString()));
                    }

                } else if(usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType() == UsageTypes.ISO){
                    //Template/ISO ID
                    usageRecResponse.setUsageId(identityDao.getIdentityUuid("vm_template", usageRecord.getUsageId().toString()));
                    //Template/ISO Size
                    usageRecResponse.setSize(usageRecord.getSize());
                   
                } else if(usageRecord.getUsageType() == UsageTypes.SNAPSHOT){
                    //Snapshot ID
                    usageRecResponse.setUsageId(identityDao.getIdentityUuid("snapshots", usageRecord.getUsageId().toString()));
                    //Snapshot Size
                    usageRecResponse.setSize(usageRecord.getSize());
                   
                } else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
                    //Load Balancer Policy ID
                    usageRecResponse.setUsageId(usageRecord.getUsageId().toString());
                   
                } else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
                    //Port Forwarding Rule ID
                    usageRecResponse.setUsageId(usageRecord.getUsageId().toString());
                   
                } else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
                  //Network Offering Id
                  usageRecResponse.setOfferingId(identityDao.getIdentityUuid("network_offerings", usageRecord.getOfferingId().toString()));
                  //is Default
                  usageRecResponse.setDefault((usageRecord.getUsageId() == 1)? true:false);
                 
                } else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
                    //VPN User ID
                    usageRecResponse.setUsageId(usageRecord.getUsageId().toString());
                   
                } else if(usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP){
                  //Security Group Id
                  usageRecResponse.setUsageId(identityDao.getIdentityUuid("security_group", usageRecord.getUsageId().toString()));
                }
               
                if (usageRecord.getRawUsage() != null) {
                    DecimalFormat decimalFormat = new DecimalFormat("###########.######");
                    usageRecResponse.setRawUsage(decimalFormat.format(usageRecord.getRawUsage()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.