@Test public void testStringCreation() { Guid guid = Guid.newGuid(); Guid guidFromString = new Guid(guid.toString()); assertEquals(guidFromString, guid); guidFromString = Guid.createGuidFromString(guid.toString()); assertEquals(guidFromString, guid); guidFromString = Guid.createGuidFromString(null); assertNull(guidFromString); guidFromString = Guid.createGuidFromStringDefaultEmpty(guid.toString()); assertEquals(guidFromString, guid); guidFromString = Guid.createGuidFromStringDefaultEmpty(null); assertEquals(Guid.Empty, guidFromString); }
public VmDeviceFeEntity(VmDevice vmDevice, VM vm, boolean beingUnplugged) { if (!vmDevice.getVmId().equals(vm.getId())) { throw new IllegalArgumentException("IDs of VM and device's VM doesn't match."); //$NON-NLS-1$ } this.vmDevice = vmDevice; this.vm = vm; this.beingUnplugged = beingUnplugged; }
private void setIdIfNeeded(DbUser user) { if (Guid.isNullOrEmpty(user.getId())) { user.setId(Guid.newGuid()); } }
private void addUuid(PDU pdu, final OID prefix, int suffix, Guid val) { if (!Guid.isNullOrEmpty(val)) { addString(pdu, prefix, suffix, val.toString(), false); } }
@Override public void buildDisk() { XmlNodeList list = selectNodes(_document, "//*/Section/Disk"); for (XmlNode node : list) { Guid guid = new Guid(node.attributes.get("ovf:diskId").getValue()); _images.stream().filter(d -> d.getImageId().equals(guid)).findFirst().ifPresent(img -> readDisk(node, img)); luns.stream().filter(d -> d.getId().equals(guid)).findFirst().ifPresent(lun -> readLunDisk(node, lun)); } }
private org.ovirt.engine.core.common.businessentities.network.Network getNetwork() { List<org.ovirt.engine.core.common.businessentities.network.Network> networks = parent.getNetworks(); for (org.ovirt.engine.core.common.businessentities.network.Network entity : networks) { if (entity.getId().toString().equals(id)) { return entity; } } return null; }
private static LinkedList<Guid> convertToGuidList(String str, char delimiter) { LinkedList<Guid> results = new LinkedList<>(); if (str != null) { for (String id : str.split(String.format(" *%s *", delimiter))) { results.add(Guid.createGuidFromString(id)); } } return results; }
/** * @return A generic {@link Guid} result mapper which always takes the {@link Guid} result, regardless of how it's * column is called. */ protected RowMapper<Guid> createGuidMapper() { return (rs, rowNum) -> new Guid((UUID) rs.getObject(1)); }
private VmDevice createUnmanagedNetworkInterface(boolean plugged) { VmDevice device = createNetworkInterfaceDevice(plugged, Guid.newGuid()); device.setManaged(false); return device; }
@Override public DiskAttachment get() { DiskAttachment diskAttachment = performGet(QueryType.GetDiskVmElementById, new VmDeviceIdQueryParameters(new VmDeviceId(Guid.createGuidFromString(diskId), vmId)), Vm.class); /* * Href of the diskattachment must be set manually due to a bug (https://bugzilla.redhat.com/1647018). * The bug is the result of an exceptional case where the same entity (disk-attachment) * has the same parent (vm) in 2 different locations in the API, causing ambiguity * in the link generation process. */ diskAttachment.setHref("/ovirt-engine/api/vms/" + vmId.toString() + "/diskattachments/" + diskAttachment.getId()); return diskAttachment; }
@Test @Override public void testRoundtrip() throws Exception { Application model = Application.class.cast(populate(Application.class)); model = postPopulate(model); model.setName(NAMES[0]); model.setId(new Guid(NAMES[0].getBytes()).toString()); Mapper<String, Application> back = getMappingLocator().getMapper(String.class, Application.class); Application transform = back.map(NAMES[0], null); verify(model, transform); }
public org.ovirt.engine.core.common.businessentities.network.Network lookupNetwork(Guid id, String name, String dataCenterId) { for (org.ovirt.engine.core.common.businessentities.network.Network entity : getBackendCollection(queryType, getQueryParameters())) { if ((id != null && id.equals(entity.getId())) || (name != null && name.equals(entity.getName())) && (entity.getDataCenterId()!=null) && entity.getDataCenterId().toString().equals(dataCenterId)) { return entity; } } return null; }
private AuditLogEvent extractAuditLogEvent(ResultSet rs, Set<String> downEvents) throws SQLException { AuditLogEvent auditLogEvent = new AuditLogEvent(); auditLogEvent.setId(rs.getLong("audit_log_id")); auditLogEvent.setLogTypeName(rs.getString("log_type_name")); if (downEvents.contains(auditLogEvent.getLogTypeName())) { auditLogEvent.setType(AuditLogEventType.resolveMessage); } else { auditLogEvent.setType(AuditLogEventType.alertMessage); } auditLogEvent.setUserId(Guid.createGuidFromString(rs.getString("user_id"))); auditLogEvent.setUserName(rs.getString("user_name")); auditLogEvent.setVmId(Guid.createGuidFromString(rs.getString("vm_id"))); auditLogEvent.setVmName(rs.getString("vm_name")); auditLogEvent.setVmTemplateId(Guid.createGuidFromString(rs.getString("vm_template_id"))); auditLogEvent.setVmTemplateName(rs.getString("vm_template_name")); auditLogEvent.setVdsId(Guid.createGuidFromString(rs.getString("vds_id"))); auditLogEvent.setVdsName(rs.getString("vds_name")); auditLogEvent.setStoragePoolId(Guid.createGuidFromStringDefaultEmpty(rs.getString("storage_pool_id"))); auditLogEvent.setStoragePoolName(rs.getString("storage_pool_name")); auditLogEvent.setStorageDomainId(Guid.createGuidFromStringDefaultEmpty(rs.getString("storage_domain_id"))); auditLogEvent.setStorageDomainName(rs.getString("storage_domain_name")); auditLogEvent.setLogTime(rs.getTimestamp("log_time")); auditLogEvent.setSeverity(AuditLogSeverity.forValue(rs.getInt("severity"))); auditLogEvent.setMessage(rs.getString("message")); return auditLogEvent; }
public static Guid getImageGroupIdFromImageFile(String imageFile) { if (!StringUtils.isBlank(imageFile)) { return Guid.createGuidFromStringDefaultEmpty(imageFile.split("[/]", -1)[0]); } return null; }
@Test public void testGuidListValues() { String listValues = "e61f7070-cd52-46ca-88c2-686e1c70fe44,1eaa381a-fbf9-4ef5-bec2-6e4337f85d66"; List<Guid> stringList = Guid.createGuidListFromString(listValues); List<Guid> expectedList = new ArrayList<>(); expectedList.add(new Guid("e61f7070-cd52-46ca-88c2-686e1c70fe44")); expectedList.add(new Guid("1eaa381a-fbf9-4ef5-bec2-6e4337f85d66")); assertEquals(expectedList, stringList); }
private Guid getGuid(Guid guid) { return Guid.isNullOrEmpty(guid) ? Guid.Empty : guid; }
@Override public StorageConnection get() { return performGet(QueryType.GetStorageServerConnectionById, new StorageServerConnectionQueryParametersBase(guid.toString())); }
private void readDedicatedHostsList(XmlNode content) { vmBase.setDedicatedVmForVdsList(new LinkedList<>()); // initialize to empty list for (XmlNode hostNode : selectNodes(content, DEDICATED_VM_FOR_VDS)) { if (hostNode != null && StringUtils.isNotEmpty(hostNode.innerText)) { vmBase.getDedicatedVmForVdsList().add(Guid.createGuidFromString(hostNode.innerText)); } } }