diff options
Diffstat (limited to 'src/main')
23 files changed, 4680 insertions, 1261 deletions
diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/ImageSummaryRead.java b/src/main/java/org/openslx/bwlp/thrift/iface/ImageSummaryRead.java index 7095bba..b52289b 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/ImageSummaryRead.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/ImageSummaryRead.java @@ -34,7 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-01-04") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-07") public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRead, ImageSummaryRead._Fields>, java.io.Serializable, Cloneable, Comparable<ImageSummaryRead> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ImageSummaryRead"); @@ -57,6 +57,8 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea private static final org.apache.thrift.protocol.TField IS_TEMPLATE_FIELD_DESC = new org.apache.thrift.protocol.TField("isTemplate", org.apache.thrift.protocol.TType.BOOL, (short)17); private static final org.apache.thrift.protocol.TField DEFAULT_PERMISSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("defaultPermissions", org.apache.thrift.protocol.TType.STRUCT, (short)18); private static final org.apache.thrift.protocol.TField USER_PERMISSIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("userPermissions", org.apache.thrift.protocol.TType.STRUCT, (short)19); + private static final org.apache.thrift.protocol.TField FILE_SIZE_SUM_FIELD_DESC = new org.apache.thrift.protocol.TField("fileSizeSum", org.apache.thrift.protocol.TType.I64, (short)21); + private static final org.apache.thrift.protocol.TField VERSION_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("versionCount", org.apache.thrift.protocol.TType.I32, (short)22); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -87,6 +89,8 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea public boolean isTemplate; // required public ImagePermissions defaultPermissions; // required public ImagePermissions userPermissions; // optional + public long fileSizeSum; // optional + public int versionCount; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -112,7 +116,9 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea IS_PROCESSED((short)16, "isProcessed"), IS_TEMPLATE((short)17, "isTemplate"), DEFAULT_PERMISSIONS((short)18, "defaultPermissions"), - USER_PERMISSIONS((short)19, "userPermissions"); + USER_PERMISSIONS((short)19, "userPermissions"), + FILE_SIZE_SUM((short)21, "fileSizeSum"), + VERSION_COUNT((short)22, "versionCount"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -165,6 +171,10 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea return DEFAULT_PERMISSIONS; case 19: // USER_PERMISSIONS return USER_PERMISSIONS; + case 21: // FILE_SIZE_SUM + return FILE_SIZE_SUM; + case 22: // VERSION_COUNT + return VERSION_COUNT; default: return null; } @@ -215,8 +225,10 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea private static final int __ISVALID_ISSET_ID = 7; private static final int __ISPROCESSED_ISSET_ID = 8; private static final int __ISTEMPLATE_ISSET_ID = 9; + private static final int __FILESIZESUM_ISSET_ID = 10; + private static final int __VERSIONCOUNT_ISSET_ID = 11; private short __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.USER_PERMISSIONS}; + private static final _Fields optionals[] = {_Fields.USER_PERMISSIONS,_Fields.FILE_SIZE_SUM,_Fields.VERSION_COUNT}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -258,6 +270,10 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ImagePermissions.class))); tmpMap.put(_Fields.USER_PERMISSIONS, new org.apache.thrift.meta_data.FieldMetaData("userPermissions", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ImagePermissions.class))); + tmpMap.put(_Fields.FILE_SIZE_SUM, new org.apache.thrift.meta_data.FieldMetaData("fileSizeSum", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); + tmpMap.put(_Fields.VERSION_COUNT, new org.apache.thrift.meta_data.FieldMetaData("versionCount", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ImageSummaryRead.class, metaDataMap); } @@ -358,6 +374,8 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea if (other.isSetUserPermissions()) { this.userPermissions = new ImagePermissions(other.userPermissions); } + this.fileSizeSum = other.fileSizeSum; + this.versionCount = other.versionCount; } public ImageSummaryRead deepCopy() { @@ -395,6 +413,10 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea this.isTemplate = false; this.defaultPermissions = null; this.userPermissions = null; + setFileSizeSumIsSet(false); + this.fileSizeSum = 0; + setVersionCountIsSet(false); + this.versionCount = 0; } public String getImageBaseId() { @@ -851,6 +873,52 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea } } + public long getFileSizeSum() { + return this.fileSizeSum; + } + + public ImageSummaryRead setFileSizeSum(long fileSizeSum) { + this.fileSizeSum = fileSizeSum; + setFileSizeSumIsSet(true); + return this; + } + + public void unsetFileSizeSum() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __FILESIZESUM_ISSET_ID); + } + + /** Returns true if field fileSizeSum is set (has been assigned a value) and false otherwise */ + public boolean isSetFileSizeSum() { + return EncodingUtils.testBit(__isset_bitfield, __FILESIZESUM_ISSET_ID); + } + + public void setFileSizeSumIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __FILESIZESUM_ISSET_ID, value); + } + + public int getVersionCount() { + return this.versionCount; + } + + public ImageSummaryRead setVersionCount(int versionCount) { + this.versionCount = versionCount; + setVersionCountIsSet(true); + return this; + } + + public void unsetVersionCount() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __VERSIONCOUNT_ISSET_ID); + } + + /** Returns true if field versionCount is set (has been assigned a value) and false otherwise */ + public boolean isSetVersionCount() { + return EncodingUtils.testBit(__isset_bitfield, __VERSIONCOUNT_ISSET_ID); + } + + public void setVersionCountIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __VERSIONCOUNT_ISSET_ID, value); + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case IMAGE_BASE_ID: @@ -1005,6 +1073,22 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea } break; + case FILE_SIZE_SUM: + if (value == null) { + unsetFileSizeSum(); + } else { + setFileSizeSum((Long)value); + } + break; + + case VERSION_COUNT: + if (value == null) { + unsetVersionCount(); + } else { + setVersionCount((Integer)value); + } + break; + } } @@ -1067,6 +1151,12 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea case USER_PERMISSIONS: return getUserPermissions(); + case FILE_SIZE_SUM: + return getFileSizeSum(); + + case VERSION_COUNT: + return getVersionCount(); + } throw new IllegalStateException(); } @@ -1116,6 +1206,10 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea return isSetDefaultPermissions(); case USER_PERMISSIONS: return isSetUserPermissions(); + case FILE_SIZE_SUM: + return isSetFileSizeSum(); + case VERSION_COUNT: + return isSetVersionCount(); } throw new IllegalStateException(); } @@ -1304,6 +1398,24 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea return false; } + boolean this_present_fileSizeSum = true && this.isSetFileSizeSum(); + boolean that_present_fileSizeSum = true && that.isSetFileSizeSum(); + if (this_present_fileSizeSum || that_present_fileSizeSum) { + if (!(this_present_fileSizeSum && that_present_fileSizeSum)) + return false; + if (this.fileSizeSum != that.fileSizeSum) + return false; + } + + boolean this_present_versionCount = true && this.isSetVersionCount(); + boolean that_present_versionCount = true && that.isSetVersionCount(); + if (this_present_versionCount || that_present_versionCount) { + if (!(this_present_versionCount && that_present_versionCount)) + return false; + if (this.versionCount != that.versionCount) + return false; + } + return true; } @@ -1406,6 +1518,16 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea if (present_userPermissions) list.add(userPermissions); + boolean present_fileSizeSum = true && (isSetFileSizeSum()); + list.add(present_fileSizeSum); + if (present_fileSizeSum) + list.add(fileSizeSum); + + boolean present_versionCount = true && (isSetVersionCount()); + list.add(present_versionCount); + if (present_versionCount) + list.add(versionCount); + return list.hashCode(); } @@ -1607,6 +1729,26 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea return lastComparison; } } + lastComparison = Boolean.valueOf(isSetFileSizeSum()).compareTo(other.isSetFileSizeSum()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetFileSizeSum()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fileSizeSum, other.fileSizeSum); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetVersionCount()).compareTo(other.isSetVersionCount()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetVersionCount()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.versionCount, other.versionCount); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -1740,6 +1882,18 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea } first = false; } + if (isSetFileSizeSum()) { + if (!first) sb.append(", "); + sb.append("fileSizeSum:"); + sb.append(this.fileSizeSum); + first = false; + } + if (isSetVersionCount()) { + if (!first) sb.append(", "); + sb.append("versionCount:"); + sb.append(this.versionCount); + first = false; + } sb.append(")"); return sb.toString(); } @@ -1945,6 +2099,22 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 21: // FILE_SIZE_SUM + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.fileSizeSum = iprot.readI64(); + struct.setFileSizeSumIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 22: // VERSION_COUNT + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.versionCount = iprot.readI32(); + struct.setVersionCountIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -2037,6 +2207,16 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea oprot.writeFieldBegin(UPLOAD_TIME_FIELD_DESC); oprot.writeI64(struct.uploadTime); oprot.writeFieldEnd(); + if (struct.isSetFileSizeSum()) { + oprot.writeFieldBegin(FILE_SIZE_SUM_FIELD_DESC); + oprot.writeI64(struct.fileSizeSum); + oprot.writeFieldEnd(); + } + if (struct.isSetVersionCount()) { + oprot.writeFieldBegin(VERSION_COUNT_FIELD_DESC); + oprot.writeI32(struct.versionCount); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -2112,7 +2292,13 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea if (struct.isSetUserPermissions()) { optionals.set(18); } - oprot.writeBitSet(optionals, 19); + if (struct.isSetFileSizeSum()) { + optionals.set(19); + } + if (struct.isSetVersionCount()) { + optionals.set(20); + } + oprot.writeBitSet(optionals, 21); if (struct.isSetImageBaseId()) { oprot.writeString(struct.imageBaseId); } @@ -2170,12 +2356,18 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea if (struct.isSetUserPermissions()) { struct.userPermissions.write(oprot); } + if (struct.isSetFileSizeSum()) { + oprot.writeI64(struct.fileSizeSum); + } + if (struct.isSetVersionCount()) { + oprot.writeI32(struct.versionCount); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, ImageSummaryRead struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(19); + BitSet incoming = iprot.readBitSet(21); if (incoming.get(0)) { struct.imageBaseId = iprot.readString(); struct.setImageBaseIdIsSet(true); @@ -2254,6 +2446,14 @@ public class ImageSummaryRead implements org.apache.thrift.TBase<ImageSummaryRea struct.userPermissions.read(iprot); struct.setUserPermissionsIsSet(true); } + if (incoming.get(19)) { + struct.fileSizeSum = iprot.readI64(); + struct.setFileSizeSumIsSet(true); + } + if (incoming.get(20)) { + struct.versionCount = iprot.readI32(); + struct.setVersionCountIsSet(true); + } } } diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/LectureRead.java b/src/main/java/org/openslx/bwlp/thrift/iface/LectureRead.java index 1075a49..be1aa0c 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/LectureRead.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/LectureRead.java @@ -34,7 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-06-13") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-02-25") public class LectureRead implements org.apache.thrift.TBase<LectureRead, LectureRead._Fields>, java.io.Serializable, Cloneable, Comparable<LectureRead> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("LectureRead"); @@ -67,6 +67,10 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture private static final org.apache.thrift.protocol.TField HAS_USB_ACCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("hasUsbAccess", org.apache.thrift.protocol.TType.BOOL, (short)28); private static final org.apache.thrift.protocol.TField NETWORK_SHARES_FIELD_DESC = new org.apache.thrift.protocol.TField("networkShares", org.apache.thrift.protocol.TType.LIST, (short)29); private static final org.apache.thrift.protocol.TField LDAP_FILTERS_FIELD_DESC = new org.apache.thrift.protocol.TField("ldapFilters", org.apache.thrift.protocol.TType.LIST, (short)30); + private static final org.apache.thrift.protocol.TField PRESET_SCRIPT_IDS_FIELD_DESC = new org.apache.thrift.protocol.TField("presetScriptIds", org.apache.thrift.protocol.TType.LIST, (short)31); + private static final org.apache.thrift.protocol.TField PRESET_NETWORK_SHARES_FIELD_DESC = new org.apache.thrift.protocol.TField("presetNetworkShares", org.apache.thrift.protocol.TType.LIST, (short)32); + private static final org.apache.thrift.protocol.TField PRESET_LDAP_FILTERS_FIELD_DESC = new org.apache.thrift.protocol.TField("presetLdapFilters", org.apache.thrift.protocol.TType.LIST, (short)33); + private static final org.apache.thrift.protocol.TField PRESET_NETWORK_EXCEPTION_IDS_FIELD_DESC = new org.apache.thrift.protocol.TField("presetNetworkExceptionIds", org.apache.thrift.protocol.TType.LIST, (short)34); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -103,6 +107,10 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture public boolean hasUsbAccess; // required public List<NetShare> networkShares; // optional public List<LdapFilter> ldapFilters; // optional + public List<Integer> presetScriptIds; // optional + public List<Integer> presetNetworkShares; // optional + public List<Integer> presetLdapFilters; // optional + public List<Integer> presetNetworkExceptionIds; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -134,7 +142,11 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture LIMIT_TO_ALLOWED_USERS((short)27, "limitToAllowedUsers"), HAS_USB_ACCESS((short)28, "hasUsbAccess"), NETWORK_SHARES((short)29, "networkShares"), - LDAP_FILTERS((short)30, "ldapFilters"); + LDAP_FILTERS((short)30, "ldapFilters"), + PRESET_SCRIPT_IDS((short)31, "presetScriptIds"), + PRESET_NETWORK_SHARES((short)32, "presetNetworkShares"), + PRESET_LDAP_FILTERS((short)33, "presetLdapFilters"), + PRESET_NETWORK_EXCEPTION_IDS((short)34, "presetNetworkExceptionIds"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -207,6 +219,14 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture return NETWORK_SHARES; case 30: // LDAP_FILTERS return LDAP_FILTERS; + case 31: // PRESET_SCRIPT_IDS + return PRESET_SCRIPT_IDS; + case 32: // PRESET_NETWORK_SHARES + return PRESET_NETWORK_SHARES; + case 33: // PRESET_LDAP_FILTERS + return PRESET_LDAP_FILTERS; + case 34: // PRESET_NETWORK_EXCEPTION_IDS + return PRESET_NETWORK_EXCEPTION_IDS; default: return null; } @@ -261,7 +281,7 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture private static final int __LIMITTOALLOWEDUSERS_ISSET_ID = 11; private static final int __HASUSBACCESS_ISSET_ID = 12; private short __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.USER_PERMISSIONS,_Fields.NETWORK_SHARES,_Fields.LDAP_FILTERS}; + private static final _Fields optionals[] = {_Fields.USER_PERMISSIONS,_Fields.NETWORK_SHARES,_Fields.LDAP_FILTERS,_Fields.PRESET_SCRIPT_IDS,_Fields.PRESET_NETWORK_SHARES,_Fields.PRESET_LDAP_FILTERS,_Fields.PRESET_NETWORK_EXCEPTION_IDS}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -329,6 +349,18 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture tmpMap.put(_Fields.LDAP_FILTERS, new org.apache.thrift.meta_data.FieldMetaData("ldapFilters", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, LdapFilter.class)))); + tmpMap.put(_Fields.PRESET_SCRIPT_IDS, new org.apache.thrift.meta_data.FieldMetaData("presetScriptIds", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + tmpMap.put(_Fields.PRESET_NETWORK_SHARES, new org.apache.thrift.meta_data.FieldMetaData("presetNetworkShares", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + tmpMap.put(_Fields.PRESET_LDAP_FILTERS, new org.apache.thrift.meta_data.FieldMetaData("presetLdapFilters", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + tmpMap.put(_Fields.PRESET_NETWORK_EXCEPTION_IDS, new org.apache.thrift.meta_data.FieldMetaData("presetNetworkExceptionIds", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(LectureRead.class, metaDataMap); } @@ -487,6 +519,22 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture } this.ldapFilters = __this__ldapFilters; } + if (other.isSetPresetScriptIds()) { + List<Integer> __this__presetScriptIds = new ArrayList<Integer>(other.presetScriptIds); + this.presetScriptIds = __this__presetScriptIds; + } + if (other.isSetPresetNetworkShares()) { + List<Integer> __this__presetNetworkShares = new ArrayList<Integer>(other.presetNetworkShares); + this.presetNetworkShares = __this__presetNetworkShares; + } + if (other.isSetPresetLdapFilters()) { + List<Integer> __this__presetLdapFilters = new ArrayList<Integer>(other.presetLdapFilters); + this.presetLdapFilters = __this__presetLdapFilters; + } + if (other.isSetPresetNetworkExceptionIds()) { + List<Integer> __this__presetNetworkExceptionIds = new ArrayList<Integer>(other.presetNetworkExceptionIds); + this.presetNetworkExceptionIds = __this__presetNetworkExceptionIds; + } } public LectureRead deepCopy() { @@ -537,6 +585,10 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture this.hasUsbAccess = false; this.networkShares = null; this.ldapFilters = null; + this.presetScriptIds = null; + this.presetNetworkShares = null; + this.presetLdapFilters = null; + this.presetNetworkExceptionIds = null; } public String getLectureId() { @@ -1312,6 +1364,162 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture } } + public int getPresetScriptIdsSize() { + return (this.presetScriptIds == null) ? 0 : this.presetScriptIds.size(); + } + + public java.util.Iterator<Integer> getPresetScriptIdsIterator() { + return (this.presetScriptIds == null) ? null : this.presetScriptIds.iterator(); + } + + public void addToPresetScriptIds(int elem) { + if (this.presetScriptIds == null) { + this.presetScriptIds = new ArrayList<Integer>(); + } + this.presetScriptIds.add(elem); + } + + public List<Integer> getPresetScriptIds() { + return this.presetScriptIds; + } + + public LectureRead setPresetScriptIds(List<Integer> presetScriptIds) { + this.presetScriptIds = presetScriptIds; + return this; + } + + public void unsetPresetScriptIds() { + this.presetScriptIds = null; + } + + /** Returns true if field presetScriptIds is set (has been assigned a value) and false otherwise */ + public boolean isSetPresetScriptIds() { + return this.presetScriptIds != null; + } + + public void setPresetScriptIdsIsSet(boolean value) { + if (!value) { + this.presetScriptIds = null; + } + } + + public int getPresetNetworkSharesSize() { + return (this.presetNetworkShares == null) ? 0 : this.presetNetworkShares.size(); + } + + public java.util.Iterator<Integer> getPresetNetworkSharesIterator() { + return (this.presetNetworkShares == null) ? null : this.presetNetworkShares.iterator(); + } + + public void addToPresetNetworkShares(int elem) { + if (this.presetNetworkShares == null) { + this.presetNetworkShares = new ArrayList<Integer>(); + } + this.presetNetworkShares.add(elem); + } + + public List<Integer> getPresetNetworkShares() { + return this.presetNetworkShares; + } + + public LectureRead setPresetNetworkShares(List<Integer> presetNetworkShares) { + this.presetNetworkShares = presetNetworkShares; + return this; + } + + public void unsetPresetNetworkShares() { + this.presetNetworkShares = null; + } + + /** Returns true if field presetNetworkShares is set (has been assigned a value) and false otherwise */ + public boolean isSetPresetNetworkShares() { + return this.presetNetworkShares != null; + } + + public void setPresetNetworkSharesIsSet(boolean value) { + if (!value) { + this.presetNetworkShares = null; + } + } + + public int getPresetLdapFiltersSize() { + return (this.presetLdapFilters == null) ? 0 : this.presetLdapFilters.size(); + } + + public java.util.Iterator<Integer> getPresetLdapFiltersIterator() { + return (this.presetLdapFilters == null) ? null : this.presetLdapFilters.iterator(); + } + + public void addToPresetLdapFilters(int elem) { + if (this.presetLdapFilters == null) { + this.presetLdapFilters = new ArrayList<Integer>(); + } + this.presetLdapFilters.add(elem); + } + + public List<Integer> getPresetLdapFilters() { + return this.presetLdapFilters; + } + + public LectureRead setPresetLdapFilters(List<Integer> presetLdapFilters) { + this.presetLdapFilters = presetLdapFilters; + return this; + } + + public void unsetPresetLdapFilters() { + this.presetLdapFilters = null; + } + + /** Returns true if field presetLdapFilters is set (has been assigned a value) and false otherwise */ + public boolean isSetPresetLdapFilters() { + return this.presetLdapFilters != null; + } + + public void setPresetLdapFiltersIsSet(boolean value) { + if (!value) { + this.presetLdapFilters = null; + } + } + + public int getPresetNetworkExceptionIdsSize() { + return (this.presetNetworkExceptionIds == null) ? 0 : this.presetNetworkExceptionIds.size(); + } + + public java.util.Iterator<Integer> getPresetNetworkExceptionIdsIterator() { + return (this.presetNetworkExceptionIds == null) ? null : this.presetNetworkExceptionIds.iterator(); + } + + public void addToPresetNetworkExceptionIds(int elem) { + if (this.presetNetworkExceptionIds == null) { + this.presetNetworkExceptionIds = new ArrayList<Integer>(); + } + this.presetNetworkExceptionIds.add(elem); + } + + public List<Integer> getPresetNetworkExceptionIds() { + return this.presetNetworkExceptionIds; + } + + public LectureRead setPresetNetworkExceptionIds(List<Integer> presetNetworkExceptionIds) { + this.presetNetworkExceptionIds = presetNetworkExceptionIds; + return this; + } + + public void unsetPresetNetworkExceptionIds() { + this.presetNetworkExceptionIds = null; + } + + /** Returns true if field presetNetworkExceptionIds is set (has been assigned a value) and false otherwise */ + public boolean isSetPresetNetworkExceptionIds() { + return this.presetNetworkExceptionIds != null; + } + + public void setPresetNetworkExceptionIdsIsSet(boolean value) { + if (!value) { + this.presetNetworkExceptionIds = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case LECTURE_ID: @@ -1546,6 +1754,38 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture } break; + case PRESET_SCRIPT_IDS: + if (value == null) { + unsetPresetScriptIds(); + } else { + setPresetScriptIds((List<Integer>)value); + } + break; + + case PRESET_NETWORK_SHARES: + if (value == null) { + unsetPresetNetworkShares(); + } else { + setPresetNetworkShares((List<Integer>)value); + } + break; + + case PRESET_LDAP_FILTERS: + if (value == null) { + unsetPresetLdapFilters(); + } else { + setPresetLdapFilters((List<Integer>)value); + } + break; + + case PRESET_NETWORK_EXCEPTION_IDS: + if (value == null) { + unsetPresetNetworkExceptionIds(); + } else { + setPresetNetworkExceptionIds((List<Integer>)value); + } + break; + } } @@ -1638,6 +1878,18 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture case LDAP_FILTERS: return getLdapFilters(); + case PRESET_SCRIPT_IDS: + return getPresetScriptIds(); + + case PRESET_NETWORK_SHARES: + return getPresetNetworkShares(); + + case PRESET_LDAP_FILTERS: + return getPresetLdapFilters(); + + case PRESET_NETWORK_EXCEPTION_IDS: + return getPresetNetworkExceptionIds(); + } throw new IllegalStateException(); } @@ -1707,6 +1959,14 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture return isSetNetworkShares(); case LDAP_FILTERS: return isSetLdapFilters(); + case PRESET_SCRIPT_IDS: + return isSetPresetScriptIds(); + case PRESET_NETWORK_SHARES: + return isSetPresetNetworkShares(); + case PRESET_LDAP_FILTERS: + return isSetPresetLdapFilters(); + case PRESET_NETWORK_EXCEPTION_IDS: + return isSetPresetNetworkExceptionIds(); } throw new IllegalStateException(); } @@ -1985,6 +2245,42 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture return false; } + boolean this_present_presetScriptIds = true && this.isSetPresetScriptIds(); + boolean that_present_presetScriptIds = true && that.isSetPresetScriptIds(); + if (this_present_presetScriptIds || that_present_presetScriptIds) { + if (!(this_present_presetScriptIds && that_present_presetScriptIds)) + return false; + if (!this.presetScriptIds.equals(that.presetScriptIds)) + return false; + } + + boolean this_present_presetNetworkShares = true && this.isSetPresetNetworkShares(); + boolean that_present_presetNetworkShares = true && that.isSetPresetNetworkShares(); + if (this_present_presetNetworkShares || that_present_presetNetworkShares) { + if (!(this_present_presetNetworkShares && that_present_presetNetworkShares)) + return false; + if (!this.presetNetworkShares.equals(that.presetNetworkShares)) + return false; + } + + boolean this_present_presetLdapFilters = true && this.isSetPresetLdapFilters(); + boolean that_present_presetLdapFilters = true && that.isSetPresetLdapFilters(); + if (this_present_presetLdapFilters || that_present_presetLdapFilters) { + if (!(this_present_presetLdapFilters && that_present_presetLdapFilters)) + return false; + if (!this.presetLdapFilters.equals(that.presetLdapFilters)) + return false; + } + + boolean this_present_presetNetworkExceptionIds = true && this.isSetPresetNetworkExceptionIds(); + boolean that_present_presetNetworkExceptionIds = true && that.isSetPresetNetworkExceptionIds(); + if (this_present_presetNetworkExceptionIds || that_present_presetNetworkExceptionIds) { + if (!(this_present_presetNetworkExceptionIds && that_present_presetNetworkExceptionIds)) + return false; + if (!this.presetNetworkExceptionIds.equals(that.presetNetworkExceptionIds)) + return false; + } + return true; } @@ -2137,6 +2433,26 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture if (present_ldapFilters) list.add(ldapFilters); + boolean present_presetScriptIds = true && (isSetPresetScriptIds()); + list.add(present_presetScriptIds); + if (present_presetScriptIds) + list.add(presetScriptIds); + + boolean present_presetNetworkShares = true && (isSetPresetNetworkShares()); + list.add(present_presetNetworkShares); + if (present_presetNetworkShares) + list.add(presetNetworkShares); + + boolean present_presetLdapFilters = true && (isSetPresetLdapFilters()); + list.add(present_presetLdapFilters); + if (present_presetLdapFilters) + list.add(presetLdapFilters); + + boolean present_presetNetworkExceptionIds = true && (isSetPresetNetworkExceptionIds()); + list.add(present_presetNetworkExceptionIds); + if (present_presetNetworkExceptionIds) + list.add(presetNetworkExceptionIds); + return list.hashCode(); } @@ -2438,6 +2754,46 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture return lastComparison; } } + lastComparison = Boolean.valueOf(isSetPresetScriptIds()).compareTo(other.isSetPresetScriptIds()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPresetScriptIds()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.presetScriptIds, other.presetScriptIds); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPresetNetworkShares()).compareTo(other.isSetPresetNetworkShares()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPresetNetworkShares()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.presetNetworkShares, other.presetNetworkShares); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPresetLdapFilters()).compareTo(other.isSetPresetLdapFilters()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPresetLdapFilters()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.presetLdapFilters, other.presetLdapFilters); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPresetNetworkExceptionIds()).compareTo(other.isSetPresetNetworkExceptionIds()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPresetNetworkExceptionIds()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.presetNetworkExceptionIds, other.presetNetworkExceptionIds); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -2643,6 +2999,46 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture } first = false; } + if (isSetPresetScriptIds()) { + if (!first) sb.append(", "); + sb.append("presetScriptIds:"); + if (this.presetScriptIds == null) { + sb.append("null"); + } else { + sb.append(this.presetScriptIds); + } + first = false; + } + if (isSetPresetNetworkShares()) { + if (!first) sb.append(", "); + sb.append("presetNetworkShares:"); + if (this.presetNetworkShares == null) { + sb.append("null"); + } else { + sb.append(this.presetNetworkShares); + } + first = false; + } + if (isSetPresetLdapFilters()) { + if (!first) sb.append(", "); + sb.append("presetLdapFilters:"); + if (this.presetLdapFilters == null) { + sb.append("null"); + } else { + sb.append(this.presetLdapFilters); + } + first = false; + } + if (isSetPresetNetworkExceptionIds()) { + if (!first) sb.append(", "); + sb.append("presetNetworkExceptionIds:"); + if (this.presetNetworkExceptionIds == null) { + sb.append("null"); + } else { + sb.append(this.presetNetworkExceptionIds); + } + first = false; + } sb.append(")"); return sb.toString(); } @@ -2825,13 +3221,13 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture case 14: // NICS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list146 = iprot.readListBegin(); - struct.nics = new ArrayList<String>(_list146.size); - String _elem147; - for (int _i148 = 0; _i148 < _list146.size; ++_i148) + org.apache.thrift.protocol.TList _list202 = iprot.readListBegin(); + struct.nics = new ArrayList<String>(_list202.size); + String _elem203; + for (int _i204 = 0; _i204 < _list202.size; ++_i204) { - _elem147 = iprot.readString(); - struct.nics.add(_elem147); + _elem203 = iprot.readString(); + struct.nics.add(_elem203); } iprot.readListEnd(); } @@ -2843,13 +3239,13 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture case 15: // ALLOWED_USERS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list149 = iprot.readListBegin(); - struct.allowedUsers = new ArrayList<String>(_list149.size); - String _elem150; - for (int _i151 = 0; _i151 < _list149.size; ++_i151) + org.apache.thrift.protocol.TList _list205 = iprot.readListBegin(); + struct.allowedUsers = new ArrayList<String>(_list205.size); + String _elem206; + for (int _i207 = 0; _i207 < _list205.size; ++_i207) { - _elem150 = iprot.readString(); - struct.allowedUsers.add(_elem150); + _elem206 = iprot.readString(); + struct.allowedUsers.add(_elem206); } iprot.readListEnd(); } @@ -2861,14 +3257,14 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture case 16: // NETWORK_EXCEPTIONS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list152 = iprot.readListBegin(); - struct.networkExceptions = new ArrayList<NetRule>(_list152.size); - NetRule _elem153; - for (int _i154 = 0; _i154 < _list152.size; ++_i154) + org.apache.thrift.protocol.TList _list208 = iprot.readListBegin(); + struct.networkExceptions = new ArrayList<NetRule>(_list208.size); + NetRule _elem209; + for (int _i210 = 0; _i210 < _list208.size; ++_i210) { - _elem153 = new NetRule(); - _elem153.read(iprot); - struct.networkExceptions.add(_elem153); + _elem209 = new NetRule(); + _elem209.read(iprot); + struct.networkExceptions.add(_elem209); } iprot.readListEnd(); } @@ -2914,13 +3310,13 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture case 25: // LOCATION_IDS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list155 = iprot.readListBegin(); - struct.locationIds = new ArrayList<Integer>(_list155.size); - int _elem156; - for (int _i157 = 0; _i157 < _list155.size; ++_i157) + org.apache.thrift.protocol.TList _list211 = iprot.readListBegin(); + struct.locationIds = new ArrayList<Integer>(_list211.size); + int _elem212; + for (int _i213 = 0; _i213 < _list211.size; ++_i213) { - _elem156 = iprot.readI32(); - struct.locationIds.add(_elem156); + _elem212 = iprot.readI32(); + struct.locationIds.add(_elem212); } iprot.readListEnd(); } @@ -2956,14 +3352,14 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture case 29: // NETWORK_SHARES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list158 = iprot.readListBegin(); - struct.networkShares = new ArrayList<NetShare>(_list158.size); - NetShare _elem159; - for (int _i160 = 0; _i160 < _list158.size; ++_i160) + org.apache.thrift.protocol.TList _list214 = iprot.readListBegin(); + struct.networkShares = new ArrayList<NetShare>(_list214.size); + NetShare _elem215; + for (int _i216 = 0; _i216 < _list214.size; ++_i216) { - _elem159 = new NetShare(); - _elem159.read(iprot); - struct.networkShares.add(_elem159); + _elem215 = new NetShare(); + _elem215.read(iprot); + struct.networkShares.add(_elem215); } iprot.readListEnd(); } @@ -2975,14 +3371,14 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture case 30: // LDAP_FILTERS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list161 = iprot.readListBegin(); - struct.ldapFilters = new ArrayList<LdapFilter>(_list161.size); - LdapFilter _elem162; - for (int _i163 = 0; _i163 < _list161.size; ++_i163) + org.apache.thrift.protocol.TList _list217 = iprot.readListBegin(); + struct.ldapFilters = new ArrayList<LdapFilter>(_list217.size); + LdapFilter _elem218; + for (int _i219 = 0; _i219 < _list217.size; ++_i219) { - _elem162 = new LdapFilter(); - _elem162.read(iprot); - struct.ldapFilters.add(_elem162); + _elem218 = new LdapFilter(); + _elem218.read(iprot); + struct.ldapFilters.add(_elem218); } iprot.readListEnd(); } @@ -2991,6 +3387,78 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 31: // PRESET_SCRIPT_IDS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list220 = iprot.readListBegin(); + struct.presetScriptIds = new ArrayList<Integer>(_list220.size); + int _elem221; + for (int _i222 = 0; _i222 < _list220.size; ++_i222) + { + _elem221 = iprot.readI32(); + struct.presetScriptIds.add(_elem221); + } + iprot.readListEnd(); + } + struct.setPresetScriptIdsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 32: // PRESET_NETWORK_SHARES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list223 = iprot.readListBegin(); + struct.presetNetworkShares = new ArrayList<Integer>(_list223.size); + int _elem224; + for (int _i225 = 0; _i225 < _list223.size; ++_i225) + { + _elem224 = iprot.readI32(); + struct.presetNetworkShares.add(_elem224); + } + iprot.readListEnd(); + } + struct.setPresetNetworkSharesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 33: // PRESET_LDAP_FILTERS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list226 = iprot.readListBegin(); + struct.presetLdapFilters = new ArrayList<Integer>(_list226.size); + int _elem227; + for (int _i228 = 0; _i228 < _list226.size; ++_i228) + { + _elem227 = iprot.readI32(); + struct.presetLdapFilters.add(_elem227); + } + iprot.readListEnd(); + } + struct.setPresetLdapFiltersIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 34: // PRESET_NETWORK_EXCEPTION_IDS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list229 = iprot.readListBegin(); + struct.presetNetworkExceptionIds = new ArrayList<Integer>(_list229.size); + int _elem230; + for (int _i231 = 0; _i231 < _list229.size; ++_i231) + { + _elem230 = iprot.readI32(); + struct.presetNetworkExceptionIds.add(_elem230); + } + iprot.readListEnd(); + } + struct.setPresetNetworkExceptionIdsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -3058,9 +3526,9 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture oprot.writeFieldBegin(NICS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.nics.size())); - for (String _iter164 : struct.nics) + for (String _iter232 : struct.nics) { - oprot.writeString(_iter164); + oprot.writeString(_iter232); } oprot.writeListEnd(); } @@ -3070,9 +3538,9 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture oprot.writeFieldBegin(ALLOWED_USERS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.allowedUsers.size())); - for (String _iter165 : struct.allowedUsers) + for (String _iter233 : struct.allowedUsers) { - oprot.writeString(_iter165); + oprot.writeString(_iter233); } oprot.writeListEnd(); } @@ -3082,9 +3550,9 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture oprot.writeFieldBegin(NETWORK_EXCEPTIONS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.networkExceptions.size())); - for (NetRule _iter166 : struct.networkExceptions) + for (NetRule _iter234 : struct.networkExceptions) { - _iter166.write(oprot); + _iter234.write(oprot); } oprot.writeListEnd(); } @@ -3128,9 +3596,9 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture oprot.writeFieldBegin(LOCATION_IDS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.locationIds.size())); - for (int _iter167 : struct.locationIds) + for (int _iter235 : struct.locationIds) { - oprot.writeI32(_iter167); + oprot.writeI32(_iter235); } oprot.writeListEnd(); } @@ -3150,9 +3618,9 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture oprot.writeFieldBegin(NETWORK_SHARES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.networkShares.size())); - for (NetShare _iter168 : struct.networkShares) + for (NetShare _iter236 : struct.networkShares) { - _iter168.write(oprot); + _iter236.write(oprot); } oprot.writeListEnd(); } @@ -3164,9 +3632,65 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture oprot.writeFieldBegin(LDAP_FILTERS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.ldapFilters.size())); - for (LdapFilter _iter169 : struct.ldapFilters) + for (LdapFilter _iter237 : struct.ldapFilters) { - _iter169.write(oprot); + _iter237.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.presetScriptIds != null) { + if (struct.isSetPresetScriptIds()) { + oprot.writeFieldBegin(PRESET_SCRIPT_IDS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.presetScriptIds.size())); + for (int _iter238 : struct.presetScriptIds) + { + oprot.writeI32(_iter238); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.presetNetworkShares != null) { + if (struct.isSetPresetNetworkShares()) { + oprot.writeFieldBegin(PRESET_NETWORK_SHARES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.presetNetworkShares.size())); + for (int _iter239 : struct.presetNetworkShares) + { + oprot.writeI32(_iter239); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.presetLdapFilters != null) { + if (struct.isSetPresetLdapFilters()) { + oprot.writeFieldBegin(PRESET_LDAP_FILTERS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.presetLdapFilters.size())); + for (int _iter240 : struct.presetLdapFilters) + { + oprot.writeI32(_iter240); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.presetNetworkExceptionIds != null) { + if (struct.isSetPresetNetworkExceptionIds()) { + oprot.writeFieldBegin(PRESET_NETWORK_EXCEPTION_IDS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.presetNetworkExceptionIds.size())); + for (int _iter241 : struct.presetNetworkExceptionIds) + { + oprot.writeI32(_iter241); } oprot.writeListEnd(); } @@ -3278,7 +3802,19 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture if (struct.isSetLdapFilters()) { optionals.set(28); } - oprot.writeBitSet(optionals, 29); + if (struct.isSetPresetScriptIds()) { + optionals.set(29); + } + if (struct.isSetPresetNetworkShares()) { + optionals.set(30); + } + if (struct.isSetPresetLdapFilters()) { + optionals.set(31); + } + if (struct.isSetPresetNetworkExceptionIds()) { + optionals.set(32); + } + oprot.writeBitSet(optionals, 33); if (struct.isSetLectureId()) { oprot.writeString(struct.lectureId); } @@ -3330,27 +3866,27 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture if (struct.isSetNics()) { { oprot.writeI32(struct.nics.size()); - for (String _iter170 : struct.nics) + for (String _iter242 : struct.nics) { - oprot.writeString(_iter170); + oprot.writeString(_iter242); } } } if (struct.isSetAllowedUsers()) { { oprot.writeI32(struct.allowedUsers.size()); - for (String _iter171 : struct.allowedUsers) + for (String _iter243 : struct.allowedUsers) { - oprot.writeString(_iter171); + oprot.writeString(_iter243); } } } if (struct.isSetNetworkExceptions()) { { oprot.writeI32(struct.networkExceptions.size()); - for (NetRule _iter172 : struct.networkExceptions) + for (NetRule _iter244 : struct.networkExceptions) { - _iter172.write(oprot); + _iter244.write(oprot); } } } @@ -3369,9 +3905,9 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture if (struct.isSetLocationIds()) { { oprot.writeI32(struct.locationIds.size()); - for (int _iter173 : struct.locationIds) + for (int _iter245 : struct.locationIds) { - oprot.writeI32(_iter173); + oprot.writeI32(_iter245); } } } @@ -3387,18 +3923,54 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture if (struct.isSetNetworkShares()) { { oprot.writeI32(struct.networkShares.size()); - for (NetShare _iter174 : struct.networkShares) + for (NetShare _iter246 : struct.networkShares) { - _iter174.write(oprot); + _iter246.write(oprot); } } } if (struct.isSetLdapFilters()) { { oprot.writeI32(struct.ldapFilters.size()); - for (LdapFilter _iter175 : struct.ldapFilters) + for (LdapFilter _iter247 : struct.ldapFilters) + { + _iter247.write(oprot); + } + } + } + if (struct.isSetPresetScriptIds()) { + { + oprot.writeI32(struct.presetScriptIds.size()); + for (int _iter248 : struct.presetScriptIds) + { + oprot.writeI32(_iter248); + } + } + } + if (struct.isSetPresetNetworkShares()) { + { + oprot.writeI32(struct.presetNetworkShares.size()); + for (int _iter249 : struct.presetNetworkShares) { - _iter175.write(oprot); + oprot.writeI32(_iter249); + } + } + } + if (struct.isSetPresetLdapFilters()) { + { + oprot.writeI32(struct.presetLdapFilters.size()); + for (int _iter250 : struct.presetLdapFilters) + { + oprot.writeI32(_iter250); + } + } + } + if (struct.isSetPresetNetworkExceptionIds()) { + { + oprot.writeI32(struct.presetNetworkExceptionIds.size()); + for (int _iter251 : struct.presetNetworkExceptionIds) + { + oprot.writeI32(_iter251); } } } @@ -3407,7 +3979,7 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture @Override public void read(org.apache.thrift.protocol.TProtocol prot, LectureRead struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(29); + BitSet incoming = iprot.readBitSet(33); if (incoming.get(0)) { struct.lectureId = iprot.readString(); struct.setLectureIdIsSet(true); @@ -3474,40 +4046,40 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture } if (incoming.get(16)) { { - org.apache.thrift.protocol.TList _list176 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.nics = new ArrayList<String>(_list176.size); - String _elem177; - for (int _i178 = 0; _i178 < _list176.size; ++_i178) + org.apache.thrift.protocol.TList _list252 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.nics = new ArrayList<String>(_list252.size); + String _elem253; + for (int _i254 = 0; _i254 < _list252.size; ++_i254) { - _elem177 = iprot.readString(); - struct.nics.add(_elem177); + _elem253 = iprot.readString(); + struct.nics.add(_elem253); } } struct.setNicsIsSet(true); } if (incoming.get(17)) { { - org.apache.thrift.protocol.TList _list179 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.allowedUsers = new ArrayList<String>(_list179.size); - String _elem180; - for (int _i181 = 0; _i181 < _list179.size; ++_i181) + org.apache.thrift.protocol.TList _list255 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.allowedUsers = new ArrayList<String>(_list255.size); + String _elem256; + for (int _i257 = 0; _i257 < _list255.size; ++_i257) { - _elem180 = iprot.readString(); - struct.allowedUsers.add(_elem180); + _elem256 = iprot.readString(); + struct.allowedUsers.add(_elem256); } } struct.setAllowedUsersIsSet(true); } if (incoming.get(18)) { { - org.apache.thrift.protocol.TList _list182 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.networkExceptions = new ArrayList<NetRule>(_list182.size); - NetRule _elem183; - for (int _i184 = 0; _i184 < _list182.size; ++_i184) + org.apache.thrift.protocol.TList _list258 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkExceptions = new ArrayList<NetRule>(_list258.size); + NetRule _elem259; + for (int _i260 = 0; _i260 < _list258.size; ++_i260) { - _elem183 = new NetRule(); - _elem183.read(iprot); - struct.networkExceptions.add(_elem183); + _elem259 = new NetRule(); + _elem259.read(iprot); + struct.networkExceptions.add(_elem259); } } struct.setNetworkExceptionsIsSet(true); @@ -3532,13 +4104,13 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture } if (incoming.get(23)) { { - org.apache.thrift.protocol.TList _list185 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.locationIds = new ArrayList<Integer>(_list185.size); - int _elem186; - for (int _i187 = 0; _i187 < _list185.size; ++_i187) + org.apache.thrift.protocol.TList _list261 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.locationIds = new ArrayList<Integer>(_list261.size); + int _elem262; + for (int _i263 = 0; _i263 < _list261.size; ++_i263) { - _elem186 = iprot.readI32(); - struct.locationIds.add(_elem186); + _elem262 = iprot.readI32(); + struct.locationIds.add(_elem262); } } struct.setLocationIdsIsSet(true); @@ -3557,32 +4129,84 @@ public class LectureRead implements org.apache.thrift.TBase<LectureRead, Lecture } if (incoming.get(27)) { { - org.apache.thrift.protocol.TList _list188 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.networkShares = new ArrayList<NetShare>(_list188.size); - NetShare _elem189; - for (int _i190 = 0; _i190 < _list188.size; ++_i190) + org.apache.thrift.protocol.TList _list264 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkShares = new ArrayList<NetShare>(_list264.size); + NetShare _elem265; + for (int _i266 = 0; _i266 < _list264.size; ++_i266) { - _elem189 = new NetShare(); - _elem189.read(iprot); - struct.networkShares.add(_elem189); + _elem265 = new NetShare(); + _elem265.read(iprot); + struct.networkShares.add(_elem265); } } struct.setNetworkSharesIsSet(true); } if (incoming.get(28)) { { - org.apache.thrift.protocol.TList _list191 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.ldapFilters = new ArrayList<LdapFilter>(_list191.size); - LdapFilter _elem192; - for (int _i193 = 0; _i193 < _list191.size; ++_i193) + org.apache.thrift.protocol.TList _list267 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilters = new ArrayList<LdapFilter>(_list267.size); + LdapFilter _elem268; + for (int _i269 = 0; _i269 < _list267.size; ++_i269) { - _elem192 = new LdapFilter(); - _elem192.read(iprot); - struct.ldapFilters.add(_elem192); + _elem268 = new LdapFilter(); + _elem268.read(iprot); + struct.ldapFilters.add(_elem268); } } struct.setLdapFiltersIsSet(true); } + if (incoming.get(29)) { + { + org.apache.thrift.protocol.TList _list270 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetScriptIds = new ArrayList<Integer>(_list270.size); + int _elem271; + for (int _i272 = 0; _i272 < _list270.size; ++_i272) + { + _elem271 = iprot.readI32(); + struct.presetScriptIds.add(_elem271); + } + } + struct.setPresetScriptIdsIsSet(true); + } + if (incoming.get(30)) { + { + org.apache.thrift.protocol.TList _list273 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetNetworkShares = new ArrayList<Integer>(_list273.size); + int _elem274; + for (int _i275 = 0; _i275 < _list273.size; ++_i275) + { + _elem274 = iprot.readI32(); + struct.presetNetworkShares.add(_elem274); + } + } + struct.setPresetNetworkSharesIsSet(true); + } + if (incoming.get(31)) { + { + org.apache.thrift.protocol.TList _list276 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetLdapFilters = new ArrayList<Integer>(_list276.size); + int _elem277; + for (int _i278 = 0; _i278 < _list276.size; ++_i278) + { + _elem277 = iprot.readI32(); + struct.presetLdapFilters.add(_elem277); + } + } + struct.setPresetLdapFiltersIsSet(true); + } + if (incoming.get(32)) { + { + org.apache.thrift.protocol.TList _list279 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetNetworkExceptionIds = new ArrayList<Integer>(_list279.size); + int _elem280; + for (int _i281 = 0; _i281 < _list279.size; ++_i281) + { + _elem280 = iprot.readI32(); + struct.presetNetworkExceptionIds.add(_elem280); + } + } + struct.setPresetNetworkExceptionIdsIsSet(true); + } } } diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/LectureWrite.java b/src/main/java/org/openslx/bwlp/thrift/iface/LectureWrite.java index fc0f59d..921ea64 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/LectureWrite.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/LectureWrite.java @@ -34,7 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-06-13") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-02-25") public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, LectureWrite._Fields>, java.io.Serializable, Cloneable, Comparable<LectureWrite> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("LectureWrite"); @@ -59,6 +59,8 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu private static final org.apache.thrift.protocol.TField HAS_USB_ACCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("hasUsbAccess", org.apache.thrift.protocol.TType.BOOL, (short)20); private static final org.apache.thrift.protocol.TField NETWORK_SHARES_FIELD_DESC = new org.apache.thrift.protocol.TField("networkShares", org.apache.thrift.protocol.TType.LIST, (short)21); private static final org.apache.thrift.protocol.TField LDAP_FILTERS_FIELD_DESC = new org.apache.thrift.protocol.TField("ldapFilters", org.apache.thrift.protocol.TType.LIST, (short)22); + private static final org.apache.thrift.protocol.TField PRESET_SCRIPT_IDS_FIELD_DESC = new org.apache.thrift.protocol.TField("presetScriptIds", org.apache.thrift.protocol.TType.LIST, (short)23); + private static final org.apache.thrift.protocol.TField PRESET_NETWORK_EXCEPTION_IDS_FIELD_DESC = new org.apache.thrift.protocol.TField("presetNetworkExceptionIds", org.apache.thrift.protocol.TType.LIST, (short)24); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -87,6 +89,8 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu public boolean hasUsbAccess; // required public List<NetShare> networkShares; // optional public List<LdapFilter> ldapFilters; // optional + public List<Integer> presetScriptIds; // optional + public List<Integer> presetNetworkExceptionIds; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -110,7 +114,9 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu LIMIT_TO_ALLOWED_USERS((short)19, "limitToAllowedUsers"), HAS_USB_ACCESS((short)20, "hasUsbAccess"), NETWORK_SHARES((short)21, "networkShares"), - LDAP_FILTERS((short)22, "ldapFilters"); + LDAP_FILTERS((short)22, "ldapFilters"), + PRESET_SCRIPT_IDS((short)23, "presetScriptIds"), + PRESET_NETWORK_EXCEPTION_IDS((short)24, "presetNetworkExceptionIds"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -167,6 +173,10 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu return NETWORK_SHARES; case 22: // LDAP_FILTERS return LDAP_FILTERS; + case 23: // PRESET_SCRIPT_IDS + return PRESET_SCRIPT_IDS; + case 24: // PRESET_NETWORK_EXCEPTION_IDS + return PRESET_NETWORK_EXCEPTION_IDS; default: return null; } @@ -217,7 +227,7 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu private static final int __LIMITTOALLOWEDUSERS_ISSET_ID = 7; private static final int __HASUSBACCESS_ISSET_ID = 8; private short __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.NETWORK_EXCEPTIONS,_Fields.ADD_ALLOWED_USERS,_Fields.REM_ALLOWED_USERS,_Fields.NETWORK_SHARES,_Fields.LDAP_FILTERS}; + private static final _Fields optionals[] = {_Fields.NETWORK_EXCEPTIONS,_Fields.ADD_ALLOWED_USERS,_Fields.REM_ALLOWED_USERS,_Fields.NETWORK_SHARES,_Fields.LDAP_FILTERS,_Fields.PRESET_SCRIPT_IDS,_Fields.PRESET_NETWORK_EXCEPTION_IDS}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -270,6 +280,12 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu tmpMap.put(_Fields.LDAP_FILTERS, new org.apache.thrift.meta_data.FieldMetaData("ldapFilters", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, LdapFilter.class)))); + tmpMap.put(_Fields.PRESET_SCRIPT_IDS, new org.apache.thrift.meta_data.FieldMetaData("presetScriptIds", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + tmpMap.put(_Fields.PRESET_NETWORK_EXCEPTION_IDS, new org.apache.thrift.meta_data.FieldMetaData("presetNetworkExceptionIds", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(LectureWrite.class, metaDataMap); } @@ -389,6 +405,14 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu } this.ldapFilters = __this__ldapFilters; } + if (other.isSetPresetScriptIds()) { + List<Integer> __this__presetScriptIds = new ArrayList<Integer>(other.presetScriptIds); + this.presetScriptIds = __this__presetScriptIds; + } + if (other.isSetPresetNetworkExceptionIds()) { + List<Integer> __this__presetNetworkExceptionIds = new ArrayList<Integer>(other.presetNetworkExceptionIds); + this.presetNetworkExceptionIds = __this__presetNetworkExceptionIds; + } } public LectureWrite deepCopy() { @@ -427,6 +451,8 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu this.hasUsbAccess = false; this.networkShares = null; this.ldapFilters = null; + this.presetScriptIds = null; + this.presetNetworkExceptionIds = null; } public String getLectureName() { @@ -1029,6 +1055,84 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu } } + public int getPresetScriptIdsSize() { + return (this.presetScriptIds == null) ? 0 : this.presetScriptIds.size(); + } + + public java.util.Iterator<Integer> getPresetScriptIdsIterator() { + return (this.presetScriptIds == null) ? null : this.presetScriptIds.iterator(); + } + + public void addToPresetScriptIds(int elem) { + if (this.presetScriptIds == null) { + this.presetScriptIds = new ArrayList<Integer>(); + } + this.presetScriptIds.add(elem); + } + + public List<Integer> getPresetScriptIds() { + return this.presetScriptIds; + } + + public LectureWrite setPresetScriptIds(List<Integer> presetScriptIds) { + this.presetScriptIds = presetScriptIds; + return this; + } + + public void unsetPresetScriptIds() { + this.presetScriptIds = null; + } + + /** Returns true if field presetScriptIds is set (has been assigned a value) and false otherwise */ + public boolean isSetPresetScriptIds() { + return this.presetScriptIds != null; + } + + public void setPresetScriptIdsIsSet(boolean value) { + if (!value) { + this.presetScriptIds = null; + } + } + + public int getPresetNetworkExceptionIdsSize() { + return (this.presetNetworkExceptionIds == null) ? 0 : this.presetNetworkExceptionIds.size(); + } + + public java.util.Iterator<Integer> getPresetNetworkExceptionIdsIterator() { + return (this.presetNetworkExceptionIds == null) ? null : this.presetNetworkExceptionIds.iterator(); + } + + public void addToPresetNetworkExceptionIds(int elem) { + if (this.presetNetworkExceptionIds == null) { + this.presetNetworkExceptionIds = new ArrayList<Integer>(); + } + this.presetNetworkExceptionIds.add(elem); + } + + public List<Integer> getPresetNetworkExceptionIds() { + return this.presetNetworkExceptionIds; + } + + public LectureWrite setPresetNetworkExceptionIds(List<Integer> presetNetworkExceptionIds) { + this.presetNetworkExceptionIds = presetNetworkExceptionIds; + return this; + } + + public void unsetPresetNetworkExceptionIds() { + this.presetNetworkExceptionIds = null; + } + + /** Returns true if field presetNetworkExceptionIds is set (has been assigned a value) and false otherwise */ + public boolean isSetPresetNetworkExceptionIds() { + return this.presetNetworkExceptionIds != null; + } + + public void setPresetNetworkExceptionIdsIsSet(boolean value) { + if (!value) { + this.presetNetworkExceptionIds = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case LECTURE_NAME: @@ -1199,6 +1303,22 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu } break; + case PRESET_SCRIPT_IDS: + if (value == null) { + unsetPresetScriptIds(); + } else { + setPresetScriptIds((List<Integer>)value); + } + break; + + case PRESET_NETWORK_EXCEPTION_IDS: + if (value == null) { + unsetPresetNetworkExceptionIds(); + } else { + setPresetNetworkExceptionIds((List<Integer>)value); + } + break; + } } @@ -1267,6 +1387,12 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu case LDAP_FILTERS: return getLdapFilters(); + case PRESET_SCRIPT_IDS: + return getPresetScriptIds(); + + case PRESET_NETWORK_EXCEPTION_IDS: + return getPresetNetworkExceptionIds(); + } throw new IllegalStateException(); } @@ -1320,6 +1446,10 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu return isSetNetworkShares(); case LDAP_FILTERS: return isSetLdapFilters(); + case PRESET_SCRIPT_IDS: + return isSetPresetScriptIds(); + case PRESET_NETWORK_EXCEPTION_IDS: + return isSetPresetNetworkExceptionIds(); } throw new IllegalStateException(); } @@ -1526,6 +1656,24 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu return false; } + boolean this_present_presetScriptIds = true && this.isSetPresetScriptIds(); + boolean that_present_presetScriptIds = true && that.isSetPresetScriptIds(); + if (this_present_presetScriptIds || that_present_presetScriptIds) { + if (!(this_present_presetScriptIds && that_present_presetScriptIds)) + return false; + if (!this.presetScriptIds.equals(that.presetScriptIds)) + return false; + } + + boolean this_present_presetNetworkExceptionIds = true && this.isSetPresetNetworkExceptionIds(); + boolean that_present_presetNetworkExceptionIds = true && that.isSetPresetNetworkExceptionIds(); + if (this_present_presetNetworkExceptionIds || that_present_presetNetworkExceptionIds) { + if (!(this_present_presetNetworkExceptionIds && that_present_presetNetworkExceptionIds)) + return false; + if (!this.presetNetworkExceptionIds.equals(that.presetNetworkExceptionIds)) + return false; + } + return true; } @@ -1638,6 +1786,16 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu if (present_ldapFilters) list.add(ldapFilters); + boolean present_presetScriptIds = true && (isSetPresetScriptIds()); + list.add(present_presetScriptIds); + if (present_presetScriptIds) + list.add(presetScriptIds); + + boolean present_presetNetworkExceptionIds = true && (isSetPresetNetworkExceptionIds()); + list.add(present_presetNetworkExceptionIds); + if (present_presetNetworkExceptionIds) + list.add(presetNetworkExceptionIds); + return list.hashCode(); } @@ -1859,6 +2017,26 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu return lastComparison; } } + lastComparison = Boolean.valueOf(isSetPresetScriptIds()).compareTo(other.isSetPresetScriptIds()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPresetScriptIds()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.presetScriptIds, other.presetScriptIds); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPresetNetworkExceptionIds()).compareTo(other.isSetPresetNetworkExceptionIds()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPresetNetworkExceptionIds()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.presetNetworkExceptionIds, other.presetNetworkExceptionIds); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -2020,6 +2198,26 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu } first = false; } + if (isSetPresetScriptIds()) { + if (!first) sb.append(", "); + sb.append("presetScriptIds:"); + if (this.presetScriptIds == null) { + sb.append("null"); + } else { + sb.append(this.presetScriptIds); + } + first = false; + } + if (isSetPresetNetworkExceptionIds()) { + if (!first) sb.append(", "); + sb.append("presetNetworkExceptionIds:"); + if (this.presetNetworkExceptionIds == null) { + sb.append("null"); + } else { + sb.append(this.presetNetworkExceptionIds); + } + first = false; + } sb.append(")"); return sb.toString(); } @@ -2135,13 +2333,13 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu case 10: // NICS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list90 = iprot.readListBegin(); - struct.nics = new ArrayList<String>(_list90.size); - String _elem91; - for (int _i92 = 0; _i92 < _list90.size; ++_i92) + org.apache.thrift.protocol.TList _list130 = iprot.readListBegin(); + struct.nics = new ArrayList<String>(_list130.size); + String _elem131; + for (int _i132 = 0; _i132 < _list130.size; ++_i132) { - _elem91 = iprot.readString(); - struct.nics.add(_elem91); + _elem131 = iprot.readString(); + struct.nics.add(_elem131); } iprot.readListEnd(); } @@ -2153,14 +2351,14 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu case 12: // NETWORK_EXCEPTIONS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list93 = iprot.readListBegin(); - struct.networkExceptions = new ArrayList<NetRule>(_list93.size); - NetRule _elem94; - for (int _i95 = 0; _i95 < _list93.size; ++_i95) + org.apache.thrift.protocol.TList _list133 = iprot.readListBegin(); + struct.networkExceptions = new ArrayList<NetRule>(_list133.size); + NetRule _elem134; + for (int _i135 = 0; _i135 < _list133.size; ++_i135) { - _elem94 = new NetRule(); - _elem94.read(iprot); - struct.networkExceptions.add(_elem94); + _elem134 = new NetRule(); + _elem134.read(iprot); + struct.networkExceptions.add(_elem134); } iprot.readListEnd(); } @@ -2197,13 +2395,13 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu case 11: // ADD_ALLOWED_USERS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list96 = iprot.readListBegin(); - struct.addAllowedUsers = new ArrayList<String>(_list96.size); - String _elem97; - for (int _i98 = 0; _i98 < _list96.size; ++_i98) + org.apache.thrift.protocol.TList _list136 = iprot.readListBegin(); + struct.addAllowedUsers = new ArrayList<String>(_list136.size); + String _elem137; + for (int _i138 = 0; _i138 < _list136.size; ++_i138) { - _elem97 = iprot.readString(); - struct.addAllowedUsers.add(_elem97); + _elem137 = iprot.readString(); + struct.addAllowedUsers.add(_elem137); } iprot.readListEnd(); } @@ -2215,13 +2413,13 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu case 16: // REM_ALLOWED_USERS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list99 = iprot.readListBegin(); - struct.remAllowedUsers = new ArrayList<String>(_list99.size); - String _elem100; - for (int _i101 = 0; _i101 < _list99.size; ++_i101) + org.apache.thrift.protocol.TList _list139 = iprot.readListBegin(); + struct.remAllowedUsers = new ArrayList<String>(_list139.size); + String _elem140; + for (int _i141 = 0; _i141 < _list139.size; ++_i141) { - _elem100 = iprot.readString(); - struct.remAllowedUsers.add(_elem100); + _elem140 = iprot.readString(); + struct.remAllowedUsers.add(_elem140); } iprot.readListEnd(); } @@ -2233,13 +2431,13 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu case 17: // LOCATION_IDS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list102 = iprot.readListBegin(); - struct.locationIds = new ArrayList<Integer>(_list102.size); - int _elem103; - for (int _i104 = 0; _i104 < _list102.size; ++_i104) + org.apache.thrift.protocol.TList _list142 = iprot.readListBegin(); + struct.locationIds = new ArrayList<Integer>(_list142.size); + int _elem143; + for (int _i144 = 0; _i144 < _list142.size; ++_i144) { - _elem103 = iprot.readI32(); - struct.locationIds.add(_elem103); + _elem143 = iprot.readI32(); + struct.locationIds.add(_elem143); } iprot.readListEnd(); } @@ -2275,14 +2473,14 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu case 21: // NETWORK_SHARES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list105 = iprot.readListBegin(); - struct.networkShares = new ArrayList<NetShare>(_list105.size); - NetShare _elem106; - for (int _i107 = 0; _i107 < _list105.size; ++_i107) + org.apache.thrift.protocol.TList _list145 = iprot.readListBegin(); + struct.networkShares = new ArrayList<NetShare>(_list145.size); + NetShare _elem146; + for (int _i147 = 0; _i147 < _list145.size; ++_i147) { - _elem106 = new NetShare(); - _elem106.read(iprot); - struct.networkShares.add(_elem106); + _elem146 = new NetShare(); + _elem146.read(iprot); + struct.networkShares.add(_elem146); } iprot.readListEnd(); } @@ -2294,14 +2492,14 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu case 22: // LDAP_FILTERS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list108 = iprot.readListBegin(); - struct.ldapFilters = new ArrayList<LdapFilter>(_list108.size); - LdapFilter _elem109; - for (int _i110 = 0; _i110 < _list108.size; ++_i110) + org.apache.thrift.protocol.TList _list148 = iprot.readListBegin(); + struct.ldapFilters = new ArrayList<LdapFilter>(_list148.size); + LdapFilter _elem149; + for (int _i150 = 0; _i150 < _list148.size; ++_i150) { - _elem109 = new LdapFilter(); - _elem109.read(iprot); - struct.ldapFilters.add(_elem109); + _elem149 = new LdapFilter(); + _elem149.read(iprot); + struct.ldapFilters.add(_elem149); } iprot.readListEnd(); } @@ -2310,6 +2508,42 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 23: // PRESET_SCRIPT_IDS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list151 = iprot.readListBegin(); + struct.presetScriptIds = new ArrayList<Integer>(_list151.size); + int _elem152; + for (int _i153 = 0; _i153 < _list151.size; ++_i153) + { + _elem152 = iprot.readI32(); + struct.presetScriptIds.add(_elem152); + } + iprot.readListEnd(); + } + struct.setPresetScriptIdsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 24: // PRESET_NETWORK_EXCEPTION_IDS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list154 = iprot.readListBegin(); + struct.presetNetworkExceptionIds = new ArrayList<Integer>(_list154.size); + int _elem155; + for (int _i156 = 0; _i156 < _list154.size; ++_i156) + { + _elem155 = iprot.readI32(); + struct.presetNetworkExceptionIds.add(_elem155); + } + iprot.readListEnd(); + } + struct.setPresetNetworkExceptionIdsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -2361,9 +2595,9 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu oprot.writeFieldBegin(NICS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.nics.size())); - for (String _iter111 : struct.nics) + for (String _iter157 : struct.nics) { - oprot.writeString(_iter111); + oprot.writeString(_iter157); } oprot.writeListEnd(); } @@ -2374,9 +2608,9 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu oprot.writeFieldBegin(ADD_ALLOWED_USERS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.addAllowedUsers.size())); - for (String _iter112 : struct.addAllowedUsers) + for (String _iter158 : struct.addAllowedUsers) { - oprot.writeString(_iter112); + oprot.writeString(_iter158); } oprot.writeListEnd(); } @@ -2388,9 +2622,9 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu oprot.writeFieldBegin(NETWORK_EXCEPTIONS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.networkExceptions.size())); - for (NetRule _iter113 : struct.networkExceptions) + for (NetRule _iter159 : struct.networkExceptions) { - _iter113.write(oprot); + _iter159.write(oprot); } oprot.writeListEnd(); } @@ -2413,9 +2647,9 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu oprot.writeFieldBegin(REM_ALLOWED_USERS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.remAllowedUsers.size())); - for (String _iter114 : struct.remAllowedUsers) + for (String _iter160 : struct.remAllowedUsers) { - oprot.writeString(_iter114); + oprot.writeString(_iter160); } oprot.writeListEnd(); } @@ -2426,9 +2660,9 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu oprot.writeFieldBegin(LOCATION_IDS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.locationIds.size())); - for (int _iter115 : struct.locationIds) + for (int _iter161 : struct.locationIds) { - oprot.writeI32(_iter115); + oprot.writeI32(_iter161); } oprot.writeListEnd(); } @@ -2448,9 +2682,9 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu oprot.writeFieldBegin(NETWORK_SHARES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.networkShares.size())); - for (NetShare _iter116 : struct.networkShares) + for (NetShare _iter162 : struct.networkShares) { - _iter116.write(oprot); + _iter162.write(oprot); } oprot.writeListEnd(); } @@ -2462,9 +2696,37 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu oprot.writeFieldBegin(LDAP_FILTERS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.ldapFilters.size())); - for (LdapFilter _iter117 : struct.ldapFilters) + for (LdapFilter _iter163 : struct.ldapFilters) { - _iter117.write(oprot); + _iter163.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.presetScriptIds != null) { + if (struct.isSetPresetScriptIds()) { + oprot.writeFieldBegin(PRESET_SCRIPT_IDS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.presetScriptIds.size())); + for (int _iter164 : struct.presetScriptIds) + { + oprot.writeI32(_iter164); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + } + if (struct.presetNetworkExceptionIds != null) { + if (struct.isSetPresetNetworkExceptionIds()) { + oprot.writeFieldBegin(PRESET_NETWORK_EXCEPTION_IDS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.presetNetworkExceptionIds.size())); + for (int _iter165 : struct.presetNetworkExceptionIds) + { + oprot.writeI32(_iter165); } oprot.writeListEnd(); } @@ -2552,7 +2814,13 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu if (struct.isSetLdapFilters()) { optionals.set(20); } - oprot.writeBitSet(optionals, 21); + if (struct.isSetPresetScriptIds()) { + optionals.set(21); + } + if (struct.isSetPresetNetworkExceptionIds()) { + optionals.set(22); + } + oprot.writeBitSet(optionals, 23); if (struct.isSetLectureName()) { oprot.writeString(struct.lectureName); } @@ -2580,18 +2848,18 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu if (struct.isSetNics()) { { oprot.writeI32(struct.nics.size()); - for (String _iter118 : struct.nics) + for (String _iter166 : struct.nics) { - oprot.writeString(_iter118); + oprot.writeString(_iter166); } } } if (struct.isSetNetworkExceptions()) { { oprot.writeI32(struct.networkExceptions.size()); - for (NetRule _iter119 : struct.networkExceptions) + for (NetRule _iter167 : struct.networkExceptions) { - _iter119.write(oprot); + _iter167.write(oprot); } } } @@ -2607,27 +2875,27 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu if (struct.isSetAddAllowedUsers()) { { oprot.writeI32(struct.addAllowedUsers.size()); - for (String _iter120 : struct.addAllowedUsers) + for (String _iter168 : struct.addAllowedUsers) { - oprot.writeString(_iter120); + oprot.writeString(_iter168); } } } if (struct.isSetRemAllowedUsers()) { { oprot.writeI32(struct.remAllowedUsers.size()); - for (String _iter121 : struct.remAllowedUsers) + for (String _iter169 : struct.remAllowedUsers) { - oprot.writeString(_iter121); + oprot.writeString(_iter169); } } } if (struct.isSetLocationIds()) { { oprot.writeI32(struct.locationIds.size()); - for (int _iter122 : struct.locationIds) + for (int _iter170 : struct.locationIds) { - oprot.writeI32(_iter122); + oprot.writeI32(_iter170); } } } @@ -2643,18 +2911,36 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu if (struct.isSetNetworkShares()) { { oprot.writeI32(struct.networkShares.size()); - for (NetShare _iter123 : struct.networkShares) + for (NetShare _iter171 : struct.networkShares) { - _iter123.write(oprot); + _iter171.write(oprot); } } } if (struct.isSetLdapFilters()) { { oprot.writeI32(struct.ldapFilters.size()); - for (LdapFilter _iter124 : struct.ldapFilters) + for (LdapFilter _iter172 : struct.ldapFilters) + { + _iter172.write(oprot); + } + } + } + if (struct.isSetPresetScriptIds()) { + { + oprot.writeI32(struct.presetScriptIds.size()); + for (int _iter173 : struct.presetScriptIds) + { + oprot.writeI32(_iter173); + } + } + } + if (struct.isSetPresetNetworkExceptionIds()) { + { + oprot.writeI32(struct.presetNetworkExceptionIds.size()); + for (int _iter174 : struct.presetNetworkExceptionIds) { - _iter124.write(oprot); + oprot.writeI32(_iter174); } } } @@ -2663,7 +2949,7 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu @Override public void read(org.apache.thrift.protocol.TProtocol prot, LectureWrite struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(21); + BitSet incoming = iprot.readBitSet(23); if (incoming.get(0)) { struct.lectureName = iprot.readString(); struct.setLectureNameIsSet(true); @@ -2698,27 +2984,27 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu } if (incoming.get(8)) { { - org.apache.thrift.protocol.TList _list125 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.nics = new ArrayList<String>(_list125.size); - String _elem126; - for (int _i127 = 0; _i127 < _list125.size; ++_i127) + org.apache.thrift.protocol.TList _list175 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.nics = new ArrayList<String>(_list175.size); + String _elem176; + for (int _i177 = 0; _i177 < _list175.size; ++_i177) { - _elem126 = iprot.readString(); - struct.nics.add(_elem126); + _elem176 = iprot.readString(); + struct.nics.add(_elem176); } } struct.setNicsIsSet(true); } if (incoming.get(9)) { { - org.apache.thrift.protocol.TList _list128 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.networkExceptions = new ArrayList<NetRule>(_list128.size); - NetRule _elem129; - for (int _i130 = 0; _i130 < _list128.size; ++_i130) + org.apache.thrift.protocol.TList _list178 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkExceptions = new ArrayList<NetRule>(_list178.size); + NetRule _elem179; + for (int _i180 = 0; _i180 < _list178.size; ++_i180) { - _elem129 = new NetRule(); - _elem129.read(iprot); - struct.networkExceptions.add(_elem129); + _elem179 = new NetRule(); + _elem179.read(iprot); + struct.networkExceptions.add(_elem179); } } struct.setNetworkExceptionsIsSet(true); @@ -2738,39 +3024,39 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu } if (incoming.get(13)) { { - org.apache.thrift.protocol.TList _list131 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.addAllowedUsers = new ArrayList<String>(_list131.size); - String _elem132; - for (int _i133 = 0; _i133 < _list131.size; ++_i133) + org.apache.thrift.protocol.TList _list181 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.addAllowedUsers = new ArrayList<String>(_list181.size); + String _elem182; + for (int _i183 = 0; _i183 < _list181.size; ++_i183) { - _elem132 = iprot.readString(); - struct.addAllowedUsers.add(_elem132); + _elem182 = iprot.readString(); + struct.addAllowedUsers.add(_elem182); } } struct.setAddAllowedUsersIsSet(true); } if (incoming.get(14)) { { - org.apache.thrift.protocol.TList _list134 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.remAllowedUsers = new ArrayList<String>(_list134.size); - String _elem135; - for (int _i136 = 0; _i136 < _list134.size; ++_i136) + org.apache.thrift.protocol.TList _list184 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.remAllowedUsers = new ArrayList<String>(_list184.size); + String _elem185; + for (int _i186 = 0; _i186 < _list184.size; ++_i186) { - _elem135 = iprot.readString(); - struct.remAllowedUsers.add(_elem135); + _elem185 = iprot.readString(); + struct.remAllowedUsers.add(_elem185); } } struct.setRemAllowedUsersIsSet(true); } if (incoming.get(15)) { { - org.apache.thrift.protocol.TList _list137 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.locationIds = new ArrayList<Integer>(_list137.size); - int _elem138; - for (int _i139 = 0; _i139 < _list137.size; ++_i139) + org.apache.thrift.protocol.TList _list187 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.locationIds = new ArrayList<Integer>(_list187.size); + int _elem188; + for (int _i189 = 0; _i189 < _list187.size; ++_i189) { - _elem138 = iprot.readI32(); - struct.locationIds.add(_elem138); + _elem188 = iprot.readI32(); + struct.locationIds.add(_elem188); } } struct.setLocationIdsIsSet(true); @@ -2789,32 +3075,58 @@ public class LectureWrite implements org.apache.thrift.TBase<LectureWrite, Lectu } if (incoming.get(19)) { { - org.apache.thrift.protocol.TList _list140 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.networkShares = new ArrayList<NetShare>(_list140.size); - NetShare _elem141; - for (int _i142 = 0; _i142 < _list140.size; ++_i142) + org.apache.thrift.protocol.TList _list190 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkShares = new ArrayList<NetShare>(_list190.size); + NetShare _elem191; + for (int _i192 = 0; _i192 < _list190.size; ++_i192) { - _elem141 = new NetShare(); - _elem141.read(iprot); - struct.networkShares.add(_elem141); + _elem191 = new NetShare(); + _elem191.read(iprot); + struct.networkShares.add(_elem191); } } struct.setNetworkSharesIsSet(true); } if (incoming.get(20)) { { - org.apache.thrift.protocol.TList _list143 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.ldapFilters = new ArrayList<LdapFilter>(_list143.size); - LdapFilter _elem144; - for (int _i145 = 0; _i145 < _list143.size; ++_i145) + org.apache.thrift.protocol.TList _list193 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilters = new ArrayList<LdapFilter>(_list193.size); + LdapFilter _elem194; + for (int _i195 = 0; _i195 < _list193.size; ++_i195) { - _elem144 = new LdapFilter(); - _elem144.read(iprot); - struct.ldapFilters.add(_elem144); + _elem194 = new LdapFilter(); + _elem194.read(iprot); + struct.ldapFilters.add(_elem194); } } struct.setLdapFiltersIsSet(true); } + if (incoming.get(21)) { + { + org.apache.thrift.protocol.TList _list196 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetScriptIds = new ArrayList<Integer>(_list196.size); + int _elem197; + for (int _i198 = 0; _i198 < _list196.size; ++_i198) + { + _elem197 = iprot.readI32(); + struct.presetScriptIds.add(_elem197); + } + } + struct.setPresetScriptIdsIsSet(true); + } + if (incoming.get(22)) { + { + org.apache.thrift.protocol.TList _list199 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetNetworkExceptionIds = new ArrayList<Integer>(_list199.size); + int _elem200; + for (int _i201 = 0; _i201 < _list199.size; ++_i201) + { + _elem200 = iprot.readI32(); + struct.presetNetworkExceptionIds.add(_elem200); + } + } + struct.setPresetNetworkExceptionIdsIsSet(true); + } } } diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/NetRule.java b/src/main/java/org/openslx/bwlp/thrift/iface/NetRule.java index 8fcabe9..abc7486 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/NetRule.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/NetRule.java @@ -34,7 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-03-04") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-02-25") public class NetRule implements org.apache.thrift.TBase<NetRule, NetRule._Fields>, java.io.Serializable, Cloneable, Comparable<NetRule> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("NetRule"); diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/PredefinedData.java b/src/main/java/org/openslx/bwlp/thrift/iface/PredefinedData.java index 67e2463..4032b4e 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/PredefinedData.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/PredefinedData.java @@ -34,12 +34,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-11-23") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-02-25") public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, PredefinedData._Fields>, java.io.Serializable, Cloneable, Comparable<PredefinedData> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PredefinedData"); private static final org.apache.thrift.protocol.TField NET_SHARES_FIELD_DESC = new org.apache.thrift.protocol.TField("netShares", org.apache.thrift.protocol.TType.LIST, (short)1); private static final org.apache.thrift.protocol.TField LDAP_FILTER_FIELD_DESC = new org.apache.thrift.protocol.TField("ldapFilter", org.apache.thrift.protocol.TType.LIST, (short)2); + private static final org.apache.thrift.protocol.TField RUN_SCRIPTS_FIELD_DESC = new org.apache.thrift.protocol.TField("runScripts", org.apache.thrift.protocol.TType.LIST, (short)3); + private static final org.apache.thrift.protocol.TField NETWORK_EXCEPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("networkExceptions", org.apache.thrift.protocol.TType.LIST, (short)4); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -49,11 +51,15 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P public List<NetShare> netShares; // required public List<LdapFilter> ldapFilter; // required + public List<PresetRunScript> runScripts; // required + public List<PresetNetRule> networkExceptions; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { NET_SHARES((short)1, "netShares"), - LDAP_FILTER((short)2, "ldapFilter"); + LDAP_FILTER((short)2, "ldapFilter"), + RUN_SCRIPTS((short)3, "runScripts"), + NETWORK_EXCEPTIONS((short)4, "networkExceptions"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -72,6 +78,10 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P return NET_SHARES; case 2: // LDAP_FILTER return LDAP_FILTER; + case 3: // RUN_SCRIPTS + return RUN_SCRIPTS; + case 4: // NETWORK_EXCEPTIONS + return NETWORK_EXCEPTIONS; default: return null; } @@ -121,6 +131,12 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P tmpMap.put(_Fields.LDAP_FILTER, new org.apache.thrift.meta_data.FieldMetaData("ldapFilter", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, LdapFilter.class)))); + tmpMap.put(_Fields.RUN_SCRIPTS, new org.apache.thrift.meta_data.FieldMetaData("runScripts", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PresetRunScript.class)))); + tmpMap.put(_Fields.NETWORK_EXCEPTIONS, new org.apache.thrift.meta_data.FieldMetaData("networkExceptions", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PresetNetRule.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PredefinedData.class, metaDataMap); } @@ -130,11 +146,15 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P public PredefinedData( List<NetShare> netShares, - List<LdapFilter> ldapFilter) + List<LdapFilter> ldapFilter, + List<PresetRunScript> runScripts, + List<PresetNetRule> networkExceptions) { this(); this.netShares = netShares; this.ldapFilter = ldapFilter; + this.runScripts = runScripts; + this.networkExceptions = networkExceptions; } /** @@ -155,6 +175,20 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P } this.ldapFilter = __this__ldapFilter; } + if (other.isSetRunScripts()) { + List<PresetRunScript> __this__runScripts = new ArrayList<PresetRunScript>(other.runScripts.size()); + for (PresetRunScript other_element : other.runScripts) { + __this__runScripts.add(new PresetRunScript(other_element)); + } + this.runScripts = __this__runScripts; + } + if (other.isSetNetworkExceptions()) { + List<PresetNetRule> __this__networkExceptions = new ArrayList<PresetNetRule>(other.networkExceptions.size()); + for (PresetNetRule other_element : other.networkExceptions) { + __this__networkExceptions.add(new PresetNetRule(other_element)); + } + this.networkExceptions = __this__networkExceptions; + } } public PredefinedData deepCopy() { @@ -165,6 +199,8 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P public void clear() { this.netShares = null; this.ldapFilter = null; + this.runScripts = null; + this.networkExceptions = null; } public int getNetSharesSize() { @@ -245,6 +281,84 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P } } + public int getRunScriptsSize() { + return (this.runScripts == null) ? 0 : this.runScripts.size(); + } + + public java.util.Iterator<PresetRunScript> getRunScriptsIterator() { + return (this.runScripts == null) ? null : this.runScripts.iterator(); + } + + public void addToRunScripts(PresetRunScript elem) { + if (this.runScripts == null) { + this.runScripts = new ArrayList<PresetRunScript>(); + } + this.runScripts.add(elem); + } + + public List<PresetRunScript> getRunScripts() { + return this.runScripts; + } + + public PredefinedData setRunScripts(List<PresetRunScript> runScripts) { + this.runScripts = runScripts; + return this; + } + + public void unsetRunScripts() { + this.runScripts = null; + } + + /** Returns true if field runScripts is set (has been assigned a value) and false otherwise */ + public boolean isSetRunScripts() { + return this.runScripts != null; + } + + public void setRunScriptsIsSet(boolean value) { + if (!value) { + this.runScripts = null; + } + } + + public int getNetworkExceptionsSize() { + return (this.networkExceptions == null) ? 0 : this.networkExceptions.size(); + } + + public java.util.Iterator<PresetNetRule> getNetworkExceptionsIterator() { + return (this.networkExceptions == null) ? null : this.networkExceptions.iterator(); + } + + public void addToNetworkExceptions(PresetNetRule elem) { + if (this.networkExceptions == null) { + this.networkExceptions = new ArrayList<PresetNetRule>(); + } + this.networkExceptions.add(elem); + } + + public List<PresetNetRule> getNetworkExceptions() { + return this.networkExceptions; + } + + public PredefinedData setNetworkExceptions(List<PresetNetRule> networkExceptions) { + this.networkExceptions = networkExceptions; + return this; + } + + public void unsetNetworkExceptions() { + this.networkExceptions = null; + } + + /** Returns true if field networkExceptions is set (has been assigned a value) and false otherwise */ + public boolean isSetNetworkExceptions() { + return this.networkExceptions != null; + } + + public void setNetworkExceptionsIsSet(boolean value) { + if (!value) { + this.networkExceptions = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case NET_SHARES: @@ -263,6 +377,22 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P } break; + case RUN_SCRIPTS: + if (value == null) { + unsetRunScripts(); + } else { + setRunScripts((List<PresetRunScript>)value); + } + break; + + case NETWORK_EXCEPTIONS: + if (value == null) { + unsetNetworkExceptions(); + } else { + setNetworkExceptions((List<PresetNetRule>)value); + } + break; + } } @@ -274,6 +404,12 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P case LDAP_FILTER: return getLdapFilter(); + case RUN_SCRIPTS: + return getRunScripts(); + + case NETWORK_EXCEPTIONS: + return getNetworkExceptions(); + } throw new IllegalStateException(); } @@ -289,6 +425,10 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P return isSetNetShares(); case LDAP_FILTER: return isSetLdapFilter(); + case RUN_SCRIPTS: + return isSetRunScripts(); + case NETWORK_EXCEPTIONS: + return isSetNetworkExceptions(); } throw new IllegalStateException(); } @@ -324,6 +464,24 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P return false; } + boolean this_present_runScripts = true && this.isSetRunScripts(); + boolean that_present_runScripts = true && that.isSetRunScripts(); + if (this_present_runScripts || that_present_runScripts) { + if (!(this_present_runScripts && that_present_runScripts)) + return false; + if (!this.runScripts.equals(that.runScripts)) + return false; + } + + boolean this_present_networkExceptions = true && this.isSetNetworkExceptions(); + boolean that_present_networkExceptions = true && that.isSetNetworkExceptions(); + if (this_present_networkExceptions || that_present_networkExceptions) { + if (!(this_present_networkExceptions && that_present_networkExceptions)) + return false; + if (!this.networkExceptions.equals(that.networkExceptions)) + return false; + } + return true; } @@ -341,6 +499,16 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P if (present_ldapFilter) list.add(ldapFilter); + boolean present_runScripts = true && (isSetRunScripts()); + list.add(present_runScripts); + if (present_runScripts) + list.add(runScripts); + + boolean present_networkExceptions = true && (isSetNetworkExceptions()); + list.add(present_networkExceptions); + if (present_networkExceptions) + list.add(networkExceptions); + return list.hashCode(); } @@ -372,6 +540,26 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P return lastComparison; } } + lastComparison = Boolean.valueOf(isSetRunScripts()).compareTo(other.isSetRunScripts()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRunScripts()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.runScripts, other.runScripts); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetNetworkExceptions()).compareTo(other.isSetNetworkExceptions()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNetworkExceptions()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.networkExceptions, other.networkExceptions); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -407,6 +595,22 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P sb.append(this.ldapFilter); } first = false; + if (!first) sb.append(", "); + sb.append("runScripts:"); + if (this.runScripts == null) { + sb.append("null"); + } else { + sb.append(this.runScripts); + } + first = false; + if (!first) sb.append(", "); + sb.append("networkExceptions:"); + if (this.networkExceptions == null) { + sb.append("null"); + } else { + sb.append(this.networkExceptions); + } + first = false; sb.append(")"); return sb.toString(); } @@ -453,14 +657,14 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P case 1: // NET_SHARES if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list90 = iprot.readListBegin(); - struct.netShares = new ArrayList<NetShare>(_list90.size); - NetShare _elem91; - for (int _i92 = 0; _i92 < _list90.size; ++_i92) + org.apache.thrift.protocol.TList _list106 = iprot.readListBegin(); + struct.netShares = new ArrayList<NetShare>(_list106.size); + NetShare _elem107; + for (int _i108 = 0; _i108 < _list106.size; ++_i108) { - _elem91 = new NetShare(); - _elem91.read(iprot); - struct.netShares.add(_elem91); + _elem107 = new NetShare(); + _elem107.read(iprot); + struct.netShares.add(_elem107); } iprot.readListEnd(); } @@ -472,14 +676,14 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P case 2: // LDAP_FILTER if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list93 = iprot.readListBegin(); - struct.ldapFilter = new ArrayList<LdapFilter>(_list93.size); - LdapFilter _elem94; - for (int _i95 = 0; _i95 < _list93.size; ++_i95) + org.apache.thrift.protocol.TList _list109 = iprot.readListBegin(); + struct.ldapFilter = new ArrayList<LdapFilter>(_list109.size); + LdapFilter _elem110; + for (int _i111 = 0; _i111 < _list109.size; ++_i111) { - _elem94 = new LdapFilter(); - _elem94.read(iprot); - struct.ldapFilter.add(_elem94); + _elem110 = new LdapFilter(); + _elem110.read(iprot); + struct.ldapFilter.add(_elem110); } iprot.readListEnd(); } @@ -488,6 +692,44 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 3: // RUN_SCRIPTS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list112 = iprot.readListBegin(); + struct.runScripts = new ArrayList<PresetRunScript>(_list112.size); + PresetRunScript _elem113; + for (int _i114 = 0; _i114 < _list112.size; ++_i114) + { + _elem113 = new PresetRunScript(); + _elem113.read(iprot); + struct.runScripts.add(_elem113); + } + iprot.readListEnd(); + } + struct.setRunScriptsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // NETWORK_EXCEPTIONS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list115 = iprot.readListBegin(); + struct.networkExceptions = new ArrayList<PresetNetRule>(_list115.size); + PresetNetRule _elem116; + for (int _i117 = 0; _i117 < _list115.size; ++_i117) + { + _elem116 = new PresetNetRule(); + _elem116.read(iprot); + struct.networkExceptions.add(_elem116); + } + iprot.readListEnd(); + } + struct.setNetworkExceptionsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -507,9 +749,9 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P oprot.writeFieldBegin(NET_SHARES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.netShares.size())); - for (NetShare _iter96 : struct.netShares) + for (NetShare _iter118 : struct.netShares) { - _iter96.write(oprot); + _iter118.write(oprot); } oprot.writeListEnd(); } @@ -519,9 +761,33 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P oprot.writeFieldBegin(LDAP_FILTER_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.ldapFilter.size())); - for (LdapFilter _iter97 : struct.ldapFilter) + for (LdapFilter _iter119 : struct.ldapFilter) + { + _iter119.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.runScripts != null) { + oprot.writeFieldBegin(RUN_SCRIPTS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.runScripts.size())); + for (PresetRunScript _iter120 : struct.runScripts) { - _iter97.write(oprot); + _iter120.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.networkExceptions != null) { + oprot.writeFieldBegin(NETWORK_EXCEPTIONS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.networkExceptions.size())); + for (PresetNetRule _iter121 : struct.networkExceptions) + { + _iter121.write(oprot); } oprot.writeListEnd(); } @@ -551,22 +817,46 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P if (struct.isSetLdapFilter()) { optionals.set(1); } - oprot.writeBitSet(optionals, 2); + if (struct.isSetRunScripts()) { + optionals.set(2); + } + if (struct.isSetNetworkExceptions()) { + optionals.set(3); + } + oprot.writeBitSet(optionals, 4); if (struct.isSetNetShares()) { { oprot.writeI32(struct.netShares.size()); - for (NetShare _iter98 : struct.netShares) + for (NetShare _iter122 : struct.netShares) { - _iter98.write(oprot); + _iter122.write(oprot); } } } if (struct.isSetLdapFilter()) { { oprot.writeI32(struct.ldapFilter.size()); - for (LdapFilter _iter99 : struct.ldapFilter) + for (LdapFilter _iter123 : struct.ldapFilter) { - _iter99.write(oprot); + _iter123.write(oprot); + } + } + } + if (struct.isSetRunScripts()) { + { + oprot.writeI32(struct.runScripts.size()); + for (PresetRunScript _iter124 : struct.runScripts) + { + _iter124.write(oprot); + } + } + } + if (struct.isSetNetworkExceptions()) { + { + oprot.writeI32(struct.networkExceptions.size()); + for (PresetNetRule _iter125 : struct.networkExceptions) + { + _iter125.write(oprot); } } } @@ -575,35 +865,63 @@ public class PredefinedData implements org.apache.thrift.TBase<PredefinedData, P @Override public void read(org.apache.thrift.protocol.TProtocol prot, PredefinedData struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(2); + BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { { - org.apache.thrift.protocol.TList _list100 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.netShares = new ArrayList<NetShare>(_list100.size); - NetShare _elem101; - for (int _i102 = 0; _i102 < _list100.size; ++_i102) + org.apache.thrift.protocol.TList _list126 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.netShares = new ArrayList<NetShare>(_list126.size); + NetShare _elem127; + for (int _i128 = 0; _i128 < _list126.size; ++_i128) { - _elem101 = new NetShare(); - _elem101.read(iprot); - struct.netShares.add(_elem101); + _elem127 = new NetShare(); + _elem127.read(iprot); + struct.netShares.add(_elem127); } } struct.setNetSharesIsSet(true); } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list103 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.ldapFilter = new ArrayList<LdapFilter>(_list103.size); - LdapFilter _elem104; - for (int _i105 = 0; _i105 < _list103.size; ++_i105) + org.apache.thrift.protocol.TList _list129 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilter = new ArrayList<LdapFilter>(_list129.size); + LdapFilter _elem130; + for (int _i131 = 0; _i131 < _list129.size; ++_i131) { - _elem104 = new LdapFilter(); - _elem104.read(iprot); - struct.ldapFilter.add(_elem104); + _elem130 = new LdapFilter(); + _elem130.read(iprot); + struct.ldapFilter.add(_elem130); } } struct.setLdapFilterIsSet(true); } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list132 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.runScripts = new ArrayList<PresetRunScript>(_list132.size); + PresetRunScript _elem133; + for (int _i134 = 0; _i134 < _list132.size; ++_i134) + { + _elem133 = new PresetRunScript(); + _elem133.read(iprot); + struct.runScripts.add(_elem133); + } + } + struct.setRunScriptsIsSet(true); + } + if (incoming.get(3)) { + { + org.apache.thrift.protocol.TList _list135 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkExceptions = new ArrayList<PresetNetRule>(_list135.size); + PresetNetRule _elem136; + for (int _i137 = 0; _i137 < _list135.size; ++_i137) + { + _elem136 = new PresetNetRule(); + _elem136.read(iprot); + struct.networkExceptions.add(_elem136); + } + } + struct.setNetworkExceptionsIsSet(true); + } } } diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/PresetNetRule.java b/src/main/java/org/openslx/bwlp/thrift/iface/PresetNetRule.java new file mode 100644 index 0000000..262c8ac --- /dev/null +++ b/src/main/java/org/openslx/bwlp/thrift/iface/PresetNetRule.java @@ -0,0 +1,660 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.openslx.bwlp.thrift.iface; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-02-25") +public class PresetNetRule implements org.apache.thrift.TBase<PresetNetRule, PresetNetRule._Fields>, java.io.Serializable, Cloneable, Comparable<PresetNetRule> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PresetNetRule"); + + private static final org.apache.thrift.protocol.TField RULE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("ruleId", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField DISPLAY_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("displayName", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField NET_RULES_FIELD_DESC = new org.apache.thrift.protocol.TField("netRules", org.apache.thrift.protocol.TType.LIST, (short)3); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new PresetNetRuleStandardSchemeFactory()); + schemes.put(TupleScheme.class, new PresetNetRuleTupleSchemeFactory()); + } + + public int ruleId; // required + public String displayName; // required + public List<NetRule> netRules; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + RULE_ID((short)1, "ruleId"), + DISPLAY_NAME((short)2, "displayName"), + NET_RULES((short)3, "netRules"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // RULE_ID + return RULE_ID; + case 2: // DISPLAY_NAME + return DISPLAY_NAME; + case 3: // NET_RULES + return NET_RULES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __RULEID_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.RULE_ID, new org.apache.thrift.meta_data.FieldMetaData("ruleId", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.DISPLAY_NAME, new org.apache.thrift.meta_data.FieldMetaData("displayName", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.NET_RULES, new org.apache.thrift.meta_data.FieldMetaData("netRules", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, NetRule.class)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PresetNetRule.class, metaDataMap); + } + + public PresetNetRule() { + } + + public PresetNetRule( + int ruleId, + String displayName, + List<NetRule> netRules) + { + this(); + this.ruleId = ruleId; + setRuleIdIsSet(true); + this.displayName = displayName; + this.netRules = netRules; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public PresetNetRule(PresetNetRule other) { + __isset_bitfield = other.__isset_bitfield; + this.ruleId = other.ruleId; + if (other.isSetDisplayName()) { + this.displayName = other.displayName; + } + if (other.isSetNetRules()) { + List<NetRule> __this__netRules = new ArrayList<NetRule>(other.netRules.size()); + for (NetRule other_element : other.netRules) { + __this__netRules.add(new NetRule(other_element)); + } + this.netRules = __this__netRules; + } + } + + public PresetNetRule deepCopy() { + return new PresetNetRule(this); + } + + @Override + public void clear() { + setRuleIdIsSet(false); + this.ruleId = 0; + this.displayName = null; + this.netRules = null; + } + + public int getRuleId() { + return this.ruleId; + } + + public PresetNetRule setRuleId(int ruleId) { + this.ruleId = ruleId; + setRuleIdIsSet(true); + return this; + } + + public void unsetRuleId() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __RULEID_ISSET_ID); + } + + /** Returns true if field ruleId is set (has been assigned a value) and false otherwise */ + public boolean isSetRuleId() { + return EncodingUtils.testBit(__isset_bitfield, __RULEID_ISSET_ID); + } + + public void setRuleIdIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __RULEID_ISSET_ID, value); + } + + public String getDisplayName() { + return this.displayName; + } + + public PresetNetRule setDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + public void unsetDisplayName() { + this.displayName = null; + } + + /** Returns true if field displayName is set (has been assigned a value) and false otherwise */ + public boolean isSetDisplayName() { + return this.displayName != null; + } + + public void setDisplayNameIsSet(boolean value) { + if (!value) { + this.displayName = null; + } + } + + public int getNetRulesSize() { + return (this.netRules == null) ? 0 : this.netRules.size(); + } + + public java.util.Iterator<NetRule> getNetRulesIterator() { + return (this.netRules == null) ? null : this.netRules.iterator(); + } + + public void addToNetRules(NetRule elem) { + if (this.netRules == null) { + this.netRules = new ArrayList<NetRule>(); + } + this.netRules.add(elem); + } + + public List<NetRule> getNetRules() { + return this.netRules; + } + + public PresetNetRule setNetRules(List<NetRule> netRules) { + this.netRules = netRules; + return this; + } + + public void unsetNetRules() { + this.netRules = null; + } + + /** Returns true if field netRules is set (has been assigned a value) and false otherwise */ + public boolean isSetNetRules() { + return this.netRules != null; + } + + public void setNetRulesIsSet(boolean value) { + if (!value) { + this.netRules = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case RULE_ID: + if (value == null) { + unsetRuleId(); + } else { + setRuleId((Integer)value); + } + break; + + case DISPLAY_NAME: + if (value == null) { + unsetDisplayName(); + } else { + setDisplayName((String)value); + } + break; + + case NET_RULES: + if (value == null) { + unsetNetRules(); + } else { + setNetRules((List<NetRule>)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case RULE_ID: + return getRuleId(); + + case DISPLAY_NAME: + return getDisplayName(); + + case NET_RULES: + return getNetRules(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case RULE_ID: + return isSetRuleId(); + case DISPLAY_NAME: + return isSetDisplayName(); + case NET_RULES: + return isSetNetRules(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof PresetNetRule) + return this.equals((PresetNetRule)that); + return false; + } + + public boolean equals(PresetNetRule that) { + if (that == null) + return false; + + boolean this_present_ruleId = true; + boolean that_present_ruleId = true; + if (this_present_ruleId || that_present_ruleId) { + if (!(this_present_ruleId && that_present_ruleId)) + return false; + if (this.ruleId != that.ruleId) + return false; + } + + boolean this_present_displayName = true && this.isSetDisplayName(); + boolean that_present_displayName = true && that.isSetDisplayName(); + if (this_present_displayName || that_present_displayName) { + if (!(this_present_displayName && that_present_displayName)) + return false; + if (!this.displayName.equals(that.displayName)) + return false; + } + + boolean this_present_netRules = true && this.isSetNetRules(); + boolean that_present_netRules = true && that.isSetNetRules(); + if (this_present_netRules || that_present_netRules) { + if (!(this_present_netRules && that_present_netRules)) + return false; + if (!this.netRules.equals(that.netRules)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List<Object> list = new ArrayList<Object>(); + + boolean present_ruleId = true; + list.add(present_ruleId); + if (present_ruleId) + list.add(ruleId); + + boolean present_displayName = true && (isSetDisplayName()); + list.add(present_displayName); + if (present_displayName) + list.add(displayName); + + boolean present_netRules = true && (isSetNetRules()); + list.add(present_netRules); + if (present_netRules) + list.add(netRules); + + return list.hashCode(); + } + + @Override + public int compareTo(PresetNetRule other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetRuleId()).compareTo(other.isSetRuleId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRuleId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ruleId, other.ruleId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDisplayName()).compareTo(other.isSetDisplayName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDisplayName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.displayName, other.displayName); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetNetRules()).compareTo(other.isSetNetRules()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetNetRules()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.netRules, other.netRules); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("PresetNetRule("); + boolean first = true; + + sb.append("ruleId:"); + sb.append(this.ruleId); + first = false; + if (!first) sb.append(", "); + sb.append("displayName:"); + if (this.displayName == null) { + sb.append("null"); + } else { + sb.append(this.displayName); + } + first = false; + if (!first) sb.append(", "); + sb.append("netRules:"); + if (this.netRules == null) { + sb.append("null"); + } else { + sb.append(this.netRules); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class PresetNetRuleStandardSchemeFactory implements SchemeFactory { + public PresetNetRuleStandardScheme getScheme() { + return new PresetNetRuleStandardScheme(); + } + } + + private static class PresetNetRuleStandardScheme extends StandardScheme<PresetNetRule> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, PresetNetRule struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // RULE_ID + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.ruleId = iprot.readI32(); + struct.setRuleIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // DISPLAY_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.displayName = iprot.readString(); + struct.setDisplayNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // NET_RULES + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list98 = iprot.readListBegin(); + struct.netRules = new ArrayList<NetRule>(_list98.size); + NetRule _elem99; + for (int _i100 = 0; _i100 < _list98.size; ++_i100) + { + _elem99 = new NetRule(); + _elem99.read(iprot); + struct.netRules.add(_elem99); + } + iprot.readListEnd(); + } + struct.setNetRulesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, PresetNetRule struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(RULE_ID_FIELD_DESC); + oprot.writeI32(struct.ruleId); + oprot.writeFieldEnd(); + if (struct.displayName != null) { + oprot.writeFieldBegin(DISPLAY_NAME_FIELD_DESC); + oprot.writeString(struct.displayName); + oprot.writeFieldEnd(); + } + if (struct.netRules != null) { + oprot.writeFieldBegin(NET_RULES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.netRules.size())); + for (NetRule _iter101 : struct.netRules) + { + _iter101.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class PresetNetRuleTupleSchemeFactory implements SchemeFactory { + public PresetNetRuleTupleScheme getScheme() { + return new PresetNetRuleTupleScheme(); + } + } + + private static class PresetNetRuleTupleScheme extends TupleScheme<PresetNetRule> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, PresetNetRule struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetRuleId()) { + optionals.set(0); + } + if (struct.isSetDisplayName()) { + optionals.set(1); + } + if (struct.isSetNetRules()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetRuleId()) { + oprot.writeI32(struct.ruleId); + } + if (struct.isSetDisplayName()) { + oprot.writeString(struct.displayName); + } + if (struct.isSetNetRules()) { + { + oprot.writeI32(struct.netRules.size()); + for (NetRule _iter102 : struct.netRules) + { + _iter102.write(oprot); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, PresetNetRule struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.ruleId = iprot.readI32(); + struct.setRuleIdIsSet(true); + } + if (incoming.get(1)) { + struct.displayName = iprot.readString(); + struct.setDisplayNameIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list103 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.netRules = new ArrayList<NetRule>(_list103.size); + NetRule _elem104; + for (int _i105 = 0; _i105 < _list103.size; ++_i105) + { + _elem104 = new NetRule(); + _elem104.read(iprot); + struct.netRules.add(_elem104); + } + } + struct.setNetRulesIsSet(true); + } + } + } + +} + diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/PresetRunScript.java b/src/main/java/org/openslx/bwlp/thrift/iface/PresetRunScript.java new file mode 100644 index 0000000..da245ef --- /dev/null +++ b/src/main/java/org/openslx/bwlp/thrift/iface/PresetRunScript.java @@ -0,0 +1,655 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.openslx.bwlp.thrift.iface; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-11") +public class PresetRunScript implements org.apache.thrift.TBase<PresetRunScript, PresetRunScript._Fields>, java.io.Serializable, Cloneable, Comparable<PresetRunScript> { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PresetRunScript"); + + private static final org.apache.thrift.protocol.TField SCRIPT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("scriptId", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField DISPLAYNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("displayname", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField OS_IDS_FIELD_DESC = new org.apache.thrift.protocol.TField("osIds", org.apache.thrift.protocol.TType.LIST, (short)3); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new PresetRunScriptStandardSchemeFactory()); + schemes.put(TupleScheme.class, new PresetRunScriptTupleSchemeFactory()); + } + + public int scriptId; // required + public String displayname; // required + public List<Integer> osIds; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SCRIPT_ID((short)1, "scriptId"), + DISPLAYNAME((short)2, "displayname"), + OS_IDS((short)3, "osIds"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // SCRIPT_ID + return SCRIPT_ID; + case 2: // DISPLAYNAME + return DISPLAYNAME; + case 3: // OS_IDS + return OS_IDS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __SCRIPTID_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SCRIPT_ID, new org.apache.thrift.meta_data.FieldMetaData("scriptId", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.DISPLAYNAME, new org.apache.thrift.meta_data.FieldMetaData("displayname", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.OS_IDS, new org.apache.thrift.meta_data.FieldMetaData("osIds", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PresetRunScript.class, metaDataMap); + } + + public PresetRunScript() { + } + + public PresetRunScript( + int scriptId, + String displayname, + List<Integer> osIds) + { + this(); + this.scriptId = scriptId; + setScriptIdIsSet(true); + this.displayname = displayname; + this.osIds = osIds; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public PresetRunScript(PresetRunScript other) { + __isset_bitfield = other.__isset_bitfield; + this.scriptId = other.scriptId; + if (other.isSetDisplayname()) { + this.displayname = other.displayname; + } + if (other.isSetOsIds()) { + List<Integer> __this__osIds = new ArrayList<Integer>(other.osIds); + this.osIds = __this__osIds; + } + } + + public PresetRunScript deepCopy() { + return new PresetRunScript(this); + } + + @Override + public void clear() { + setScriptIdIsSet(false); + this.scriptId = 0; + this.displayname = null; + this.osIds = null; + } + + public int getScriptId() { + return this.scriptId; + } + + public PresetRunScript setScriptId(int scriptId) { + this.scriptId = scriptId; + setScriptIdIsSet(true); + return this; + } + + public void unsetScriptId() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SCRIPTID_ISSET_ID); + } + + /** Returns true if field scriptId is set (has been assigned a value) and false otherwise */ + public boolean isSetScriptId() { + return EncodingUtils.testBit(__isset_bitfield, __SCRIPTID_ISSET_ID); + } + + public void setScriptIdIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SCRIPTID_ISSET_ID, value); + } + + public String getDisplayname() { + return this.displayname; + } + + public PresetRunScript setDisplayname(String displayname) { + this.displayname = displayname; + return this; + } + + public void unsetDisplayname() { + this.displayname = null; + } + + /** Returns true if field displayname is set (has been assigned a value) and false otherwise */ + public boolean isSetDisplayname() { + return this.displayname != null; + } + + public void setDisplaynameIsSet(boolean value) { + if (!value) { + this.displayname = null; + } + } + + public int getOsIdsSize() { + return (this.osIds == null) ? 0 : this.osIds.size(); + } + + public java.util.Iterator<Integer> getOsIdsIterator() { + return (this.osIds == null) ? null : this.osIds.iterator(); + } + + public void addToOsIds(int elem) { + if (this.osIds == null) { + this.osIds = new ArrayList<Integer>(); + } + this.osIds.add(elem); + } + + public List<Integer> getOsIds() { + return this.osIds; + } + + public PresetRunScript setOsIds(List<Integer> osIds) { + this.osIds = osIds; + return this; + } + + public void unsetOsIds() { + this.osIds = null; + } + + /** Returns true if field osIds is set (has been assigned a value) and false otherwise */ + public boolean isSetOsIds() { + return this.osIds != null; + } + + public void setOsIdsIsSet(boolean value) { + if (!value) { + this.osIds = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SCRIPT_ID: + if (value == null) { + unsetScriptId(); + } else { + setScriptId((Integer)value); + } + break; + + case DISPLAYNAME: + if (value == null) { + unsetDisplayname(); + } else { + setDisplayname((String)value); + } + break; + + case OS_IDS: + if (value == null) { + unsetOsIds(); + } else { + setOsIds((List<Integer>)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SCRIPT_ID: + return getScriptId(); + + case DISPLAYNAME: + return getDisplayname(); + + case OS_IDS: + return getOsIds(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SCRIPT_ID: + return isSetScriptId(); + case DISPLAYNAME: + return isSetDisplayname(); + case OS_IDS: + return isSetOsIds(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof PresetRunScript) + return this.equals((PresetRunScript)that); + return false; + } + + public boolean equals(PresetRunScript that) { + if (that == null) + return false; + + boolean this_present_scriptId = true; + boolean that_present_scriptId = true; + if (this_present_scriptId || that_present_scriptId) { + if (!(this_present_scriptId && that_present_scriptId)) + return false; + if (this.scriptId != that.scriptId) + return false; + } + + boolean this_present_displayname = true && this.isSetDisplayname(); + boolean that_present_displayname = true && that.isSetDisplayname(); + if (this_present_displayname || that_present_displayname) { + if (!(this_present_displayname && that_present_displayname)) + return false; + if (!this.displayname.equals(that.displayname)) + return false; + } + + boolean this_present_osIds = true && this.isSetOsIds(); + boolean that_present_osIds = true && that.isSetOsIds(); + if (this_present_osIds || that_present_osIds) { + if (!(this_present_osIds && that_present_osIds)) + return false; + if (!this.osIds.equals(that.osIds)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List<Object> list = new ArrayList<Object>(); + + boolean present_scriptId = true; + list.add(present_scriptId); + if (present_scriptId) + list.add(scriptId); + + boolean present_displayname = true && (isSetDisplayname()); + list.add(present_displayname); + if (present_displayname) + list.add(displayname); + + boolean present_osIds = true && (isSetOsIds()); + list.add(present_osIds); + if (present_osIds) + list.add(osIds); + + return list.hashCode(); + } + + @Override + public int compareTo(PresetRunScript other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetScriptId()).compareTo(other.isSetScriptId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetScriptId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.scriptId, other.scriptId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDisplayname()).compareTo(other.isSetDisplayname()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDisplayname()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.displayname, other.displayname); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetOsIds()).compareTo(other.isSetOsIds()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOsIds()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.osIds, other.osIds); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("PresetRunScript("); + boolean first = true; + + sb.append("scriptId:"); + sb.append(this.scriptId); + first = false; + if (!first) sb.append(", "); + sb.append("displayname:"); + if (this.displayname == null) { + sb.append("null"); + } else { + sb.append(this.displayname); + } + first = false; + if (!first) sb.append(", "); + sb.append("osIds:"); + if (this.osIds == null) { + sb.append("null"); + } else { + sb.append(this.osIds); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class PresetRunScriptStandardSchemeFactory implements SchemeFactory { + public PresetRunScriptStandardScheme getScheme() { + return new PresetRunScriptStandardScheme(); + } + } + + private static class PresetRunScriptStandardScheme extends StandardScheme<PresetRunScript> { + + public void read(org.apache.thrift.protocol.TProtocol iprot, PresetRunScript struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // SCRIPT_ID + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.scriptId = iprot.readI32(); + struct.setScriptIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // DISPLAYNAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.displayname = iprot.readString(); + struct.setDisplaynameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // OS_IDS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list90 = iprot.readListBegin(); + struct.osIds = new ArrayList<Integer>(_list90.size); + int _elem91; + for (int _i92 = 0; _i92 < _list90.size; ++_i92) + { + _elem91 = iprot.readI32(); + struct.osIds.add(_elem91); + } + iprot.readListEnd(); + } + struct.setOsIdsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, PresetRunScript struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(SCRIPT_ID_FIELD_DESC); + oprot.writeI32(struct.scriptId); + oprot.writeFieldEnd(); + if (struct.displayname != null) { + oprot.writeFieldBegin(DISPLAYNAME_FIELD_DESC); + oprot.writeString(struct.displayname); + oprot.writeFieldEnd(); + } + if (struct.osIds != null) { + oprot.writeFieldBegin(OS_IDS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.osIds.size())); + for (int _iter93 : struct.osIds) + { + oprot.writeI32(_iter93); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class PresetRunScriptTupleSchemeFactory implements SchemeFactory { + public PresetRunScriptTupleScheme getScheme() { + return new PresetRunScriptTupleScheme(); + } + } + + private static class PresetRunScriptTupleScheme extends TupleScheme<PresetRunScript> { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, PresetRunScript struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetScriptId()) { + optionals.set(0); + } + if (struct.isSetDisplayname()) { + optionals.set(1); + } + if (struct.isSetOsIds()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetScriptId()) { + oprot.writeI32(struct.scriptId); + } + if (struct.isSetDisplayname()) { + oprot.writeString(struct.displayname); + } + if (struct.isSetOsIds()) { + { + oprot.writeI32(struct.osIds.size()); + for (int _iter94 : struct.osIds) + { + oprot.writeI32(_iter94); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, PresetRunScript struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.scriptId = iprot.readI32(); + struct.setScriptIdIsSet(true); + } + if (incoming.get(1)) { + struct.displayname = iprot.readString(); + struct.setDisplaynameIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list95 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.osIds = new ArrayList<Integer>(_list95.size); + int _elem96; + for (int _i97 = 0; _i97 < _list95.size; ++_i97) + { + _elem96 = iprot.readI32(); + struct.osIds.add(_elem96); + } + } + struct.setOsIdsIsSet(true); + } + } + } + +} + diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteConfig.java b/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteConfig.java index 08482a7..4737596 100644 --- a/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteConfig.java +++ b/src/main/java/org/openslx/bwlp/thrift/iface/SatelliteConfig.java @@ -34,7 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-01-24") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-02-22") public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, SatelliteConfig._Fields>, java.io.Serializable, Cloneable, Comparable<SatelliteConfig> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SatelliteConfig"); @@ -47,6 +47,7 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, private static final org.apache.thrift.protocol.TField MAX_CONNECTIONS_PER_TRANSFER_FIELD_DESC = new org.apache.thrift.protocol.TField("maxConnectionsPerTransfer", org.apache.thrift.protocol.TType.I32, (short)7); private static final org.apache.thrift.protocol.TField MAX_LOCATIONS_PER_LECTURE_FIELD_DESC = new org.apache.thrift.protocol.TField("maxLocationsPerLecture", org.apache.thrift.protocol.TType.I32, (short)8); private static final org.apache.thrift.protocol.TField ALLOW_LOGIN_BY_DEFAULT_FIELD_DESC = new org.apache.thrift.protocol.TField("allowLoginByDefault", org.apache.thrift.protocol.TType.BOOL, (short)9); + private static final org.apache.thrift.protocol.TField SERVER_SIDE_COPY_FIELD_DESC = new org.apache.thrift.protocol.TField("serverSideCopy", org.apache.thrift.protocol.TType.I32, (short)10); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -63,6 +64,11 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, public int maxConnectionsPerTransfer; // optional public int maxLocationsPerLecture; // optional public boolean allowLoginByDefault; // optional + /** + * + * @see SscMode + */ + public SscMode serverSideCopy; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -74,7 +80,12 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, MAX_TRANSFERS((short)6, "maxTransfers"), MAX_CONNECTIONS_PER_TRANSFER((short)7, "maxConnectionsPerTransfer"), MAX_LOCATIONS_PER_LECTURE((short)8, "maxLocationsPerLecture"), - ALLOW_LOGIN_BY_DEFAULT((short)9, "allowLoginByDefault"); + ALLOW_LOGIN_BY_DEFAULT((short)9, "allowLoginByDefault"), + /** + * + * @see SscMode + */ + SERVER_SIDE_COPY((short)10, "serverSideCopy"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -107,6 +118,8 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, return MAX_LOCATIONS_PER_LECTURE; case 9: // ALLOW_LOGIN_BY_DEFAULT return ALLOW_LOGIN_BY_DEFAULT; + case 10: // SERVER_SIDE_COPY + return SERVER_SIDE_COPY; default: return null; } @@ -155,7 +168,7 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, private static final int __MAXLOCATIONSPERLECTURE_ISSET_ID = 5; private static final int __ALLOWLOGINBYDEFAULT_ISSET_ID = 6; private byte __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.MAX_TRANSFERS,_Fields.MAX_CONNECTIONS_PER_TRANSFER,_Fields.MAX_LOCATIONS_PER_LECTURE,_Fields.ALLOW_LOGIN_BY_DEFAULT}; + private static final _Fields optionals[] = {_Fields.MAX_TRANSFERS,_Fields.MAX_CONNECTIONS_PER_TRANSFER,_Fields.MAX_LOCATIONS_PER_LECTURE,_Fields.ALLOW_LOGIN_BY_DEFAULT,_Fields.SERVER_SIDE_COPY}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -177,6 +190,8 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.ALLOW_LOGIN_BY_DEFAULT, new org.apache.thrift.meta_data.FieldMetaData("allowLoginByDefault", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.SERVER_SIDE_COPY, new org.apache.thrift.meta_data.FieldMetaData("serverSideCopy", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, SscMode.class))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SatelliteConfig.class, metaDataMap); } @@ -220,6 +235,9 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, this.maxConnectionsPerTransfer = other.maxConnectionsPerTransfer; this.maxLocationsPerLecture = other.maxLocationsPerLecture; this.allowLoginByDefault = other.allowLoginByDefault; + if (other.isSetServerSideCopy()) { + this.serverSideCopy = other.serverSideCopy; + } } public SatelliteConfig deepCopy() { @@ -244,6 +262,7 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, this.maxLocationsPerLecture = 0; setAllowLoginByDefaultIsSet(false); this.allowLoginByDefault = false; + this.serverSideCopy = null; } public int getPageSize() { @@ -455,6 +474,38 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ALLOWLOGINBYDEFAULT_ISSET_ID, value); } + /** + * + * @see SscMode + */ + public SscMode getServerSideCopy() { + return this.serverSideCopy; + } + + /** + * + * @see SscMode + */ + public SatelliteConfig setServerSideCopy(SscMode serverSideCopy) { + this.serverSideCopy = serverSideCopy; + return this; + } + + public void unsetServerSideCopy() { + this.serverSideCopy = null; + } + + /** Returns true if field serverSideCopy is set (has been assigned a value) and false otherwise */ + public boolean isSetServerSideCopy() { + return this.serverSideCopy != null; + } + + public void setServerSideCopyIsSet(boolean value) { + if (!value) { + this.serverSideCopy = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case PAGE_SIZE: @@ -529,6 +580,14 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, } break; + case SERVER_SIDE_COPY: + if (value == null) { + unsetServerSideCopy(); + } else { + setServerSideCopy((SscMode)value); + } + break; + } } @@ -561,6 +620,9 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, case ALLOW_LOGIN_BY_DEFAULT: return isAllowLoginByDefault(); + case SERVER_SIDE_COPY: + return getServerSideCopy(); + } throw new IllegalStateException(); } @@ -590,6 +652,8 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, return isSetMaxLocationsPerLecture(); case ALLOW_LOGIN_BY_DEFAULT: return isSetAllowLoginByDefault(); + case SERVER_SIDE_COPY: + return isSetServerSideCopy(); } throw new IllegalStateException(); } @@ -688,6 +752,15 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, return false; } + boolean this_present_serverSideCopy = true && this.isSetServerSideCopy(); + boolean that_present_serverSideCopy = true && that.isSetServerSideCopy(); + if (this_present_serverSideCopy || that_present_serverSideCopy) { + if (!(this_present_serverSideCopy && that_present_serverSideCopy)) + return false; + if (!this.serverSideCopy.equals(that.serverSideCopy)) + return false; + } + return true; } @@ -740,6 +813,11 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, if (present_allowLoginByDefault) list.add(allowLoginByDefault); + boolean present_serverSideCopy = true && (isSetServerSideCopy()); + list.add(present_serverSideCopy); + if (present_serverSideCopy) + list.add(serverSideCopy.getValue()); + return list.hashCode(); } @@ -841,6 +919,16 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, return lastComparison; } } + lastComparison = Boolean.valueOf(isSetServerSideCopy()).compareTo(other.isSetServerSideCopy()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetServerSideCopy()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serverSideCopy, other.serverSideCopy); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -912,6 +1000,16 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, sb.append(this.allowLoginByDefault); first = false; } + if (isSetServerSideCopy()) { + if (!first) sb.append(", "); + sb.append("serverSideCopy:"); + if (this.serverSideCopy == null) { + sb.append("null"); + } else { + sb.append(this.serverSideCopy); + } + first = false; + } sb.append(")"); return sb.toString(); } @@ -1037,6 +1135,14 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 10: // SERVER_SIDE_COPY + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.serverSideCopy = org.openslx.bwlp.thrift.iface.SscMode.findByValue(iprot.readI32()); + struct.setServerSideCopyIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -1091,6 +1197,13 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, oprot.writeBool(struct.allowLoginByDefault); oprot.writeFieldEnd(); } + if (struct.serverSideCopy != null) { + if (struct.isSetServerSideCopy()) { + oprot.writeFieldBegin(SERVER_SIDE_COPY_FIELD_DESC); + oprot.writeI32(struct.serverSideCopy.getValue()); + oprot.writeFieldEnd(); + } + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -1136,7 +1249,10 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, if (struct.isSetAllowLoginByDefault()) { optionals.set(8); } - oprot.writeBitSet(optionals, 9); + if (struct.isSetServerSideCopy()) { + optionals.set(9); + } + oprot.writeBitSet(optionals, 10); if (struct.isSetPageSize()) { oprot.writeI32(struct.pageSize); } @@ -1164,12 +1280,15 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, if (struct.isSetAllowLoginByDefault()) { oprot.writeBool(struct.allowLoginByDefault); } + if (struct.isSetServerSideCopy()) { + oprot.writeI32(struct.serverSideCopy.getValue()); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, SatelliteConfig struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(9); + BitSet incoming = iprot.readBitSet(10); if (incoming.get(0)) { struct.pageSize = iprot.readI32(); struct.setPageSizeIsSet(true); @@ -1208,6 +1327,10 @@ public class SatelliteConfig implements org.apache.thrift.TBase<SatelliteConfig, struct.allowLoginByDefault = iprot.readBool(); struct.setAllowLoginByDefaultIsSet(true); } + if (incoming.get(9)) { + struct.serverSideCopy = org.openslx.bwlp.thrift.iface.SscMode.findByValue(iprot.readI32()); + struct.setServerSideCopyIsSet(true); + } } } diff --git a/src/main/java/org/openslx/bwlp/thrift/iface/SscMode.java b/src/main/java/org/openslx/bwlp/thrift/iface/SscMode.java new file mode 100644 index 0000000..dae1b41 --- /dev/null +++ b/src/main/java/org/openslx/bwlp/thrift/iface/SscMode.java @@ -0,0 +1,51 @@ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.openslx.bwlp.thrift.iface; + + +import java.util.Map; +import java.util.HashMap; +import org.apache.thrift.TEnum; + +public enum SscMode implements org.apache.thrift.TEnum { + OFF(0), + ON(1), + AUTO(2), + USER(3); + + private final int value; + + private SscMode(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static SscMode findByValue(int value) { + switch (value) { + case 0: + return OFF; + case 1: + return ON; + case 2: + return AUTO; + case 3: + return USER; + default: + return null; + } + } +} diff --git a/src/main/java/org/openslx/filetransfer/util/AbstractTransfer.java b/src/main/java/org/openslx/filetransfer/util/AbstractTransfer.java index 636f880..8171d93 100644 --- a/src/main/java/org/openslx/filetransfer/util/AbstractTransfer.java +++ b/src/main/java/org/openslx/filetransfer/util/AbstractTransfer.java @@ -78,7 +78,7 @@ public abstract class AbstractTransfer public final boolean countsTowardsConnectionLimit( long now ) { - return getActiveConnectionCount() > 0 || lastActivityTime.get() + HOT_IDLE_TIMEOUT > now; + return isActive() && ( getActiveConnectionCount() > 0 || lastActivityTime.get() + HOT_IDLE_TIMEOUT > now ); } public final int connectFailCount() diff --git a/src/main/java/org/openslx/filetransfer/util/HashChecker.java b/src/main/java/org/openslx/filetransfer/util/HashChecker.java index bddf829..f6b27f7 100644 --- a/src/main/java/org/openslx/filetransfer/util/HashChecker.java +++ b/src/main/java/org/openslx/filetransfer/util/HashChecker.java @@ -106,7 +106,8 @@ public class HashChecker execCallback( task, HashResult.FAILURE ); return true; } - if ( queue.isEmpty() ) { + if ( threads.isEmpty() ) { + // This is the first thread -- keep it around CheckThread thread; try { thread = new CheckThread( false ); @@ -120,6 +121,7 @@ public class HashChecker } } if ( queue.remainingCapacity() <= 1 && threads.size() < Runtime.getRuntime().availableProcessors() ) { + // Queue starts to fill up -- add more temporary threads try { CheckThread thread = new CheckThread( true ); thread.start(); diff --git a/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java b/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java index a1d3548..8a69020 100644 --- a/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java +++ b/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java @@ -145,6 +145,9 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H localCopyManager.interrupt(); } safeClose( tmpFileHandle ); + if ( getTransferInfo() != null && getTransferInfo().token != null ) { + LOGGER.debug( "Cancelled upload " + getTransferInfo().token ); + } } @Override @@ -460,34 +463,37 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H @Override public void run() { - CbHandler cbh = new CbHandler( connection ); - if ( connection.download( cbh, cbh ) ) { - connectFails.set( 0 ); - } else { - connectFails.incrementAndGet(); - if ( cbh.currentChunk != null ) { - // If the download failed and we have a current chunk, put it back into - // the queue, so it will be handled again later... - chunks.markFailed( cbh.currentChunk ); - // Possibly queue for local copy - if ( localCopyManager != null && cbh.currentChunk.sha1sum != null ) { - List<byte[]> lst = new ArrayList<>( 1 ); - lst.add( cbh.currentChunk.sha1sum ); - checkLocalCopyCandidates( lst, 0 ); + try { + CbHandler cbh = new CbHandler( connection ); + if ( connection.download( cbh, cbh ) ) { + connectFails.set( 0 ); + } else { + connectFails.incrementAndGet(); + if ( cbh.currentChunk != null ) { + // If the download failed and we have a current chunk, put it back into + // the queue, so it will be handled again later... + chunks.markFailed( cbh.currentChunk ); + // Possibly queue for local copy + if ( localCopyManager != null && cbh.currentChunk.sha1sum != null ) { + List<byte[]> lst = new ArrayList<>( 1 ); + lst.add( cbh.currentChunk.sha1sum ); + checkLocalCopyCandidates( lst, 0 ); + } + chunkStatusChanged( cbh.currentChunk ); } - chunkStatusChanged( cbh.currentChunk ); + LOGGER.debug( "Connection for " + getTmpFileName().getAbsolutePath() + " dropped" ); + } + if ( state != TransferState.FINISHED && state != TransferState.ERROR ) { + lastActivityTime.set( System.currentTimeMillis() ); + } + } finally { + synchronized ( downloads ) { + downloads.remove( connection ); } - LOGGER.debug( "Connection for " + getTmpFileName().getAbsolutePath() + " dropped" ); - } - if ( state != TransferState.FINISHED && state != TransferState.ERROR ) { - lastActivityTime.set( System.currentTimeMillis() ); - } - synchronized ( downloads ) { - downloads.remove( connection ); } if ( chunks.isComplete() ) { finishUploadInternal(); - } else { + } else if ( state == TransferState.WORKING ) { // Keep pumping unhashed chunks into the hasher queueUnhashedChunk( true ); if ( localCopyManager != null ) { diff --git a/src/main/java/org/openslx/sat/thrift/version/Feature.java b/src/main/java/org/openslx/sat/thrift/version/Feature.java index e06c78a..b81d65f 100644 --- a/src/main/java/org/openslx/sat/thrift/version/Feature.java +++ b/src/main/java/org/openslx/sat/thrift/version/Feature.java @@ -31,4 +31,9 @@ public enum Feature { */ LECTURE_FILTER_LDAP, + /** + * Allow editing of USB speed + */ + CONFIGURE_USB, + } diff --git a/src/main/java/org/openslx/sat/thrift/version/Version.java b/src/main/java/org/openslx/sat/thrift/version/Version.java index 16e00f8..dfa9353 100644 --- a/src/main/java/org/openslx/sat/thrift/version/Version.java +++ b/src/main/java/org/openslx/sat/thrift/version/Version.java @@ -8,8 +8,8 @@ package org.openslx.sat.thrift.version; */ public class Version { - public static final long MIN_VERSION = 2; + public static final long MIN_VERSION = 4; - public static final long VERSION = 4; + public static final long VERSION = 5; } diff --git a/src/main/java/org/openslx/util/Json.java b/src/main/java/org/openslx/util/Json.java index 84dc22b..f92bb58 100644 --- a/src/main/java/org/openslx/util/Json.java +++ b/src/main/java/org/openslx/util/Json.java @@ -1,10 +1,12 @@ package org.openslx.util; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import org.apache.log4j.Logger; import org.apache.thrift.TBase; @@ -16,6 +18,9 @@ import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; import com.google.gson.JsonSyntaxException; public class Json { @@ -25,14 +30,53 @@ public class Json { /** * Global static instance. The Gson object is thread-safe. */ - private static final Gson gson = new Gson(); + private static final AtomicReference<Gson> gsonRef = new AtomicReference<>(); private static final GsonBuilder gsonThriftBuilder = new GsonBuilder(); - - public static <T> void registerThriftClass(Class<T> thriftClass) { - if (!TBase.class.isAssignableFrom(thriftClass)) - throw new IllegalArgumentException(thriftClass.getName() + " is not a thrift struct."); - gsonThriftBuilder.registerTypeAdapter(thriftClass, new ThriftDeserializer<T>(thriftClass)); + + public static <T extends TBase<?, ?>> void registerThriftClass(Class<T> thriftClass) { + // Determine all relevant fields + Field[] fieldArray = thriftClass.getFields(); + List<ThriftField> fields = new ArrayList<>(fieldArray.length); + for ( Field field : fieldArray ) { + if ( "__isset_bitfield".equals( field.getName() ) ) + continue; + if ( Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()) + || Modifier.isTransient( field.getModifiers() )) + continue; + String upperName = field.getName().substring(0, 1).toUpperCase() + + field.getName().substring(1); + try { + Method getter; + try { + getter = thriftClass.getMethod( "get" + upperName ); + } catch (NoSuchMethodException e) { + getter = thriftClass.getMethod( "is" + upperName ); + } + fields.add( new ThriftField( field, + getter, + thriftClass.getMethod( "set" + upperName, field.getType() ), + thriftClass.getMethod( "isSet" + upperName) ) ); + } catch (NoSuchMethodException e) { + LOGGER.warn( "Nein", e ); + } + } + synchronized ( Json.class ) { + gsonThriftBuilder.registerTypeAdapter(thriftClass, new JsonThriftHandler<T>(thriftClass, fields)); + gsonRef.set( null ); + } + } + + private static Gson getInstance() + { + Gson gson = gsonRef.get(); + if (gson == null) { + synchronized ( Json.class ) { + gson = gsonThriftBuilder.create(); + gsonRef.set( gson ); + } + } + return gson; } /** @@ -45,22 +89,13 @@ public class Json { */ public static <T> T deserialize(String data, Class<T> classOfData) { try { - return gson.fromJson(data, classOfData); + return getInstance().fromJson(data, classOfData); } catch (JsonSyntaxException e) { LOGGER.warn("Cannot deserialize to " + classOfData.getSimpleName(), e); return null; } } - public static <T> T deserializeThrift(String data, Class<T> thriftClass) { - try { - return gsonThriftBuilder.create().fromJson(data, thriftClass); - } catch (JsonSyntaxException e) { - LOGGER.warn("Cannot deserialize to " + thriftClass.getSimpleName(), e); - return null; - } - } - /** * Serialize the given POJO. All fields except transient ones will be * serialized. @@ -69,14 +104,16 @@ public class Json { * @return JSON formatted represenatation of <code>object</code> */ public static String serialize(Object object) { - return gson.toJson(object); + return getInstance().toJson(object); } - private static class ThriftDeserializer<T> implements JsonDeserializer<T> { + private static class JsonThriftHandler<T> implements JsonDeserializer<T>, JsonSerializer<T> { private final Class<T> clazz; + private final List<ThriftField> fields; - public ThriftDeserializer(Class<T> classOfData) { + public JsonThriftHandler(Class<T> classOfData, List<ThriftField> fields) { this.clazz = classOfData; + this.fields = fields; } @Override @@ -84,38 +121,76 @@ public class Json { throws JsonParseException { if (!(json instanceof JsonObject)) throw new JsonParseException("Need a json object, have " + json.getClass().getSimpleName()); + // We're deserializing a json object {..} here JsonObject obj = (JsonObject) json; + // Create the Thrift object we want to deserialize into final T inst; try { inst = clazz.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + } catch (Exception e) { LOGGER.warn("Could not deserialize to class " + clazz.getName(), e); throw new JsonParseException("Cannot instantiate class " + clazz.getSimpleName()); } - for (Field field : clazz.getFields()) { - if (Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())) - continue; - final String methodName = "set" + field.getName().substring(0, 1).toUpperCase() - + field.getName().substring(1); - final Method setter; - try { - setter = clazz.getMethod(methodName, field.getType()); - } catch (NoSuchMethodException e) { - LOGGER.warn(clazz.getSimpleName() + " has no method " + methodName); - continue; - } - JsonElement element = obj.get(field.getName()); + // Iterate over all fields in the Thrift object + for (ThriftField field : fields) { + JsonElement element = obj.get(field.field.getName()); if (element == null || element.isJsonNull()) continue; try { - setter.invoke(inst, context.deserialize(element, field.getType())); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - LOGGER.warn("Could not call " + methodName + " on " + clazz.getSimpleName(), e); + field.setter.invoke(inst, context.deserialize(element, field.field.getType())); + } catch (Exception e) { + LOGGER.warn("Could not call " + field.setter.getName() + " on " + clazz.getSimpleName(), e); } } return inst; } + @Override + public JsonElement serialize( T thriftClass, Type typeOfT, JsonSerializationContext context ) + { + JsonObject o = new JsonObject(); + for ( ThriftField thrift : fields ) { + try { + Object ret = thrift.isset.invoke( thriftClass ); + if ( !(ret instanceof Boolean) || !(Boolean)ret ) + continue; + Object value = thrift.getter.invoke( thriftClass ); + if ( value == null ) + continue; + JsonElement jo = null; + if ( value instanceof Number ) { + jo = new JsonPrimitive( (Number)value ); + } else if ( value instanceof String ) { + jo = new JsonPrimitive( (String)value ); + } else if ( value instanceof Character ) { + jo = new JsonPrimitive( (Character)value ); + } else if ( value instanceof Boolean ) { + jo = new JsonPrimitive( (Boolean)value ); + } else { + jo = context.serialize( value ); + } + o.add( thrift.field.getName(), jo ); + } catch ( Exception e ) { + LOGGER.warn( "Cannot serialize field " + thrift.field.getName() + " of thift class " + + thriftClass.getClass().getSimpleName(), e ); + } + } + return o; + } + + } + + private static class ThriftField + { + public final Method getter, setter, isset; + public final Field field; + ThriftField(Field field, Method getter, Method setter, Method isset) + { + this.field = field; + this.getter = getter; + this.setter = setter; + this.isset = isset; + } } } diff --git a/src/main/java/org/openslx/util/vm/DiskImage.java b/src/main/java/org/openslx/util/vm/DiskImage.java index ca016f2..30fea99 100644 --- a/src/main/java/org/openslx/util/vm/DiskImage.java +++ b/src/main/java/org/openslx/util/vm/DiskImage.java @@ -71,9 +71,14 @@ public class DiskImage LOGGER.debug( "Validating disk file: " + disk.getAbsolutePath() ); try ( RandomAccessFile file = new RandomAccessFile( disk, "r" ) ) { // vmdk - if ( file.readInt() == VMDK_MAGIC ) { - file.seek( 512 ); - byte[] buffer = new byte[ 2048 ]; + boolean isVmdkMagic = ( file.readInt() == VMDK_MAGIC ); + if ( isVmdkMagic || file.length() < 4096 ) { + if ( isVmdkMagic ) { + file.seek( 512 ); + } else { + file.seek( 0 ); + } + byte[] buffer = new byte[ (int)Math.min( 2048, file.length() ) ]; file.readFully( buffer ); VmwareConfig config; try { @@ -82,20 +87,23 @@ public class DiskImage config = null; } if ( config != null ) { - subFormat = config.get( "createType" ); + String sf = config.get( "createType" ); String parent = config.get( "parentCID" ); - this.isStandalone = isStandaloneCreateType( subFormat, parent ); - this.isCompressed = subFormat != null && subFormat.equalsIgnoreCase( "streamOptimized" ); - this.isSnapshot = parent != null && !parent.equalsIgnoreCase( "ffffffff" ); - this.format = ImageFormat.VMDK; - String hwv = config.get( "ddb.virtualHWVersion" ); - if ( hwv == null ) { - this.hwVersion = 10; - } else { - this.hwVersion = Util.parseInt( hwv, 10 ); + if ( sf != null || parent != null ) { + subFormat = sf; + this.isStandalone = isStandaloneCreateType( subFormat, parent ); + this.isCompressed = subFormat != null && subFormat.equalsIgnoreCase( "streamOptimized" ); + this.isSnapshot = parent != null && !parent.equalsIgnoreCase( "ffffffff" ); + this.format = ImageFormat.VMDK; + String hwv = config.get( "ddb.virtualHWVersion" ); + if ( hwv == null ) { + this.hwVersion = 10; + } else { + this.hwVersion = Util.parseInt( hwv, 10 ); + } + this.diskDescription = null; + return; } - this.diskDescription = null; - return; } } // Format spec from: https://forums.virtualbox.org/viewtopic.php?t=8046 @@ -152,30 +160,30 @@ public class DiskImage return; } - file.seek(0); - //TODO: Standalone & Snapshot - if (file.readInt() == QEMU_MAGIC) { - //skip the next 14 ints as they don't interest us - // - QFI version (4 bytes) - // - backing file offset (8 bytes) - // - backing (8 bytes) - // - crypt method (4 bytes) - // - l1 size (4 bytes) - // - l1 table offset (8 bytes) - // - refcount table offset (8 bytes) - // - refcount cluster (4 bytes) - file.skipBytes( 14 * 4 ); - this.isSnapshot = file.readInt() > 0; - //skip the next 14 ints as they don't interest us - file.seek(374); - this.isCompressed = file.read() == 1; - this.diskDescription = null; - this.format = ImageFormat.QCOW2; - this.isStandalone = true; - this.subFormat = null; - this.hwVersion = 0; - return; - } + file.seek(0); + //TODO: Standalone & Snapshot + if (file.readInt() == QEMU_MAGIC) { + //skip the next 14 ints as they don't interest us + // - QFI version (4 bytes) + // - backing file offset (8 bytes) + // - backing (8 bytes) + // - crypt method (4 bytes) + // - l1 size (4 bytes) + // - l1 table offset (8 bytes) + // - refcount table offset (8 bytes) + // - refcount cluster (4 bytes) + file.skipBytes( 14 * 4 ); + this.isSnapshot = file.readInt() > 0; + //skip the next 14 ints as they don't interest us + file.seek(374); + this.isCompressed = file.read() == 1; + this.diskDescription = null; + this.format = ImageFormat.QCOW2; + this.isStandalone = true; + this.subFormat = null; + this.hwVersion = 0; + return; + } } throw new UnknownImageFormatException(); } diff --git a/src/main/java/org/openslx/util/vm/QemuConfig.java b/src/main/java/org/openslx/util/vm/QemuConfig.java index ceb3285..89df62c 100644 --- a/src/main/java/org/openslx/util/vm/QemuConfig.java +++ b/src/main/java/org/openslx/util/vm/QemuConfig.java @@ -297,8 +297,8 @@ public final class QemuConfig { case "scsi": bus = DriveBusType.SCSI; break; - case "virtio": - bus = DriveBusType.VIRTIO; +// case "virtio": + // bus = DriveBusType.VIRTIO; case "sata": //not available for Qemu. Others : sd, mtd, floppy, pflash break; @@ -340,9 +340,6 @@ public final class QemuConfig { case SCSI: controllerDevice = "scsi-generic"; break; - case VIRTIO: - controllerDevice = "virtio-9p-device"; - break; default: controllerDevice = "scsi-generic"; break; diff --git a/src/main/java/org/openslx/util/vm/QemuMetaData.java b/src/main/java/org/openslx/util/vm/QemuMetaData.java index 8855f9c..814bfa4 100644 --- a/src/main/java/org/openslx/util/vm/QemuMetaData.java +++ b/src/main/java/org/openslx/util/vm/QemuMetaData.java @@ -51,8 +51,19 @@ class QemuSoundCardMeta { value = val; } } +class QemuUSBMeta { -public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAccelMeta, QemuHWVersionMeta, QemuEthernetDevTypeMeta> { + public final String value; + public final int speed; + + public QemuUSBMeta(String value, int speed) { + + this.value = value; + this.speed = speed; + } +} + +public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAccelMeta, QemuHWVersionMeta, QemuEthernetDevTypeMeta, QemuUSBMeta> { private static final Logger LOGGER = Logger.getLogger(QemuMetaData.class); @@ -288,6 +299,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce @Override public void setEthernetDevType(int cardIndex, VmMetaData.EthernetDevType type) { + /* //TODO QemuEthernetDevTypeMeta dev = networkCards.get(type); header = new LinkedHashMap<>(); @@ -297,6 +309,7 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce //option.put("netdev", "net" + cardIndex); config.set(header, option); netdevCounter++; + */ } @Override @@ -363,25 +376,45 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce return virtualizer; } - @Override - public void enableUsb(boolean enabled) { - option = new TreeMap<>(); - if (enabled) { - option.put("usb", "on"); - } else { - option.put("usb", "off"); - } - - header = new LinkedHashMap<>(); - header.put(MACHINE.getHeader(), MACHINE.getID()); - config.set(header, option); - } - - @Override - public boolean disableSuspend() { - return false; - } - +// @Override +// public void enableUsb(boolean enabled) { +// option = new TreeMap<>(); +// if (enabled) { +// option.put("usb", "on"); +// } else { +// option.put("usb", "off"); +// } +// +// header = new LinkedHashMap<>(); +// header.put(MACHINE.getHeader(), MACHINE.getID()); +// config.set(header, option); +// } + +// @Override +// public boolean disableSuspend() { +// return false; +// } + @Override + public boolean tweakForNonPersistent() { + return false; + } + public void setMaxUsbSpeed( VmMetaData.UsbSpeed speed ) + { + // TODO: Actual speed setting? + if ( speed == null || speed == VmMetaData.UsbSpeed.NONE ) { + option.remove( "usb" ); + } else { + option.put( "usb", "" ); + } + } + + @Override + public VmMetaData.UsbSpeed getMaxUsbSpeed() + { + if (option.containsKey( "usb" ) ) + return VmMetaData.UsbSpeed.USB2_0; // TODO + return VmMetaData.UsbSpeed.NONE; + } @Override public void registerVirtualHW() { soundCards.put(VmMetaData.SoundCardType.NONE, new QemuSoundCardMeta(false, null)); @@ -390,16 +423,20 @@ public final class QemuMetaData extends VmMetaData<QemuSoundCardMeta, QemuDDAcce soundCards.put(VmMetaData.SoundCardType.ES, new QemuSoundCardMeta(true, "es1370")); soundCards.put(VmMetaData.SoundCardType.SOUND_BLASTER, new QemuSoundCardMeta(true, "sb16")); - ddacc.put(DDAcceleration.OFF, new QemuDDAccelMeta(false)); - ddacc.put(DDAcceleration.ON, new QemuDDAccelMeta(true)); + ddacc.put(VmMetaData.DDAcceleration.OFF, new QemuDDAccelMeta(false)); + ddacc.put(VmMetaData.DDAcceleration.ON, new QemuDDAccelMeta(true)); - hwversion.put(HWVersion.DEFAULT, new QemuHWVersionMeta(0)); + hwversion.put(VmMetaData.HWVersion.DEFAULT, new QemuHWVersionMeta(0)); - networkCards.put(EthernetDevType.VIRTIO, new QemuEthernetDevTypeMeta("virtio-net-pci")); - networkCards.put(EthernetDevType.E1000, new QemuEthernetDevTypeMeta("e1000")); - networkCards.put(EthernetDevType.PCNET32, new QemuEthernetDevTypeMeta("pcnet")); - networkCards.put(EthernetDevType.RTL8139, new QemuEthernetDevTypeMeta("rtl8139")); + usbSpeeds.put(VmMetaData.UsbSpeed.NONE, new QemuUSBMeta(null, 0)); + usbSpeeds.put(VmMetaData.UsbSpeed.USB1_1, new QemuUSBMeta("usb", 1)); + usbSpeeds.put(VmMetaData.UsbSpeed.USB2_0, new QemuUSBMeta("ehci", 2)); + usbSpeeds.put(VmMetaData.UsbSpeed.USB3_0, new QemuUSBMeta("usb_xhci", 3)); - } + //networkCards.put(VmMetaData.EthernetDevType.VIRTIO, new QemuEthernetDevTypeMeta("virtio-net-pci")); + networkCards.put(VmMetaData.EthernetDevType.E1000, new QemuEthernetDevTypeMeta("e1000")); + networkCards.put(VmMetaData.EthernetDevType.PCNET32, new QemuEthernetDevTypeMeta("pcnet")); + //networkCards.put(VmMetaData.EthernetDevType.RTL8139, new QemuEthernetDevTypeMeta("rtl8139")); + } } diff --git a/src/main/java/org/openslx/util/vm/VboxConfig.java b/src/main/java/org/openslx/util/vm/VboxConfig.java index 9d6e6f1..6153abf 100644 --- a/src/main/java/org/openslx/util/vm/VboxConfig.java +++ b/src/main/java/org/openslx/util/vm/VboxConfig.java @@ -6,6 +6,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.List; import javax.xml.XMLConstants; import javax.xml.transform.stream.StreamSource; @@ -47,7 +48,6 @@ public class VboxConfig "/VirtualBox/Machine/Hardware/GuestProperties", "/VirtualBox/Machine/Hardware/VideoCapture", "/VirtualBox/Machine/Hardware/HID", - "/VirtualBox/Machine/Hardware/USB", "/VirtualBox/Machine/Hardware/LPT", "/VirtualBox/Machine/Hardware/SharedFolders", "/VirtualBox/Machine/Hardware/Network/Adapter[@enabled='true']/*", @@ -143,6 +143,7 @@ public class VboxConfig try { ensureHardwareUuid(); setOsType(); + fixUsb(); // Since we now support selecting specific speed if ( checkForPlaceholders() ) { return; } @@ -154,6 +155,33 @@ public class VboxConfig return; } } + + private void fixUsb() + { + NodeList list = findNodes( "/VirtualBox/Machine/Hardware/USB/Controllers/Controller" ); + if ( list != null && list.getLength() != 0 ) { + LOGGER.info( "USB present, not fixing anything" ); + return; + } + // If there's no USB section, this can mean two things: + // 1) Old config that would always default to USB 2.0 for "USB enabled" or nothing for disabled + // 2) New config with USB disabled + list = findNodes( "/VirtualBox/OpenSLX/USB[@disabled]" ); + if ( list != null && list.getLength() != 0 ) { + LOGGER.info( "USB explicitly disabled" ); + return; // Explicitly marked as disabled, do nothing + } + // We assume case 1) and add USB 2.0 + LOGGER.info( "Fixing USB: Adding USB 2.0" ); + Element controller; + Element node = createNodeRecursive( "/VirtualBox/Machine/Hardware/USB/Controllers" ); + controller = addNewNode( node, "Controller" ); + controller.setAttribute( "name", "OHCI" ); + controller.setAttribute( "type", "OHCI" ); + controller = addNewNode( node, "Controller" ); + controller.setAttribute( "name", "EHCI" ); + controller.setAttribute( "type", "EHCI" ); + } /** * Saves the machine's uuid as hardware uuid to prevent VMs from @@ -308,24 +336,42 @@ public class VboxConfig } /** - * Search disk drives within the DOM using this class + * Search for attached hard drives and determine their controller and their path. * * @throws XPathExpressionException */ public void setHdds() throws XPathExpressionException { - XPathExpression hddsExpr = XmlHelper.XPath.compile( "/VirtualBox/Machine/MediaRegistry/HardDisks/*" ); + XPathExpression hddsExpr = XmlHelper.XPath.compile( "/VirtualBox/Machine/StorageControllers/StorageController/AttachedDevice[@type='HardDisk']/Image" ); NodeList nodes = (NodeList)hddsExpr.evaluate( this.doc, XPathConstants.NODESET ); + if ( nodes == null ) { + LOGGER.error( "Failed to find attached hard drives." ); + return; + } for ( int i = 0; i < nodes.getLength(); i++ ) { Element hddElement = (Element)nodes.item( i ); if ( hddElement == null ) continue; - String fileName = hddElement.getAttribute( "location" ); - String type = hddElement.getAttribute( "type" ); + String uuid = hddElement.getAttribute( "uuid" ); + if ( uuid.isEmpty() ) + continue; + // got uuid, check if it was registered + XPathExpression hddsRegistered = XmlHelper.XPath.compile( "/VirtualBox/Machine/MediaRegistry/HardDisks/HardDisk[@uuid='" + uuid + "']" ); + NodeList hddsRegisteredNodes = (NodeList)hddsRegistered.evaluate( this.doc, XPathConstants.NODESET ); + if ( hddsRegisteredNodes == null || hddsRegisteredNodes.getLength() != 1 ) { + LOGGER.error( "Found hard disk with uuid '" + uuid + "' which does not appear (unique) in the Media Registry. Skipping." ); + continue; + } + Element hddElementReg = (Element)hddsRegisteredNodes.item( 0 ); + if ( hddElementReg == null ) + continue; + String fileName = hddElementReg.getAttribute( "location" ); + String type = hddElementReg.getAttribute( "type" ); if ( !type.equals( "Normal" ) && !type.equals( "Writethrough" ) ) { LOGGER.warn( "Type of the disk file is neither 'Normal' nor 'Writethrough' but: " + type ); LOGGER.warn( "This makes the image not directly modificable, which might lead to problems when editing it locally." ); } + // search if it is also attached to a controller Node hddDevice = hddElement.getParentNode(); if ( hddDevice == null ) { LOGGER.error( "HDD node had a null parent, shouldn't happen" ); @@ -336,18 +382,19 @@ public class VboxConfig LOGGER.error( "HDD node had a null parent, shouldn't happen" ); continue; } - String controllerDevice = hddController.getAttribute( "type" ); - String bus = hddController.getAttribute( "name" ); + String controllerMode = hddController.getAttribute( "type" ); + String controllerType = hddController.getAttribute( "name" ); DriveBusType busType = null; - if ( bus.equals( "IDE" ) ) { + if ( controllerType.equals( "IDE" ) ) { busType = DriveBusType.IDE; - } else if ( bus.equals( "SCSI" ) ) { + } else if ( controllerType.equals( "SCSI" ) ) { busType = DriveBusType.SCSI; - } else if ( bus.equals( "SATA" ) ) { + } else if ( controllerType.equals( "SATA" ) ) { busType = DriveBusType.SATA; - } - // add them together - hddsArray.add( new HardDisk( controllerDevice, busType, fileName ) ); + } else + continue; + LOGGER.info( "Adding hard disk with controller: " + busType + " (" + controllerMode + ") from file '" + fileName + "'." ); + hddsArray.add( new HardDisk( controllerMode, busType, fileName ) ); } } @@ -362,35 +409,6 @@ public class VboxConfig } /** - * Enable USB by adding the element /VirtualBox/Machine/Hardware/USB - * and adding controllers for OHCI and EHCI (thus enabling USB 2.0). - */ - public void enableUsb() - { - addNewNode( "/VirtualBox/Machine/Hardware", "USB" ); - addNewNode( "/VirtualBox/Machine/Hardware/USB", "Controllers" ); - // OHCI for USB 1.0 - Node ohci = addNewNode( "/VirtualBox/Machine/Hardware/USB/Controllers", "Controller" ); - addAttributeToNode( ohci, "name", "OHCI" ); - addAttributeToNode( ohci, "type", "OHCI" ); - // EHCI for USB 2.0 - Node ehci = addNewNode( "/VirtualBox/Machine/Hardware/USB/Controllers", "Controller" ); - addAttributeToNode( ehci, "name", "EHCI" ); - addAttributeToNode( ehci, "type", "EHCI" ); - } - - /** - * Removes all USB elements - */ - public void disableUsb() - { - NodeList usbList = findNodes( "/VirtualBox/Machine/Hardware/USB" ); - for ( int i = 0; i < usbList.getLength(); i++ ) { - removeNode( usbList.item( 0 ) ); - } - } - - /** * Detect if the vbox file has any machine snapshot by looking at * the existance of '/VirtualBox/Machine/Snapshot' elements. * @@ -485,6 +503,58 @@ public class VboxConfig return addNewNode( possibleParents.item( 0 ), childName ); } + public Element createNodeRecursive( String xPath ) + { + String[] nodeNames = xPath.split( "/" ); + Node parent = this.doc; + Element latest = null; + for ( int nodeIndex = 0; nodeIndex < nodeNames.length; ++nodeIndex ) { + if ( nodeNames[nodeIndex].length() == 0 ) + continue; + Node node = skipNonElementNodes( parent.getFirstChild() ); + while ( node != null ) { + if ( node.getNodeType() == Node.ELEMENT_NODE && nodeNames[nodeIndex].equals( node.getNodeName() ) ) + break; // Found existing + // Check next on same level + node = skipNonElementNodes( node.getNextSibling() ); + } + if ( node == null ) { + node = doc.createElement( nodeNames[nodeIndex] ); + parent.appendChild( node ); + } + parent = node; + latest = (Element)node; + } + return latest; + } + + private Element skipNonElementNodes( Node nn ) + { + while ( nn != null && nn.getNodeType() != Node.ELEMENT_NODE ) { + nn = nn.getNextSibling(); + } + return (Element)nn; + } + + public void setExtraData( String key, String value ) + { + NodeList nl = findNodes( "/VirtualBox/Machine/ExtraData/ExtraDataItem[@name='" + key + "']" ); + Element e = null; + for ( int i = 0; i < nl.getLength(); ++i ) { + Node n = nl.item( i ); + if ( n.getNodeType() == Node.ELEMENT_NODE ) { + e = (Element)n; + break; + } + } + if ( e == null ) { + Element p = createNodeRecursive( "/VirtualBox/Machine/ExtraData" ); + e = addNewNode( p, "ExtraDataItem" ); + e.setAttribute( "name", key ); + } + e.setAttribute( "value", value ); + } + /** * Creates a new element to the given parent node. * @@ -492,12 +562,12 @@ public class VboxConfig * @param childName name of the new element to create * @return the newly created node */ - public Node addNewNode( Node parent, String childName ) + public Element addNewNode( Node parent, String childName ) { if ( parent == null || parent.getNodeType() != Node.ELEMENT_NODE ) { return null; } - Node newNode = null; + Element newNode = null; try { newNode = doc.createElement( childName ); parent.appendChild( newNode ); @@ -531,4 +601,30 @@ public class VboxConfig { return XmlHelper.getXmlFromDocument( doc, prettyPrint ); } + + /** + * Remove all nodes with name childName from parentPath + * @param parentPath XPath to parent node of where child nodes are to be deleted + * @param childName Name of nodes to delete + */ + public void removeNodes( String parentPath, String childName ) + { + NodeList parentNodes = findNodes( parentPath ); + // XPath might match multiple nodes + for ( int i = 0; i < parentNodes.getLength(); ++i ) { + Node parent = parentNodes.item( i ); + List<Node> delList = new ArrayList<>( 0 ); + // Iterate over child nodes + for ( Node child = parent.getFirstChild(); child != null; child = child.getNextSibling() ) { + if ( childName.equals( child.getNodeName() ) ) { + // Remember all to be deleted (don't delete while iterating) + delList.add( child ); + } + } + // Now delete them all + for ( Node child : delList ) { + parent.removeChild( child ); + } + } + } } diff --git a/src/main/java/org/openslx/util/vm/VboxMetaData.java b/src/main/java/org/openslx/util/vm/VboxMetaData.java index 00ca8ad..da5189e 100644 --- a/src/main/java/org/openslx/util/vm/VboxMetaData.java +++ b/src/main/java/org/openslx/util/vm/VboxMetaData.java @@ -7,6 +7,7 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; +import java.util.Map.Entry; import java.util.UUID; import org.apache.log4j.Logger; @@ -14,6 +15,7 @@ import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.Virtualizer; import org.openslx.thrifthelper.TConst; import org.openslx.util.vm.VboxConfig.PlaceHolder; +import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -62,7 +64,18 @@ class VBoxEthernetDevTypeMeta } } -public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, VBoxHWVersionMeta, VBoxEthernetDevTypeMeta> +class VBoxUsbSpeedMeta +{ + public final String value; + public final int speed; + public VBoxUsbSpeedMeta( String value, int speed ) + { + this.value = value; + this.speed = speed; + } +} + +public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, VBoxHWVersionMeta, VBoxEthernetDevTypeMeta, VBoxUsbSpeedMeta> { private static final Logger LOGGER = Logger.getLogger( VboxMetaData.class ); @@ -114,16 +127,6 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, } @Override - public void enableUsb( boolean enabled ) - { - if ( !enabled ) { - config.disableUsb(); - } else { - config.enableUsb(); - } - } - - @Override public void applySettingsForLocalEdit() { // TODO Auto-generated method stub @@ -415,6 +418,7 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, public void registerVirtualHW() { // none type needs to have a valid value; it takes the value of AC97; if value is left null or empty vm will not start because value is not valid + // TODO: Maybe just remove the entire section from the XML? Same for ethernet... soundCards.put( VmMetaData.SoundCardType.NONE, new VBoxSoundCardMeta( false, "AC97" ) ); soundCards.put( VmMetaData.SoundCardType.SOUND_BLASTER, new VBoxSoundCardMeta( true, "SB16" ) ); soundCards.put( VmMetaData.SoundCardType.HD_AUDIO, new VBoxSoundCardMeta( true, "HDA" ) ); @@ -433,6 +437,11 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, networkCards.put( VmMetaData.EthernetDevType.PRO1000TS, new VBoxEthernetDevTypeMeta( true, "82543GC" ) ); networkCards.put( VmMetaData.EthernetDevType.PRO1000MTS, new VBoxEthernetDevTypeMeta( true, "82545EM" ) ); networkCards.put( VmMetaData.EthernetDevType.PARAVIRT, new VBoxEthernetDevTypeMeta( true, "virtio" ) ); + + usbSpeeds.put( VmMetaData.UsbSpeed.NONE, new VBoxUsbSpeedMeta( null, 0 ) ); + usbSpeeds.put( VmMetaData.UsbSpeed.USB1_1, new VBoxUsbSpeedMeta( "OHCI", 1 ) ); + usbSpeeds.put( VmMetaData.UsbSpeed.USB2_0, new VBoxUsbSpeedMeta( "EHCI", 2 ) ); + usbSpeeds.put( VmMetaData.UsbSpeed.USB3_0, new VBoxUsbSpeedMeta( "XHCI", 3 ) ); } @Override @@ -447,12 +456,66 @@ public class VboxMetaData extends VmMetaData<VBoxSoundCardMeta, VBoxDDAccelMeta, } @Override - public boolean disableSuspend() + public boolean tweakForNonPersistent() { - // TODO how?? - // short answer is: you can't + // Cannot disable suspend // https://forums.virtualbox.org/viewtopic.php?f=6&t=77169 // https://forums.virtualbox.org/viewtopic.php?f=8&t=80338 + // But some other stuff that won't make sense in non-persistent mode + config.setExtraData( "GUI/LastCloseAction", "PowerOff" ); + // Could use "Default" instead of "Last" above, but you won't get any confirmation dialog in that case + config.setExtraData( "GUI/RestrictedRuntimeHelpMenuActions", "All" ); + config.setExtraData( "GUI/RestrictedRuntimeMachineMenuActions", "TakeSnapshot,Pause,SaveState" ); + config.setExtraData( "GUI/RestrictedRuntimeMenus", "Help" ); + config.setExtraData( "GUI/PreventSnapshotOperations", "true" ); + config.setExtraData( "GUI/PreventApplicationUpdate", "true" ); + config.setExtraData( "GUI/RestrictedCloseActions", "SaveState,PowerOffRestoringSnapshot,Detach" ); return true; } + + @Override + public void setMaxUsbSpeed( VmMetaData.UsbSpeed speed ) + { + // Wipe existing ones + config.removeNodes( "/VirtualBox/Machine/Hardware", "USB" ); + if ( speed == null || speed == VmMetaData.UsbSpeed.NONE ) { + // Add marker so we know it's not an old config and we really want no USB + Element node = config.createNodeRecursive( "/VirtualBox/OpenSLX/USB" ); + if ( node != null ) { + node.setAttribute( "disabled", "true" ); + } + return; // NO USB + } + Element node = config.createNodeRecursive( "/VirtualBox/Machine/Hardware/USB/Controllers/Controller" ); + VBoxUsbSpeedMeta vboxSpeed = usbSpeeds.get( speed ); + node.setAttribute( "type", vboxSpeed.value ); + node.setAttribute( "name", vboxSpeed.value ); + if ( speed == UsbSpeed.USB2_0 ) { + // If EHCI (2.0) is selected, VBox adds an OHCI controller too... + node.setAttribute( "type", "OHCI" ); + node.setAttribute( "name", "OHCI" ); + } + } + + @Override + public VmMetaData.UsbSpeed getMaxUsbSpeed() + { + NodeList nodes = config.findNodes( "/VirtualBox/Machine/Hardware/USB/Controllers/Controller/@type" ); + int maxSpeed = 0; + VmMetaData.UsbSpeed maxItem = VmMetaData.UsbSpeed.NONE; + for ( int i = 0; i < nodes.getLength(); ++i ) { + if ( nodes.item( i ).getNodeType() != Node.ATTRIBUTE_NODE ) { + LOGGER.info( "Not ATTRIBUTE type" ); + continue; + } + String type = ((Attr)nodes.item( i )).getValue(); + for ( Entry<VmMetaData.UsbSpeed, VBoxUsbSpeedMeta> s : usbSpeeds.entrySet() ) { + if ( s.getValue().speed > maxSpeed && type.equals( s.getValue().value ) ) { + maxSpeed = s.getValue().speed; + maxItem = s.getKey(); + } + } + } + return maxItem; + } } diff --git a/src/main/java/org/openslx/util/vm/VmMetaData.java b/src/main/java/org/openslx/util/vm/VmMetaData.java index c17df89..714a7e4 100644 --- a/src/main/java/org/openslx/util/vm/VmMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmMetaData.java @@ -18,96 +18,133 @@ import org.openslx.bwlp.thrift.iface.Virtualizer; * Describes a configured virtual machine. This class is parsed from a machine * description, like a *.vmx for VMware machines. */ -public abstract class VmMetaData<T, U, V, W> { - +public abstract class VmMetaData<T, U, V, W, X> +{ private static final Logger LOGGER = Logger.getLogger(VmMetaData.class); /* * Helper types - */ - protected Map<SoundCardType, T> soundCards = new HashMap<>(); - protected Map<DDAcceleration, U> ddacc = new HashMap<>(); - protected Map<HWVersion, V> hwversion = new HashMap<>(); - protected Map<EthernetDevType, W> networkCards = new HashMap<>(); - - /** - * Virtual sound cards types - */ - public static enum SoundCardType { - NONE("None"), DEFAULT("(default)"), SOUND_BLASTER("Sound Blaster 16"), ES("ES 1371"), HD_AUDIO("Intel Integrated HD Audio"), AC("Intel ICH Audio Codec 97"); - - public final String displayName; - - private SoundCardType(String dName) { - this.displayName = dName; - } - } - - /** - * 3D acceleration types - */ - public static enum DDAcceleration { - OFF("Off"), ON("On"); - - public final String displayName; - - private DDAcceleration(String dName) { - this.displayName = dName; - } - } - - /** - * Virtual hardware version - currently only in use for VMPlayer - */ - public static enum HWVersion { - NONE("(invalid)"), THREE(" 3 (Workstation 4/5, Player 1)"), FOUR(" 4 (Workstation 4/5, Player 1/2, Fusion 1)"), SIX(" 6 (Workstation 6)"), SEVEN( - " 7 (Workstation 6.5/7, Player 3, Fusion 2/3)"), EIGHT(" 8 (Workstation 8, Player/Fusion 4)"), NINE(" 9 (Workstation 9, Player/Fusion 5)"), TEN( - "10 (Workstation 10, Player/Fusion 6)"), ELEVEN( - "11 (Workstation 11, Player/Fusion 7)"), TWELVE("12 (Workstation/Player 12, Fusion 8)"), DEFAULT("default"); - - public final String displayName; - - private HWVersion(String dName) { - this.displayName = dName; - } - } - - /** - * Virtual network cards - */ - public static enum EthernetDevType { - AUTO("(default)"), PCNET32("AMD PCnet32"), E1000("Intel E1000 (PCI)"), E1000E("Intel E1000e (PCI-Express)"), VMXNET("VMXnet"), VMXNET3("VMXnet 3"), PCNETPCI2( - "PCnet-PCI II"), PCNETFAST3("PCnet-FAST III"), PRO1000MTD("Intel PRO/1000 MT Desktop"), PRO1000TS( - "Intel PRO/1000 T Server"), PRO1000MTS("Intel PRO/1000 MT Server"), PARAVIRT("Paravirtualized Network"), VIRTIO("Virtual High Performance Ethernet card"), RTL8139("Realtek Fast Ethernet "), NONE("No Network Card"); - - public final String displayName; - - private EthernetDevType(String dName) { - this.displayName = dName; - } - } - - public static enum DriveBusType { - SCSI, IDE, SATA, VIRTIO; - } - - public static class HardDisk { - - public final String chipsetDriver; - public final DriveBusType bus; - public final String diskImage; - - public HardDisk(String chipsetDriver, DriveBusType bus, String diskImage) { - this.chipsetDriver = chipsetDriver; - this.bus = bus; - this.diskImage = diskImage; - } - } - - public static enum EtherType { - NAT, BRIDGED, HOST_ONLY; - } - /* + */ + protected Map<SoundCardType, T> soundCards = new HashMap<>(); + protected Map<DDAcceleration, U> ddacc = new HashMap<>(); + protected Map<HWVersion, V> hwversion = new HashMap<>(); + protected Map<EthernetDevType, W> networkCards = new HashMap<>(); + protected Map<UsbSpeed, X> usbSpeeds = new HashMap<>(); + + /** + * Virtual sound cards types + */ + public static enum SoundCardType + { + NONE( "None" ), DEFAULT( "(default)" ), SOUND_BLASTER( "Sound Blaster 16" ), ES( "ES 1371" ), HD_AUDIO( "Intel Integrated HD Audio" ), AC( "Intel ICH Audio Codec 97" ); + + public final String displayName; + + private SoundCardType( String dName ) + { + this.displayName = dName; + } + } + + /** + * 3D acceleration types + */ + public static enum DDAcceleration + { + OFF( "Off" ), ON( "On" ); + + public final String displayName; + + private DDAcceleration( String dName ) + { + this.displayName = dName; + } + } + + /** + * Virtual hardware version - currently only in use for VMPlayer + */ + public static enum HWVersion + { + NONE( "(invalid)" ), + THREE( " 3 (Workstation 4/5, Player 1)" ), + FOUR( " 4 (Workstation 4/5, Player 1/2, Fusion 1)" ), + SIX( " 6 (Workstation 6)" ), + SEVEN( " 7 (Workstation 6.5/7, Player 3, Fusion 2/3)" ), + EIGHT( " 8 (Workstation 8, Player/Fusion 4)" ), + NINE( " 9 (Workstation 9, Player/Fusion 5)" ), + TEN( "10 (Workstation 10, Player/Fusion 6)" ), + ELEVEN( "11 (Workstation 11, Player/Fusion 7)" ), + TWELVE( "12 (Workstation/Player 12, Fusion 8)" ), + FOURTEEN( "14 (Workstation/Player 14, Fusion 10)"), + FIFTEEN( "15 (Workstation/Player 15, Fusion 11)"), + FIFTEEN_ONE( "16 (Workstation/Player 15.1, Fusion 11.1)"), + DEFAULT( "default" ); + + public final String displayName; + + private HWVersion( String dName ) + { + this.displayName = dName; + } + } + + /** + * Virtual network cards + */ + public static enum EthernetDevType + { + AUTO( "(default)" ), PCNET32( "AMD PCnet32" ), E1000( "Intel E1000 (PCI)" ), E1000E( "Intel E1000e (PCI-Express)" ), VMXNET( "VMXnet" ), VMXNET3( "VMXnet 3" ), PCNETPCI2( + "PCnet-PCI II" ), PCNETFAST3( "PCnet-FAST III" ), PRO1000MTD( "Intel PRO/1000 MT Desktop" ), PRO1000TS( + "Intel PRO/1000 T Server" ), PRO1000MTS( "Intel PRO/1000 MT Server" ), PARAVIRT( "Paravirtualized Network" ), NONE( "No Network Card" ); + + public final String displayName; + + private EthernetDevType( String dName ) + { + this.displayName = dName; + } + } + + public static enum UsbSpeed + { + NONE( "None" ), + USB1_1( "USB 1.1" ), + USB2_0( "USB 2.0" ), + USB3_0( "USB 3.0" ); + + public final String displayName; + + private UsbSpeed( String dName ) + { + this.displayName = dName; + } + } + + public static enum DriveBusType + { + SCSI, IDE, SATA; + } + + public static class HardDisk + { + public final String chipsetDriver; + public final DriveBusType bus; + public final String diskImage; + + public HardDisk( String chipsetDriver, DriveBusType bus, String diskImage ) + { + this.chipsetDriver = chipsetDriver; + this.bus = bus; + this.diskImage = diskImage; + } + } + + public static enum EtherType + { + NAT, BRIDGED, HOST_ONLY; + } + /* * Members */ @@ -123,53 +160,67 @@ public abstract class VmMetaData<T, U, V, W> { /* * Getters for virtual hardware - */ - public List<SoundCardType> getSupportedSoundCards() { - ArrayList<SoundCardType> availables = new ArrayList<SoundCardType>(soundCards.keySet()); - Collections.sort(availables); - return availables; - } - - public List<DDAcceleration> getSupportedDDAccs() { - ArrayList<DDAcceleration> availables = new ArrayList<DDAcceleration>(ddacc.keySet()); - Collections.sort(availables); - return availables; - } - - public List<HWVersion> getSupportedHWVersions() { - ArrayList<HWVersion> availables = new ArrayList<HWVersion>(hwversion.keySet()); - Collections.sort(availables); - return availables; - } - - public List<EthernetDevType> getSupportedEthernetDevices() { - ArrayList<EthernetDevType> availables = new ArrayList<EthernetDevType>(networkCards.keySet()); - Collections.sort(availables); - return availables; - } - - /** - * Get operating system of this VM. - */ - public OperatingSystem getOs() { - return os; - } - - /** - * Get all hard disks of this VM. - */ - public List<HardDisk> getHdds() { - return Collections.unmodifiableList(hdds); - } - - /** - * Get display name of VM. - */ - public String getDisplayName() { - return displayName; - } - - /* + */ + public List<SoundCardType> getSupportedSoundCards() + { + ArrayList<SoundCardType> availables = new ArrayList<SoundCardType>( soundCards.keySet() ); + Collections.sort( availables ); + return availables; + } + + public List<DDAcceleration> getSupportedDDAccs() + { + ArrayList<DDAcceleration> availables = new ArrayList<DDAcceleration>( ddacc.keySet() ); + Collections.sort( availables ); + return availables; + } + + public List<HWVersion> getSupportedHWVersions() + { + ArrayList<HWVersion> availables = new ArrayList<HWVersion>( hwversion.keySet() ); + Collections.sort( availables ); + return availables; + } + + public List<EthernetDevType> getSupportedEthernetDevices() + { + ArrayList<EthernetDevType> availables = new ArrayList<EthernetDevType>( networkCards.keySet() ); + Collections.sort( availables ); + return availables; + } + + public List<UsbSpeed> getSupportedUsbSpeeds() + { + ArrayList<UsbSpeed> availables = new ArrayList<>( usbSpeeds.keySet() ); + Collections.sort( availables ); + return availables; + } + + /** + * Get operating system of this VM. + */ + public OperatingSystem getOs() + { + return os; + } + + /** + * Get all hard disks of this VM. + */ + public List<HardDisk> getHdds() + { + return Collections.unmodifiableList( hdds ); + } + + /** + * Get display name of VM. + */ + public String getDisplayName() + { + return displayName; + } + + /* * Getter for isMachineSnapshot */ public boolean isMachineSnapshot() { @@ -191,156 +242,161 @@ public abstract class VmMetaData<T, U, V, W> { /* * Methods - */ - public VmMetaData(List<OperatingSystem> osList) { - this.osList = osList; - } - - /** - * Called from subclass to set the OS. If the OS cannot be determined from - * the given parameters, it will not be set. - * - * @param virtId virtualizer, eg "vmware" for VMware - * @param virtOsId the os identifier used by the virtualizer, eg. - * windows7-64 for 64bit Windows 7 on VMware - */ - protected final void setOs(String virtId, String virtOsId) { - OperatingSystem lazyMatch = null; - for (OperatingSystem os : osList) { - if (os.getVirtualizerOsId() == null) { - continue; - } - for (Entry<String, String> entry : os.getVirtualizerOsId().entrySet()) { - if (!entry.getValue().equals(virtOsId)) { - continue; - } - if (entry.getKey().equals(virtId)) { - this.os = os; - return; - } else { - lazyMatch = os; - } - } - } - this.os = lazyMatch; - } - - /** - * Apply config options that are desired when locally editing a VM. for - * vmware, this disables automatic DPI scaling of the guest. - */ - public abstract void applySettingsForLocalEdit(); - - /** - * Returns a VmMetaData instance of the given machine description given as - * file - * - * @param osList List of supported operating systems - * @param file VM's machine description file to get the metadata instance - * from - * @return VmMetaData object representing the relevant parts of the given - * machine description - */ - public static VmMetaData<?, ?, ?, ?> getInstance(List<OperatingSystem> osList, File file) - throws IOException { - try { - return new VmwareMetaData(osList, file); - } catch (UnsupportedVirtualizerFormatException e) { - LOGGER.info("Not a VMware file", e); - } - try { - return new VboxMetaData(osList, file); - } catch (UnsupportedVirtualizerFormatException e) { - LOGGER.info("Not a VirtualBox file", e); - } - try { - return new QemuMetaData(osList, file); - } catch (Exception e) { - LOGGER.info("Not a QEmu file", e); - } - LOGGER.error("Could not detect any known virtualizer format"); - return null; - } - - /** - * Returns a VmMetaData instance of the given machine description given as a - * byte array - * - * @param osList List of supported operating systems - * @param vmContent VM's machine description as byte array (e.g. stored in - * DB) - * @param length length of the byte array given as vmContent - * @return VmMetaData object representing the relevant parts of the given - * machine description - * @throws IOException - */ - public static VmMetaData<?, ?, ?, ?> getInstance(List<OperatingSystem> osList, byte[] vmContent, int length) throws IOException { - try { - return new VmwareMetaData(osList, vmContent, length); - } catch (UnsupportedVirtualizerFormatException e) { - LOGGER.info("Not a VMware file", e); - } - try { - return new VboxMetaData(osList, vmContent, length); - } catch (UnsupportedVirtualizerFormatException e) { - LOGGER.info("Not a VirtualBox file", e); - } - try { - return new QemuMetaData(osList, vmContent, length); - } catch (UnsupportedVirtualizerFormatException e) { - LOGGER.info("Not a VirtualBox file", e); - } - // TODO QEmu -- hack above expects qcow2 file, so we can't do anything here yet - LOGGER.error("Could not detect any known virtualizer format"); - return null; - } - - public abstract boolean addHddTemplate(File diskImage, String hddMode, String redoDir); - - public abstract boolean addHddTemplate(String diskImagePath, String hddMode, String redoDir); - - public abstract boolean addDefaultNat(); - - public abstract void setOs(String vendorOsId); - - public abstract boolean addDisplayName(String name); - - public abstract boolean addRam(int mem); - - public abstract void addFloppy(int index, String image, boolean readOnly); - - public abstract boolean addCdrom(String image); - - public abstract boolean addCpuCoreCount(int nrOfCores); - - public abstract void setSoundCard(SoundCardType type); - - public abstract SoundCardType getSoundCard(); - - public abstract void setDDAcceleration(DDAcceleration type); - - public abstract DDAcceleration getDDAcceleration(); - - public abstract void setHWVersion(HWVersion type); - - public abstract HWVersion getHWVersion(); - - public abstract void setEthernetDevType(int cardIndex, EthernetDevType type); - - public abstract EthernetDevType getEthernetDevType(int cardIndex); - - public abstract byte[] getDefinitionArray(); - - public abstract boolean addEthernet(EtherType type); - - public abstract Virtualizer getVirtualizer(); - - public abstract void enableUsb(boolean enabled); - - public abstract boolean disableSuspend(); - - /** - * Function used to register virtual devices - */ - public abstract void registerVirtualHW(); + */ + + public VmMetaData( List<OperatingSystem> osList ) + { + this.osList = osList; + } + + /** + * Called from subclass to set the OS. If the OS cannot be determined from the + * given parameters, it will not be set. + * + * @param virtId + * virtualizer, eg "vmware" for VMware + * @param virtOsId + * the os identifier used by the virtualizer, eg. windows7-64 for + * 64bit Windows 7 on VMware + */ + protected final void setOs( String virtId, String virtOsId ) + { + OperatingSystem lazyMatch = null; + for ( OperatingSystem os : osList ) { + if ( os.getVirtualizerOsId() == null ) + continue; + for ( Entry<String, String> entry : os.getVirtualizerOsId().entrySet() ) { + if ( !entry.getValue().equals( virtOsId ) ) + continue; + if ( entry.getKey().equals( virtId ) ) { + this.os = os; + return; + } else { + lazyMatch = os; + } + } + } + this.os = lazyMatch; + } + + /** + * Apply config options that are desired when locally editing a VM. for vmware, + * this disables automatic DPI scaling of the guest. + */ + public abstract void applySettingsForLocalEdit(); + + /** + * Returns a VmMetaData instance of the given machine description given as file + * + * @param osList List of supported operating systems + * @param file VM's machine description file to get the metadata instance from + * @return VmMetaData object representing the relevant parts of the given machine description + */ + public static VmMetaData<?, ?, ?, ?, ?> getInstance( List<OperatingSystem> osList, File file ) + throws IOException + { + try { + return new VmwareMetaData( osList, file ); + } catch ( UnsupportedVirtualizerFormatException e ) { + LOGGER.info( "Not a VMware file", e ); + } + try { + return new VboxMetaData( osList, file ); + } catch ( UnsupportedVirtualizerFormatException e ) { + LOGGER.info( "Not a VirtualBox file", e ); + } + try { + return new QemuMetaData( osList, file ); + } catch ( Exception e ) { + LOGGER.info( "Not a QEmu file", e ); + } + LOGGER.error( "Could not detect any known virtualizer format" ); + return null; + } + + /** + * Returns a VmMetaData instance of the given machine description given as a byte array + * + * @param osList List of supported operating systems + * @param vmContent VM's machine description as byte array (e.g. stored in DB) + * @param length length of the byte array given as vmContent + * @return VmMetaData object representing the relevant parts of the given machine description + * @throws IOException + */ + public static VmMetaData<?, ?, ?, ?, ?> getInstance( List<OperatingSystem> osList, byte[] vmContent, int length ) throws IOException + { + Map<String, Exception> exceptions = new HashMap<>(); + try { + return new VmwareMetaData( osList, vmContent, length ); + } catch ( UnsupportedVirtualizerFormatException e ) { + exceptions.put( "Not a VMware file", e ); + } + try { + return new VboxMetaData( osList, vmContent, length ); + } catch ( UnsupportedVirtualizerFormatException e ) { + exceptions.put( "Not a VirtualBox file", e ); + } + try { + return new QemuMetaData( osList, vmContent, length ); + } catch ( UnsupportedVirtualizerFormatException e ) { + exceptions.put( "Not a QEMU file", e ); + } + // TODO QEmu -- hack above expects qcow2 file, so we can't do anything here yet + LOGGER.error( "Could not detect any known virtualizer format" ); + for ( Entry<String, Exception> e : exceptions.entrySet() ) { + LOGGER.error( e.getKey(), e.getValue() ); + } + return null; + } + + public abstract boolean addHddTemplate( File diskImage, String hddMode, String redoDir ); + + public abstract boolean addHddTemplate( String diskImagePath, String hddMode, String redoDir ); + + public abstract boolean addDefaultNat(); + + public abstract void setOs( String vendorOsId ); + + public abstract boolean addDisplayName( String name ); + + public abstract boolean addRam( int mem ); + + public abstract void addFloppy( int index, String image, boolean readOnly ); + + public abstract boolean addCdrom( String image ); + + public abstract boolean addCpuCoreCount( int nrOfCores ); + + public abstract void setSoundCard( SoundCardType type ); + + public abstract SoundCardType getSoundCard(); + + public abstract void setDDAcceleration( DDAcceleration type ); + + public abstract DDAcceleration getDDAcceleration(); + + public abstract void setHWVersion( HWVersion type ); + + public abstract HWVersion getHWVersion(); + + public abstract void setEthernetDevType( int cardIndex, EthernetDevType type ); + + public abstract EthernetDevType getEthernetDevType( int cardIndex ); + + public abstract void setMaxUsbSpeed( UsbSpeed speed ); + + public abstract UsbSpeed getMaxUsbSpeed(); + + public abstract byte[] getDefinitionArray(); + + public abstract boolean addEthernet( EtherType type ); + + public abstract Virtualizer getVirtualizer(); + + public abstract boolean tweakForNonPersistent(); + + /** + * Function used to register virtual devices + */ + public abstract void registerVirtualHW(); } diff --git a/src/main/java/org/openslx/util/vm/VmwareMetaData.java b/src/main/java/org/openslx/util/vm/VmwareMetaData.java index c54ded8..fab90de 100644 --- a/src/main/java/org/openslx/util/vm/VmwareMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmwareMetaData.java @@ -55,505 +55,605 @@ class VmWareEthernetDevTypeMeta { } } -public class VmwareMetaData extends VmMetaData<VmWareSoundCardMeta, VmWareDDAccelMeta, VmWareHWVersionMeta, VmWareEthernetDevTypeMeta> { - - private static final Logger LOGGER = Logger.getLogger(VmwareMetaData.class); - - private static final Virtualizer virtualizer = new Virtualizer(TConst.VIRT_VMWARE, "VMware"); - - private static final Pattern hddKey = Pattern.compile("^(ide\\d|scsi\\d|sata\\d):?(\\d)?\\.(.*)", Pattern.CASE_INSENSITIVE); - - // Lowercase list of allowed settings for upload (as regex) - private static final Pattern[] whitelist; - - private final VmwareConfig config; - - // Init static members - static { - String[] list = {"^guestos", "^uuid\\.bios", "^config\\.version", "^ehci\\.", "^mks\\.enable3d", "^virtualhw\\.", "^sound\\.", "\\.pcislotnumber$", "^pcibridge", - "\\.virtualdev$", "^tools\\.syncTime$", "^time\\.synchronize", "^bios\\.bootDelay", "^rtc\\.", "^xhci\\."}; - whitelist = new Pattern[list.length]; - for (int i = 0; i < list.length; ++i) { - whitelist[i] = Pattern.compile(list[i].toLowerCase()); - } - } - - public static enum EthernetType { - NAT("vmnet1"), BRIDGED("vmnet0"), HOST_ONLY("vmnet2"); - - public final String vmnet; - - private EthernetType(String vnet) { - this.vmnet = vnet; - } - } - - private final Map<String, Controller> disks = new HashMap<>(); - - public VmwareMetaData(List<OperatingSystem> osList, File file) throws IOException, UnsupportedVirtualizerFormatException { - super(osList); - this.config = new VmwareConfig(file); - init(); - } - - public VmwareMetaData(List<OperatingSystem> osList, byte[] vmxContent, int length) throws UnsupportedVirtualizerFormatException { - super(osList); - this.config = new VmwareConfig(vmxContent, length); // still unfiltered - init(); // now filtered - } - - private void init() { - registerVirtualHW(); - - for (Entry<String, ConfigEntry> entry : config.entrySet()) { - handleLoadEntry(entry); - } - // if we find this tag, we already went through the hdd's - so we're done. - if (config.get("#SLX_HDD_BUS") != null) { - return; - } - // Now find the HDDs and add to list - for (Entry<String, Controller> cEntry : disks.entrySet()) { - Controller controller = cEntry.getValue(); - String controllerType = cEntry.getKey(); - if (!controller.present) { - continue; - } - for (Entry<String, Device> dEntry : controller.devices.entrySet()) { - Device device = dEntry.getValue(); - if (!device.present) { - continue; // Not present - } - if (device.deviceType != null && !device.deviceType.toLowerCase().endsWith("disk")) { - continue; // Not a HDD - } - DriveBusType bus = null; - if (controllerType.startsWith("ide")) { - bus = DriveBusType.IDE; - } else if (controllerType.startsWith("scsi")) { - bus = DriveBusType.SCSI; - } else if (controllerType.startsWith("sata")) { - bus = DriveBusType.SATA; - } - hdds.add(new HardDisk(controller.virtualDev, bus, device.filename)); - } - } - // TODO check if this machine is in a paused/suspended state - this.isMachineSnapshot = false; - - // Add HDD to cleaned vmx - if (!hdds.isEmpty()) { - HardDisk hdd = hdds.get(0); - addFiltered("#SLX_HDD_BUS", hdd.bus.toString()); - if (hdd.chipsetDriver != null) { - addFiltered("#SLX_HDD_CHIP", hdd.chipsetDriver); - } - } - } - - private void addFiltered(String key, String value) { - config.set(key, value).filtered(true); - } - - private boolean isSetAndTrue(String key) { - String value = config.get(key); - return value != null && value.equalsIgnoreCase("true"); - } - - private void handleLoadEntry(Entry<String, ConfigEntry> entry) { - String lowerKey = entry.getKey().toLowerCase(); - // Cleaned vmx construction - for (Pattern exp : whitelist) { - if (exp.matcher(lowerKey).find()) { - entry.getValue().filtered(true); - break; - } - } - // - // Dig Usable meta data - String value = entry.getValue().getValue(); - if (lowerKey.equals("guestos")) { - setOs(value); - return; - } - if (lowerKey.equals("displayname")) { - displayName = value; - return; - } - Matcher hdd = hddKey.matcher(entry.getKey()); - if (hdd.find()) { - handleHddEntry(hdd.group(1).toLowerCase(), hdd.group(2), hdd.group(3), value); - } - } - - private void handleHddEntry(String controllerStr, String deviceStr, String property, String value) { - Controller controller = disks.get(controllerStr); - if (controller == null) { - controller = new Controller(); - disks.put(controllerStr, controller); - } - if (deviceStr == null || deviceStr.isEmpty()) { - // Controller property - if (property.equalsIgnoreCase("present")) { - controller.present = Boolean.parseBoolean(value); - } else if (property.equalsIgnoreCase("virtualDev")) { - controller.virtualDev = value; - } - return; - } - // Device property - Device device = controller.devices.get(deviceStr); - if (device == null) { - device = new Device(); - controller.devices.put(deviceStr, device); - } - if (property.equalsIgnoreCase("deviceType")) { - device.deviceType = value; - } else if (property.equalsIgnoreCase("filename")) { - device.filename = value; - } else if (property.equalsIgnoreCase("present")) { - device.present = Boolean.parseBoolean(value); - } - } - - @Override - public boolean addHddTemplate(File diskImage, String hddMode, String redoDir) { - return addHddTemplate(diskImage.getName(), hddMode, redoDir); - } - - @Override - public boolean addHddTemplate(String diskImagePath, String hddMode, String redoDir) { - if (diskImagePath.isEmpty()) { - LOGGER.error("Empty disk image path given!"); - return false; - } - DriveBusType bus; - try { - bus = DriveBusType.valueOf(config.get("#SLX_HDD_BUS")); - } catch (Exception e) { - LOGGER.warn("Unknown bus type: " + config.get("#SLX_HDD_BUS") + ". Cannot add hdd config."); - return false; - } - String chipset = config.get("#SLX_HDD_CHIP"); - String prefix; - switch (bus) { - case IDE: - prefix = "ide0:0"; - addFiltered("ide0.present", "TRUE"); - break; - case SATA: - // Cannot happen?... use lsisas1068 - case SCSI: - prefix = "scsi0:0"; - addFiltered("scsi0.present", "TRUE"); - if (chipset != null) { - addFiltered("scsi0.virtualDev", chipset); - } - break; - default: - LOGGER.warn("Unknown HDD bus type: " + bus.toString()); - return false; - } - // Gen - addFiltered(prefix + ".present", "TRUE"); - addFiltered(prefix + ".deviceType", "disk"); - addFiltered(prefix + ".fileName", diskImagePath); - if (hddMode != null) { - addFiltered(prefix + ".mode", hddMode); - addFiltered(prefix + ".redo", ""); - addFiltered(prefix + ".redoLogDir", redoDir); - } - config.remove("#SLX_HDD_BUS"); - config.remove("#SLX_HDD_CHIP"); - return true; - } - - public boolean addDefaultNat() { - addFiltered("ethernet0.present", "TRUE"); - addFiltered("ethernet0.connectionType", "nat"); - return true; - } - - public boolean addEthernet(VmMetaData.EtherType type) { - boolean ret = false; - int index = 0; - for (;; ++index) { - if (config.get("ethernet" + index + ".present") == null) { - break; - } - } - switch (type) { - case NAT: - ret = addEthernet(index, EthernetType.NAT); - break; - case BRIDGED: - ret = addEthernet(index, EthernetType.BRIDGED); - break; - case HOST_ONLY: - ret = addEthernet(index, EthernetType.HOST_ONLY); - break; - default: - // Should not come to this... - break; - } - return ret; - } - - public boolean addEthernet(int index, EthernetType type) { - String ether = "ethernet" + index; - addFiltered(ether + ".present", "TRUE"); - addFiltered(ether + ".connectionType", "custom"); - addFiltered(ether + ".vnet", type.vmnet); - if (config.get(ether + ".virtualDev") == null) { - String dev = config.get("ethernet0.virtualDev"); - if (dev != null) { - addFiltered(ether + ".virtualDev", dev); - } - } - return true; - } - - public void addFloppy(int index, String image, boolean readOnly) { - String pre = "floppy" + index; - addFiltered(pre + ".present", "TRUE"); - if (image == null) { - addFiltered(pre + ".startConnected", "FALSE"); - addFiltered(pre + ".fileType", "device"); - config.remove(pre + ".fileName"); - config.remove(pre + ".readonly"); - addFiltered(pre + ".autodetect", "TRUE"); - } else { - addFiltered(pre + ".startConnected", "TRUE"); - addFiltered(pre + ".fileType", "file"); - addFiltered(pre + ".fileName", image); - addFiltered(pre + ".readonly", vmBoolean(readOnly)); - config.remove(pre + ".autodetect"); - } - } - - public boolean addCdrom(String image) { - for (String port : new String[]{"ide0:0", "ide0:1", "ide1:0", "ide1:1", "scsi0:1"}) { - if (!isSetAndTrue(port + ".present")) { - addFiltered(port + ".present", "TRUE"); - if (image == null) { - addFiltered(port + ".autodetect", "TRUE"); - addFiltered(port + ".deviceType", "cdrom-raw"); - config.remove(port + ".fileName"); - } else { - config.remove(port + ".autodetect"); - addFiltered(port + ".deviceType", "cdrom-image"); - addFiltered(port + ".fileName", image); - } - return true; - } - } - return false; - } - - private static String vmBoolean(boolean var) { - return Boolean.toString(var).toUpperCase(); - } - - private static String vmInteger(int val) { - return Integer.toString(val); - } - - @Override - public boolean disableSuspend() { - addFiltered("suspend.disabled", "TRUE"); - return true; - } - - @Override - public boolean addDisplayName(String name) { - addFiltered("displayName", name); - return true; - } - - @Override - public boolean addRam(int mem) { - addFiltered("memsize", Integer.toString(mem)); - return true; - } - - public void setOs(String vendorOsId) { - addFiltered("guestOS", vendorOsId); - setOs(TConst.VIRT_VMWARE, vendorOsId); - } - - @Override - public byte[] getFilteredDefinitionArray() { - return config.toString(true, false).getBytes(StandardCharsets.UTF_8); - } - - public byte[] getDefinitionArray() { - return config.toString(false, false).getBytes(StandardCharsets.UTF_8); - } - - @Override - public Virtualizer getVirtualizer() { - return virtualizer; - } - - private static class Device { - - public boolean present = false; - public String deviceType = null; - public String filename = null; - - @Override - public String toString() { - return filename + " is " + deviceType + " (present: " + present + ")"; - } - } - - private static class Controller { - - public boolean present = true; // Seems to be implicit, seen at least for IDE... - public String virtualDev = null; - Map<String, Device> devices = new HashMap<>(); - - @Override - public String toString() { - return virtualDev + " is (present: " + present + "): " + devices.toString(); - } - } - - @Override - public void enableUsb(boolean enabled) { - addFiltered("usb.present", vmBoolean(enabled)); - addFiltered("ehci.present", vmBoolean(enabled)); - } - - @Override - public void applySettingsForLocalEdit() { - addFiltered("gui.applyHostDisplayScalingToGuest", "FALSE"); - } - - public String getValue(String key) { - return config.get(key); - } - - public void setSoundCard(VmMetaData.SoundCardType type) { - VmWareSoundCardMeta soundCardMeta = soundCards.get(type); - addFiltered("sound.present", vmBoolean(soundCardMeta.isPresent)); - if (soundCardMeta.value != null) { - addFiltered("sound.virtualDev", soundCardMeta.value); - } else { - config.remove("sound.virtualDev"); - } - } - - public VmMetaData.SoundCardType getSoundCard() { - if (!isSetAndTrue("sound.present") || !isSetAndTrue("sound.autodetect")) { - return VmMetaData.SoundCardType.NONE; - } - String current = config.get("sound.virtualDev"); - if (current != null) { - VmWareSoundCardMeta soundCardMeta = null; - for (VmMetaData.SoundCardType type : VmMetaData.SoundCardType.values()) { - soundCardMeta = soundCards.get(type); - if (soundCardMeta != null) { - if (current.equals(soundCardMeta.value)) { - return type; - } - } - } - } - return VmMetaData.SoundCardType.DEFAULT; - } - - public void setDDAcceleration(VmMetaData.DDAcceleration type) { - VmWareDDAccelMeta ddaMeta = ddacc.get(type); - addFiltered("mks.enable3d", vmBoolean(ddaMeta.isPresent)); - } - - public VmMetaData.DDAcceleration getDDAcceleration() { - if (isSetAndTrue("mks.enable3d")) { - return VmMetaData.DDAcceleration.ON; - } else { - return VmMetaData.DDAcceleration.OFF; - } - } - - public void setHWVersion(VmMetaData.HWVersion type) { - VmWareHWVersionMeta hwVersionMeta = hwversion.get(type); - addFiltered("virtualHW.version", vmInteger(hwVersionMeta.version)); - } - - public VmMetaData.HWVersion getHWVersion() { - int currentValue = Util.parseInt(config.get("virtualHW.version"), -1); - VmWareHWVersionMeta hwVersionMeta = null; - for (VmMetaData.HWVersion ver : VmMetaData.HWVersion.values()) { - hwVersionMeta = hwversion.get(ver); - if (hwVersionMeta == null) { - continue; - } - if (currentValue == hwVersionMeta.version) { - return ver; - } - } - return HWVersion.NONE; - } - - public void setEthernetDevType(int cardIndex, VmMetaData.EthernetDevType type) { - VmWareEthernetDevTypeMeta ethernetDevTypeMeta = networkCards.get(type); - if (ethernetDevTypeMeta.value != null) { - addFiltered("ethernet" + cardIndex + ".virtualDev", ethernetDevTypeMeta.value); - } else { - config.remove("ethernet" + cardIndex + ".virtualDev"); - } - } - - public EthernetDevType getEthernetDevType(int cardIndex) { - String temp = config.get("ethernet" + cardIndex + ".virtualDev"); - if (temp != null) { - VmWareEthernetDevTypeMeta ethernetDevTypeMeta = null; - for (EthernetDevType type : VmMetaData.EthernetDevType.values()) { - ethernetDevTypeMeta = networkCards.get(type); - if (ethernetDevTypeMeta == null) { - continue; - } - if (temp.equals(ethernetDevTypeMeta.value)) { - return type; - } - } - } - return EthernetDevType.AUTO; - } - - @Override - public boolean addCpuCoreCount(int numCores) { - // TODO actually add the cpu core count to the machine description - return false; - } +class VmwareUsbSpeed +{ + public final String keyName; + public final int speedNumeric; + + public VmwareUsbSpeed( int speed, String key ) + { + this.keyName = key + ".present"; + this.speedNumeric = speed; + } +} - public void registerVirtualHW() { - soundCards.put(VmMetaData.SoundCardType.NONE, new VmWareSoundCardMeta(false, null)); - soundCards.put(VmMetaData.SoundCardType.DEFAULT, new VmWareSoundCardMeta(true, null)); - soundCards.put(VmMetaData.SoundCardType.SOUND_BLASTER, new VmWareSoundCardMeta(true, "sb16")); - soundCards.put(VmMetaData.SoundCardType.ES, new VmWareSoundCardMeta(true, "es1371")); - soundCards.put(VmMetaData.SoundCardType.HD_AUDIO, new VmWareSoundCardMeta(true, "hdaudio")); - - ddacc.put(VmMetaData.DDAcceleration.OFF, new VmWareDDAccelMeta(false)); - ddacc.put(VmMetaData.DDAcceleration.ON, new VmWareDDAccelMeta(true)); - - hwversion.put(VmMetaData.HWVersion.NONE, new VmWareHWVersionMeta(0)); - hwversion.put(VmMetaData.HWVersion.THREE, new VmWareHWVersionMeta(3)); - hwversion.put(VmMetaData.HWVersion.FOUR, new VmWareHWVersionMeta(4)); - hwversion.put(VmMetaData.HWVersion.SIX, new VmWareHWVersionMeta(6)); - hwversion.put(VmMetaData.HWVersion.SEVEN, new VmWareHWVersionMeta(7)); - hwversion.put(VmMetaData.HWVersion.EIGHT, new VmWareHWVersionMeta(8)); - hwversion.put(VmMetaData.HWVersion.NINE, new VmWareHWVersionMeta(9)); - hwversion.put(VmMetaData.HWVersion.TEN, new VmWareHWVersionMeta(10)); - hwversion.put(VmMetaData.HWVersion.ELEVEN, new VmWareHWVersionMeta(11)); - hwversion.put(VmMetaData.HWVersion.TWELVE, new VmWareHWVersionMeta(12)); - - networkCards.put(VmMetaData.EthernetDevType.AUTO, new VmWareEthernetDevTypeMeta(null)); - networkCards.put(VmMetaData.EthernetDevType.PCNET32, new VmWareEthernetDevTypeMeta("vlance")); - networkCards.put(VmMetaData.EthernetDevType.E1000, new VmWareEthernetDevTypeMeta("e1000")); - networkCards.put(VmMetaData.EthernetDevType.E1000E, new VmWareEthernetDevTypeMeta("e1000e")); - networkCards.put(VmMetaData.EthernetDevType.VMXNET, new VmWareEthernetDevTypeMeta("vmxnet")); - networkCards.put(VmMetaData.EthernetDevType.VMXNET3, new VmWareEthernetDevTypeMeta("vmxnet3")); - } +public class VmwareMetaData extends VmMetaData<VmWareSoundCardMeta, VmWareDDAccelMeta, VmWareHWVersionMeta, VmWareEthernetDevTypeMeta, VmwareUsbSpeed> +{ + + private static final Logger LOGGER = Logger.getLogger( VmwareMetaData.class ); + + private static final Virtualizer virtualizer = new Virtualizer( TConst.VIRT_VMWARE, "VMware" ); + + private static final Pattern hddKey = Pattern.compile( "^(ide\\d|scsi\\d|sata\\d):?(\\d)?\\.(.*)", Pattern.CASE_INSENSITIVE ); + + // Lowercase list of allowed settings for upload (as regex) + private static final Pattern[] whitelist; + + private final VmwareConfig config; + + // Init static members + static { + String[] list = { "^guestos", "^uuid\\.bios", "^config\\.version", "^ehci[.:]", "^mks\\.enable3d", "^virtualhw\\.", + "^sound[.:]", "\\.pcislotnumber$", "^pcibridge", "\\.virtualdev$", "^tools\\.syncTime$", "^time\\.synchronize", + "^bios\\.bootDelay", "^rtc\\.", "^xhci[.:]", "^usb_xhci[.:]", "\\.deviceType$", "\\.port$", "\\.parent$", "^usb[.:]", + "^firmware" }; + whitelist = new Pattern[ list.length ]; + for ( int i = 0; i < list.length; ++i ) { + whitelist[i] = Pattern.compile( list[i].toLowerCase() ); + } + } + + public static enum EthernetType + { + NAT( "vmnet1" ), BRIDGED( "vmnet0" ), HOST_ONLY( "vmnet2" ); + + public final String vmnet; + + private EthernetType( String vnet ) + { + this.vmnet = vnet; + } + } + + private final Map<String, Controller> disks = new HashMap<>(); + + public VmwareMetaData( List<OperatingSystem> osList, File file ) throws IOException, UnsupportedVirtualizerFormatException + { + super( osList ); + this.config = new VmwareConfig( file ); + init(); + } + + public VmwareMetaData( List<OperatingSystem> osList, byte[] vmxContent, int length ) throws UnsupportedVirtualizerFormatException + { + super( osList ); + this.config = new VmwareConfig( vmxContent, length ); // still unfiltered + init(); // now filtered + } + + private void init() + { + registerVirtualHW(); + + for ( Entry<String, ConfigEntry> entry : config.entrySet() ) { + handleLoadEntry( entry ); + } + // Fix accidentally filtered USB config if we see EHCI is present + if ( isSetAndTrue( "ehci.present" ) && !isSetAndTrue( "usb.present" ) ) { + addFiltered( "usb.present", "TRUE" ); + } + // if we find this tag, we already went through the hdd's - so we're done. + if ( config.get( "#SLX_HDD_BUS" ) != null ) { + return; + } + // Now find the HDDs and add to list + for ( Entry<String, Controller> cEntry : disks.entrySet() ) { + Controller controller = cEntry.getValue(); + String controllerType = cEntry.getKey(); + if ( !controller.present ) + continue; + for ( Entry<String, Device> dEntry : controller.devices.entrySet() ) { + Device device = dEntry.getValue(); + if ( !device.present ) + continue; // Not present + if ( device.deviceType != null && !device.deviceType.toLowerCase().endsWith( "disk" ) ) + continue; // Not a HDD + DriveBusType bus = null; + if ( controllerType.startsWith( "ide" ) ) { + bus = DriveBusType.IDE; + } else if ( controllerType.startsWith( "scsi" ) ) { + bus = DriveBusType.SCSI; + } else if ( controllerType.startsWith( "sata" ) ) { + bus = DriveBusType.SATA; + } + hdds.add( new HardDisk( controller.virtualDev, bus, device.filename ) ); + } + } + // TODO check if this machine is in a paused/suspended state + this.isMachineSnapshot = false; + + // Add HDD to cleaned vmx + if ( !hdds.isEmpty() ) { + HardDisk hdd = hdds.get( 0 ); + addFiltered( "#SLX_HDD_BUS", hdd.bus.toString() ); + if ( hdd.chipsetDriver != null ) { + addFiltered( "#SLX_HDD_CHIP", hdd.chipsetDriver ); + } + } + } + + private void addFiltered( String key, String value ) + { + config.set( key, value ).filtered( true ); + } + + private boolean isSetAndTrue( String key ) + { + String value = config.get( key ); + return value != null && value.equalsIgnoreCase( "true" ); + } + + private void handleLoadEntry( Entry<String, ConfigEntry> entry ) + { + String lowerKey = entry.getKey().toLowerCase(); + // Cleaned vmx construction + for ( Pattern exp : whitelist ) { + if ( exp.matcher( lowerKey ).find() ) { + entry.getValue().filtered( true ); + break; + } + } + // + // Dig Usable meta data + String value = entry.getValue().getValue(); + if ( lowerKey.equals( "guestos" ) ) { + setOs( value ); + return; + } + if ( lowerKey.equals( "displayname" ) ) { + displayName = value; + return; + } + Matcher hdd = hddKey.matcher( entry.getKey() ); + if ( hdd.find() ) { + handleHddEntry( hdd.group( 1 ).toLowerCase(), hdd.group( 2 ), hdd.group( 3 ), value ); + } + } + + private void handleHddEntry( String controllerStr, String deviceStr, String property, String value ) + { + Controller controller = disks.get( controllerStr ); + if ( controller == null ) { + controller = new Controller(); + disks.put( controllerStr, controller ); + } + if ( deviceStr == null || deviceStr.isEmpty() ) { + // Controller property + if ( property.equalsIgnoreCase( "present" ) ) { + controller.present = Boolean.parseBoolean( value ); + } else if ( property.equalsIgnoreCase( "virtualDev" ) ) { + controller.virtualDev = value; + } + return; + } + // Device property + Device device = controller.devices.get( deviceStr ); + if ( device == null ) { + device = new Device(); + controller.devices.put( deviceStr, device ); + } + if ( property.equalsIgnoreCase( "deviceType" ) ) { + device.deviceType = value; + } else if ( property.equalsIgnoreCase( "filename" ) ) { + device.filename = value; + } else if ( property.equalsIgnoreCase( "present" ) ) { + device.present = Boolean.parseBoolean( value ); + } + } + + @Override + public boolean addHddTemplate( File diskImage, String hddMode, String redoDir ) + { + return addHddTemplate( diskImage.getName(), hddMode, redoDir ); + } + + @Override + public boolean addHddTemplate( String diskImagePath, String hddMode, String redoDir ) + { + if ( diskImagePath.isEmpty() ) { + LOGGER.error( "Empty disk image path given!" ); + return false; + } + DriveBusType bus; + try { + bus = DriveBusType.valueOf( config.get( "#SLX_HDD_BUS" ) ); + } catch ( Exception e ) { + LOGGER.warn( "Unknown bus type: " + config.get( "#SLX_HDD_BUS" ) + ". Cannot add hdd config." ); + return false; + } + String chipset = config.get( "#SLX_HDD_CHIP" ); + String prefix; + switch ( bus ) { + case IDE: + prefix = "ide0:0"; + addFiltered( "ide0.present", "TRUE" ); + break; + case SATA: + // Cannot happen?... use lsisas1068 + case SCSI: + prefix = "scsi0:0"; + addFiltered( "scsi0.present", "TRUE" ); + if ( chipset != null ) { + addFiltered( "scsi0.virtualDev", chipset ); + } + break; + default: + LOGGER.warn( "Unknown HDD bus type: " + bus.toString() ); + return false; + } + // Gen + addFiltered( prefix + ".present", "TRUE" ); + addFiltered( prefix + ".deviceType", "disk" ); + addFiltered( prefix + ".fileName", diskImagePath ); + if ( hddMode != null ) { + addFiltered( prefix + ".mode", hddMode ); + addFiltered( prefix + ".redo", "" ); + addFiltered( prefix + ".redoLogDir", redoDir ); + } + config.remove( "#SLX_HDD_BUS" ); + config.remove( "#SLX_HDD_CHIP" ); + return true; + } + + public boolean addDefaultNat() + { + addFiltered( "ethernet0.present", "TRUE" ); + addFiltered( "ethernet0.connectionType", "nat" ); + return true; + } + + public boolean addEthernet( VmMetaData.EtherType type ) + { + boolean ret = false; + int index = 0; + for ( ;; ++index ) { + if ( config.get( "ethernet" + index + ".present" ) == null ) + break; + } + switch ( type ) { + case NAT: + ret = addEthernet( index, EthernetType.NAT ); + break; + case BRIDGED: + ret = addEthernet( index, EthernetType.BRIDGED ); + break; + case HOST_ONLY: + ret = addEthernet( index, EthernetType.HOST_ONLY ); + break; + default: + // Should not come to this... + break; + } + return ret; + } + + public boolean addEthernet( int index, EthernetType type ) + { + String ether = "ethernet" + index; + addFiltered( ether + ".present", "TRUE" ); + addFiltered( ether + ".connectionType", "custom" ); + addFiltered( ether + ".vnet", type.vmnet ); + if ( config.get( ether + ".virtualDev" ) == null ) { + String dev = config.get( "ethernet0.virtualDev" ); + if ( dev != null ) { + addFiltered( ether + ".virtualDev", dev ); + } + } + return true; + } + + public void addFloppy( int index, String image, boolean readOnly ) + { + String pre = "floppy" + index; + addFiltered( pre + ".present", "TRUE" ); + if ( image == null ) { + addFiltered( pre + ".startConnected", "FALSE" ); + addFiltered( pre + ".fileType", "device" ); + config.remove( pre + ".fileName" ); + config.remove( pre + ".readonly" ); + addFiltered( pre + ".autodetect", "TRUE" ); + } else { + addFiltered( pre + ".startConnected", "TRUE" ); + addFiltered( pre + ".fileType", "file" ); + addFiltered( pre + ".fileName", image ); + addFiltered( pre + ".readonly", vmBoolean( readOnly ) ); + config.remove( pre + ".autodetect" ); + } + } + + public boolean addCdrom( String image ) + { + for ( String port : new String[] { "ide0:0", "ide0:1", "ide1:0", "ide1:1", "scsi0:1" } ) { + if ( !isSetAndTrue( port + ".present" ) ) { + addFiltered( port + ".present", "TRUE" ); + if ( image == null ) { + addFiltered( port + ".autodetect", "TRUE" ); + addFiltered( port + ".deviceType", "cdrom-raw" ); + config.remove( port + ".fileName" ); + } else { + config.remove( port + ".autodetect" ); + addFiltered( port + ".deviceType", "cdrom-image" ); + addFiltered( port + ".fileName", image ); + } + return true; + } + } + return false; + } + + private static String vmBoolean( boolean var ) + { + return Boolean.toString( var ).toUpperCase(); + } + + private static String vmInteger( int val ) + { + return Integer.toString( val ); + } + + @Override + public boolean tweakForNonPersistent() + { + addFiltered( "suspend.disabled", "TRUE" ); + return true; + } + + @Override + public boolean addDisplayName( String name ) + { + addFiltered( "displayName", name ); + return true; + } + + @Override + public boolean addRam( int mem ) + { + addFiltered( "memsize", Integer.toString( mem ) ); + return true; + } + + public void setOs( String vendorOsId ) + { + addFiltered( "guestOS", vendorOsId ); + setOs( TConst.VIRT_VMWARE, vendorOsId ); + } + + @Override + public byte[] getFilteredDefinitionArray() + { + return config.toString( true, false ).getBytes( StandardCharsets.UTF_8 ); + } + + public byte[] getDefinitionArray() + { + return config.toString( false, false ).getBytes( StandardCharsets.UTF_8 ); + } + + @Override + public Virtualizer getVirtualizer() + { + return virtualizer; + } + + private static class Device + { + public boolean present = false; + public String deviceType = null; + public String filename = null; + + @Override + public String toString() + { + return filename + " is " + deviceType + " (present: " + present + ")"; + } + } + + private static class Controller + { + public boolean present = true; // Seems to be implicit, seen at least for IDE... + public String virtualDev = null; + Map<String, Device> devices = new HashMap<>(); + + @Override + public String toString() + { + return virtualDev + " is (present: " + present + "): " + devices.toString(); + } + } + + @Override + public void applySettingsForLocalEdit() + { + addFiltered( "gui.applyHostDisplayScalingToGuest", "FALSE" ); + } + + public String getValue( String key ) + { + return config.get( key ); + } + + public void setSoundCard( VmMetaData.SoundCardType type ) + { + VmWareSoundCardMeta soundCardMeta = soundCards.get( type ); + addFiltered( "sound.present", vmBoolean( soundCardMeta.isPresent ) ); + if ( soundCardMeta.value != null ) { + addFiltered( "sound.virtualDev", soundCardMeta.value ); + } else { + config.remove( "sound.virtualDev" ); + } + } + + public VmMetaData.SoundCardType getSoundCard() + { + if ( !isSetAndTrue( "sound.present" ) || !isSetAndTrue( "sound.autodetect" ) ) { + return VmMetaData.SoundCardType.NONE; + } + String current = config.get( "sound.virtualDev" ); + if ( current != null ) { + VmWareSoundCardMeta soundCardMeta = null; + for ( VmMetaData.SoundCardType type : VmMetaData.SoundCardType.values() ) { + soundCardMeta = soundCards.get( type ); + if ( soundCardMeta != null ) { + if ( current.equals( soundCardMeta.value ) ) { + return type; + } + } + } + } + return VmMetaData.SoundCardType.DEFAULT; + } + + public void setDDAcceleration( VmMetaData.DDAcceleration type ) + { + VmWareDDAccelMeta ddaMeta = ddacc.get( type ); + addFiltered( "mks.enable3d", vmBoolean( ddaMeta.isPresent ) ); + } + + public VmMetaData.DDAcceleration getDDAcceleration() + { + if ( isSetAndTrue( "mks.enable3d" ) ) { + return VmMetaData.DDAcceleration.ON; + } else { + return VmMetaData.DDAcceleration.OFF; + } + } + + public void setHWVersion( VmMetaData.HWVersion type ) + { + VmWareHWVersionMeta hwVersionMeta = hwversion.get( type ); + addFiltered( "virtualHW.version", vmInteger( hwVersionMeta.version ) ); + } + + public VmMetaData.HWVersion getHWVersion() + { + int currentValue = Util.parseInt( config.get( "virtualHW.version" ), -1 ); + VmWareHWVersionMeta hwVersionMeta = null; + for ( VmMetaData.HWVersion ver : VmMetaData.HWVersion.values() ) { + hwVersionMeta = hwversion.get( ver ); + if ( hwVersionMeta == null ) { + continue; + } + if ( currentValue == hwVersionMeta.version ) { + return ver; + } + } + return HWVersion.NONE; + } + + public void setEthernetDevType( int cardIndex, VmMetaData.EthernetDevType type ) + { + VmWareEthernetDevTypeMeta ethernetDevTypeMeta = networkCards.get( type ); + if ( ethernetDevTypeMeta.value != null ) { + addFiltered( "ethernet" + cardIndex + ".virtualDev", ethernetDevTypeMeta.value ); + } else { + config.remove( "ethernet" + cardIndex + ".virtualDev" ); + } + } + + public VmMetaData.EthernetDevType getEthernetDevType( int cardIndex ) + { + String temp = config.get( "ethernet" + cardIndex + ".virtualDev" ); + if ( temp != null ) { + VmWareEthernetDevTypeMeta ethernetDevTypeMeta = null; + for ( VmMetaData.EthernetDevType type : VmMetaData.EthernetDevType.values() ) { + ethernetDevTypeMeta = networkCards.get( type ); + if ( ethernetDevTypeMeta == null ) { + continue; + } + if ( temp.equals( ethernetDevTypeMeta.value ) ) { + return type; + } + } + } + return VmMetaData.EthernetDevType.AUTO; + } + + @Override + public void setMaxUsbSpeed( VmMetaData.UsbSpeed newSpeed ) + { + if ( newSpeed == null ) { + newSpeed = VmMetaData.UsbSpeed.NONE; + } + VmwareUsbSpeed newSpeedMeta = usbSpeeds.get( newSpeed ); + if ( newSpeedMeta == null ) { + throw new RuntimeException( "USB Speed " + newSpeed.name() + " not registered with VMware" ); + } + for ( VmwareUsbSpeed meta : usbSpeeds.values() ) { + if ( meta == null ) + continue; // Should not happen + if ( meta.keyName == null ) + continue; // "No USB" has no config entry, obviously + if ( meta.speedNumeric <= newSpeedMeta.speedNumeric ) { + // Enable desired speed class, plus all lower ones + addFiltered( meta.keyName, "TRUE" ); + } else { + // This one is higher – remove + config.remove( meta.keyName ); + } + } + // VMware 14+ needs this to use USB 3.0 devices at USB 3.0 ports in VMs configured for < 3.0 + if ( newSpeedMeta.speedNumeric > 0 && newSpeedMeta.speedNumeric < 3 ) { + addFiltered( "usb.mangleUsb3Speed", "TRUE" ); + } + } + + @Override + public VmMetaData.UsbSpeed getMaxUsbSpeed() + { + int max = 0; + VmMetaData.UsbSpeed maxEnum = VmMetaData.UsbSpeed.NONE; + for ( Entry<VmMetaData.UsbSpeed, VmwareUsbSpeed> entry : usbSpeeds.entrySet() ) { + VmwareUsbSpeed v = entry.getValue(); + if ( v.speedNumeric > max && isSetAndTrue( v.keyName ) ) { + max = v.speedNumeric; + maxEnum = entry.getKey(); + } + } + return maxEnum; + } + + @Override + public boolean addCpuCoreCount( int numCores ) + { + // TODO actually add the cpu core count to the machine description + return false; + } + + public void registerVirtualHW() + { + soundCards.put( VmMetaData.SoundCardType.NONE, new VmWareSoundCardMeta( false, null ) ); + soundCards.put( VmMetaData.SoundCardType.DEFAULT, new VmWareSoundCardMeta( true, null ) ); + soundCards.put( VmMetaData.SoundCardType.SOUND_BLASTER, new VmWareSoundCardMeta( true, "sb16" ) ); + soundCards.put( VmMetaData.SoundCardType.ES, new VmWareSoundCardMeta( true, "es1371" ) ); + soundCards.put( VmMetaData.SoundCardType.HD_AUDIO, new VmWareSoundCardMeta( true, "hdaudio" ) ); + + ddacc.put( VmMetaData.DDAcceleration.OFF, new VmWareDDAccelMeta( false ) ); + ddacc.put( VmMetaData.DDAcceleration.ON, new VmWareDDAccelMeta( true ) ); + + hwversion.put( VmMetaData.HWVersion.NONE, new VmWareHWVersionMeta( 0 ) ); + hwversion.put( VmMetaData.HWVersion.THREE, new VmWareHWVersionMeta( 3 ) ); + hwversion.put( VmMetaData.HWVersion.FOUR, new VmWareHWVersionMeta( 4 ) ); + hwversion.put( VmMetaData.HWVersion.SIX, new VmWareHWVersionMeta( 6 ) ); + hwversion.put( VmMetaData.HWVersion.SEVEN, new VmWareHWVersionMeta( 7 ) ); + hwversion.put( VmMetaData.HWVersion.EIGHT, new VmWareHWVersionMeta( 8 ) ); + hwversion.put( VmMetaData.HWVersion.NINE, new VmWareHWVersionMeta( 9 ) ); + hwversion.put( VmMetaData.HWVersion.TEN, new VmWareHWVersionMeta( 10 ) ); + hwversion.put( VmMetaData.HWVersion.ELEVEN, new VmWareHWVersionMeta( 11 ) ); + hwversion.put( VmMetaData.HWVersion.TWELVE, new VmWareHWVersionMeta( 12 ) ); + hwversion.put( VmMetaData.HWVersion.FOURTEEN, new VmWareHWVersionMeta( 14 ) ); + hwversion.put( VmMetaData.HWVersion.FIFTEEN, new VmWareHWVersionMeta( 15 ) ); + hwversion.put( VmMetaData.HWVersion.FIFTEEN_ONE, new VmWareHWVersionMeta( 16 ) ); + + networkCards.put( VmMetaData.EthernetDevType.AUTO, new VmWareEthernetDevTypeMeta( null ) ); + networkCards.put( VmMetaData.EthernetDevType.PCNET32, new VmWareEthernetDevTypeMeta( "vlance" ) ); + networkCards.put( VmMetaData.EthernetDevType.E1000, new VmWareEthernetDevTypeMeta( "e1000" ) ); + networkCards.put( VmMetaData.EthernetDevType.E1000E, new VmWareEthernetDevTypeMeta( "e1000e" ) ); + networkCards.put( VmMetaData.EthernetDevType.VMXNET, new VmWareEthernetDevTypeMeta( "vmxnet" ) ); + networkCards.put( VmMetaData.EthernetDevType.VMXNET3, new VmWareEthernetDevTypeMeta( "vmxnet3" ) ); + + usbSpeeds.put( VmMetaData.UsbSpeed.NONE, new VmwareUsbSpeed( 0, null )); + usbSpeeds.put( VmMetaData.UsbSpeed.USB1_1, new VmwareUsbSpeed( 1, "usb" ) ); + usbSpeeds.put( VmMetaData.UsbSpeed.USB2_0, new VmwareUsbSpeed( 2, "ehci" ) ); + usbSpeeds.put( VmMetaData.UsbSpeed.USB3_0, new VmwareUsbSpeed( 3, "usb_xhci" ) ); + } } diff --git a/src/main/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift index 0d82503..94afcf1 100644 --- a/src/main/thrift/bwlp.thrift +++ b/src/main/thrift/bwlp.thrift @@ -76,6 +76,13 @@ enum NetShareAuth { OTHER_USER } +enum SscMode { + OFF, + ON, + AUTO, + USER, +} + // ############## STRUCT ############### struct UserInfo { @@ -186,6 +193,8 @@ struct ImageSummaryRead { 17: bool isTemplate, 18: ImagePermissions defaultPermissions, 19: optional ImagePermissions userPermissions, + 21: optional i64 fileSizeSum, + 22: optional i32 versionCount, } struct ImageVersionDetails { @@ -259,9 +268,23 @@ struct LdapFilter { 4: optional string title, } +struct PresetRunScript { + 1: i32 scriptId, + 2: string displayname, + 3: list<i32> osIds, +} + +struct PresetNetRule { + 1: i32 ruleId, + 2: string displayName, + 3: list<NetRule> netRules, +} + struct PredefinedData { 1: list<NetShare> netShares, 2: list<LdapFilter> ldapFilter, + 3: list<PresetRunScript> runScripts, + 4: list<PresetNetRule> networkExceptions, } // Write lecture to sat. if optional fields are not set or null, their value stays unchanged @@ -287,6 +310,8 @@ struct LectureWrite { 20: bool hasUsbAccess, 21: optional list<NetShare> networkShares, 22: optional list<LdapFilter> ldapFilters, + 23: optional list<i32> presetScriptIds, + 24: optional list<i32> presetNetworkExceptionIds, } struct LectureSummary { @@ -339,6 +364,10 @@ struct LectureRead { 28: bool hasUsbAccess, 29: optional list<NetShare> networkShares, 30: optional list<LdapFilter> ldapFilters, + 31: optional list<i32> presetScriptIds, + 32: optional list<i32> presetNetworkShares, + 33: optional list<i32> presetLdapFilters, + 34: optional list<i32> presetNetworkExceptionIds, } struct MasterTag { @@ -390,6 +419,8 @@ struct SatelliteConfig { 8: optional i32 maxLocationsPerLecture, // Whether users connecting to the sat for the first time are allowed to login 9: optional bool allowLoginByDefault, + // ServerSide Copy on, off, auto or controlled by user + 10: optional SscMode serverSideCopy, } struct SatelliteStatus { |