Package org.webharvest.exception

Examples of org.webharvest.exception.ScraperXQueryException


    public String toString() {
        if (stringValue == null) {
            try {
                stringValue = CommonUtil.serializeItem(this.item);
            } catch (XPathException e) {
                throw new ScraperXQueryException("Error serializing XML item!", e);

            }
        }

        return stringValue;
View Full Code Here


                    externalParamType = DEFAULT_PARAM_TYPE;
                }

                // check if param type is one of allowed
                if ( !ALLOWED_PARAM_TYPES.contains(externalParamType) ) {
                    throw new ScraperXQueryException("Type " + externalParamType + " is not allowed. Use one of " + ALLOWED_PARAM_TYPES.toString());
                }

                if ( externalParamType.endsWith("*") ) {
                    BodyProcessor bodyProcessor = new BodyProcessor(externalParamDef);
                    bodyProcessor.setProperty("Name", externalParamName);
                    bodyProcessor.setProperty("Type", externalParamType);
                    ListVariable listVar = (ListVariable) bodyProcessor.run(scraper, context);
                    debug(externalParamDef, scraper, listVar);
                   
                    Iterator it = listVar.toList().iterator();
                    List paramList = new ArrayList();
                    while (it.hasNext()) {
                        Variable currVar =  (Variable) it.next();
                        paramList.add( castSimpleValue(externalParamType, currVar, sqc) );
                    }

                    dynamicContext.setParameter(externalParamName, paramList);
                } else {
                    KeyValuePair props[] = {new KeyValuePair("Name", externalParamName), new KeyValuePair("Type", externalParamType)};
                    Variable var = getBodyTextContent(externalParamDef, scraper, context, true, props);

                    debug(externalParamDef, scraper, var);
                   
                    Object value = castSimpleValue(externalParamType, var, sqc);
                    dynamicContext.setParameter(externalParamName, value);
                }
            }

          return XmlUtil.createListOfXmlNodes(exp, dynamicContext);
      } catch (XPathException e) {
        throw new ScraperXQueryException("Error executing XQuery expression (XQuery = [" + xqExpression + "])!", e);
      }
    }
View Full Code Here

TOP

Related Classes of org.webharvest.exception.ScraperXQueryException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.