From 2c7fb53e256f9562a74dd5eca567327774b1d9de Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 5 Dec 2018 13:37:32 +0100 Subject: Unify JSON serializer thrift/nonthrift --- src/main/java/org/openslx/util/Json.java | 139 +++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/openslx/util/Json.java b/src/main/java/org/openslx/util/Json.java index 84dc22b..d9fb659 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,47 @@ public class Json { /** * Global static instance. The Gson object is thread-safe. */ - private static final Gson gson = new Gson(); + private static final AtomicReference gsonRef = new AtomicReference<>(); private static final GsonBuilder gsonThriftBuilder = new GsonBuilder(); - - public static void registerThriftClass(Class thriftClass) { - if (!TBase.class.isAssignableFrom(thriftClass)) - throw new IllegalArgumentException(thriftClass.getName() + " is not a thrift struct."); - gsonThriftBuilder.registerTypeAdapter(thriftClass, new ThriftDeserializer(thriftClass)); + + public static > void registerThriftClass(Class thriftClass) { + // Determine all relevant fields + Field[] fieldArray = thriftClass.getFields(); + List 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 { + fields.add( new ThriftField( field, + thriftClass.getMethod( "get" + upperName ), + thriftClass.getMethod( "set" + upperName, field.getType() ), + thriftClass.getMethod( "isSet" + upperName) ) ); + } catch (NoSuchMethodException e) { + // Not a thrift field, apparently + } + } + synchronized ( Json.class ) { + gsonThriftBuilder.registerTypeAdapter(thriftClass, new JsonThriftHandler(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 +83,13 @@ public class Json { */ public static T deserialize(String data, Class 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 deserializeThrift(String data, Class 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 +98,16 @@ public class Json { * @return JSON formatted represenatation of object */ public static String serialize(Object object) { - return gson.toJson(object); + return getInstance().toJson(object); } - private static class ThriftDeserializer implements JsonDeserializer { + private static class JsonThriftHandler implements JsonDeserializer, JsonSerializer { private final Class clazz; + private final List fields; - public ThriftDeserializer(Class classOfData) { + public JsonThriftHandler(Class classOfData, List fields) { this.clazz = classOfData; + this.fields = fields; } @Override @@ -88,34 +119,68 @@ public class Json { 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()); + 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 { + if ( !(Boolean)thrift.isset.invoke( thriftClass ) ) + 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; + } } } -- cgit v1.2.3-55-g7522 From f01a417c81a63b809ef788107c391f75c26ff99d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 7 Dec 2018 16:01:15 +0100 Subject: Update to RPC version 5, break compat Add some stuff while we're at it.. --- .../bwlp/thrift/iface/ImageSummaryRead.java | 210 ++++++++++++++++++++- .../org/openslx/sat/thrift/version/Feature.java | 29 --- .../org/openslx/sat/thrift/version/Version.java | 4 +- src/main/thrift/bwlp.thrift | 2 + 4 files changed, 209 insertions(+), 36 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, java.io.Serializable, Cloneable, Comparable { 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, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -87,6 +89,8 @@ public class ImageSummaryRead implements org.apache.thrift.TBase byName = new HashMap(); @@ -165,6 +171,10 @@ public class ImageSummaryRead implements org.apache.thrift.TBase 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, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("LectureRead"); @@ -67,6 +67,7 @@ public class LectureRead implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -103,6 +104,7 @@ public class LectureRead implements org.apache.thrift.TBase networkShares; // optional public List ldapFilters; // optional + public List presetScriptIds; // 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 +136,8 @@ public class LectureRead implements org.apache.thrift.TBase byName = new HashMap(); @@ -207,6 +210,8 @@ public class LectureRead implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -329,6 +334,9 @@ public class LectureRead implements org.apache.thrift.TBase __this__presetScriptIds = new ArrayList(other.presetScriptIds); + this.presetScriptIds = __this__presetScriptIds; + } } public LectureRead deepCopy() { @@ -537,6 +549,7 @@ public class LectureRead implements org.apache.thrift.TBase getPresetScriptIdsIterator() { + return (this.presetScriptIds == null) ? null : this.presetScriptIds.iterator(); + } + + public void addToPresetScriptIds(int elem) { + if (this.presetScriptIds == null) { + this.presetScriptIds = new ArrayList(); + } + this.presetScriptIds.add(elem); + } + + public List getPresetScriptIds() { + return this.presetScriptIds; + } + + public LectureRead setPresetScriptIds(List 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 void setFieldValue(_Fields field, Object value) { switch (field) { case LECTURE_ID: @@ -1546,6 +1598,14 @@ public class LectureRead implements org.apache.thrift.TBase)value); + } + break; + } } @@ -1638,6 +1698,9 @@ public class LectureRead implements org.apache.thrift.TBase(_list146.size); - String _elem147; - for (int _i148 = 0; _i148 < _list146.size; ++_i148) + org.apache.thrift.protocol.TList _list186 = iprot.readListBegin(); + struct.nics = new ArrayList(_list186.size); + String _elem187; + for (int _i188 = 0; _i188 < _list186.size; ++_i188) { - _elem147 = iprot.readString(); - struct.nics.add(_elem147); + _elem187 = iprot.readString(); + struct.nics.add(_elem187); } iprot.readListEnd(); } @@ -2843,13 +2942,13 @@ public class LectureRead implements org.apache.thrift.TBase(_list149.size); - String _elem150; - for (int _i151 = 0; _i151 < _list149.size; ++_i151) + org.apache.thrift.protocol.TList _list189 = iprot.readListBegin(); + struct.allowedUsers = new ArrayList(_list189.size); + String _elem190; + for (int _i191 = 0; _i191 < _list189.size; ++_i191) { - _elem150 = iprot.readString(); - struct.allowedUsers.add(_elem150); + _elem190 = iprot.readString(); + struct.allowedUsers.add(_elem190); } iprot.readListEnd(); } @@ -2861,14 +2960,14 @@ public class LectureRead implements org.apache.thrift.TBase(_list152.size); - NetRule _elem153; - for (int _i154 = 0; _i154 < _list152.size; ++_i154) + org.apache.thrift.protocol.TList _list192 = iprot.readListBegin(); + struct.networkExceptions = new ArrayList(_list192.size); + NetRule _elem193; + for (int _i194 = 0; _i194 < _list192.size; ++_i194) { - _elem153 = new NetRule(); - _elem153.read(iprot); - struct.networkExceptions.add(_elem153); + _elem193 = new NetRule(); + _elem193.read(iprot); + struct.networkExceptions.add(_elem193); } iprot.readListEnd(); } @@ -2914,13 +3013,13 @@ public class LectureRead implements org.apache.thrift.TBase(_list155.size); - int _elem156; - for (int _i157 = 0; _i157 < _list155.size; ++_i157) + org.apache.thrift.protocol.TList _list195 = iprot.readListBegin(); + struct.locationIds = new ArrayList(_list195.size); + int _elem196; + for (int _i197 = 0; _i197 < _list195.size; ++_i197) { - _elem156 = iprot.readI32(); - struct.locationIds.add(_elem156); + _elem196 = iprot.readI32(); + struct.locationIds.add(_elem196); } iprot.readListEnd(); } @@ -2956,14 +3055,14 @@ public class LectureRead implements org.apache.thrift.TBase(_list158.size); - NetShare _elem159; - for (int _i160 = 0; _i160 < _list158.size; ++_i160) + org.apache.thrift.protocol.TList _list198 = iprot.readListBegin(); + struct.networkShares = new ArrayList(_list198.size); + NetShare _elem199; + for (int _i200 = 0; _i200 < _list198.size; ++_i200) { - _elem159 = new NetShare(); - _elem159.read(iprot); - struct.networkShares.add(_elem159); + _elem199 = new NetShare(); + _elem199.read(iprot); + struct.networkShares.add(_elem199); } iprot.readListEnd(); } @@ -2975,14 +3074,14 @@ public class LectureRead implements org.apache.thrift.TBase(_list161.size); - LdapFilter _elem162; - for (int _i163 = 0; _i163 < _list161.size; ++_i163) + org.apache.thrift.protocol.TList _list201 = iprot.readListBegin(); + struct.ldapFilters = new ArrayList(_list201.size); + LdapFilter _elem202; + for (int _i203 = 0; _i203 < _list201.size; ++_i203) { - _elem162 = new LdapFilter(); - _elem162.read(iprot); - struct.ldapFilters.add(_elem162); + _elem202 = new LdapFilter(); + _elem202.read(iprot); + struct.ldapFilters.add(_elem202); } iprot.readListEnd(); } @@ -2991,6 +3090,24 @@ public class LectureRead implements org.apache.thrift.TBase(_list204.size); + int _elem205; + for (int _i206 = 0; _i206 < _list204.size; ++_i206) + { + _elem205 = iprot.readI32(); + struct.presetScriptIds.add(_elem205); + } + iprot.readListEnd(); + } + struct.setPresetScriptIdsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -3058,9 +3175,9 @@ public class LectureRead implements org.apache.thrift.TBase(_list176.size); - String _elem177; - for (int _i178 = 0; _i178 < _list176.size; ++_i178) + org.apache.thrift.protocol.TList _list221 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.nics = new ArrayList(_list221.size); + String _elem222; + for (int _i223 = 0; _i223 < _list221.size; ++_i223) { - _elem177 = iprot.readString(); - struct.nics.add(_elem177); + _elem222 = iprot.readString(); + struct.nics.add(_elem222); } } 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(_list179.size); - String _elem180; - for (int _i181 = 0; _i181 < _list179.size; ++_i181) + org.apache.thrift.protocol.TList _list224 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.allowedUsers = new ArrayList(_list224.size); + String _elem225; + for (int _i226 = 0; _i226 < _list224.size; ++_i226) { - _elem180 = iprot.readString(); - struct.allowedUsers.add(_elem180); + _elem225 = iprot.readString(); + struct.allowedUsers.add(_elem225); } } 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(_list182.size); - NetRule _elem183; - for (int _i184 = 0; _i184 < _list182.size; ++_i184) + org.apache.thrift.protocol.TList _list227 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkExceptions = new ArrayList(_list227.size); + NetRule _elem228; + for (int _i229 = 0; _i229 < _list227.size; ++_i229) { - _elem183 = new NetRule(); - _elem183.read(iprot); - struct.networkExceptions.add(_elem183); + _elem228 = new NetRule(); + _elem228.read(iprot); + struct.networkExceptions.add(_elem228); } } struct.setNetworkExceptionsIsSet(true); @@ -3532,13 +3675,13 @@ public class LectureRead implements org.apache.thrift.TBase(_list185.size); - int _elem186; - for (int _i187 = 0; _i187 < _list185.size; ++_i187) + org.apache.thrift.protocol.TList _list230 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.locationIds = new ArrayList(_list230.size); + int _elem231; + for (int _i232 = 0; _i232 < _list230.size; ++_i232) { - _elem186 = iprot.readI32(); - struct.locationIds.add(_elem186); + _elem231 = iprot.readI32(); + struct.locationIds.add(_elem231); } } struct.setLocationIdsIsSet(true); @@ -3557,32 +3700,45 @@ public class LectureRead implements org.apache.thrift.TBase(_list188.size); - NetShare _elem189; - for (int _i190 = 0; _i190 < _list188.size; ++_i190) + org.apache.thrift.protocol.TList _list233 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkShares = new ArrayList(_list233.size); + NetShare _elem234; + for (int _i235 = 0; _i235 < _list233.size; ++_i235) { - _elem189 = new NetShare(); - _elem189.read(iprot); - struct.networkShares.add(_elem189); + _elem234 = new NetShare(); + _elem234.read(iprot); + struct.networkShares.add(_elem234); } } 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(_list191.size); - LdapFilter _elem192; - for (int _i193 = 0; _i193 < _list191.size; ++_i193) + org.apache.thrift.protocol.TList _list236 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilters = new ArrayList(_list236.size); + LdapFilter _elem237; + for (int _i238 = 0; _i238 < _list236.size; ++_i238) { - _elem192 = new LdapFilter(); - _elem192.read(iprot); - struct.ldapFilters.add(_elem192); + _elem237 = new LdapFilter(); + _elem237.read(iprot); + struct.ldapFilters.add(_elem237); } } struct.setLdapFiltersIsSet(true); } + if (incoming.get(29)) { + { + org.apache.thrift.protocol.TList _list239 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetScriptIds = new ArrayList(_list239.size); + int _elem240; + for (int _i241 = 0; _i241 < _list239.size; ++_i241) + { + _elem240 = iprot.readI32(); + struct.presetScriptIds.add(_elem240); + } + } + struct.setPresetScriptIdsIsSet(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..dfdc415 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 = "2018-12-08") public class LectureWrite implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("LectureWrite"); @@ -59,6 +59,7 @@ public class LectureWrite implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -87,6 +88,7 @@ public class LectureWrite implements org.apache.thrift.TBase networkShares; // optional public List ldapFilters; // optional + public List presetScriptIds; // 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 +112,8 @@ public class LectureWrite implements org.apache.thrift.TBase byName = new HashMap(); @@ -167,6 +170,8 @@ public class LectureWrite implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -270,6 +275,9 @@ public class LectureWrite implements org.apache.thrift.TBase __this__presetScriptIds = new ArrayList(other.presetScriptIds); + this.presetScriptIds = __this__presetScriptIds; + } } public LectureWrite deepCopy() { @@ -427,6 +439,7 @@ public class LectureWrite implements org.apache.thrift.TBase getPresetScriptIdsIterator() { + return (this.presetScriptIds == null) ? null : this.presetScriptIds.iterator(); + } + + public void addToPresetScriptIds(int elem) { + if (this.presetScriptIds == null) { + this.presetScriptIds = new ArrayList(); + } + this.presetScriptIds.add(elem); + } + + public List getPresetScriptIds() { + return this.presetScriptIds; + } + + public LectureWrite setPresetScriptIds(List 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 void setFieldValue(_Fields field, Object value) { switch (field) { case LECTURE_NAME: @@ -1199,6 +1251,14 @@ public class LectureWrite implements org.apache.thrift.TBase)value); + } + break; + } } @@ -1267,6 +1327,9 @@ public class LectureWrite implements org.apache.thrift.TBase(_list90.size); - String _elem91; - for (int _i92 = 0; _i92 < _list90.size; ++_i92) + org.apache.thrift.protocol.TList _list122 = iprot.readListBegin(); + struct.nics = new ArrayList(_list122.size); + String _elem123; + for (int _i124 = 0; _i124 < _list122.size; ++_i124) { - _elem91 = iprot.readString(); - struct.nics.add(_elem91); + _elem123 = iprot.readString(); + struct.nics.add(_elem123); } iprot.readListEnd(); } @@ -2153,14 +2252,14 @@ public class LectureWrite implements org.apache.thrift.TBase(_list93.size); - NetRule _elem94; - for (int _i95 = 0; _i95 < _list93.size; ++_i95) + org.apache.thrift.protocol.TList _list125 = iprot.readListBegin(); + struct.networkExceptions = new ArrayList(_list125.size); + NetRule _elem126; + for (int _i127 = 0; _i127 < _list125.size; ++_i127) { - _elem94 = new NetRule(); - _elem94.read(iprot); - struct.networkExceptions.add(_elem94); + _elem126 = new NetRule(); + _elem126.read(iprot); + struct.networkExceptions.add(_elem126); } iprot.readListEnd(); } @@ -2197,13 +2296,13 @@ public class LectureWrite implements org.apache.thrift.TBase(_list96.size); - String _elem97; - for (int _i98 = 0; _i98 < _list96.size; ++_i98) + org.apache.thrift.protocol.TList _list128 = iprot.readListBegin(); + struct.addAllowedUsers = new ArrayList(_list128.size); + String _elem129; + for (int _i130 = 0; _i130 < _list128.size; ++_i130) { - _elem97 = iprot.readString(); - struct.addAllowedUsers.add(_elem97); + _elem129 = iprot.readString(); + struct.addAllowedUsers.add(_elem129); } iprot.readListEnd(); } @@ -2215,13 +2314,13 @@ public class LectureWrite implements org.apache.thrift.TBase(_list99.size); - String _elem100; - for (int _i101 = 0; _i101 < _list99.size; ++_i101) + org.apache.thrift.protocol.TList _list131 = iprot.readListBegin(); + struct.remAllowedUsers = new ArrayList(_list131.size); + String _elem132; + for (int _i133 = 0; _i133 < _list131.size; ++_i133) { - _elem100 = iprot.readString(); - struct.remAllowedUsers.add(_elem100); + _elem132 = iprot.readString(); + struct.remAllowedUsers.add(_elem132); } iprot.readListEnd(); } @@ -2233,13 +2332,13 @@ public class LectureWrite implements org.apache.thrift.TBase(_list102.size); - int _elem103; - for (int _i104 = 0; _i104 < _list102.size; ++_i104) + org.apache.thrift.protocol.TList _list134 = iprot.readListBegin(); + struct.locationIds = new ArrayList(_list134.size); + int _elem135; + for (int _i136 = 0; _i136 < _list134.size; ++_i136) { - _elem103 = iprot.readI32(); - struct.locationIds.add(_elem103); + _elem135 = iprot.readI32(); + struct.locationIds.add(_elem135); } iprot.readListEnd(); } @@ -2275,14 +2374,14 @@ public class LectureWrite implements org.apache.thrift.TBase(_list105.size); - NetShare _elem106; - for (int _i107 = 0; _i107 < _list105.size; ++_i107) + org.apache.thrift.protocol.TList _list137 = iprot.readListBegin(); + struct.networkShares = new ArrayList(_list137.size); + NetShare _elem138; + for (int _i139 = 0; _i139 < _list137.size; ++_i139) { - _elem106 = new NetShare(); - _elem106.read(iprot); - struct.networkShares.add(_elem106); + _elem138 = new NetShare(); + _elem138.read(iprot); + struct.networkShares.add(_elem138); } iprot.readListEnd(); } @@ -2294,14 +2393,14 @@ public class LectureWrite implements org.apache.thrift.TBase(_list108.size); - LdapFilter _elem109; - for (int _i110 = 0; _i110 < _list108.size; ++_i110) + org.apache.thrift.protocol.TList _list140 = iprot.readListBegin(); + struct.ldapFilters = new ArrayList(_list140.size); + LdapFilter _elem141; + for (int _i142 = 0; _i142 < _list140.size; ++_i142) { - _elem109 = new LdapFilter(); - _elem109.read(iprot); - struct.ldapFilters.add(_elem109); + _elem141 = new LdapFilter(); + _elem141.read(iprot); + struct.ldapFilters.add(_elem141); } iprot.readListEnd(); } @@ -2310,6 +2409,24 @@ public class LectureWrite implements org.apache.thrift.TBase(_list143.size); + int _elem144; + for (int _i145 = 0; _i145 < _list143.size; ++_i145) + { + _elem144 = iprot.readI32(); + struct.presetScriptIds.add(_elem144); + } + iprot.readListEnd(); + } + struct.setPresetScriptIdsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -2361,9 +2478,9 @@ public class LectureWrite implements org.apache.thrift.TBase(_list125.size); - String _elem126; - for (int _i127 = 0; _i127 < _list125.size; ++_i127) + org.apache.thrift.protocol.TList _list162 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.nics = new ArrayList(_list162.size); + String _elem163; + for (int _i164 = 0; _i164 < _list162.size; ++_i164) { - _elem126 = iprot.readString(); - struct.nics.add(_elem126); + _elem163 = iprot.readString(); + struct.nics.add(_elem163); } } 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(_list128.size); - NetRule _elem129; - for (int _i130 = 0; _i130 < _list128.size; ++_i130) + org.apache.thrift.protocol.TList _list165 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkExceptions = new ArrayList(_list165.size); + NetRule _elem166; + for (int _i167 = 0; _i167 < _list165.size; ++_i167) { - _elem129 = new NetRule(); - _elem129.read(iprot); - struct.networkExceptions.add(_elem129); + _elem166 = new NetRule(); + _elem166.read(iprot); + struct.networkExceptions.add(_elem166); } } struct.setNetworkExceptionsIsSet(true); @@ -2738,39 +2881,39 @@ public class LectureWrite implements org.apache.thrift.TBase(_list131.size); - String _elem132; - for (int _i133 = 0; _i133 < _list131.size; ++_i133) + org.apache.thrift.protocol.TList _list168 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.addAllowedUsers = new ArrayList(_list168.size); + String _elem169; + for (int _i170 = 0; _i170 < _list168.size; ++_i170) { - _elem132 = iprot.readString(); - struct.addAllowedUsers.add(_elem132); + _elem169 = iprot.readString(); + struct.addAllowedUsers.add(_elem169); } } 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(_list134.size); - String _elem135; - for (int _i136 = 0; _i136 < _list134.size; ++_i136) + org.apache.thrift.protocol.TList _list171 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.remAllowedUsers = new ArrayList(_list171.size); + String _elem172; + for (int _i173 = 0; _i173 < _list171.size; ++_i173) { - _elem135 = iprot.readString(); - struct.remAllowedUsers.add(_elem135); + _elem172 = iprot.readString(); + struct.remAllowedUsers.add(_elem172); } } 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(_list137.size); - int _elem138; - for (int _i139 = 0; _i139 < _list137.size; ++_i139) + org.apache.thrift.protocol.TList _list174 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.locationIds = new ArrayList(_list174.size); + int _elem175; + for (int _i176 = 0; _i176 < _list174.size; ++_i176) { - _elem138 = iprot.readI32(); - struct.locationIds.add(_elem138); + _elem175 = iprot.readI32(); + struct.locationIds.add(_elem175); } } struct.setLocationIdsIsSet(true); @@ -2789,32 +2932,45 @@ public class LectureWrite implements org.apache.thrift.TBase(_list140.size); - NetShare _elem141; - for (int _i142 = 0; _i142 < _list140.size; ++_i142) + org.apache.thrift.protocol.TList _list177 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkShares = new ArrayList(_list177.size); + NetShare _elem178; + for (int _i179 = 0; _i179 < _list177.size; ++_i179) { - _elem141 = new NetShare(); - _elem141.read(iprot); - struct.networkShares.add(_elem141); + _elem178 = new NetShare(); + _elem178.read(iprot); + struct.networkShares.add(_elem178); } } 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(_list143.size); - LdapFilter _elem144; - for (int _i145 = 0; _i145 < _list143.size; ++_i145) + org.apache.thrift.protocol.TList _list180 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilters = new ArrayList(_list180.size); + LdapFilter _elem181; + for (int _i182 = 0; _i182 < _list180.size; ++_i182) { - _elem144 = new LdapFilter(); - _elem144.read(iprot); - struct.ldapFilters.add(_elem144); + _elem181 = new LdapFilter(); + _elem181.read(iprot); + struct.ldapFilters.add(_elem181); } } struct.setLdapFiltersIsSet(true); } + if (incoming.get(21)) { + { + org.apache.thrift.protocol.TList _list183 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetScriptIds = new ArrayList(_list183.size); + int _elem184; + for (int _i185 = 0; _i185 < _list183.size; ++_i185) + { + _elem184 = iprot.readI32(); + struct.presetScriptIds.add(_elem184); + } + } + struct.setPresetScriptIdsIsSet(true); + } } } 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..539fb0e 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,13 @@ 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 = "2018-12-08") public class PredefinedData implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { 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 Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -49,11 +50,13 @@ public class PredefinedData implements org.apache.thrift.TBase netShares; // required public List ldapFilter; // required + public List runScripts; // 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"); private static final Map byName = new HashMap(); @@ -72,6 +75,8 @@ public class PredefinedData implements org.apache.thrift.TBase netShares, - List ldapFilter) + List ldapFilter, + List runScripts) { this(); this.netShares = netShares; this.ldapFilter = ldapFilter; + this.runScripts = runScripts; } /** @@ -155,6 +165,13 @@ public class PredefinedData implements org.apache.thrift.TBase __this__runScripts = new ArrayList(other.runScripts.size()); + for (PresetRunScript other_element : other.runScripts) { + __this__runScripts.add(new PresetRunScript(other_element)); + } + this.runScripts = __this__runScripts; + } } public PredefinedData deepCopy() { @@ -165,6 +182,7 @@ public class PredefinedData implements org.apache.thrift.TBase getRunScriptsIterator() { + return (this.runScripts == null) ? null : this.runScripts.iterator(); + } + + public void addToRunScripts(PresetRunScript elem) { + if (this.runScripts == null) { + this.runScripts = new ArrayList(); + } + this.runScripts.add(elem); + } + + public List getRunScripts() { + return this.runScripts; + } + + public PredefinedData setRunScripts(List 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 void setFieldValue(_Fields field, Object value) { switch (field) { case NET_SHARES: @@ -263,6 +320,14 @@ public class PredefinedData implements org.apache.thrift.TBase)value); + } + break; + } } @@ -274,6 +339,9 @@ public class PredefinedData implements org.apache.thrift.TBase(_list90.size); - NetShare _elem91; - for (int _i92 = 0; _i92 < _list90.size; ++_i92) + org.apache.thrift.protocol.TList _list98 = iprot.readListBegin(); + struct.netShares = new ArrayList(_list98.size); + NetShare _elem99; + for (int _i100 = 0; _i100 < _list98.size; ++_i100) { - _elem91 = new NetShare(); - _elem91.read(iprot); - struct.netShares.add(_elem91); + _elem99 = new NetShare(); + _elem99.read(iprot); + struct.netShares.add(_elem99); } iprot.readListEnd(); } @@ -472,14 +574,14 @@ public class PredefinedData implements org.apache.thrift.TBase(_list93.size); - LdapFilter _elem94; - for (int _i95 = 0; _i95 < _list93.size; ++_i95) + org.apache.thrift.protocol.TList _list101 = iprot.readListBegin(); + struct.ldapFilter = new ArrayList(_list101.size); + LdapFilter _elem102; + for (int _i103 = 0; _i103 < _list101.size; ++_i103) { - _elem94 = new LdapFilter(); - _elem94.read(iprot); - struct.ldapFilter.add(_elem94); + _elem102 = new LdapFilter(); + _elem102.read(iprot); + struct.ldapFilter.add(_elem102); } iprot.readListEnd(); } @@ -488,6 +590,25 @@ public class PredefinedData implements org.apache.thrift.TBase(_list104.size); + PresetRunScript _elem105; + for (int _i106 = 0; _i106 < _list104.size; ++_i106) + { + _elem105 = new PresetRunScript(); + _elem105.read(iprot); + struct.runScripts.add(_elem105); + } + iprot.readListEnd(); + } + struct.setRunScriptsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -507,9 +628,9 @@ public class PredefinedData implements org.apache.thrift.TBase(_list100.size); - NetShare _elem101; - for (int _i102 = 0; _i102 < _list100.size; ++_i102) + org.apache.thrift.protocol.TList _list113 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.netShares = new ArrayList(_list113.size); + NetShare _elem114; + for (int _i115 = 0; _i115 < _list113.size; ++_i115) { - _elem101 = new NetShare(); - _elem101.read(iprot); - struct.netShares.add(_elem101); + _elem114 = new NetShare(); + _elem114.read(iprot); + struct.netShares.add(_elem114); } } 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(_list103.size); - LdapFilter _elem104; - for (int _i105 = 0; _i105 < _list103.size; ++_i105) + org.apache.thrift.protocol.TList _list116 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilter = new ArrayList(_list116.size); + LdapFilter _elem117; + for (int _i118 = 0; _i118 < _list116.size; ++_i118) { - _elem104 = new LdapFilter(); - _elem104.read(iprot); - struct.ldapFilter.add(_elem104); + _elem117 = new LdapFilter(); + _elem117.read(iprot); + struct.ldapFilter.add(_elem117); } } struct.setLdapFilterIsSet(true); } + if (incoming.get(2)) { + { + org.apache.thrift.protocol.TList _list119 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.runScripts = new ArrayList(_list119.size); + PresetRunScript _elem120; + for (int _i121 = 0; _i121 < _list119.size; ++_i121) + { + _elem120 = new PresetRunScript(); + _elem120.read(iprot); + struct.runScripts.add(_elem120); + } + } + struct.setRunScriptsIsSet(true); + } } } diff --git a/src/main/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift index a9a7301..8b7af3f 100644 --- a/src/main/thrift/bwlp.thrift +++ b/src/main/thrift/bwlp.thrift @@ -261,9 +261,16 @@ struct LdapFilter { 4: optional string title, } +struct PresetRunScript { + 1: i32 scriptId, + 2: string displayname, + 3: list osIds, +} + struct PredefinedData { 1: list netShares, 2: list ldapFilter, + 3: list runScripts, } // Write lecture to sat. if optional fields are not set or null, their value stays unchanged @@ -289,6 +296,7 @@ struct LectureWrite { 20: bool hasUsbAccess, 21: optional list networkShares, 22: optional list ldapFilters, + 23: optional list presetScriptIds, } struct LectureSummary { @@ -341,6 +349,7 @@ struct LectureRead { 28: bool hasUsbAccess, 29: optional list networkShares, 30: optional list ldapFilters, + 31: optional list presetScriptIds, } struct MasterTag { -- cgit v1.2.3-55-g7522 From 7e97a37c4f406b1691eaa186591b591a2c26161b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sat, 8 Dec 2018 16:20:25 +0100 Subject: Refine diff check for compiled thrift classes --- thrift-compile.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thrift-compile.sh b/thrift-compile.sh index f7a6561..c47cc86 100755 --- a/thrift-compile.sh +++ b/thrift-compile.sh @@ -18,8 +18,8 @@ if thrift --gen java src/main/thrift/bwlp.thrift; then bn=$(basename "$file") if [ -e "src/main/java/org/openslx/bwlp/thrift/iface/$bn" ]; then diff -q \ - <(sed -r 's/_i[0-9]+/_ix/g;s/_iter[0-9]+/_iterx/g;s/_elem[0-9]+/_elemx/g;s/_list[0-9]+/_listx/g;/@Generated/d' "$file") \ - <(sed -r 's/_i[0-9]+/_ix/g;s/_iter[0-9]+/_iterx/g;s/_elem[0-9]+/_elemx/g;s/_list[0-9]+/_listx/g;/@Generated/d' "src/main/java/org/openslx/bwlp/thrift/iface/$bn") + <(sed -r 's/_(i|iter|elem|list|map|key|val)[0-9]+/\1x/g;/@Generated/d' "$file") \ + <(sed -r 's/_(i|iter|elem|list|map|key|val)[0-9]+/\1x/g;/@Generated/d' "src/main/java/org/openslx/bwlp/thrift/iface/$bn") ret=$? [ "$ret" = 0 ] && continue fi -- cgit v1.2.3-55-g7522 From 5adfe5c98f4a316cf28c29c13a26c1fa17e39e5d Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 11 Dec 2018 08:41:15 +0100 Subject: add missing thrift generated class --- .../openslx/bwlp/thrift/iface/PresetRunScript.java | 655 +++++++++++++++++++++ 1 file changed, 655 insertions(+) create mode 100644 src/main/java/org/openslx/bwlp/thrift/iface/PresetRunScript.java 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, java.io.Serializable, Cloneable, Comparable { + 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, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new PresetRunScriptStandardSchemeFactory()); + schemes.put(TupleScheme.class, new PresetRunScriptTupleSchemeFactory()); + } + + public int scriptId; // required + public String displayname; // required + public List 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 byName = new HashMap(); + + 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 osIds) + { + this(); + this.scriptId = scriptId; + setScriptIdIsSet(true); + this.displayname = displayname; + this.osIds = osIds; + } + + /** + * Performs a deep copy on other. + */ + public PresetRunScript(PresetRunScript other) { + __isset_bitfield = other.__isset_bitfield; + this.scriptId = other.scriptId; + if (other.isSetDisplayname()) { + this.displayname = other.displayname; + } + if (other.isSetOsIds()) { + List __this__osIds = new ArrayList(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 getOsIdsIterator() { + return (this.osIds == null) ? null : this.osIds.iterator(); + } + + public void addToOsIds(int elem) { + if (this.osIds == null) { + this.osIds = new ArrayList(); + } + this.osIds.add(elem); + } + + public List getOsIds() { + return this.osIds; + } + + public PresetRunScript setOsIds(List 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)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 list = new ArrayList(); + + 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 { + + 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(_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 { + + @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(_list95.size); + int _elem96; + for (int _i97 = 0; _i97 < _list95.size; ++_i97) + { + _elem96 = iprot.readI32(); + struct.osIds.add(_elem96); + } + } + struct.setOsIdsIsSet(true); + } + } + } + +} + -- cgit v1.2.3-55-g7522 From 67ba101edb960ae93264bf20c65973556154c193 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 11 Dec 2018 10:41:22 +0100 Subject: Redesign preset* handling to aim for backwards compat --- .../org/openslx/bwlp/thrift/iface/LectureRead.java | 496 +++++++++++++++++---- src/main/thrift/bwlp.thrift | 2 + 2 files changed, 406 insertions(+), 92 deletions(-) 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 a60e316..b2a183f 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-12-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-11") public class LectureRead implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("LectureRead"); @@ -66,7 +66,9 @@ public class LectureRead implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); @@ -103,7 +105,9 @@ public class LectureRead implements org.apache.thrift.TBase networkShares; // optional + public List presetNetworkShares; // optional public List ldapFilters; // optional + public List presetLdapFilters; // optional public List presetScriptIds; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @@ -136,7 +140,9 @@ public class LectureRead implements org.apache.thrift.TBase byName = new HashMap(); @@ -208,8 +214,12 @@ public class LectureRead implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -331,9 +341,15 @@ public class LectureRead implements org.apache.thrift.TBase __this__presetNetworkShares = new ArrayList(other.presetNetworkShares); + this.presetNetworkShares = __this__presetNetworkShares; + } if (other.isSetLdapFilters()) { List __this__ldapFilters = new ArrayList(other.ldapFilters.size()); for (LdapFilter other_element : other.ldapFilters) { @@ -495,6 +515,10 @@ public class LectureRead implements org.apache.thrift.TBase __this__presetLdapFilters = new ArrayList(other.presetLdapFilters); + this.presetLdapFilters = __this__presetLdapFilters; + } if (other.isSetPresetScriptIds()) { List __this__presetScriptIds = new ArrayList(other.presetScriptIds); this.presetScriptIds = __this__presetScriptIds; @@ -548,7 +572,9 @@ public class LectureRead implements org.apache.thrift.TBase getPresetNetworkSharesIterator() { + return (this.presetNetworkShares == null) ? null : this.presetNetworkShares.iterator(); + } + + public void addToPresetNetworkShares(int elem) { + if (this.presetNetworkShares == null) { + this.presetNetworkShares = new ArrayList(); + } + this.presetNetworkShares.add(elem); + } + + public List getPresetNetworkShares() { + return this.presetNetworkShares; + } + + public LectureRead setPresetNetworkShares(List 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 getLdapFiltersSize() { return (this.ldapFilters == null) ? 0 : this.ldapFilters.size(); } @@ -1325,6 +1390,45 @@ public class LectureRead implements org.apache.thrift.TBase getPresetLdapFiltersIterator() { + return (this.presetLdapFilters == null) ? null : this.presetLdapFilters.iterator(); + } + + public void addToPresetLdapFilters(int elem) { + if (this.presetLdapFilters == null) { + this.presetLdapFilters = new ArrayList(); + } + this.presetLdapFilters.add(elem); + } + + public List getPresetLdapFilters() { + return this.presetLdapFilters; + } + + public LectureRead setPresetLdapFilters(List 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 getPresetScriptIdsSize() { return (this.presetScriptIds == null) ? 0 : this.presetScriptIds.size(); } @@ -1590,6 +1694,14 @@ public class LectureRead implements org.apache.thrift.TBase)value); + } + break; + case LDAP_FILTERS: if (value == null) { unsetLdapFilters(); @@ -1598,6 +1710,14 @@ public class LectureRead implements org.apache.thrift.TBase)value); + } + break; + case PRESET_SCRIPT_IDS: if (value == null) { unsetPresetScriptIds(); @@ -1695,9 +1815,15 @@ public class LectureRead implements org.apache.thrift.TBase(_list201.size); - LdapFilter _elem202; + struct.presetNetworkShares = new ArrayList(_list201.size); + int _elem202; for (int _i203 = 0; _i203 < _list201.size; ++_i203) { - _elem202 = new LdapFilter(); - _elem202.read(iprot); - struct.ldapFilters.add(_elem202); + _elem202 = iprot.readI32(); + struct.presetNetworkShares.add(_elem202); } iprot.readListEnd(); } - struct.setLdapFiltersIsSet(true); + struct.setPresetNetworkSharesIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 31: // PRESET_SCRIPT_IDS + case 30: // LDAP_FILTERS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list204 = iprot.readListBegin(); - struct.presetScriptIds = new ArrayList(_list204.size); - int _elem205; + struct.ldapFilters = new ArrayList(_list204.size); + LdapFilter _elem205; for (int _i206 = 0; _i206 < _list204.size; ++_i206) { - _elem205 = iprot.readI32(); - struct.presetScriptIds.add(_elem205); + _elem205 = new LdapFilter(); + _elem205.read(iprot); + struct.ldapFilters.add(_elem205); + } + iprot.readListEnd(); + } + struct.setLdapFiltersIsSet(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 _list207 = iprot.readListBegin(); + struct.presetLdapFilters = new ArrayList(_list207.size); + int _elem208; + for (int _i209 = 0; _i209 < _list207.size; ++_i209) + { + _elem208 = iprot.readI32(); + struct.presetLdapFilters.add(_elem208); + } + iprot.readListEnd(); + } + struct.setPresetLdapFiltersIsSet(true); + } else { + 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 _list210 = iprot.readListBegin(); + struct.presetScriptIds = new ArrayList(_list210.size); + int _elem211; + for (int _i212 = 0; _i212 < _list210.size; ++_i212) + { + _elem211 = iprot.readI32(); + struct.presetScriptIds.add(_elem211); } iprot.readListEnd(); } @@ -3175,9 +3409,9 @@ public class LectureRead implements org.apache.thrift.TBase(_list221.size); - String _elem222; - for (int _i223 = 0; _i223 < _list221.size; ++_i223) + org.apache.thrift.protocol.TList _list231 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.nics = new ArrayList(_list231.size); + String _elem232; + for (int _i233 = 0; _i233 < _list231.size; ++_i233) { - _elem222 = iprot.readString(); - struct.nics.add(_elem222); + _elem232 = iprot.readString(); + struct.nics.add(_elem232); } } struct.setNicsIsSet(true); } if (incoming.get(17)) { { - org.apache.thrift.protocol.TList _list224 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.allowedUsers = new ArrayList(_list224.size); - String _elem225; - for (int _i226 = 0; _i226 < _list224.size; ++_i226) + org.apache.thrift.protocol.TList _list234 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.allowedUsers = new ArrayList(_list234.size); + String _elem235; + for (int _i236 = 0; _i236 < _list234.size; ++_i236) { - _elem225 = iprot.readString(); - struct.allowedUsers.add(_elem225); + _elem235 = iprot.readString(); + struct.allowedUsers.add(_elem235); } } struct.setAllowedUsersIsSet(true); } if (incoming.get(18)) { { - org.apache.thrift.protocol.TList _list227 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.networkExceptions = new ArrayList(_list227.size); - NetRule _elem228; - for (int _i229 = 0; _i229 < _list227.size; ++_i229) + org.apache.thrift.protocol.TList _list237 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkExceptions = new ArrayList(_list237.size); + NetRule _elem238; + for (int _i239 = 0; _i239 < _list237.size; ++_i239) { - _elem228 = new NetRule(); - _elem228.read(iprot); - struct.networkExceptions.add(_elem228); + _elem238 = new NetRule(); + _elem238.read(iprot); + struct.networkExceptions.add(_elem238); } } struct.setNetworkExceptionsIsSet(true); @@ -3675,13 +3961,13 @@ public class LectureRead implements org.apache.thrift.TBase(_list230.size); - int _elem231; - for (int _i232 = 0; _i232 < _list230.size; ++_i232) + org.apache.thrift.protocol.TList _list240 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.locationIds = new ArrayList(_list240.size); + int _elem241; + for (int _i242 = 0; _i242 < _list240.size; ++_i242) { - _elem231 = iprot.readI32(); - struct.locationIds.add(_elem231); + _elem241 = iprot.readI32(); + struct.locationIds.add(_elem241); } } struct.setLocationIdsIsSet(true); @@ -3700,41 +3986,67 @@ public class LectureRead implements org.apache.thrift.TBase(_list233.size); - NetShare _elem234; - for (int _i235 = 0; _i235 < _list233.size; ++_i235) + org.apache.thrift.protocol.TList _list243 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkShares = new ArrayList(_list243.size); + NetShare _elem244; + for (int _i245 = 0; _i245 < _list243.size; ++_i245) { - _elem234 = new NetShare(); - _elem234.read(iprot); - struct.networkShares.add(_elem234); + _elem244 = new NetShare(); + _elem244.read(iprot); + struct.networkShares.add(_elem244); } } struct.setNetworkSharesIsSet(true); } if (incoming.get(28)) { { - org.apache.thrift.protocol.TList _list236 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.ldapFilters = new ArrayList(_list236.size); - LdapFilter _elem237; - for (int _i238 = 0; _i238 < _list236.size; ++_i238) + org.apache.thrift.protocol.TList _list246 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetNetworkShares = new ArrayList(_list246.size); + int _elem247; + for (int _i248 = 0; _i248 < _list246.size; ++_i248) { - _elem237 = new LdapFilter(); - _elem237.read(iprot); - struct.ldapFilters.add(_elem237); + _elem247 = iprot.readI32(); + struct.presetNetworkShares.add(_elem247); } } - struct.setLdapFiltersIsSet(true); + struct.setPresetNetworkSharesIsSet(true); } if (incoming.get(29)) { { - org.apache.thrift.protocol.TList _list239 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.presetScriptIds = new ArrayList(_list239.size); - int _elem240; - for (int _i241 = 0; _i241 < _list239.size; ++_i241) + org.apache.thrift.protocol.TList _list249 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilters = new ArrayList(_list249.size); + LdapFilter _elem250; + for (int _i251 = 0; _i251 < _list249.size; ++_i251) + { + _elem250 = new LdapFilter(); + _elem250.read(iprot); + struct.ldapFilters.add(_elem250); + } + } + struct.setLdapFiltersIsSet(true); + } + if (incoming.get(30)) { + { + org.apache.thrift.protocol.TList _list252 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetLdapFilters = new ArrayList(_list252.size); + int _elem253; + for (int _i254 = 0; _i254 < _list252.size; ++_i254) + { + _elem253 = iprot.readI32(); + struct.presetLdapFilters.add(_elem253); + } + } + struct.setPresetLdapFiltersIsSet(true); + } + if (incoming.get(31)) { + { + org.apache.thrift.protocol.TList _list255 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetScriptIds = new ArrayList(_list255.size); + int _elem256; + for (int _i257 = 0; _i257 < _list255.size; ++_i257) { - _elem240 = iprot.readI32(); - struct.presetScriptIds.add(_elem240); + _elem256 = iprot.readI32(); + struct.presetScriptIds.add(_elem256); } } struct.setPresetScriptIdsIsSet(true); diff --git a/src/main/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift index 8b7af3f..bed99f8 100644 --- a/src/main/thrift/bwlp.thrift +++ b/src/main/thrift/bwlp.thrift @@ -348,7 +348,9 @@ struct LectureRead { 27: bool limitToAllowedUsers, 28: bool hasUsbAccess, 29: optional list networkShares, + 32: optional list presetNetworkShares, 30: optional list ldapFilters, + 33: optional list presetLdapFilters, 31: optional list presetScriptIds, } -- cgit v1.2.3-55-g7522 From de1ebf3786141018e5207955ecf6a837d016e090 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 11 Dec 2018 10:45:27 +0100 Subject: Partially Revert "Update to RPC version 5, break compat" Only increase MIN_VERSION to 4... This reverts commit f01a417c81a63b809ef788107c391f75c26ff99d. --- .../org/openslx/sat/thrift/version/Feature.java | 29 ++++++++++++++++++++++ .../org/openslx/sat/thrift/version/Version.java | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) 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 3c40b3e..e06c78a 100644 --- a/src/main/java/org/openslx/sat/thrift/version/Feature.java +++ b/src/main/java/org/openslx/sat/thrift/version/Feature.java @@ -1,5 +1,34 @@ package org.openslx.sat.thrift.version; public enum Feature { + + /** + * Server can properly extend the expiration time of an image version that + * is already expired, but has not been deleted yet. (Early versions of dmsd + * did not handle this case properly.) + */ + EXTEND_EXPIRED_VM, + + /** + * Server supports configuring network shares for individual lectures. Whether + * these will function on the clients further depends on the minilinux version! + */ + NETWORK_SHARES, + + /** + * Server supports multiple hypervisors which requires special handling since + * multiple components needs to be compatible to fully support them. + */ + MULTIPLE_HYPERVISORS, + + /** + * Server supports copying existing blocks server side. + */ + SERVER_SIDE_COPY, + + /** + * Server supports filtering lectures by LDAP/AD attributes + */ + LECTURE_FILTER_LDAP, } 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 404a01b..16e00f8 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 = 5; + public static final long MIN_VERSION = 2; - public static final long VERSION = 5; + public static final long VERSION = 4; } -- cgit v1.2.3-55-g7522 From c5c5b7c5692fc4198adf1e84aecaede144e10138 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 11 Dec 2018 10:48:31 +0100 Subject: RPC Version 5, MIN_VERSION 4 --- src/main/java/org/openslx/sat/thrift/version/Version.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } -- cgit v1.2.3-55-g7522 From 9e8553a71645e225c6d702e6e1c1ee865f824af7 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 12 Dec 2018 11:09:19 +0100 Subject: DiskImage: Support split vmdk files with plain text header Closes #3505 --- src/main/java/org/openslx/util/vm/DiskImage.java | 38 ++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/openslx/util/vm/DiskImage.java b/src/main/java/org/openslx/util/vm/DiskImage.java index fc57e79..ed8f5db 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 -- cgit v1.2.3-55-g7522 From 1761bed478ee2d399f2d8b24db222ae462426a6a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 12 Dec 2018 11:18:31 +0100 Subject: DiskImage: Proper qcow2 detection --- src/main/java/org/openslx/util/vm/DiskImage.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/openslx/util/vm/DiskImage.java b/src/main/java/org/openslx/util/vm/DiskImage.java index ed8f5db..2b24a3f 100644 --- a/src/main/java/org/openslx/util/vm/DiskImage.java +++ b/src/main/java/org/openslx/util/vm/DiskImage.java @@ -19,7 +19,10 @@ public class DiskImage */ private static final int VMDK_MAGIC = 0x4b444d56; private static final int VDI_MAGIC = 0x7f10dabe; - private static final String QEMU = "QFI"; + /** + * Big endian representation of the 4 bytes 'QFI\xFB' + */ + private static final int QEMU_MAGIC = 0x514649fb; public enum ImageFormat { @@ -162,10 +165,7 @@ public class DiskImage // TODO: qcow file.seek( 0 ); - byte[] qcowBuffer = new byte[ QEMU.length() ]; - file.readFully( qcowBuffer ); - String qcowString = new String( qcowBuffer ); - if ( QEMU.equals( qcowString ) ) { + if ( file.readInt() == QEMU_MAGIC ) { // dummy values this.isStandalone = true; this.isCompressed = false; -- cgit v1.2.3-55-g7522 From 4348f12c6d56e94148dde7cac911275f4584b11c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 16 Jan 2019 11:27:24 +0100 Subject: [HashChecker] Fix unlimited spawning of check threads Stupid variable mixup resulted in endless spawning of new checker threads that wouldn't go away after they're done. --- src/main/java/org/openslx/filetransfer/util/HashChecker.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(); -- cgit v1.2.3-55-g7522 From e58b428c7aed96c7abe34b664df0659cc56e5b27 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 22 Feb 2019 12:04:26 +0100 Subject: Add Server Side Copy setting to SatelliteConfig --- .../openslx/bwlp/thrift/iface/SatelliteConfig.java | 133 ++++++++++++++++++++- .../org/openslx/bwlp/thrift/iface/SscMode.java | 51 ++++++++ src/main/thrift/bwlp.thrift | 9 ++ 3 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/openslx/bwlp/thrift/iface/SscMode.java 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, java.io.Serializable, Cloneable, Comparable { 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, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -63,6 +64,11 @@ public class SatelliteConfig implements org.apache.thrift.TBase byName = new HashMap(); @@ -107,6 +118,8 @@ public class SatelliteConfig implements org.apache.thrift.TBase 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, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("LectureRead"); @@ -66,10 +66,11 @@ public class LectureRead implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -105,10 +106,11 @@ public class LectureRead implements org.apache.thrift.TBase networkShares; // optional - public List presetNetworkShares; // optional public List ldapFilters; // optional - public List presetLdapFilters; // optional public List presetScriptIds; // optional + public List presetNetworkShares; // optional + public List presetLdapFilters; // optional + public List 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 { @@ -140,10 +142,11 @@ public class LectureRead implements org.apache.thrift.TBase byName = new HashMap(); @@ -214,14 +217,16 @@ public class LectureRead implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -341,16 +346,19 @@ public class LectureRead implements org.apache.thrift.TBase __this__presetNetworkShares = new ArrayList(other.presetNetworkShares); - this.presetNetworkShares = __this__presetNetworkShares; - } if (other.isSetLdapFilters()) { List __this__ldapFilters = new ArrayList(other.ldapFilters.size()); for (LdapFilter other_element : other.ldapFilters) { @@ -515,13 +519,21 @@ public class LectureRead implements org.apache.thrift.TBase __this__presetScriptIds = new ArrayList(other.presetScriptIds); + this.presetScriptIds = __this__presetScriptIds; + } + if (other.isSetPresetNetworkShares()) { + List __this__presetNetworkShares = new ArrayList(other.presetNetworkShares); + this.presetNetworkShares = __this__presetNetworkShares; + } if (other.isSetPresetLdapFilters()) { List __this__presetLdapFilters = new ArrayList(other.presetLdapFilters); this.presetLdapFilters = __this__presetLdapFilters; } - if (other.isSetPresetScriptIds()) { - List __this__presetScriptIds = new ArrayList(other.presetScriptIds); - this.presetScriptIds = __this__presetScriptIds; + if (other.isSetPresetNetworkExceptionIds()) { + List __this__presetNetworkExceptionIds = new ArrayList(other.presetNetworkExceptionIds); + this.presetNetworkExceptionIds = __this__presetNetworkExceptionIds; } } @@ -572,10 +584,11 @@ public class LectureRead implements org.apache.thrift.TBase getPresetNetworkSharesIterator() { - return (this.presetNetworkShares == null) ? null : this.presetNetworkShares.iterator(); + public java.util.Iterator getLdapFiltersIterator() { + return (this.ldapFilters == null) ? null : this.ldapFilters.iterator(); } - public void addToPresetNetworkShares(int elem) { - if (this.presetNetworkShares == null) { - this.presetNetworkShares = new ArrayList(); + public void addToLdapFilters(LdapFilter elem) { + if (this.ldapFilters == null) { + this.ldapFilters = new ArrayList(); } - this.presetNetworkShares.add(elem); + this.ldapFilters.add(elem); } - public List getPresetNetworkShares() { - return this.presetNetworkShares; + public List getLdapFilters() { + return this.ldapFilters; } - public LectureRead setPresetNetworkShares(List presetNetworkShares) { - this.presetNetworkShares = presetNetworkShares; + public LectureRead setLdapFilters(List ldapFilters) { + this.ldapFilters = ldapFilters; return this; } - public void unsetPresetNetworkShares() { - this.presetNetworkShares = null; + public void unsetLdapFilters() { + this.ldapFilters = null; } - /** Returns true if field presetNetworkShares is set (has been assigned a value) and false otherwise */ - public boolean isSetPresetNetworkShares() { - return this.presetNetworkShares != null; + /** Returns true if field ldapFilters is set (has been assigned a value) and false otherwise */ + public boolean isSetLdapFilters() { + return this.ldapFilters != null; } - public void setPresetNetworkSharesIsSet(boolean value) { + public void setLdapFiltersIsSet(boolean value) { if (!value) { - this.presetNetworkShares = null; + this.ldapFilters = null; } } - public int getLdapFiltersSize() { - return (this.ldapFilters == null) ? 0 : this.ldapFilters.size(); + public int getPresetScriptIdsSize() { + return (this.presetScriptIds == null) ? 0 : this.presetScriptIds.size(); } - public java.util.Iterator getLdapFiltersIterator() { - return (this.ldapFilters == null) ? null : this.ldapFilters.iterator(); + public java.util.Iterator getPresetScriptIdsIterator() { + return (this.presetScriptIds == null) ? null : this.presetScriptIds.iterator(); } - public void addToLdapFilters(LdapFilter elem) { - if (this.ldapFilters == null) { - this.ldapFilters = new ArrayList(); + public void addToPresetScriptIds(int elem) { + if (this.presetScriptIds == null) { + this.presetScriptIds = new ArrayList(); } - this.ldapFilters.add(elem); + this.presetScriptIds.add(elem); } - public List getLdapFilters() { - return this.ldapFilters; + public List getPresetScriptIds() { + return this.presetScriptIds; } - public LectureRead setLdapFilters(List ldapFilters) { - this.ldapFilters = ldapFilters; + public LectureRead setPresetScriptIds(List presetScriptIds) { + this.presetScriptIds = presetScriptIds; return this; } - public void unsetLdapFilters() { - this.ldapFilters = null; + public void unsetPresetScriptIds() { + this.presetScriptIds = null; } - /** Returns true if field ldapFilters is set (has been assigned a value) and false otherwise */ - public boolean isSetLdapFilters() { - return this.ldapFilters != 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 setLdapFiltersIsSet(boolean value) { + public void setPresetScriptIdsIsSet(boolean value) { if (!value) { - this.ldapFilters = null; + this.presetScriptIds = null; + } + } + + public int getPresetNetworkSharesSize() { + return (this.presetNetworkShares == null) ? 0 : this.presetNetworkShares.size(); + } + + public java.util.Iterator getPresetNetworkSharesIterator() { + return (this.presetNetworkShares == null) ? null : this.presetNetworkShares.iterator(); + } + + public void addToPresetNetworkShares(int elem) { + if (this.presetNetworkShares == null) { + this.presetNetworkShares = new ArrayList(); + } + this.presetNetworkShares.add(elem); + } + + public List getPresetNetworkShares() { + return this.presetNetworkShares; + } + + public LectureRead setPresetNetworkShares(List 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; } } @@ -1429,42 +1481,42 @@ public class LectureRead implements org.apache.thrift.TBase getPresetScriptIdsIterator() { - return (this.presetScriptIds == null) ? null : this.presetScriptIds.iterator(); + public java.util.Iterator getPresetNetworkExceptionIdsIterator() { + return (this.presetNetworkExceptionIds == null) ? null : this.presetNetworkExceptionIds.iterator(); } - public void addToPresetScriptIds(int elem) { - if (this.presetScriptIds == null) { - this.presetScriptIds = new ArrayList(); + public void addToPresetNetworkExceptionIds(int elem) { + if (this.presetNetworkExceptionIds == null) { + this.presetNetworkExceptionIds = new ArrayList(); } - this.presetScriptIds.add(elem); + this.presetNetworkExceptionIds.add(elem); } - public List getPresetScriptIds() { - return this.presetScriptIds; + public List getPresetNetworkExceptionIds() { + return this.presetNetworkExceptionIds; } - public LectureRead setPresetScriptIds(List presetScriptIds) { - this.presetScriptIds = presetScriptIds; + public LectureRead setPresetNetworkExceptionIds(List presetNetworkExceptionIds) { + this.presetNetworkExceptionIds = presetNetworkExceptionIds; return this; } - public void unsetPresetScriptIds() { - this.presetScriptIds = null; + public void unsetPresetNetworkExceptionIds() { + this.presetNetworkExceptionIds = null; } - /** Returns true if field presetScriptIds is set (has been assigned a value) and false otherwise */ - public boolean isSetPresetScriptIds() { - return this.presetScriptIds != 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 setPresetScriptIdsIsSet(boolean value) { + public void setPresetNetworkExceptionIdsIsSet(boolean value) { if (!value) { - this.presetScriptIds = null; + this.presetNetworkExceptionIds = null; } } @@ -1694,19 +1746,27 @@ public class LectureRead implements org.apache.thrift.TBase)value); + setLdapFilters((List)value); } break; - case LDAP_FILTERS: + case PRESET_SCRIPT_IDS: if (value == null) { - unsetLdapFilters(); + unsetPresetScriptIds(); } else { - setLdapFilters((List)value); + setPresetScriptIds((List)value); + } + break; + + case PRESET_NETWORK_SHARES: + if (value == null) { + unsetPresetNetworkShares(); + } else { + setPresetNetworkShares((List)value); } break; @@ -1718,11 +1778,11 @@ public class LectureRead implements org.apache.thrift.TBase)value); + setPresetNetworkExceptionIds((List)value); } break; @@ -1815,17 +1875,20 @@ public class LectureRead implements org.apache.thrift.TBase(_list186.size); - String _elem187; - for (int _i188 = 0; _i188 < _list186.size; ++_i188) + org.apache.thrift.protocol.TList _list202 = iprot.readListBegin(); + struct.nics = new ArrayList(_list202.size); + String _elem203; + for (int _i204 = 0; _i204 < _list202.size; ++_i204) { - _elem187 = iprot.readString(); - struct.nics.add(_elem187); + _elem203 = iprot.readString(); + struct.nics.add(_elem203); } iprot.readListEnd(); } @@ -3140,13 +3239,13 @@ public class LectureRead implements org.apache.thrift.TBase(_list189.size); - String _elem190; - for (int _i191 = 0; _i191 < _list189.size; ++_i191) + org.apache.thrift.protocol.TList _list205 = iprot.readListBegin(); + struct.allowedUsers = new ArrayList(_list205.size); + String _elem206; + for (int _i207 = 0; _i207 < _list205.size; ++_i207) { - _elem190 = iprot.readString(); - struct.allowedUsers.add(_elem190); + _elem206 = iprot.readString(); + struct.allowedUsers.add(_elem206); } iprot.readListEnd(); } @@ -3158,14 +3257,14 @@ public class LectureRead implements org.apache.thrift.TBase(_list192.size); - NetRule _elem193; - for (int _i194 = 0; _i194 < _list192.size; ++_i194) + org.apache.thrift.protocol.TList _list208 = iprot.readListBegin(); + struct.networkExceptions = new ArrayList(_list208.size); + NetRule _elem209; + for (int _i210 = 0; _i210 < _list208.size; ++_i210) { - _elem193 = new NetRule(); - _elem193.read(iprot); - struct.networkExceptions.add(_elem193); + _elem209 = new NetRule(); + _elem209.read(iprot); + struct.networkExceptions.add(_elem209); } iprot.readListEnd(); } @@ -3211,13 +3310,13 @@ public class LectureRead implements org.apache.thrift.TBase(_list195.size); - int _elem196; - for (int _i197 = 0; _i197 < _list195.size; ++_i197) + org.apache.thrift.protocol.TList _list211 = iprot.readListBegin(); + struct.locationIds = new ArrayList(_list211.size); + int _elem212; + for (int _i213 = 0; _i213 < _list211.size; ++_i213) { - _elem196 = iprot.readI32(); - struct.locationIds.add(_elem196); + _elem212 = iprot.readI32(); + struct.locationIds.add(_elem212); } iprot.readListEnd(); } @@ -3253,14 +3352,14 @@ public class LectureRead implements org.apache.thrift.TBase(_list198.size); - NetShare _elem199; - for (int _i200 = 0; _i200 < _list198.size; ++_i200) + org.apache.thrift.protocol.TList _list214 = iprot.readListBegin(); + struct.networkShares = new ArrayList(_list214.size); + NetShare _elem215; + for (int _i216 = 0; _i216 < _list214.size; ++_i216) { - _elem199 = new NetShare(); - _elem199.read(iprot); - struct.networkShares.add(_elem199); + _elem215 = new NetShare(); + _elem215.read(iprot); + struct.networkShares.add(_elem215); } iprot.readListEnd(); } @@ -3269,39 +3368,57 @@ public class LectureRead implements org.apache.thrift.TBase(_list201.size); - int _elem202; - for (int _i203 = 0; _i203 < _list201.size; ++_i203) + org.apache.thrift.protocol.TList _list217 = iprot.readListBegin(); + struct.ldapFilters = new ArrayList(_list217.size); + LdapFilter _elem218; + for (int _i219 = 0; _i219 < _list217.size; ++_i219) { - _elem202 = iprot.readI32(); - struct.presetNetworkShares.add(_elem202); + _elem218 = new LdapFilter(); + _elem218.read(iprot); + struct.ldapFilters.add(_elem218); } iprot.readListEnd(); } - struct.setPresetNetworkSharesIsSet(true); + struct.setLdapFiltersIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 30: // LDAP_FILTERS + case 31: // PRESET_SCRIPT_IDS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list204 = iprot.readListBegin(); - struct.ldapFilters = new ArrayList(_list204.size); - LdapFilter _elem205; - for (int _i206 = 0; _i206 < _list204.size; ++_i206) + org.apache.thrift.protocol.TList _list220 = iprot.readListBegin(); + struct.presetScriptIds = new ArrayList(_list220.size); + int _elem221; + for (int _i222 = 0; _i222 < _list220.size; ++_i222) { - _elem205 = new LdapFilter(); - _elem205.read(iprot); - struct.ldapFilters.add(_elem205); + _elem221 = iprot.readI32(); + struct.presetScriptIds.add(_elem221); } iprot.readListEnd(); } - struct.setLdapFiltersIsSet(true); + 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(_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); } @@ -3309,13 +3426,13 @@ public class LectureRead implements org.apache.thrift.TBase(_list207.size); - int _elem208; - for (int _i209 = 0; _i209 < _list207.size; ++_i209) + org.apache.thrift.protocol.TList _list226 = iprot.readListBegin(); + struct.presetLdapFilters = new ArrayList(_list226.size); + int _elem227; + for (int _i228 = 0; _i228 < _list226.size; ++_i228) { - _elem208 = iprot.readI32(); - struct.presetLdapFilters.add(_elem208); + _elem227 = iprot.readI32(); + struct.presetLdapFilters.add(_elem227); } iprot.readListEnd(); } @@ -3324,20 +3441,20 @@ public class LectureRead implements org.apache.thrift.TBase(_list210.size); - int _elem211; - for (int _i212 = 0; _i212 < _list210.size; ++_i212) + org.apache.thrift.protocol.TList _list229 = iprot.readListBegin(); + struct.presetNetworkExceptionIds = new ArrayList(_list229.size); + int _elem230; + for (int _i231 = 0; _i231 < _list229.size; ++_i231) { - _elem211 = iprot.readI32(); - struct.presetScriptIds.add(_elem211); + _elem230 = iprot.readI32(); + struct.presetNetworkExceptionIds.add(_elem230); } iprot.readListEnd(); } - struct.setPresetScriptIdsIsSet(true); + struct.setPresetNetworkExceptionIdsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -3409,9 +3526,9 @@ public class LectureRead implements org.apache.thrift.TBase(_list231.size); - String _elem232; - for (int _i233 = 0; _i233 < _list231.size; ++_i233) + org.apache.thrift.protocol.TList _list252 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.nics = new ArrayList(_list252.size); + String _elem253; + for (int _i254 = 0; _i254 < _list252.size; ++_i254) { - _elem232 = iprot.readString(); - struct.nics.add(_elem232); + _elem253 = iprot.readString(); + struct.nics.add(_elem253); } } struct.setNicsIsSet(true); } if (incoming.get(17)) { { - org.apache.thrift.protocol.TList _list234 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.allowedUsers = new ArrayList(_list234.size); - String _elem235; - for (int _i236 = 0; _i236 < _list234.size; ++_i236) + org.apache.thrift.protocol.TList _list255 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.allowedUsers = new ArrayList(_list255.size); + String _elem256; + for (int _i257 = 0; _i257 < _list255.size; ++_i257) { - _elem235 = iprot.readString(); - struct.allowedUsers.add(_elem235); + _elem256 = iprot.readString(); + struct.allowedUsers.add(_elem256); } } struct.setAllowedUsersIsSet(true); } if (incoming.get(18)) { { - org.apache.thrift.protocol.TList _list237 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.networkExceptions = new ArrayList(_list237.size); - NetRule _elem238; - for (int _i239 = 0; _i239 < _list237.size; ++_i239) + org.apache.thrift.protocol.TList _list258 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkExceptions = new ArrayList(_list258.size); + NetRule _elem259; + for (int _i260 = 0; _i260 < _list258.size; ++_i260) { - _elem238 = new NetRule(); - _elem238.read(iprot); - struct.networkExceptions.add(_elem238); + _elem259 = new NetRule(); + _elem259.read(iprot); + struct.networkExceptions.add(_elem259); } } struct.setNetworkExceptionsIsSet(true); @@ -3961,13 +4104,13 @@ public class LectureRead implements org.apache.thrift.TBase(_list240.size); - int _elem241; - for (int _i242 = 0; _i242 < _list240.size; ++_i242) + org.apache.thrift.protocol.TList _list261 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.locationIds = new ArrayList(_list261.size); + int _elem262; + for (int _i263 = 0; _i263 < _list261.size; ++_i263) { - _elem241 = iprot.readI32(); - struct.locationIds.add(_elem241); + _elem262 = iprot.readI32(); + struct.locationIds.add(_elem262); } } struct.setLocationIdsIsSet(true); @@ -3986,70 +4129,83 @@ public class LectureRead implements org.apache.thrift.TBase(_list243.size); - NetShare _elem244; - for (int _i245 = 0; _i245 < _list243.size; ++_i245) + org.apache.thrift.protocol.TList _list264 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkShares = new ArrayList(_list264.size); + NetShare _elem265; + for (int _i266 = 0; _i266 < _list264.size; ++_i266) { - _elem244 = new NetShare(); - _elem244.read(iprot); - struct.networkShares.add(_elem244); + _elem265 = new NetShare(); + _elem265.read(iprot); + struct.networkShares.add(_elem265); } } struct.setNetworkSharesIsSet(true); } if (incoming.get(28)) { { - org.apache.thrift.protocol.TList _list246 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.presetNetworkShares = new ArrayList(_list246.size); - int _elem247; - for (int _i248 = 0; _i248 < _list246.size; ++_i248) + org.apache.thrift.protocol.TList _list267 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilters = new ArrayList(_list267.size); + LdapFilter _elem268; + for (int _i269 = 0; _i269 < _list267.size; ++_i269) { - _elem247 = iprot.readI32(); - struct.presetNetworkShares.add(_elem247); + _elem268 = new LdapFilter(); + _elem268.read(iprot); + struct.ldapFilters.add(_elem268); } } - struct.setPresetNetworkSharesIsSet(true); + struct.setLdapFiltersIsSet(true); } if (incoming.get(29)) { { - org.apache.thrift.protocol.TList _list249 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.ldapFilters = new ArrayList(_list249.size); - LdapFilter _elem250; - for (int _i251 = 0; _i251 < _list249.size; ++_i251) + org.apache.thrift.protocol.TList _list270 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetScriptIds = new ArrayList(_list270.size); + int _elem271; + for (int _i272 = 0; _i272 < _list270.size; ++_i272) { - _elem250 = new LdapFilter(); - _elem250.read(iprot); - struct.ldapFilters.add(_elem250); + _elem271 = iprot.readI32(); + struct.presetScriptIds.add(_elem271); } } - struct.setLdapFiltersIsSet(true); + struct.setPresetScriptIdsIsSet(true); } if (incoming.get(30)) { { - org.apache.thrift.protocol.TList _list252 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.presetLdapFilters = new ArrayList(_list252.size); - int _elem253; - for (int _i254 = 0; _i254 < _list252.size; ++_i254) + org.apache.thrift.protocol.TList _list273 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetNetworkShares = new ArrayList(_list273.size); + int _elem274; + for (int _i275 = 0; _i275 < _list273.size; ++_i275) { - _elem253 = iprot.readI32(); - struct.presetLdapFilters.add(_elem253); + _elem274 = iprot.readI32(); + struct.presetNetworkShares.add(_elem274); } } - struct.setPresetLdapFiltersIsSet(true); + struct.setPresetNetworkSharesIsSet(true); } if (incoming.get(31)) { { - org.apache.thrift.protocol.TList _list255 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.presetScriptIds = new ArrayList(_list255.size); - int _elem256; - for (int _i257 = 0; _i257 < _list255.size; ++_i257) + org.apache.thrift.protocol.TList _list276 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetLdapFilters = new ArrayList(_list276.size); + int _elem277; + for (int _i278 = 0; _i278 < _list276.size; ++_i278) { - _elem256 = iprot.readI32(); - struct.presetScriptIds.add(_elem256); + _elem277 = iprot.readI32(); + struct.presetLdapFilters.add(_elem277); } } - struct.setPresetScriptIdsIsSet(true); + 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(_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 dfdc415..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-12-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-02-25") public class LectureWrite implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("LectureWrite"); @@ -60,6 +60,7 @@ public class LectureWrite implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -89,6 +90,7 @@ public class LectureWrite implements org.apache.thrift.TBase networkShares; // optional public List ldapFilters; // optional public List presetScriptIds; // optional + public List 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 { @@ -113,7 +115,8 @@ public class LectureWrite implements org.apache.thrift.TBase byName = new HashMap(); @@ -172,6 +175,8 @@ public class LectureWrite implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -278,6 +283,9 @@ public class LectureWrite implements org.apache.thrift.TBase __this__presetScriptIds = new ArrayList(other.presetScriptIds); this.presetScriptIds = __this__presetScriptIds; } + if (other.isSetPresetNetworkExceptionIds()) { + List __this__presetNetworkExceptionIds = new ArrayList(other.presetNetworkExceptionIds); + this.presetNetworkExceptionIds = __this__presetNetworkExceptionIds; + } } public LectureWrite deepCopy() { @@ -440,6 +452,7 @@ public class LectureWrite implements org.apache.thrift.TBase getPresetNetworkExceptionIdsIterator() { + return (this.presetNetworkExceptionIds == null) ? null : this.presetNetworkExceptionIds.iterator(); + } + + public void addToPresetNetworkExceptionIds(int elem) { + if (this.presetNetworkExceptionIds == null) { + this.presetNetworkExceptionIds = new ArrayList(); + } + this.presetNetworkExceptionIds.add(elem); + } + + public List getPresetNetworkExceptionIds() { + return this.presetNetworkExceptionIds; + } + + public LectureWrite setPresetNetworkExceptionIds(List 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: @@ -1259,6 +1311,14 @@ public class LectureWrite implements org.apache.thrift.TBase)value); + } + break; + } } @@ -1330,6 +1390,9 @@ public class LectureWrite implements org.apache.thrift.TBase(_list122.size); - String _elem123; - for (int _i124 = 0; _i124 < _list122.size; ++_i124) + org.apache.thrift.protocol.TList _list130 = iprot.readListBegin(); + struct.nics = new ArrayList(_list130.size); + String _elem131; + for (int _i132 = 0; _i132 < _list130.size; ++_i132) { - _elem123 = iprot.readString(); - struct.nics.add(_elem123); + _elem131 = iprot.readString(); + struct.nics.add(_elem131); } iprot.readListEnd(); } @@ -2252,14 +2351,14 @@ public class LectureWrite implements org.apache.thrift.TBase(_list125.size); - NetRule _elem126; - for (int _i127 = 0; _i127 < _list125.size; ++_i127) + org.apache.thrift.protocol.TList _list133 = iprot.readListBegin(); + struct.networkExceptions = new ArrayList(_list133.size); + NetRule _elem134; + for (int _i135 = 0; _i135 < _list133.size; ++_i135) { - _elem126 = new NetRule(); - _elem126.read(iprot); - struct.networkExceptions.add(_elem126); + _elem134 = new NetRule(); + _elem134.read(iprot); + struct.networkExceptions.add(_elem134); } iprot.readListEnd(); } @@ -2296,13 +2395,13 @@ public class LectureWrite implements org.apache.thrift.TBase(_list128.size); - String _elem129; - for (int _i130 = 0; _i130 < _list128.size; ++_i130) + org.apache.thrift.protocol.TList _list136 = iprot.readListBegin(); + struct.addAllowedUsers = new ArrayList(_list136.size); + String _elem137; + for (int _i138 = 0; _i138 < _list136.size; ++_i138) { - _elem129 = iprot.readString(); - struct.addAllowedUsers.add(_elem129); + _elem137 = iprot.readString(); + struct.addAllowedUsers.add(_elem137); } iprot.readListEnd(); } @@ -2314,13 +2413,13 @@ public class LectureWrite implements org.apache.thrift.TBase(_list131.size); - String _elem132; - for (int _i133 = 0; _i133 < _list131.size; ++_i133) + org.apache.thrift.protocol.TList _list139 = iprot.readListBegin(); + struct.remAllowedUsers = new ArrayList(_list139.size); + String _elem140; + for (int _i141 = 0; _i141 < _list139.size; ++_i141) { - _elem132 = iprot.readString(); - struct.remAllowedUsers.add(_elem132); + _elem140 = iprot.readString(); + struct.remAllowedUsers.add(_elem140); } iprot.readListEnd(); } @@ -2332,13 +2431,13 @@ public class LectureWrite implements org.apache.thrift.TBase(_list134.size); - int _elem135; - for (int _i136 = 0; _i136 < _list134.size; ++_i136) + org.apache.thrift.protocol.TList _list142 = iprot.readListBegin(); + struct.locationIds = new ArrayList(_list142.size); + int _elem143; + for (int _i144 = 0; _i144 < _list142.size; ++_i144) { - _elem135 = iprot.readI32(); - struct.locationIds.add(_elem135); + _elem143 = iprot.readI32(); + struct.locationIds.add(_elem143); } iprot.readListEnd(); } @@ -2374,14 +2473,14 @@ public class LectureWrite implements org.apache.thrift.TBase(_list137.size); - NetShare _elem138; - for (int _i139 = 0; _i139 < _list137.size; ++_i139) + org.apache.thrift.protocol.TList _list145 = iprot.readListBegin(); + struct.networkShares = new ArrayList(_list145.size); + NetShare _elem146; + for (int _i147 = 0; _i147 < _list145.size; ++_i147) { - _elem138 = new NetShare(); - _elem138.read(iprot); - struct.networkShares.add(_elem138); + _elem146 = new NetShare(); + _elem146.read(iprot); + struct.networkShares.add(_elem146); } iprot.readListEnd(); } @@ -2393,14 +2492,14 @@ public class LectureWrite implements org.apache.thrift.TBase(_list140.size); - LdapFilter _elem141; - for (int _i142 = 0; _i142 < _list140.size; ++_i142) + org.apache.thrift.protocol.TList _list148 = iprot.readListBegin(); + struct.ldapFilters = new ArrayList(_list148.size); + LdapFilter _elem149; + for (int _i150 = 0; _i150 < _list148.size; ++_i150) { - _elem141 = new LdapFilter(); - _elem141.read(iprot); - struct.ldapFilters.add(_elem141); + _elem149 = new LdapFilter(); + _elem149.read(iprot); + struct.ldapFilters.add(_elem149); } iprot.readListEnd(); } @@ -2412,13 +2511,13 @@ public class LectureWrite implements org.apache.thrift.TBase(_list143.size); - int _elem144; - for (int _i145 = 0; _i145 < _list143.size; ++_i145) + org.apache.thrift.protocol.TList _list151 = iprot.readListBegin(); + struct.presetScriptIds = new ArrayList(_list151.size); + int _elem152; + for (int _i153 = 0; _i153 < _list151.size; ++_i153) { - _elem144 = iprot.readI32(); - struct.presetScriptIds.add(_elem144); + _elem152 = iprot.readI32(); + struct.presetScriptIds.add(_elem152); } iprot.readListEnd(); } @@ -2427,6 +2526,24 @@ public class LectureWrite implements org.apache.thrift.TBase(_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); } @@ -2478,9 +2595,9 @@ public class LectureWrite implements org.apache.thrift.TBase(_list162.size); - String _elem163; - for (int _i164 = 0; _i164 < _list162.size; ++_i164) + org.apache.thrift.protocol.TList _list175 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.nics = new ArrayList(_list175.size); + String _elem176; + for (int _i177 = 0; _i177 < _list175.size; ++_i177) { - _elem163 = iprot.readString(); - struct.nics.add(_elem163); + _elem176 = iprot.readString(); + struct.nics.add(_elem176); } } struct.setNicsIsSet(true); } if (incoming.get(9)) { { - org.apache.thrift.protocol.TList _list165 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.networkExceptions = new ArrayList(_list165.size); - NetRule _elem166; - for (int _i167 = 0; _i167 < _list165.size; ++_i167) + org.apache.thrift.protocol.TList _list178 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkExceptions = new ArrayList(_list178.size); + NetRule _elem179; + for (int _i180 = 0; _i180 < _list178.size; ++_i180) { - _elem166 = new NetRule(); - _elem166.read(iprot); - struct.networkExceptions.add(_elem166); + _elem179 = new NetRule(); + _elem179.read(iprot); + struct.networkExceptions.add(_elem179); } } struct.setNetworkExceptionsIsSet(true); @@ -2881,39 +3024,39 @@ public class LectureWrite implements org.apache.thrift.TBase(_list168.size); - String _elem169; - for (int _i170 = 0; _i170 < _list168.size; ++_i170) + org.apache.thrift.protocol.TList _list181 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.addAllowedUsers = new ArrayList(_list181.size); + String _elem182; + for (int _i183 = 0; _i183 < _list181.size; ++_i183) { - _elem169 = iprot.readString(); - struct.addAllowedUsers.add(_elem169); + _elem182 = iprot.readString(); + struct.addAllowedUsers.add(_elem182); } } struct.setAddAllowedUsersIsSet(true); } if (incoming.get(14)) { { - org.apache.thrift.protocol.TList _list171 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); - struct.remAllowedUsers = new ArrayList(_list171.size); - String _elem172; - for (int _i173 = 0; _i173 < _list171.size; ++_i173) + org.apache.thrift.protocol.TList _list184 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.remAllowedUsers = new ArrayList(_list184.size); + String _elem185; + for (int _i186 = 0; _i186 < _list184.size; ++_i186) { - _elem172 = iprot.readString(); - struct.remAllowedUsers.add(_elem172); + _elem185 = iprot.readString(); + struct.remAllowedUsers.add(_elem185); } } struct.setRemAllowedUsersIsSet(true); } if (incoming.get(15)) { { - org.apache.thrift.protocol.TList _list174 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.locationIds = new ArrayList(_list174.size); - int _elem175; - for (int _i176 = 0; _i176 < _list174.size; ++_i176) + org.apache.thrift.protocol.TList _list187 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.locationIds = new ArrayList(_list187.size); + int _elem188; + for (int _i189 = 0; _i189 < _list187.size; ++_i189) { - _elem175 = iprot.readI32(); - struct.locationIds.add(_elem175); + _elem188 = iprot.readI32(); + struct.locationIds.add(_elem188); } } struct.setLocationIdsIsSet(true); @@ -2932,45 +3075,58 @@ public class LectureWrite implements org.apache.thrift.TBase(_list177.size); - NetShare _elem178; - for (int _i179 = 0; _i179 < _list177.size; ++_i179) + org.apache.thrift.protocol.TList _list190 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.networkShares = new ArrayList(_list190.size); + NetShare _elem191; + for (int _i192 = 0; _i192 < _list190.size; ++_i192) { - _elem178 = new NetShare(); - _elem178.read(iprot); - struct.networkShares.add(_elem178); + _elem191 = new NetShare(); + _elem191.read(iprot); + struct.networkShares.add(_elem191); } } struct.setNetworkSharesIsSet(true); } if (incoming.get(20)) { { - org.apache.thrift.protocol.TList _list180 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.ldapFilters = new ArrayList(_list180.size); - LdapFilter _elem181; - for (int _i182 = 0; _i182 < _list180.size; ++_i182) + org.apache.thrift.protocol.TList _list193 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilters = new ArrayList(_list193.size); + LdapFilter _elem194; + for (int _i195 = 0; _i195 < _list193.size; ++_i195) { - _elem181 = new LdapFilter(); - _elem181.read(iprot); - struct.ldapFilters.add(_elem181); + _elem194 = new LdapFilter(); + _elem194.read(iprot); + struct.ldapFilters.add(_elem194); } } struct.setLdapFiltersIsSet(true); } if (incoming.get(21)) { { - org.apache.thrift.protocol.TList _list183 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); - struct.presetScriptIds = new ArrayList(_list183.size); - int _elem184; - for (int _i185 = 0; _i185 < _list183.size; ++_i185) + org.apache.thrift.protocol.TList _list196 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.presetScriptIds = new ArrayList(_list196.size); + int _elem197; + for (int _i198 = 0; _i198 < _list196.size; ++_i198) { - _elem184 = iprot.readI32(); - struct.presetScriptIds.add(_elem184); + _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(_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, java.io.Serializable, Cloneable, Comparable { 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 539fb0e..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,13 +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-12-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2019-02-25") public class PredefinedData implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { 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, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -51,12 +52,14 @@ public class PredefinedData implements org.apache.thrift.TBase netShares; // required public List ldapFilter; // required public List runScripts; // required + public List 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"), - RUN_SCRIPTS((short)3, "runScripts"); + RUN_SCRIPTS((short)3, "runScripts"), + NETWORK_EXCEPTIONS((short)4, "networkExceptions"); private static final Map byName = new HashMap(); @@ -77,6 +80,8 @@ public class PredefinedData implements org.apache.thrift.TBase netShares, List ldapFilter, - List runScripts) + List runScripts, + List networkExceptions) { this(); this.netShares = netShares; this.ldapFilter = ldapFilter; this.runScripts = runScripts; + this.networkExceptions = networkExceptions; } /** @@ -172,6 +182,13 @@ public class PredefinedData implements org.apache.thrift.TBase __this__networkExceptions = new ArrayList(other.networkExceptions.size()); + for (PresetNetRule other_element : other.networkExceptions) { + __this__networkExceptions.add(new PresetNetRule(other_element)); + } + this.networkExceptions = __this__networkExceptions; + } } public PredefinedData deepCopy() { @@ -183,6 +200,7 @@ public class PredefinedData implements org.apache.thrift.TBase getNetworkExceptionsIterator() { + return (this.networkExceptions == null) ? null : this.networkExceptions.iterator(); + } + + public void addToNetworkExceptions(PresetNetRule elem) { + if (this.networkExceptions == null) { + this.networkExceptions = new ArrayList(); + } + this.networkExceptions.add(elem); + } + + public List getNetworkExceptions() { + return this.networkExceptions; + } + + public PredefinedData setNetworkExceptions(List 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: @@ -328,6 +385,14 @@ public class PredefinedData implements org.apache.thrift.TBase)value); + } + break; + } } @@ -342,6 +407,9 @@ public class PredefinedData implements org.apache.thrift.TBase(_list98.size); - NetShare _elem99; - for (int _i100 = 0; _i100 < _list98.size; ++_i100) + org.apache.thrift.protocol.TList _list106 = iprot.readListBegin(); + struct.netShares = new ArrayList(_list106.size); + NetShare _elem107; + for (int _i108 = 0; _i108 < _list106.size; ++_i108) { - _elem99 = new NetShare(); - _elem99.read(iprot); - struct.netShares.add(_elem99); + _elem107 = new NetShare(); + _elem107.read(iprot); + struct.netShares.add(_elem107); } iprot.readListEnd(); } @@ -574,14 +676,14 @@ public class PredefinedData implements org.apache.thrift.TBase(_list101.size); - LdapFilter _elem102; - for (int _i103 = 0; _i103 < _list101.size; ++_i103) + org.apache.thrift.protocol.TList _list109 = iprot.readListBegin(); + struct.ldapFilter = new ArrayList(_list109.size); + LdapFilter _elem110; + for (int _i111 = 0; _i111 < _list109.size; ++_i111) { - _elem102 = new LdapFilter(); - _elem102.read(iprot); - struct.ldapFilter.add(_elem102); + _elem110 = new LdapFilter(); + _elem110.read(iprot); + struct.ldapFilter.add(_elem110); } iprot.readListEnd(); } @@ -593,14 +695,14 @@ public class PredefinedData implements org.apache.thrift.TBase(_list104.size); - PresetRunScript _elem105; - for (int _i106 = 0; _i106 < _list104.size; ++_i106) + org.apache.thrift.protocol.TList _list112 = iprot.readListBegin(); + struct.runScripts = new ArrayList(_list112.size); + PresetRunScript _elem113; + for (int _i114 = 0; _i114 < _list112.size; ++_i114) { - _elem105 = new PresetRunScript(); - _elem105.read(iprot); - struct.runScripts.add(_elem105); + _elem113 = new PresetRunScript(); + _elem113.read(iprot); + struct.runScripts.add(_elem113); } iprot.readListEnd(); } @@ -609,6 +711,25 @@ public class PredefinedData implements org.apache.thrift.TBase(_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); } @@ -628,9 +749,9 @@ public class PredefinedData implements org.apache.thrift.TBase(_list113.size); - NetShare _elem114; - for (int _i115 = 0; _i115 < _list113.size; ++_i115) + org.apache.thrift.protocol.TList _list126 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.netShares = new ArrayList(_list126.size); + NetShare _elem127; + for (int _i128 = 0; _i128 < _list126.size; ++_i128) { - _elem114 = new NetShare(); - _elem114.read(iprot); - struct.netShares.add(_elem114); + _elem127 = new NetShare(); + _elem127.read(iprot); + struct.netShares.add(_elem127); } } struct.setNetSharesIsSet(true); } if (incoming.get(1)) { { - org.apache.thrift.protocol.TList _list116 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.ldapFilter = new ArrayList(_list116.size); - LdapFilter _elem117; - for (int _i118 = 0; _i118 < _list116.size; ++_i118) + org.apache.thrift.protocol.TList _list129 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.ldapFilter = new ArrayList(_list129.size); + LdapFilter _elem130; + for (int _i131 = 0; _i131 < _list129.size; ++_i131) { - _elem117 = new LdapFilter(); - _elem117.read(iprot); - struct.ldapFilter.add(_elem117); + _elem130 = new LdapFilter(); + _elem130.read(iprot); + struct.ldapFilter.add(_elem130); } } struct.setLdapFilterIsSet(true); } if (incoming.get(2)) { { - org.apache.thrift.protocol.TList _list119 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.runScripts = new ArrayList(_list119.size); - PresetRunScript _elem120; - for (int _i121 = 0; _i121 < _list119.size; ++_i121) + org.apache.thrift.protocol.TList _list132 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.runScripts = new ArrayList(_list132.size); + PresetRunScript _elem133; + for (int _i134 = 0; _i134 < _list132.size; ++_i134) { - _elem120 = new PresetRunScript(); - _elem120.read(iprot); - struct.runScripts.add(_elem120); + _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(_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, java.io.Serializable, Cloneable, Comparable { + 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, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new PresetNetRuleStandardSchemeFactory()); + schemes.put(TupleScheme.class, new PresetNetRuleTupleSchemeFactory()); + } + + public int ruleId; // required + public String displayName; // required + public List 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 byName = new HashMap(); + + 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 netRules) + { + this(); + this.ruleId = ruleId; + setRuleIdIsSet(true); + this.displayName = displayName; + this.netRules = netRules; + } + + /** + * Performs a deep copy on other. + */ + public PresetNetRule(PresetNetRule other) { + __isset_bitfield = other.__isset_bitfield; + this.ruleId = other.ruleId; + if (other.isSetDisplayName()) { + this.displayName = other.displayName; + } + if (other.isSetNetRules()) { + List __this__netRules = new ArrayList(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 getNetRulesIterator() { + return (this.netRules == null) ? null : this.netRules.iterator(); + } + + public void addToNetRules(NetRule elem) { + if (this.netRules == null) { + this.netRules = new ArrayList(); + } + this.netRules.add(elem); + } + + public List getNetRules() { + return this.netRules; + } + + public PresetNetRule setNetRules(List 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)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 list = new ArrayList(); + + 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 { + + 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(_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 { + + @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(_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/thrift/bwlp.thrift b/src/main/thrift/bwlp.thrift index 308b62b..94afcf1 100644 --- a/src/main/thrift/bwlp.thrift +++ b/src/main/thrift/bwlp.thrift @@ -274,10 +274,17 @@ struct PresetRunScript { 3: list osIds, } +struct PresetNetRule { + 1: i32 ruleId, + 2: string displayName, + 3: list netRules, +} + struct PredefinedData { 1: list netShares, 2: list ldapFilter, 3: list runScripts, + 4: list networkExceptions, } // Write lecture to sat. if optional fields are not set or null, their value stays unchanged @@ -304,6 +311,7 @@ struct LectureWrite { 21: optional list networkShares, 22: optional list ldapFilters, 23: optional list presetScriptIds, + 24: optional list presetNetworkExceptionIds, } struct LectureSummary { @@ -355,10 +363,11 @@ struct LectureRead { 27: bool limitToAllowedUsers, 28: bool hasUsbAccess, 29: optional list networkShares, - 32: optional list presetNetworkShares, 30: optional list ldapFilters, - 33: optional list presetLdapFilters, 31: optional list presetScriptIds, + 32: optional list presetNetworkShares, + 33: optional list presetLdapFilters, + 34: optional list presetNetworkExceptionIds, } struct MasterTag { -- cgit v1.2.3-55-g7522 From 50325c96681b1b23d457aed49bac594dcd51f37f Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 28 Feb 2019 11:09:00 +0100 Subject: [vbox] fix bad detection of multiple hard drives --- src/main/java/org/openslx/util/vm/VboxConfig.java | 43 ++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/openslx/util/vm/VboxConfig.java b/src/main/java/org/openslx/util/vm/VboxConfig.java index fe85638..1eee0ed 100644 --- a/src/main/java/org/openslx/util/vm/VboxConfig.java +++ b/src/main/java/org/openslx/util/vm/VboxConfig.java @@ -306,24 +306,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" ); @@ -334,18 +352,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 ) ); } } -- cgit v1.2.3-55-g7522 From 3c665eaf6c731f8052e48d910eaf47b3c6256da4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 9 Apr 2019 15:10:34 +0200 Subject: [vmware] Whitelist additional VMX options --- src/main/java/org/openslx/util/vm/VmwareMetaData.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openslx/util/vm/VmwareMetaData.java b/src/main/java/org/openslx/util/vm/VmwareMetaData.java index cf190d4..151be1e 100644 --- a/src/main/java/org/openslx/util/vm/VmwareMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmwareMetaData.java @@ -75,8 +75,9 @@ public class VmwareMetaData extends VmMetaData 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/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 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 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 ) { -- cgit v1.2.3-55-g7522 From 7a7c20ee652f8d9a274fea055b38d7b8b289c641 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 29 May 2019 16:57:36 +0200 Subject: [vmware] Support hwversion 14 and 15 --- src/main/java/org/openslx/util/vm/VmMetaData.java | 17 +++++++++++++---- src/main/java/org/openslx/util/vm/VmwareMetaData.java | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openslx/util/vm/VmMetaData.java b/src/main/java/org/openslx/util/vm/VmMetaData.java index aafb6a4..c750ecc 100644 --- a/src/main/java/org/openslx/util/vm/VmMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmMetaData.java @@ -65,10 +65,19 @@ public abstract class VmMetaData */ 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" ); + 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)"), + DEFAULT( "default" ); public final String displayName; diff --git a/src/main/java/org/openslx/util/vm/VmwareMetaData.java b/src/main/java/org/openslx/util/vm/VmwareMetaData.java index 151be1e..f1e0149 100644 --- a/src/main/java/org/openslx/util/vm/VmwareMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmwareMetaData.java @@ -590,6 +590,8 @@ public class VmwareMetaData extends VmMetaData +public class QemuMetaData extends VmMetaData { private final Map arguments = new HashMap(); @@ -37,7 +37,7 @@ public class QemuMetaData extends VmMetaData 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..8fa530b 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 +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 { private static final Logger LOGGER = Logger.getLogger( VboxMetaData.class ); @@ -113,16 +126,6 @@ public class VboxMetaData extends VmMetaData 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 c750ecc..9cff9f5 100644 --- a/src/main/java/org/openslx/util/vm/VmMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmMetaData.java @@ -18,7 +18,7 @@ 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 +public abstract class VmMetaData { private static final Logger LOGGER = Logger.getLogger( VmMetaData.class ); @@ -29,6 +29,7 @@ public abstract class VmMetaData protected Map ddacc = new HashMap<>(); protected Map hwversion = new HashMap<>(); protected Map networkCards = new HashMap<>(); + protected Map usbSpeeds = new HashMap<>(); /** * Virtual sound cards types @@ -103,6 +104,21 @@ public abstract class VmMetaData 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 { @@ -172,6 +188,13 @@ public abstract class VmMetaData return availables; } + public List getSupportedUsbSpeeds() + { + ArrayList availables = new ArrayList<>( usbSpeeds.keySet() ); + Collections.sort( availables ); + return availables; + } + /** * Get operating system of this VM. */ @@ -270,7 +293,7 @@ public abstract class VmMetaData * @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 osList, File file ) + public static VmMetaData getInstance( List osList, File file ) throws IOException { try { @@ -301,20 +324,24 @@ public abstract class VmMetaData * @return VmMetaData object representing the relevant parts of the given machine description * @throws IOException */ - public static VmMetaData getInstance( List osList, byte[] vmContent, int length ) throws IOException + public static VmMetaData getInstance( List osList, byte[] vmContent, int length ) throws IOException { + Map exceptions = new HashMap<>(); try { return new VmwareMetaData( osList, vmContent, length ); } catch ( UnsupportedVirtualizerFormatException e ) { - LOGGER.info( "Not a VMware file", e ); + exceptions.put( "Not a VMware file", e ); } try { return new VboxMetaData( osList, vmContent, length ); } catch ( UnsupportedVirtualizerFormatException e ) { - LOGGER.info( "Not a VirtualBox file", e ); + exceptions.put( "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" ); + for ( Entry e : exceptions.entrySet() ) { + LOGGER.error( e.getKey(), e.getValue() ); + } return null; } @@ -352,14 +379,16 @@ public abstract class VmMetaData 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 void enableUsb( boolean enabled ); - public abstract boolean disableSuspend(); /** diff --git a/src/main/java/org/openslx/util/vm/VmwareMetaData.java b/src/main/java/org/openslx/util/vm/VmwareMetaData.java index 4e154c3..1e87d72 100644 --- a/src/main/java/org/openslx/util/vm/VmwareMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmwareMetaData.java @@ -59,7 +59,19 @@ class VmWareEthernetDevTypeMeta } } -public class VmwareMetaData extends VmMetaData +class VmwareUsbSpeed +{ + public final String keyName; + public final int speedNumeric; + + public VmwareUsbSpeed( int speed, String key ) + { + this.keyName = key + ".present"; + this.speedNumeric = speed; + } +} + +public class VmwareMetaData extends VmMetaData { private static final Logger LOGGER = Logger.getLogger( VmwareMetaData.class ); @@ -157,6 +169,11 @@ public class VmwareMetaData extends VmMetaData entry : usbSpeeds.entrySet() ) { + VmwareUsbSpeed v = entry.getValue(); + if ( v.speedNumeric > max && isSetAndTrue( v.keyName ) ) { + max = v.speedNumeric; + maxEnum = entry.getKey(); + } + } + return maxEnum; } @Override @@ -599,5 +649,11 @@ public class VmwareMetaData extends VmMetaData public abstract Virtualizer getVirtualizer(); - public abstract boolean disableSuspend(); + public abstract boolean tweakForNonPersistent(); /** * Function used to register virtual devices diff --git a/src/main/java/org/openslx/util/vm/VmwareMetaData.java b/src/main/java/org/openslx/util/vm/VmwareMetaData.java index 1e87d72..fb5b22a 100644 --- a/src/main/java/org/openslx/util/vm/VmwareMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmwareMetaData.java @@ -396,7 +396,7 @@ public class VmwareMetaData extends VmMetaData 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; diff --git a/src/main/java/org/openslx/util/vm/VmwareMetaData.java b/src/main/java/org/openslx/util/vm/VmwareMetaData.java index fb5b22a..038a10c 100644 --- a/src/main/java/org/openslx/util/vm/VmwareMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmwareMetaData.java @@ -89,7 +89,8 @@ public class VmwareMetaData extends VmMetaData 0 && newSpeedMeta.speedNumeric < 3 ) { + addFiltered( "usb.mangleUsb3Speed", "TRUE" ); + } } @Override -- cgit v1.2.3-55-g7522 From 100bf4d93adac7c207e5c0f0d81ebcee8534046b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 19 Jul 2019 16:28:02 +0200 Subject: [vm] Move workaround to actually take effect --- src/main/java/org/openslx/util/vm/VmwareMetaData.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/openslx/util/vm/VmwareMetaData.java b/src/main/java/org/openslx/util/vm/VmwareMetaData.java index c486be2..29227a7 100644 --- a/src/main/java/org/openslx/util/vm/VmwareMetaData.java +++ b/src/main/java/org/openslx/util/vm/VmwareMetaData.java @@ -132,6 +132,10 @@ public class VmwareMetaData extends VmMetaData 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; @@ -170,11 +174,6 @@ public class VmwareMetaData extends VmMetaData