Liron Aravot has posted comments on this change. Change subject: core: Adding OVF utils ......................................................................
Patch Set 3: (5 comments) http://gerrit.ovirt.org/#/c/29147/3/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OvfUtils.java File backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OvfUtils.java: Line 34: return vmEntityType; Line 35: } Line 36: Line 37: private static Guid getEntityId(String fileName) { Line 38: return Guid.createGuidFromString(fileName.substring(0, fileName.indexOf(".ovf"))); 1. replace .ovf with the constant 2. let's replace fileName.indexOf(".ovf") with filename.length - OVF_FILE_EXT.length to save the lookup in the string Line 39: } Line 40: Line 41: private static OvfEntityData createOvfEntityData(Guid storageDomainId, Line 42: String ovfData, Line 42: String ovfData, Line 43: VmEntityType vmEntityType, Line 44: String entityName, Line 45: Guid entityId) { Line 46: OvfEntityData ovfEntityData = new OvfEntityData(); lets just add ctor to ovfENtityData with all those fields Line 47: ovfEntityData.setOvfData(ovfData); Line 48: ovfEntityData.setEntityType(vmEntityType); Line 49: ovfEntityData.setEntityName(entityName); Line 50: ovfEntityData.setStorageDomainId(storageDomainId); Line 56: List<OvfEntityData> ovfEntityDataFromTar = new ArrayList<>(); Line 57: InputStream is = new ByteArrayInputStream(tarByte); Line 58: Line 59: Map<String, String> filesFromTar; Line 60: try (OutMemoryTar memoryTar = new OutMemoryTar(is)) { please use here try-with-resources. Line 61: filesFromTar = memoryTar.unTar(); Line 62: } catch (IOException e) { Line 63: throw new RuntimeException(String.format("Exception while getting OVFs files from tar file for domain %s", Line 64: storageDomainId), e); Line 63: throw new RuntimeException(String.format("Exception while getting OVFs files from tar file for domain %s", Line 64: storageDomainId), e); Line 65: } Line 66: Line 67: for (String fileName : filesFromTar.keySet()) { please iterate over the entrySet instead iterating the key and get. Line 68: if (fileName.contains(OVF_FILE_EXT)) { Line 69: String ovfData = filesFromTar.get(fileName); Line 70: Line 71: // Creates an OVF entity data. Line 64: storageDomainId), e); Line 65: } Line 66: Line 67: for (String fileName : filesFromTar.keySet()) { Line 68: if (fileName.contains(OVF_FILE_EXT)) { please replace with endsWith Line 69: String ovfData = filesFromTar.get(fileName); Line 70: Line 71: // Creates an OVF entity data. Line 72: OvfEntityData ovfEntityData = -- To view, visit http://gerrit.ovirt.org/29147 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3f36ccf2f865d11ef3baa1908346aa3aab1857d5 Gerrit-PatchSet: 3 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com> Gerrit-Reviewer: Liron Aravot <lara...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches