Package es.urjc.escet.semium.exceptions

Examples of es.urjc.escet.semium.exceptions.DataFetchException


    public String replaceValues(String in, ArrayList<ParsedEntryValue> parsedValues) throws DataFetchException{
        for(ParsedEntryValue val:parsedValues){
            in = in.replace("@value:" + val.getId() + "@",val.getValue());
        }
        if(in.contains("@value"))
            throw new DataFetchException ("Not all values in 'resolveexistingid' could be replaced: '" + in  + "'");
       
        return in;
    }
View Full Code Here


                if(config.getProtocol().compareTo("HTTPS")==0) {
                    result = Web.grabHTTPSPage(config.getHost(),config.getPage(),method);
                } else if(config.getProtocol().compareTo("HTTP")==0) {
                    result = Web.grabHTTPPage(config.getHost(),method);
                }else
                    throw new DataFetchException("Error while preparing connection to server: Protocol '" + config.getProtocol() + "' not supported'");
               
                /** Remove all escape characters to help comparision **/
                result = result.replace("\t","").replace("\n","").replace("\r","");
               
                /** First check, if the loaded page contains valid data by searching by the supplied argument "validpage_findstring" **/
                if(result.contains(config.getValidPageFindString_begin())){
                   
                    int lastBlockStartIndex = 0;
                    int blockStartIndex = -1;
                    /** First obtain the block that contains all the entity data (defined by the begin and end strings for "perentity_findstring" **/
                    while((blockStartIndex = result.indexOf(config.getPerEntityFindString_begin(),lastBlockStartIndex)) >= 0){
                        blockStartIndex += config.getPerEntityFindString_begin().length();
                        lastBlockStartIndex = blockStartIndex;
                        int blockEndIndex = result.indexOf(config.getPerEntityFindString_end(),blockStartIndex);
                        if(blockStartIndex>=0 && blockEndIndex > blockStartIndex){
                            String block = result.substring(blockStartIndex,blockEndIndex);
                            ParsedEntity ent = new ParsedEntity();
                            int lastindex = -1;
                           
                            /** Loop through the block for all the defined values **/
                            for(DataFetchValue val:config.getValues()){
                                ParsedEntryValue pval = new ParsedEntryValue();
                                pval.setId(val.getId());
                                pval.setTargetpredicate(val.getTargetpredicate());
                                String sValue = null;
                                int valueStartIndex = block.indexOf(val.getFindstring_begin());
                                int valueEndIndex = -1;
                                if(valueStartIndex>=0){
                                    valueStartIndex+=val.getFindstring_begin().length();
                                    valueEndIndex = block.indexOf(val.getFindstring_end(),valueStartIndex);
                                } // if value exists
                               
                                if(valueStartIndex>=0 && valueEndIndex>=0){
                                    pval.setValue(block.substring(valueStartIndex,valueEndIndex));
                                    ent.values.add(pval);
                                } // if all parts found
                               
                            }// for all valuedefinitions
                           
                            /** Add fixed Statements **/
                            ent.setFStatements(config.getFixedStatements());
                           
                            entities.add(ent);
                           
                        }// if block has matching endtag
                    }// While blocks found
                   
                   
                } // if: contains validpage findstring
                else
                    break;
               
               
            } // while: iterate parameters
           
            /*result = "";
            for(ParsedEntity ent:entities){
                result += "ID: " + ent.getId() + "<BR/>";
                for(ParsedEntryValue val:ent.getValues())
                    result+=" " + val.getId() + ": " + val.getValue() + " (" + val.getTargetpredicate() + ")<BR/>";
            } // for: all found entries */
           
        catch (Exception ex) {
            ex.printStackTrace();
            throw new DataFetchException("Error while grabing Data from URI: " + config.getCompleteURI() + " ( " + ex.toString() + ")");
        }
       
        return entities;
    }
View Full Code Here

           
            /** eventualy insert into model **/
            DirectImport.directImport(model,impStatements);
           
        } catch (ConfigManagerException ex) {
            throw new DataFetchException("Error while accessing config file: " + ex.getMessage());
        }
        return true;
    }
View Full Code Here

TOP

Related Classes of es.urjc.escet.semium.exceptions.DataFetchException

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.