public Object convertInbound(Class<?> paramType, InboundVariable data) { if (data.isNull()) { return null; } try { Constructor<?> converter = paramType.getConstructor(String.class); return converter.newInstance(data.getValue()); } catch (Exception ex) { throw new IllegalArgumentException(ex.toString()); } }
/** * Create an inbound file variable. * Usually called by a query parser to setup a list of known variables. * This method also checks to see if the new variable is a parameter and if * it is it updates the count of parameters * @param callNum The call number to work on * @param key The name of the variable * @param type The javascript type of the variable * @param value The value of the file */ public void createInboundVariable(int callNum, String key, String type, FormField value) { InboundVariable iv = new InboundVariable(this, key, type, value); checkInboundVariable(callNum, key, iv); }
/** * When we are sure we have finished parsing the input, we can begin to * fix all cross-references. * @throws ConversionException If cross-references don't add up */ public void dereference() throws ConversionException { for (InboundVariable variable : variables.values()) { variable.dereference(); } }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException { if (data.isNull()) { return null; } if (data.getFormField().isFile()) { // Data from file uploads is not URL encoded return data.getValue(); } else { return data.urlDecode(); } }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull()) InboundContext incx = data.getContext(); InboundVariable[] members = data.getMembers(); if (members != null) data.getContext().addConverted(data, paramType, array); Object output = converterManager.convertInbound(componentType, members[i], data.getContext().getCurrentProperty()); Array.set(array, i, output); String value = data.getValue(); if (value.startsWith(ProtocolConstants.INBOUND_ARRAY_START)) log.error("Found array end without array start: " + data.getValue()); throw new IllegalArgumentException("Could not parse input. See logs for details."); log.error("Found array end without array end: " + data.getValue()); throw new IllegalArgumentException("Could not parse input. See logs for details."); data.getContext().addConverted(data, paramType, array); InboundVariable nested = new InboundVariable(incx, null, splitType, splitValue); nested.dereference(); Object output = converterManager.convertInbound(componentType, nested, data.getContext().getCurrentProperty()); Array.set(array, i, output);
protected <T> T getValue( String name, Class<T> type, InboundVariable data, Map<String, String> tokens, InboundContext inctx) throws MarshallException { final T value; final String valueString = tokens.get(name); if (valueString != null) { final String[] split = ParseUtil.splitInbound(valueString); final String splitValue = split[LocalUtil.INBOUND_INDEX_VALUE]; final String splitType = split[LocalUtil.INBOUND_INDEX_TYPE]; final InboundVariable nested = new InboundVariable( data.getLookup(), null, splitType, splitValue); @SuppressWarnings("unchecked") final T valueDraft = (T) getConverterManager().convertInbound(type, nested, inctx, null); value = valueDraft; } else { value = null; } return value; }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull()) String value = data.getValue(); if (value == null) throw new NullPointerException(data.toString()); log.warn("Expected object while converting data for " + paramType.getName() + " in " + data.getContext().getCurrentProperty() + ". Passed: " + value); throw new ConversionException(paramType, "Data conversion error. See logs for more details.");
String value = data.getValue(); log.warn("Expected object while converting data for " + paramType.getName() + " in " + data.getContext().getCurrentProperty() + ". Passed: " + value); throw new ConversionException(paramType, "Data conversion error. See logs for more details."); data.getContext().addConverted(data, instanceType, bean); data.getContext().addConverted(data, paramType, bean); Object output = convert(val, propType, data.getContext(), property); property.setValue(bean, output);
/** * We have inbound data and a type that we need to convert it into, this * method performs the conversion. */ protected Object convert(String val, Class<?> propType, InboundContext inboundContext, Property property) { String[] split = ConvertUtil.splitInbound(val); String splitValue = split[ConvertUtil.INBOUND_INDEX_VALUE]; String splitType = split[ConvertUtil.INBOUND_INDEX_TYPE]; InboundVariable nested = new InboundVariable(inboundContext, null, splitType, splitValue); nested.dereference(); Property incc = createTypeHintContext(inboundContext, property); return converterManager.convertInbound(propType, nested, incc); }
public Object convertInbound(@SuppressWarnings("rawtypes") Class paramType, InboundVariable iv, InboundContext inctx, TypeHintContext incc) throws MarshallException { Object converted = inctx.getConverted(iv, paramType); if (converted == null) { // Was the inbound variable marshalled as an Object in the client // (could mean that this is an instance of one of our generated // JavaScript classes) Converter converter = getNamedConverter(paramType, iv.getType()); // Fall back to the standard way of locating a converter if we // didn't find anything above if (converter == null) { converter = getConverter(paramType); } if (converter == null) { throw new MarshallException(paramType, Messages.getString("DefaultConverterManager.MissingConverter", paramType)); } // We only think about doing a null conversion ourselves once we are // sure that there is a converter available. This prevents hackers // from passing null to things they are not allowed to convert if (iv.isNull()) { return null; } inctx.pushContext(incc); converted = converter.convertInbound(paramType, iv, inctx); inctx.popContext(); } return converted; }
public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull()) final FormField formField = data.getFormField(); if (paramType == FileTransfer.class)
String javaScriptType = param.getType();
@Override public boolean equals(Object obj) { if (!(obj instanceof Conversion)) { return false; } Conversion that = (Conversion) obj; return this.type.equals(that.type) && this.inboundVariable.equals(that.inboundVariable); }
@SuppressWarnings("unchecked") public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull()) String value = data.getValue(); log.warn("Expected collection while converting data for " + paramType.getName() + " in " + data.getContext().getCurrentProperty() + ". Passed: " + value); throw new ConversionException(paramType, "Data conversion error. See logs for more details."); Property parent = data.getContext().getCurrentProperty(); Property child = parent.createChild(0); child = converterManager.checkOverride(child); data.getContext().addConverted(data, paramType, col); String splitValue = split[ConvertUtil.INBOUND_INDEX_VALUE]; InboundVariable nested = new InboundVariable(data.getContext(), null, splitType, splitValue); nested.dereference();
@Override protected Object convertInbound( @SuppressWarnings({ "rawtypes" }) Class paramType, InboundVariable data, Map<String, String> tokens, InboundContext inctx, String value) throws MarshallException { final String coordinatesString = tokens.get("coordinates"); //$NON-NLS-1$ final String[] split = ParseUtil.splitInbound(coordinatesString); final String splitValue = split[LocalUtil.INBOUND_INDEX_VALUE]; final String splitType = split[LocalUtil.INBOUND_INDEX_TYPE]; final InboundVariable nested = new InboundVariable( data.getLookup(), null, splitType, splitValue); @SuppressWarnings("unchecked") final C coordinates = (C) getConverterManager().convertInbound( getCoordinatesType(), nested, inctx, null); return createGeometry(coordinates); }
@Override public Object convertInbound(Class paramClass, InboundVariable paramInboundVariable, InboundContext paramInboundContext) throws MarshallException { //Convert from string to Unit try{ //For the ONE unit if(paramInboundVariable.getValue().equals("ONE")) return Unit.ONE; else return UnitUtil.parseLocal(URLDecoder.decode(paramInboundVariable.getValue(), Common.UTF8)); }catch(Exception e){ throw new MarshallException(paramClass); } }
@SuppressWarnings("unchecked") public Object convertInbound(Class<?> paramType, InboundVariable data) throws ConversionException if (data.isNull()) String value = data.getValue(); log.warn("Expected object while converting data for " + paramType.getName() + " in " + data.getContext().getCurrentProperty() + ". Passed: " + value); throw new ConversionException(paramType, "Data conversion error. See logs for more details."); Property parent = data.getContext().getCurrentProperty(); data.getContext().addConverted(data, paramType, map); InboundContext incx = data.getContext(); String splitIvValue = splitIv[ConvertUtil.INBOUND_INDEX_VALUE]; String splitIvType = splitIv[ConvertUtil.INBOUND_INDEX_TYPE]; InboundVariable valIv = new InboundVariable(incx, null, splitIvType, splitIvValue); valIv.dereference(); Object val = converterManager.convertInbound(valType, valIv, valProp); InboundVariable keyIv = new InboundVariable(incx, null, ProtocolConstants.TYPE_STRING, keyStr); keyIv.dereference();